using MP.MONO.Data.DbModels; namespace MP.MONO.UI.Components { public partial class SchedMaintTask { #region Protected Methods protected override async Task OnInitializedAsync() { await ReloadData(); } #endregion Protected Methods #region Private Fields private int _MaxRecord = 2000; private bool _showCompleted = false; /// /// Valore limite (in ore) per permettere di chiudere un intervento /// private int hourLim = 24 * 1; private List? ListRecords = null; // FARE!!! filtro macchina private int MachineId = 1; /// /// Valore limite (in %) per indicare come rosso una scadenza /// private int redLim = 10; private List? SearchRecords = null; /// /// Valore limite (in %) per indicare come giallo una scadenza /// private int yelLim = 20; #endregion Private Fields #region Private Properties private int _currPage { get; set; } = 1; private int _numRecord { get; set; } = 10; private int currPage { get => _currPage; set { if (_currPage != value) { _currPage = value; var pUpd = Task.Run(async () => await ReloadData()); pUpd.Wait(); } } } private int currSMTaskId { get; set; } = 0; private DateTime execDate { get; set; } = DateTime.Today.AddHours(DateTime.Now.Hour); private string execName { get; set; } = ""; private bool isLoading { get; set; } = false; private int _limitDayPeriod { get; set; } = 7; private int LimitDayPeriod { get => _limitDayPeriod; set { if (_limitDayPeriod != value) { _limitDayPeriod = value; var pUpd = Task.Run(async () => await ReloadData()); pUpd.Wait(); } } } private int maxRemainHour { get => LimitDayPeriod * 24; } private int MaxRecord { get { return _MaxRecord; } set { if (_MaxRecord != value) { _MaxRecord = value; var pUpd = Task.Run(async () => await ReloadData()); pUpd.Wait(); } } } private string modalShow { get => showTaskConf ? "show" : "hide"; } private int numRecord { get => _numRecord; set { if (_numRecord != value) { _numRecord = value; var pUpd = Task.Run(async () => await ReloadData()); pUpd.Wait(); } } } private bool showCompleted { get { return _showCompleted; } set { _showCompleted = value; var pUpd = Task.Run(async () => await ReloadData()); pUpd.Wait(); } } private bool showTaskConf { get; set; } = false; private int totalCount { get { int answ = 0; if (SearchRecords != null) { answ = SearchRecords.Count; } return answ; } } #endregion Private Properties #region Private Methods private async Task ConfirmDone() { // se ho dataora ed esecutore... if (!string.IsNullOrEmpty(execName) && currSMTaskId > 0) { // salvo! bool fatto = await MMDataService.SchedMaintTaskSetDone(MachineId, currSMTaskId, execDate, execName); // rigenero! await RegenTask(); } } private void ForceReload(int newNum) { numRecord = newNum; } private void ForceReloadPage(int newNum) { currPage = newNum; } private async Task RegenTask() { await MMDataService.SchedMaintTaskCreateMissing(MachineId); await ReloadData(); } private async Task ReloadData() { isLoading = true; ListRecords = null; await Task.Delay(1); SearchRecords = await MMDataService.SchedMaintTaskGetFilt(MachineId, maxRemainHour, 0, MaxRecord, showCompleted); ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); await Task.Delay(1); await Task.Delay(1); isLoading = false; } private void ShowConfirm(int SMTaskId) { showTaskConf = !showTaskConf; currSMTaskId = SMTaskId; } private async Task ToggleCompleted() { await Task.Delay(1); showCompleted = !showCompleted; await Task.Delay(1); } #endregion Private Methods } }