133 lines
3.6 KiB
C#
133 lines
3.6 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using MP.MONO.Data.DbModels;
|
|
using MP.MONO.UI.Data;
|
|
|
|
namespace MP.MONO.UI.Components
|
|
{
|
|
public partial class EditMaintTask
|
|
{
|
|
#region Private Fields
|
|
|
|
private List<CounterModel>? ListCounters { get; set; } = null;
|
|
private List<PMTaskTopicModel>? ListTopics { get; set; } = null;
|
|
private List<PMMGroupModel>? ListMachGroup { get; set; } = null;
|
|
private List<PMUTModel>? ListUserTeam { get; set; } = null;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Protected Fields
|
|
|
|
protected PrevMaintTaskModel _currItem = new PrevMaintTaskModel();
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Private Properties
|
|
|
|
[Inject]
|
|
private IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private NavigationManager NavManager { get; set; } = null!;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected CurrentDataService DataService { get; set; } = null!;
|
|
|
|
protected bool editAll
|
|
{
|
|
get
|
|
{
|
|
bool answ = false;
|
|
var currMode = GetQueryParm("currMode");
|
|
if (!string.IsNullOrEmpty(currMode))
|
|
{
|
|
answ = currMode.Equals("debug");
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public PrevMaintTaskModel currItem
|
|
{
|
|
get
|
|
{
|
|
return _currItem;
|
|
}
|
|
set
|
|
{
|
|
_currItem = value;
|
|
var pUpd = Task.Run(async () =>
|
|
{
|
|
ListCounters = await DataService.PMCounterModelGetAll();
|
|
ListTopics = await DataService.PMTaskTopicGetAll();
|
|
ListMachGroup = await DataService.PMMachGroupGetAll();
|
|
ListUserTeam = await DataService.PMUTeamGetAll();
|
|
});
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
|
|
[Parameter]
|
|
public EventCallback<int> DataReset { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<int> DataUpdated { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task cancelUpdate()
|
|
{
|
|
await DataReset.InvokeAsync(0);
|
|
}
|
|
|
|
private async Task saveUpdate()
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Are you sure? This will update scheduled Task and create new future occurencies"))
|
|
return;
|
|
|
|
if (_currItem != null)
|
|
{
|
|
// aggiorno
|
|
await DataService.PrevMaintTaskUpdate(_currItem);
|
|
// update pending...
|
|
await DataService.SchedMaintTaskCreateMissing(_currItem.MachineId);
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("Record null!");
|
|
}
|
|
// delay x display
|
|
await DataUpdated.InvokeAsync(0);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// Blazor: get query parm from the URL
|
|
/// </summary>
|
|
/// <param name="parmName"></param>
|
|
/// <returns></returns>
|
|
protected string GetQueryParm(string parmName)
|
|
{
|
|
var uriBuilder = new UriBuilder(NavManager.Uri);
|
|
var q = System.Web.HttpUtility.ParseQueryString(uriBuilder.Query);
|
|
return q[parmName] ?? "";
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
}
|
|
} |