diff --git a/MP-TAB-SERV/Components/AlarmsMan.razor b/MP-TAB-SERV/Components/AlarmsMan.razor index 0f9b4cfe..139176c8 100644 --- a/MP-TAB-SERV/Components/AlarmsMan.razor +++ b/MP-TAB-SERV/Components/AlarmsMan.razor @@ -1,4 +1,6 @@ - +
+ +
@if (isProcessing) @@ -7,61 +9,63 @@ } else { - - - - - - - - @foreach (var item in ListPaged) - { - - +
+
- Elenco Allarmi -
-
-
-
- Mem: @($"{item.MemAddress}.{@item.MemIndex}") -
-
- @item.ValDecoded -
-
-
-
-
-
- @($"{item.DtRif:ddd dd.MM.yy HH:mm:ss}") -
-
- @($"{item.Duration:N2} min") -
-
-
- @if (!string.IsNullOrEmpty(item.UserAck)) - { - @item.UserAck - } -
-
- @if (item.ReqNotify != 0) - { - - } - @if (item.ReqAck != 0) - { - - } -
-
-
-
-
+ + + - } - -
+ Elenco Allarmi +
+ + + @foreach (var item in ListPaged) + { + + +
+
+
+ Mem: @($"{item.MemAddress}.{@item.MemIndex}") +
+
+ @item.ValDecoded +
+
+
+
+
+
+ @($"{item.DtRif:ddd dd.MM.yy HH:mm:ss}") +
+
+ @($"{item.Duration:N2} min") +
+
+
+ @if (!string.IsNullOrEmpty(item.UserAck)) + { + @item.UserAck + } +
+
+ @if (item.ReqNotify != 0) + { + + } + @if (item.ReqAck != 0) + { + + } +
+
+
+
+ + + } + + + } \ No newline at end of file diff --git a/MP-TAB-SERV/Components/CmpFooter.razor.cs b/MP-TAB-SERV/Components/CmpFooter.razor.cs index f1e0f2a9..89ea2480 100644 --- a/MP-TAB-SERV/Components/CmpFooter.razor.cs +++ b/MP-TAB-SERV/Components/CmpFooter.razor.cs @@ -22,6 +22,7 @@ namespace MP_TAB_SERV.Components { await Task.Delay(1); await InvokeAsync(() => StateHasChanged()); + //Log.Trace("CmpFooter Timer elapsed"); }); pUpd.Wait(); } @@ -29,7 +30,6 @@ namespace MP_TAB_SERV.Components public void StartTimer() { int tOutPeriod = 5000; - //int.TryParse(Configuration["ReloadStatusTimer"], out tOutPeriod); aTimer = new System.Timers.Timer(tOutPeriod); aTimer.Elapsed += ElapsedTimer; aTimer.Enabled = true; @@ -44,6 +44,7 @@ namespace MP_TAB_SERV.Components { var rawVers = typeof(Program).Assembly.GetName().Version; ; version = rawVers != null ? rawVers : new Version("0.0.0.0"); + StartTimer(); } #endregion Protected Methods diff --git a/MP-TAB-SERV/Components/ControlsMan.razor b/MP-TAB-SERV/Components/ControlsMan.razor index 0243545f..96861d63 100644 --- a/MP-TAB-SERV/Components/ControlsMan.razor +++ b/MP-TAB-SERV/Components/ControlsMan.razor @@ -21,8 +21,8 @@ else } -
-
+
+
@@ -33,8 +33,6 @@ else
- @*
-
*@
@@ -57,7 +55,7 @@ else } }
-
+
@@ -65,7 +63,7 @@ else - Elenco Controlli + Registro Controlli diff --git a/MP-TAB-SERV/Components/ControlsMan.razor.cs b/MP-TAB-SERV/Components/ControlsMan.razor.cs index 26c38499..027553c8 100644 --- a/MP-TAB-SERV/Components/ControlsMan.razor.cs +++ b/MP-TAB-SERV/Components/ControlsMan.razor.cs @@ -64,7 +64,9 @@ namespace MP_TAB_SERV.Components if (RecMSE != null) { IdxMaccSel = RecMSE.IdxMacchina; - CurrPeriodo = new Periodo(PeriodSet.ThisWeek); + DateTime fine = DateTime.Today.AddDays(1); + DateTime inizio = fine.AddDays(-8); + CurrPeriodo = new Periodo(inizio, fine); await doUpdate(); } } diff --git a/MP-TAB-SERV/Components/DeclarEditor.razor b/MP-TAB-SERV/Components/DeclarEditor.razor new file mode 100644 index 00000000..926b34da --- /dev/null +++ b/MP-TAB-SERV/Components/DeclarEditor.razor @@ -0,0 +1,47 @@ +
+
+
+
+ +
+
+
+ @if (ShowDetail) + { +
+
+
+
+ Tipol. + +
+
+
+
+ Data Ora + + +
+
+
+
+ + +
+
+
+ +
+
+
+ } +
\ No newline at end of file diff --git a/MP-TAB-SERV/Components/DeclarEditor.razor.cs b/MP-TAB-SERV/Components/DeclarEditor.razor.cs new file mode 100644 index 00000000..e29d78a3 --- /dev/null +++ b/MP-TAB-SERV/Components/DeclarEditor.razor.cs @@ -0,0 +1,212 @@ +using global::Microsoft.AspNetCore.Components; +using MP.Data; +using MP.Data.DatabaseModels; +using MP.Data.Services; + +namespace MP_TAB_SERV.Components +{ + public partial class DeclarEditor + { + #region Public Properties + + [Parameter] + public EventCallback E_Updated { get; set; } + + [Parameter] + public RegistroDichiarazioniModel? EditRec + { + get => currRec; + set + { + if (currRec != value && value != null) + { + IsNewRec = false; + ShowDetail = true; + currRec = value; + } + } + } + + [Parameter] + public MappaStatoExpl? RecMSE { get; set; } = null; + + #endregion Public Properties + + #region Protected Properties + + protected string BtnCss + { + get => IsNewRec ? "btn btn-success" : "btn btn-primary"; + } + + protected string BtnText + { + get => IsNewRec ? "Salva Nuova Dichiarazione" : "Aggiorna Dichiarazione"; + } + + protected DateTime DateSel + { + get => currRec.DtRec.Round(TimeSpan.FromSeconds(1)); + set + { + if (currRec.DtRec != value) + { + currRec.DtRec = value; + } + } + } + + protected List ListComplete { get; set; } = new List(); + + [Inject] + protected MessageService MServ { get; set; } = null!; + + [Inject] + protected SharedMemService SMServ { get; set; } = null!; + + [Inject] + protected TabDataService TabServ { get; set; } = null!; + + protected string TagCodeSel + { + get => currRec.TagCode; + set + { + if (currRec.TagCode != value) + { + currRec.TagCode = value; + } + } + } + + protected string Title + { + get => ShowDetail ? "Nascondi Inserimento Dichiarazione" : "Mostra Inserimento Dichiarazione"; + } + + #endregion Protected Properties + + #region Protected Methods + + protected void doCancel() + { + DoReset(); + } + + protected async Task DoSave() + { + if (IsNewRec) + { + // inserisco + await TabServ.RegDichiarInsert(currRec); + } + else + { + // altrimetni update... + await TabServ.RegDichiarUpdate(currRec); + } + + // reset + DoReset(); + ToggleCtrl(); + await E_Updated.InvokeAsync(true); + } + + protected override async Task OnInitializedAsync() + { + currRec = new RegistroDichiarazioniModel() + { + DtRec = DateTime.Now, + IdxMacchina = IdxMacc, + TagCode = TagCodeSel, + MatrOpr = MatrOpr, + ValString = UserComment + }; + await ReloadData(); + } + + protected async Task ReloadData() + { + ListComplete = await TabServ.AnagTagsOrd(); + } + + protected void resetDate() + { + DateSel = DateTime.Now; + } + + protected void ToggleCtrl() + { + ShowDetail = !ShowDetail; + DateSel = DateTime.Now; + if (!ShowDetail) + { + IsNewRec = true; + UserComment = ""; + } + } + + #endregion Protected Methods + + #region Private Fields + + private bool IsNewRec = true; + + #endregion Private Fields + + #region Private Properties + + private string CodArt + { + get => RecMSE != null ? RecMSE.CodArticolo : ""; + } + + private RegistroDichiarazioniModel currRec { get; set; } = new RegistroDichiarazioniModel(); + + private string IdxMacc + { + get => RecMSE != null ? RecMSE.IdxMacchina : ""; + } + + private int idxOdl { get; set; } = 0; + + private int IdxOdl + { + get => idxOdl; + set => idxOdl = value; + } + + private int MatrOpr + { + get => MServ.MatrOpr; + } + + private bool ShowDetail { get; set; } = false; + + private string UserComment + { + get => currRec.ValString.Trim(); + set + { + if (currRec.ValString != value) + { + currRec.ValString = value; + } + } + } + + #endregion Private Properties + + #region Private Methods + + private void DoReset() + { + UserComment = ""; + DateSel = DateTime.Now; + ShowDetail = true; + IsNewRec = true; + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/DeclarMan.razor b/MP-TAB-SERV/Components/DeclarMan.razor index d4d18b69..e1dfd528 100644 --- a/MP-TAB-SERV/Components/DeclarMan.razor +++ b/MP-TAB-SERV/Components/DeclarMan.razor @@ -1,6 +1,74 @@ -

DeclarList

- - -@code { + +
+
+

Tipo Selezione

+
+
+
+ + +
+
+
+@if (useOdl) +{ + } +else +{ + +} + +
+
+ +
+
+
+
+ + + + + + + + + + + + + + @foreach (var item in ListPaged) + { + + + + + + + + + } + +
TagDataOperMacchinaDichiarazione
+ + + + + @item.DtRec + + @item.CognNome + + @item.IdxMacchina + + @item.ValString +
+
+
+
+
+ +
+
\ No newline at end of file diff --git a/MP-TAB-SERV/Components/DeclarMan.razor.cs b/MP-TAB-SERV/Components/DeclarMan.razor.cs new file mode 100644 index 00000000..8e927b92 --- /dev/null +++ b/MP-TAB-SERV/Components/DeclarMan.razor.cs @@ -0,0 +1,156 @@ +using global::Microsoft.AspNetCore.Components; +using MP.Data.DatabaseModels; +using MP.Data.Services; +using NLog; +using Org.BouncyCastle.Asn1.IsisMtt.X509; +using static EgwCoreLib.Utils.DtUtils; + +namespace MP_TAB_SERV.Components +{ + public partial class DeclarMan + { + #region Public Properties + + [Parameter] + public MappaStatoExpl? RecMSE { get; set; } = null; + + #endregion Public Properties + + #region Public Methods + + /// + /// Aggiorno valori produzione alla data richiesta... + /// + /// + public async Task doUpdate() + { + isProcessing = true; + await Task.Delay(1); + if (!string.IsNullOrEmpty(IdxMaccSel)) + { + ListComplete = await TabDServ.RegDichiarGetFilt(IdxMaccSel, "", 0, IdxOdl, CurrPeriodo.Inizio, CurrPeriodo.Fine); + TotalCount = ListComplete.Count; + // esegue paginazione + UpdateTable(); + } + isProcessing = false; + await Task.Delay(1); + } + + #endregion Public Methods + + #region Protected Properties + + protected List ListComplete { get; set; } = new List(); + protected List ListPaged { get; set; } = new List(); + + protected void SetEdit(RegistroDichiarazioniModel selRec) + { + CurrRec = selRec; + } + + [Inject] + protected MessageService MServ { get; set; } = null!; + + [Inject] + protected TabDataService TabDServ { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected override async Task OnInitializedAsync() + { + await Task.Delay(1); + if (RecMSE != null) + { + IdxMaccSel = RecMSE.IdxMacchina; + DateTime fine = DateTime.Today.AddDays(1); + DateTime inizio = fine.AddDays(-8); + CurrPeriodo = new Periodo(inizio, fine); + await doUpdate(); + } + } + + protected void SaveNumRec(int newNum) + { + NumRecPage = newNum; + UpdateTable(); + } + + protected void SavePage(int newNum) + { + PageNum = newNum; + UpdateTable(); + } + + protected async Task SetMacc(string selIdxMacc) + { + isProcessing = true; + await Task.Delay(1); + IdxMaccSel = selIdxMacc; + await doUpdate(); + isProcessing = false; + await Task.Delay(1); + } + + protected async Task SetOdl(int selIdxOdl) + { + isProcessing = true; + await Task.Delay(1); + IdxOdl = selIdxOdl; + await doUpdate(); + isProcessing = false; + await Task.Delay(1); + } + + protected async Task SetPeriodo(Periodo newPeriodo) + { + CurrPeriodo = newPeriodo; + await doUpdate(); + } + + protected void UpdateTable() + { + // esegue paginazione + if (TotalCount > NumRecPage) + { + ListPaged = ListComplete.Skip((PageNum - 1) * NumRecPage).Take(NumRecPage).ToList(); + } + else + { + ListPaged = ListComplete; + } + } + + #endregion Protected Methods + + #region Private Fields + + private RegistroDichiarazioniModel? CurrRec { get; set; } = null; + + private static Logger Log = LogManager.GetCurrentClassLogger(); + private bool isProcessing = false; + private int NumRecPage = 10; + private int PageNum = 1; + private int TotalCount = 0; + private bool useOdl = false; + + #endregion Private Fields + + #region Private Properties + + private Periodo CurrPeriodo { get; set; } = new Periodo(); + + private string IdxMaccSel { get; set; } = ""; + + private int IdxOdl { get; set; } = 0; + + private string selMessage + { + get => useOdl ? "Periodo da ODL" : "Periodo Libero"; + } + + #endregion Private Properties + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/DisabledAlert.razor b/MP-TAB-SERV/Components/DisabledAlert.razor new file mode 100644 index 00000000..e8918760 --- /dev/null +++ b/MP-TAB-SERV/Components/DisabledAlert.razor @@ -0,0 +1,15 @@ +
+
+

@Title

+
+
+
+
+

+ @Subtitle +

+ @Message +
+
+
+
\ No newline at end of file diff --git a/MP-TAB-SERV/Components/DisabledAlert.razor.cs b/MP-TAB-SERV/Components/DisabledAlert.razor.cs new file mode 100644 index 00000000..fa884552 --- /dev/null +++ b/MP-TAB-SERV/Components/DisabledAlert.razor.cs @@ -0,0 +1,20 @@ +using global::Microsoft.AspNetCore.Components; + +namespace MP_TAB_SERV.Components +{ + public partial class DisabledAlert + { + #region Public Properties + + [Parameter] + public string Message { get; set; } = ""; + + [Parameter] + public string Subtitle { get; set; } = ""; + + [Parameter] + public string Title { get; set; } = ""; + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/FixOdl.razor b/MP-TAB-SERV/Components/FixOdl.razor new file mode 100644 index 00000000..e8998715 --- /dev/null +++ b/MP-TAB-SERV/Components/FixOdl.razor @@ -0,0 +1,90 @@ + + +@if (showFixOdl) +{ +
+
+

Riassegnazione ODL

+
+
+

Ultimi ODL lavorati:

+ + + + + + + + + @foreach (var item in ListPaged) + { + + + + + } + +
ODL / Articolo# Pezzi
+
+
+ @item.IdxOdl +
+
+ @item.CodArticolo +
+
+
+
+ @($"{item.DataInizio:yyyy.MM.dd HH:mm:ss}") +
+
+ +
+
+ @($"{item.DataFine:yyyy.MM.dd HH:mm:ss}") +
+
+ @if (!string.IsNullOrEmpty(item.Note)) + { +
+ @item.Note +
+ } +
+
+ @item.NumPezzi.ToString("N0") +
+
+ TC: @item.Tcassegnato.ToString("N2") | pz/pallet: @item.PzPallet +
+
+ + +
+
+
+ + +
+ + +
+
+
+
+ @if (IdxOdlSel > 0) + { + + } +
+
+} + diff --git a/MP-TAB-SERV/Components/FixOdl.razor.cs b/MP-TAB-SERV/Components/FixOdl.razor.cs new file mode 100644 index 00000000..44cfe8eb --- /dev/null +++ b/MP-TAB-SERV/Components/FixOdl.razor.cs @@ -0,0 +1,162 @@ +using Microsoft.AspNetCore.Components; +using MP.Data.DatabaseModels; +using MP.Data.Services; + +namespace MP_TAB_SERV.Components +{ + public partial class FixOdl + { + #region Public Properties + + [Parameter] + public string IdxMaccCurr { get; set; } = ""; + + #endregion Public Properties + + #region Protected Fields + + protected bool enableRPO = true; + protected int NumRecPage = 5; + protected int PageNum = 1; + protected int TotalCount = 0; + + #endregion Protected Fields + + #region Protected Properties + + protected List ListComplete { get; set; } = new List(); + protected List ListPaged { get; set; } = new List(); + + [Inject] + protected MessageService MServ { get; set; } = null!; + + [Inject] + protected NavigationManager NavMan { get; set; } = null!; + + protected bool ShowAll + { + get => showAll; + set + { + if (showAll != value) + { + showAll = value; + IdxOdlSel = 0; + var pUpd = Task.Run(async () => + { + await ReloadData(); + }); + pUpd.Wait(); + } + } + } + + [Inject] + protected SharedMemService SMServ { get; set; } = null!; + + [Inject] + protected TabDataService TabDServ { get; set; } = null!; + + protected string txtBtnFixOdl { get => showFixOdl ? "Nascondi Fix" : "Fix ODL"; } + + #endregion Protected Properties + + #region Protected Methods + + protected override void OnInitialized() + { + enableRPO = SMServ.GetConfBool("enableRPO"); + } + + protected override async Task OnParametersSetAsync() + { + await ReloadData(); + } + + protected void SaveNumRec(int newNum) + { + NumRecPage = newNum; + UpdateTable(); + } + + protected void SavePage(int newNum) + { + PageNum = newNum; + UpdateTable(); + } + + protected async Task SetupOdl() + { + await Task.Delay(1); + if (!string.IsNullOrEmpty(IdxMaccCurr) && IdxOdlSel > 0) + { + if (enableRPO) + { + // registro ODL retroattivamente... + await TabDServ.OdlSetupPromPostuma(IdxOdlSel, MServ.MatrOpr, IdxMaccCurr); + } + else + { + // registro ODL retroattivamente... + await TabDServ.OdlSetupPostumo(IdxOdlSel, IdxMaccCurr); + } + } + + // redirect + NavMan.NavigateTo(NavMan.Uri, true); + } + + protected void toggleFixOdl() + { + showFixOdl = !showFixOdl; + } + + protected void UpdateTable() + { + // esegue paginazione + if (TotalCount > NumRecPage) + { + ListPaged = ListComplete.Skip((PageNum - 1) * NumRecPage).Take(NumRecPage).ToList(); + } + else + { + ListPaged = ListComplete; + } + } + + #endregion Protected Methods + + #region Private Fields + + private bool showAll = false; + private bool showFixOdl = true; + + #endregion Private Fields + + #region Private Properties + + private int IdxOdlSel { get; set; } = 0; + private List ListSelODL { get; set; } = new List(); + private int numDayOdl { get; set; } = 30; + + #endregion Private Properties + + #region Private Methods + + private async Task ReloadData() + { + if (!string.IsNullOrEmpty(IdxMaccCurr)) + { + ListSelODL = await TabDServ.VSOdlGetUnused(IdxMaccCurr, ShowAll, numDayOdl); + DateTime dateTo = DateTime.Today.AddDays(1); + DateTime dateFrom = dateTo.AddMonths(-1); + ListComplete = await TabDServ.OdlListByMaccPeriodo(IdxMaccCurr, dateFrom, dateTo); + TotalCount = ListComplete.Count; + // esegue paginazione + UpdateTable(); + } + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/IobInfoMan.razor b/MP-TAB-SERV/Components/IobInfoMan.razor index f5a92a64..1c68b7f6 100644 --- a/MP-TAB-SERV/Components/IobInfoMan.razor +++ b/MP-TAB-SERV/Components/IobInfoMan.razor @@ -1,34 +1,51 @@ -
-
-
- -
-
- IOB Details +
+
+
+
+
Iob Type
+
+ @if(infosIob.iType == MP.Data.Objects.Enums.IobType.rPi) + { + + } + else if (infosIob.iType == MP.Data.Objects.Enums.IobType.WIN || infosIob.iType == MP.Data.Objects.Enums.IobType.ND) + { + + } +
+
-
-
    -
  • -
    Machine Code:
    -
    @idxMacch
    -
  • -
  • -
    IOB Type:
    -
      @infosIob.iType
    -
  • -
  • -
    IOB Name:
    -
    @infosIob.name
    -
  • -
  • -
    IOB Address:
    -
    @infosIob.IP
    -
  • -
  • -
    CNC Absolute counter:
    -
    @infosIob.CNC_Counter
    -
  • -
+
+
+
+
Machine Cod
+
@idxMacch
+
+
+
+
+
Iob Address
+
@infosIob.IP
+
+
+
+
+
+
+
+
+
Iob Name
+
@infosIob.name
+
+
+
+
+
+
+
CNC Absolute counter
+
@infosIob.CNC_Counter
+
+
\ No newline at end of file diff --git a/MP-TAB-SERV/Components/LongStopList.razor b/MP-TAB-SERV/Components/LongStopList.razor index 55d3d2cd..c1566122 100644 --- a/MP-TAB-SERV/Components/LongStopList.razor +++ b/MP-TAB-SERV/Components/LongStopList.razor @@ -1,26 +1,74 @@ @if (currFnq != null) { -
-
-
-
- @currFnq.Stato -
-
- @currFnq.CodArticolo +
+
+ +
+
+
+ @currFnq.Stato +
- } diff --git a/MP-TAB-SERV/Components/LongStopList.razor.cs b/MP-TAB-SERV/Components/LongStopList.razor.cs index 67399120..589f6d9b 100644 --- a/MP-TAB-SERV/Components/LongStopList.razor.cs +++ b/MP-TAB-SERV/Components/LongStopList.razor.cs @@ -1,6 +1,8 @@ using global::Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; using MP.Data.DatabaseModels; using MP.Data.Services; +using System.Data; using System.Reflection.Metadata; namespace MP_TAB_SERV.Components @@ -11,6 +13,12 @@ namespace MP_TAB_SERV.Components [Parameter] public FermiNonQualModel currFnq { get; set; } = new FermiNonQualModel(); + [Parameter] + public List currNotes { get; set; } = new List(); + [Parameter] + public EventCallback E_relData { get; set; } + [Parameter] + public EventCallback E_setComm { get; set; } #endregion Public Properties @@ -22,6 +30,9 @@ namespace MP_TAB_SERV.Components [Inject] protected NavigationManager NavMan { get; set; } = null!; + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + #endregion Protected Properties #region Protected Methods @@ -42,23 +53,79 @@ namespace MP_TAB_SERV.Components #region Private Methods + protected bool showComments { get; set; } = false; + + protected string divCss + { + get => showComments ? "col-12" : "col-6 col-sm-6 col-lg-2"; + } + + protected string cardCss + { + get => showComments ? "col-6 col-sm-6 col-lg-2" : "col-12"; + } + + protected string cardContentCss + { + get => showComments ? "col-6" : "col-12"; + } + protected string chevronDir + { + get => showComments ? "fa-chevron-left" : "fa-chevron-right"; + } + + protected async Task setComments() + { + await Task.Delay(1); + showComments = !showComments; + } + + protected string cardBorder + { + get => showComments ? "cardObjNoBL" : "cardObj"; + } + + + protected string borderColor { get; set; } = ""; + private string setSemaforo(string sem) { string answ = ""; if (sem == "sBl") { answ = "bg-primary text-warning"; + borderColor = "border-primary"; } else if (sem == "sGr") { answ = "bg-secondary text-dark"; + borderColor = "border-secondary"; } else if (sem == "sGi") { answ = "bg-warning text-dark"; + borderColor = "border-warning"; } return answ; } + [Inject] + protected TabDataService TabServ { get; set; } = null!; + protected async Task doDelete(CommentiModel currNote) + { + if (!await JSRuntime.InvokeAsync("confirm", $"Sicuro di voler eliminare il seguente commento?{Environment.NewLine}[{currNote.Value}]")) + return; + + var done = await TabServ.EvListDelete(currNote.IdxMacchina, currNote.InizioStato, currNote.IdxTipo); + if (done) + { + await E_relData.InvokeAsync(true); + } + + } + protected async Task doSet2Edit(CommentiModel currNote) + { + await E_setComm.InvokeAsync(currNote); + } #endregion Private Methods } diff --git a/MP-TAB-SERV/Components/MachSel.razor b/MP-TAB-SERV/Components/MachSel.razor index aef38a54..81b44057 100644 --- a/MP-TAB-SERV/Components/MachSel.razor +++ b/MP-TAB-SERV/Components/MachSel.razor @@ -1,7 +1,7 @@ @if (isMulti) { -
- Selezione Impianto +
+ + + - # Commenti -
- - - @if (RecordListComments == null) - { - - } - else if (RecordListComments.Count == 0) - { -
Nessun record trovato
- } - else - { - foreach (var item in RecordListComments) - { -
-
-
- @item.Operatore -
-
- -
- @item.Value -
-
-
- -
-
- -
-
-
- -
-
- } - } -
diff --git a/MP-TAB-SERV/Components/NotesMan.razor.cs b/MP-TAB-SERV/Components/NotesMan.razor.cs index d4eab56e..da0df09a 100644 --- a/MP-TAB-SERV/Components/NotesMan.razor.cs +++ b/MP-TAB-SERV/Components/NotesMan.razor.cs @@ -1,7 +1,9 @@ using global::Microsoft.AspNetCore.Components; using Microsoft.JSInterop; using MP.Data.DatabaseModels; +using MP.Data.DTO; using MP.Data.Services; +using NLog.LayoutRenderers.Wrappers; namespace MP_TAB_SERV.Components { @@ -16,17 +18,19 @@ namespace MP_TAB_SERV.Components #region Protected Properties + protected EventListModel? currEv { get; set; } = null; + protected int DurataMin { - get => _durataMin; + get => durataMinCurr; set { - if (_durataMin != value) + if (durataMinCurr != value) { - _durataMin = value; + durataMinCurr = value; var pUpd = Task.Run(async () => { - await ReloadFnq(); + await ReloadData(); }); pUpd.Wait(); } @@ -42,34 +46,17 @@ namespace MP_TAB_SERV.Components [Inject] protected NavigationManager NavMan { get; set; } = null!; - protected int NumComm - { - get => numComm; - set - { - if (numComm != value) - { - numComm = value; - var pUpd = Task.Run(async () => - { - await ReloadComments(); - }); - pUpd.Wait(); - } - } - } - protected int NumGiorni { - get => _numGiorni; + get => numGiorniCurr; set { - if (_numGiorni != value) + if (numGiorniCurr != value) { - _numGiorni = value; + numGiorniCurr = value; var pUpd = Task.Run(async () => { - await ReloadFnq(); + await ReloadData(); }); pUpd.Wait(); } @@ -78,6 +65,7 @@ namespace MP_TAB_SERV.Components protected List? RecordListComments { get; set; } = new List(); protected List RecordListFnq { get; set; } = new List(); + protected List RecordListFull { get; set; } = new List(); [Inject] protected TabDataService TabServ { get; set; } = null!; @@ -95,8 +83,27 @@ namespace MP_TAB_SERV.Components await Task.Delay(1); await TabServ.EvListDelete(currRec.IdxMacchina, currRec.InizioStato, currRec.IdxTipo); // ricarico - await ReloadComments(); - await ReloadFnq(); + await ReloadData(); + } + + protected async Task reloadAfterDelOrUpd(bool rel) + { + if (rel) + { + await ReloadComments(); + await InvokeAsync(StateHasChanged); + } + } + + protected CommentiModel? currComm { get; set; } = null; + + protected async Task setCurrComm(CommentiModel _CurrComm) + { + await Task.Delay(1); + if(_CurrComm != null) + { + currComm = _CurrComm; + } } protected async Task EditRec(CommentiModel currRec) @@ -111,21 +118,27 @@ namespace MP_TAB_SERV.Components protected override async Task OnParametersSetAsync() { - await ReloadComments(); - await ReloadFnq(); + if (durataMinCurr != durataMinLast || numGiorniCurr != numGiorniLast) + { + durataMinLast = durataMinCurr; + numGiorniLast = numGiorniCurr; + await ReloadData(); + } } - protected EventListModel? currEv { get; set; } = null; - #endregion Protected Methods - #region Private Properties + #region Private Fields - private int _durataMin { get; set; } = 5; - private int _numGiorni { get; set; } = 1; - private int numComm { get; set; } = 5; + private int durataMinCurr = 5; - #endregion Private Properties + private int durataMinLast = 0; + + private int numGiorniCurr = 3; + + private int numGiorniLast = 0; + + #endregion Private Fields #region Private Methods @@ -140,7 +153,23 @@ namespace MP_TAB_SERV.Components private async Task ReloadComments() { - RecordListComments = await TabServ.CommentiGetLastByMacc(RecMSE?.IdxMacchina, NumComm); + RecordListComments = await TabServ.CommentiGetLastByMacc(RecMSE?.IdxMacchina, NumGiorni); + } + + private async Task ReloadData() + { + await ReloadComments(); + await ReloadFnq(); + // preparo i DTO... + RecordListFull = RecordListFnq + .Select(x => new FermiCommentatiDTO() + { + Fermata = x, + CommentiFermata = RecordListComments? + .Where(c => c.InizioStato >= x.InizioStato + && c.InizioStato <= x.InizioStato.AddMinutes(x.DurataMinuti)) + .ToList() + }).ToList(); } private async Task ReloadFnq() diff --git a/MP-TAB-SERV/Components/OdlMan.razor b/MP-TAB-SERV/Components/OdlMan.razor new file mode 100644 index 00000000..4e8f6fae --- /dev/null +++ b/MP-TAB-SERV/Components/OdlMan.razor @@ -0,0 +1,275 @@ + +
+
+ +
+ @if (isProcessing) + { + + + } + else + { + @if (isSlave) + { +
+
+
@(Traduci("lblWarnHeadSlave"))
+
@(Traduci("lblWarnBodySlave"))
+
+
+ } + else + { + @if (needConfProd) + { +
+
+
@lblWarnHead
+
@lblWarnBody @numPz2Conf.ToString("N0") pz NC
+
+
+ @if (!odlOk) + { +
+ +
+ } + } + else + { +
+ Slave machine man +
+
+ Check articolo in revisione +
+ @if (cancelSetupEnabled) + { +
+ +
+ } + + @if (!inAttr && !showOdlDetail) + { +
+ +
+ } + + @if (showOdlDetail || inAttr) + { +
+
+
+
+

@titleOdlDetail

+
+
+ @if (idxPOdlSel == 0 && !inAttr) + { + + } +
+
+
+
+
+
+ P.ODL: +
+
+ @currPodl.IdxPromessa.ToString("N0") +
+
+
+
+ Rif: +
+
+ @currPodl.KeyRichiesta +
+
+
+
+ Cod: +
+
+ @currPodl.CodArticolo +
+
+
+
+
+
+ Articolo: +
+
+ @currPodl.DescArticolo +
+
+
+
+
+
+ Pezzi: +
+
+ @currPodl.NumPezzi.ToString("N0") +
+
+
+
+ TCiclo: +
+
+ @if (currOdl != null && currOdl.Tcassegnato > 0) + { + @currOdl.Tcassegnato.ToString("N2") + } + else + { + @currPodl.Tcassegnato.ToString("N2") + } +
+
+
+
+ Pz/pallet: +
+
+ @currPodl.PzPallet +
+
+
+
+ +
+
+ } + + @if (!inAttr) + { +
+ @if (idxPOdlSel > 0) + { + + } + else + { + + } +
+
+
+ + +
+ + +
+
+
+ } + @if (idxPOdlSel > 0 || inAttr) + { +
+
+ + +
+
+
+ +
+
+ Pz Pallet +
+ +
+
+ } + + @if (inAttr) + { +
+ +
+ } + else + { + if (odlOk) + { +
+
+ + +
+
+ } + } +
+ +
+
+ +
+
+ + @*
+
+
+
+
+ <%: lblCreaOdl %> +
+
+
+
+ +
+
+
*@ +
+
+ @lblOut +
+ } + } + } +
\ No newline at end of file diff --git a/MP-TAB-SERV/Components/OdlMan.razor.cs b/MP-TAB-SERV/Components/OdlMan.razor.cs new file mode 100644 index 00000000..c081fda9 --- /dev/null +++ b/MP-TAB-SERV/Components/OdlMan.razor.cs @@ -0,0 +1,1289 @@ +using global::Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MP.Data; +using MP.Data.DatabaseModels; +using MP.Data.Objects; +using MP.Data.Services; +using NLog; +using System; +using System.Text; +using static MP.Data.Objects.Enums; + +namespace MP_TAB_SERV.Components +{ + public partial class OdlMan + { + #region Public Properties + + /// + /// Post update restituisco nuova lista dati + /// + [Parameter] + public EventCallback> E_Updated { get; set; } + + [Parameter] + public MappaStatoExpl? RecMSE { get; set; } = null; + + #endregion Public Properties + + #region Protected Fields + + protected PzProdModel? prodMacchina = null; + + #endregion Protected Fields + + #region Protected Properties + + /// + /// Restituisce il codice IdxMacchina dell'altra tavola (se multi) altrimenti la stessa macchina... + /// + protected string idxMaccAltraTav + { + get + { + string answ = ""; + try + { + // verifico se SIA una tavola (ha char "#") + int iSharp = IdxMaccSel.IndexOf('#'); + if (iSharp > 0) + { + // ora verifico SE ALTRA TAVOLA ha ODL... + string nomeTav = IdxMaccSel.Substring(iSharp); + string altraTav = nomeTav.Substring(0, nomeTav.Length - 1); + altraTav += nomeTav.EndsWith("1") ? "2" : "1"; + // sistemo nome + answ = IdxMaccSel.Replace(nomeTav, altraTav); + } + } + catch + { } + return answ; + } + } + + protected int IdxPOdlSel + { + get => idxPOdlSel; + set + { + if (idxPOdlSel != value) + { + idxPOdlSel = value; + showOdlDetail = value > 0; + var pUpd = Task.Run(async () => + { + await ReloadPOdlDetailData(); + }); + pUpd.Wait(); + } + } + } + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + protected List ListODL { get; set; } = new List(); + + [Inject] + protected MailService MailServ { get; set; } = null!; + + [Inject] + protected StatusData MDataService { get; set; } = null!; + + [Inject] + protected MessageService MServ { get; set; } = null!; + + [Inject] + protected NavigationManager NavMan { get; set; } = null!; + + /// + /// Verifica ODL OK (ovvero caricato x macchina...) + /// + protected bool odlOk + { + get => (RecMSE != null && RecMSE.IdxOdl > 0); + } + + protected bool ShowAll + { + get => showAll; + set + { + if (showAll != value) + { + showAll = value; + var pUpd = Task.Run(async () => + { + await ReloadData(true); + }); + pUpd.Wait(); + } + } + } + + [Inject] + protected SharedMemService SMServ { get; set; } = null!; + + [Inject] + protected TabDataService TabDServ { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + /// + /// Gestione display avanzamento step + /// + /// + protected async Task advStep(int currStep) + { + currVal = currStep; + nextVal = currVal + 1; + await InvokeAsync(StateHasChanged); + } + + protected async Task CheckAttr() + { + // verifico attrezzaggio su macchina corrente o se multi su parent + string idxMacc2check = isMulti ? IdxMaccParent : IdxMaccSel; + StatoMacchineModel rigaStato = TabDServ.StatoMacchina(idxMacc2check); + //calcolo stato attrezzaggio, hard coded!!! + inAttr = (rigaStato.IdxStato == 2); + // se in attr --> carico podlCurr... + if (inAttr && RecMSE != null) + { + await ReloadXDL(false); + } + } + + /// + /// Aggiorno... + /// + /// + protected async Task DoUpdate() + { + isProcessing = true; + await Task.Delay(1); + isProcessing = false; + await Task.Delay(1); + } + + /// + /// Restituisce il codice IdxMacchina dell'impianto PARENT (se multi) altrimenti la stessa macchina... + /// + protected string getIdxMaccParent() + { + string answ = IdxMaccSel; + // se fosse multi controllo + if (isMulti) + { + // verifico se SIA una tavola (ha char "#") + int iSharp = IdxMaccSel.IndexOf('#'); + if (iSharp > 0) + { + // sistemo nome + answ = IdxMaccSel.Substring(0, iSharp); + } + } + return answ; + } + + /// + /// Registrazione Fine Setup / Inizio Produzione + /// + /// + /// + protected async Task OdlSetupEnd() + { + TimeSpan estDur = TimeSpan.FromMinutes((double)tcRichAttr * currPodl.NumPezzi); + string stima = estDur.TotalHours > 1 ? $"{estDur.TotalHours:N1} ore" : $"{estDur.TotalMinutes:N1} min"; + if (!await JSRuntime.InvokeAsync("confirm", $"PODL: {currPodl.IdxPromessa}{Environment.NewLine}Art: [{currPodl.CodArticolo}] {currPodl.DescArticolo}{Environment.NewLine}Pezzi: {currPodl.NumPezzi:N0} * TCiclo: {tcRichAttr:N3}min{Environment.NewLine}Tempo stimato: {stima}{Environment.NewLine}{Environment.NewLine}Confermi la chiusura della fase di attrezzaggio?")) + return; + + // preparo gestione progress display + MaxVal = 8; + int currStep = 0; + await advStep(currStep); + isProcessing = true; + await confermaProdOdl(true); + await advStep(currStep++); + // se vedesse TCRich a zero lo reimposta a quello assegnato... + if (tcRichAttr == 0) + { + tcRichAttr = currPodl.Tcassegnato; + } + // leggo idxOdl da ultimo odl attivo x macchina + var currOdl = await TabDServ.OdlCurrByMacc(IdxMaccSel, false); + int idxODLStart = currOdl.IdxOdl; + int idxEvento = 1; // !!!HARD CODED + + // aggiorno note e tempo setup + await TabDServ.OdlUpdate(idxODLStart, MatrOpr, tcRichAttr, PzPallet, noteAttr); + // controllo se TC Assegnato != TCRichiesto allora invio email x verifiche... + if (currOdl.Tcassegnato != tcRichAttr) + { + // invio email! + await SendWarnTcChangeReq(idxODLStart, currOdl.Tcassegnato, tcRichAttr); + } + await advStep(currStep++); + + // processo chiusura setup + string evText = "Registrata inizio produzione per ODL {0}"; + StringBuilder sb = new StringBuilder(); + sb.AppendLine(String.Format(evText, idxODLStart)); + await processaEvento(IdxMaccSel, idxEvento, sb.ToString(), idxODLStart); + // indico INIZIO SETUP su REDIS come EXE della macchina... + string ts = string.Format("{0:yyMMdd}T{0:HHmmss.fff}Z", DateTime.Now); + TabDServ.addTask4Machine(IdxMaccSel, taskType.stopSetup, $"TS:{ts}|MATR:{MatrOpr}|ODL:{idxODLStart}"); + await advStep(currStep++); + // se è multi processo chiusura setup x altra tavola... + if (isMulti) + { + sb.AppendLine("---"); + var tabOdlAltra = await TabDServ.OdlCurrByMacc(idxMaccAltraTav, true); + int idxOdlAltra = tabOdlAltra.IdxOdl; + sb.AppendLine(String.Format(evText, idxOdlAltra)); + await processaEvento(idxMaccAltraTav, idxEvento, String.Format(evText, idxOdlAltra), idxOdlAltra); + // invio su seconda tavola + TabDServ.addTask4Machine(idxMaccAltraTav, taskType.stopSetup, $"TS:{ts}|MATR: {MatrOpr}| Master Machine: {IdxMaccSel}"); + } + await advStep(currStep++); + // se è master --> chiamo update child! + if (isMaster) + { + // invio eventi ad IOB slave... + var slaveList = SMServ.ListM2S + .Where(x => x.IdxMacchina.Equals(IdxMaccSel, StringComparison.InvariantCultureIgnoreCase)) + .ToList(); + foreach (var machine in slaveList) + { + // invio chiusura attrezzaggio + ts = string.Format("{0:yyMMdd}T{0:HHmmss.fff}Z", DateTime.Now); + string outData = $"TS:{ts}|MATR:{MatrOpr}|ODL:{idxODLStart}"; + await processaEvento(machine.IdxMacchinaSlave, idxEvento, sb.ToString(), idxODLStart); + TabDServ.addTask4Machine(machine.IdxMacchinaSlave, taskType.fixStopSetup, outData); + } + + // hard coded 60gg last + await TabDServ.OdlFixMachineSlave(IdxMaccSel, 60, 1); + } + await advStep(currStep++); + // se c'è gestione SchedaTecnica --> chiamo procedura update x lotti + if (enableSchedaTecnica) + { + await TabDServ.ElencoLottiUpsertByOdl(idxODLStart, true); + } + await advStep(currStep++); + + // riporto stringa + lblOut = sb.ToString().Replace("---", "
"); + // update buttons... + checkAll(); + // imposto odl... + idxOdl = idxODLStart; + IdxPOdlSel = 0; + inAttr = false; + IdxPOdlSel = 0; + RecMSE = null; + await advStep(currStep++); + // faccio refresh e riporto + await RefreshData(); + await CheckAttr(); + // chiudo update... + isProcessing = false; + //await InvokeAsync(StateHasChanged); + // qui rimando a pag principale... + NavMan.NavigateTo("/", true); + } + + /// + /// Dichiarazione inizio attrezzaggio PODL indicato + /// + /// + protected async Task OdlSetupStart() + { + TimeSpan estDur = TimeSpan.FromMinutes((double)tcRichAttr * currPodl.NumPezzi); + string stima = estDur.TotalHours > 1 ? $"{estDur.TotalHours:N1} ore" : $"{estDur.TotalMinutes:N1} min"; + if (!await JSRuntime.InvokeAsync("confirm", $"PODL: {currPodl.IdxPromessa}{Environment.NewLine}Art: [{currPodl.CodArticolo}] {currPodl.DescArticolo}{Environment.NewLine}Pezzi: {currPodl.NumPezzi:N0} * TCiclo: {tcRichAttr:N3}min{Environment.NewLine}Tempo stimato: {stima}{Environment.NewLine}{Environment.NewLine}Confermi inizio della fase di attrezzaggio?")) + return; + + //if (!await JSRuntime.InvokeAsync("confirm", $"Confermi inizio della fase di attrezzaggio per l'articolo [{currPodl.CodArticolo}] {currPodl.DescArticolo}?")) + // return; + /*************************************************** + * comprende gestione machineSlave x fix ODL master --> slave + * + ***************************************************/ + + // preparo gestione progress display + MaxVal = 11; + int currStep = 0; + await advStep(currStep); + isProcessing = true; + DateTime adesso = DateTime.Now; + await advStep(currStep++); + // proseguo + int idxODL_curr = 0; + await confermaProdOdl(false); + await advStep(currStep++); + if (IdxPOdlSel > 0) + { + // se vedesse TCRich a zero lo reimposta a quello assegnato... + if (tcRichAttr == 0) + { + tcRichAttr = currPodl.Tcassegnato; + } + if (enableSplitODL && !forceCloseOdl) + { + // splitto VECCHIO ODL (se fosse rimasto qualcosa da produrre e ne sia rimasto uno.......) + try + { + var currOdl = await TabDServ.OdlCurrByMacc(IdxMaccSel, false); + int idxODLTemp = currOdl.IdxOdl; + decimal tcAss = currOdl.Tcassegnato; + await TabDServ.OdlSplit(idxODLTemp, MatrOpr, IdxMaccSel, tcAss, PzPallet, $"inizio attrezzaggio, Sospensione ODL {idxODLTemp}, generato residuo con pari TCiclo: {tcAss}", false, 0); + // se fosse multi processo ANCHE x altra tavola... + if (isMulti) + { + var otherOdl = await TabDServ.OdlCurrByMacc(IdxMaccSel, false); + int idxODLAlt = otherOdl.IdxOdl; + decimal tcAssAlt = otherOdl.Tcassegnato; + await TabDServ.OdlSplit(idxODLAlt, MatrOpr, idxMaccAltraTav, tcAssAlt, PzPallet, $"Inizio attrezzaggio, Sospensione ODL {idxODLAlt}, generato residuo con pari TCiclo: {tcAssAlt}", false, 0); + } + } + catch (Exception exc) + { + Log.Error($"Error StartSetup.01{Environment.NewLine}{exc}"); + } + } + await advStep(currStep++); + // 2018.07.24 verifico se devo lavorare come ODL classico o come RPO (Richiesta / + // Promessa / ODL) + if (enableRPO) + { + // creo nuovo ODL da promessa ed associo + await TabDServ.PODL_startSetup(currPodl, MatrOpr, tcRichAttr, PzPallet, noteAttr, adesso); + // salvo ODL attrezzato + var newOdl = await TabDServ.OdlCurrByMacc(IdxMaccSel, true); + idxODL_curr = newOdl.IdxOdl; + } + // ODL classico + else + { + // avvio NUOVO ODL + await TabDServ.OdlInizioSetup(IdxPOdlSel, MatrOpr, IdxMaccSel, tcRichAttr, PzPallet, noteAttr); + // salvo ODL Current + idxODL_curr = IdxPOdlSel; + } + await advStep(currStep++); + // process evento + int idxEvento = 2; // !!!HARD CODED + string evText = "Registrato inizio attrezzaggio per ODL {0}"; + StringBuilder sb = new StringBuilder(); + sb.AppendLine(String.Format(evText, idxODL_curr)); + await processaEvento(IdxMaccSel, idxEvento, sb.ToString(), idxODL_curr); + await advStep(currStep++); + // indico INIZIO SETUP su REDIS come EXE della macchina... + string ts = string.Format("{0:yyMMdd}T{0:HHmmss.fff}Z", DateTime.Now); + string outData = $"TS:{ts}|MATR:{MatrOpr}|ODL:{idxODL_curr}"; + // aggiungo articolo, commessa, richiesta pezzi... + try + { + var datiODL = await TabDServ.OdlCurrByMacc(IdxMaccSel, true); + string setArtVal = $"{datiODL.CodArticolo}"; + string setPzCommVal = $"{datiODL.NumPezzi}"; + string setCommVal = $"ODL{datiODL.IdxOdl:00000000}"; + // FIXME TODO: scrivere come sotto? testare valvital x linea LASCO + TabDServ.addTask4Machine(IdxMaccSel, taskType.startSetup, outData); + TabDServ.addTask4Machine(IdxMaccSel, taskType.setArt, setArtVal); + TabDServ.addTask4Machine(IdxMaccSel, taskType.setComm, setCommVal); + TabDServ.addTask4Machine(IdxMaccSel, taskType.setPzComm, setPzCommVal); + TabDServ.MachineParamUpdate(IdxMaccSel, "setArt", setArtVal); + TabDServ.MachineParamUpdate(IdxMaccSel, "setComm", setCommVal); + TabDServ.MachineParamUpdate(IdxMaccSel, "setPzComm", setPzCommVal); + TabDServ.addTask4Machine(IdxMaccSel, taskType.setParameter, "ForceUpdate"); + await advStep(currStep++); + // li aggiungo ANCHE sui PLC slave se ci sono... + if (isMaster) + { + // calcolo gli slave... + var slaveList = SMServ.ListM2S + .Where(x => x.IdxMacchina.Equals(IdxMaccSel, StringComparison.InvariantCultureIgnoreCase)) + .ToList(); + foreach (var machine in slaveList) + { + outData = $"TS:{ts}|MATR:{MatrOpr}|Master Machine: {IdxMaccSel}"; + // invio chiusura attrezzaggio + TabDServ.addTask4Machine(machine.IdxMacchinaSlave, taskType.startSetup, outData); + TabDServ.addTask4Machine(machine.IdxMacchinaSlave, taskType.setArt, setArtVal); + TabDServ.addTask4Machine(machine.IdxMacchinaSlave, taskType.setComm, setCommVal); + TabDServ.addTask4Machine(machine.IdxMacchinaSlave, taskType.setPzComm, setPzCommVal); + TabDServ.MachineParamUpdate(machine.IdxMacchinaSlave, "setArt", setArtVal); + TabDServ.MachineParamUpdate(machine.IdxMacchinaSlave, "setComm", setCommVal); + TabDServ.MachineParamUpdate(machine.IdxMacchinaSlave, "setPzComm", setPzCommVal); + TabDServ.addTask4Machine(machine.IdxMacchinaSlave, taskType.setParameter, "ForceUpdate"); + } + } + await advStep(currStep++); + } + catch (Exception exc) + { + Log.Error($"Eccezione in invio task4machine{Environment.NewLine}{exc}"); + } + + // se fosse multi CHIUDO ODL x altra tavola... + if (isMulti) + { + // se NON sono in attrezzaggio... + if (!inAttr) + { + int idxOdlAltra = 0; + try + { + var tabOdlAltra = await TabDServ.OdlCurrByMacc(idxMaccAltraTav, true); + idxOdlAltra = tabOdlAltra.IdxOdl; + } + catch (Exception exc) + { + Log.Error($"Errore Durante recupero idxOdlAltra {Environment.NewLine}{exc}"); + } + // procedo se ho ODL + if (idxOdlAltra > 0) + { + sb.AppendLine("---"); + await TabDServ.OdlFineProd(idxOdlAltra, idxMaccAltraTav); + evText = $"Registrato inizio attrezzaggio per ODL {idxOdlAltra} (setup seconda tavola)"; + sb.AppendLine(evText); + await processaEvento(idxMaccAltraTav, idxEvento, evText, idxOdlAltra); + } + lblOut = sb.ToString().Replace("---", "
"); + } + // update buttons... + checkAll(); + } + await advStep(currStep++); + // se fosse master --> chiamo update child! + if (isMaster) + { + // hard coded 60gg last + await TabDServ.OdlFixMachineSlave(IdxMaccSel, 60, 1); + } + await advStep(currStep++); + // resetto contapezzi redis... + await TabDServ.saveCounter(IdxMaccSel, "0"); + // imposto ODL su redis... + TabDServ.saveCurrODL(IdxMaccSel, idxODL_curr); + await advStep(currStep++); + } + else + { + lblOut = "Selezionare un ORDINE valido!"; + } + + // refresh finale + var tmpTCR = tcRichAttr; + checkBtnStatus(); + fixSplitBtn(false); + // faccio refresh e riporto + idxOdl = idxODL_curr; + IdxPOdlSel = 0; + RecMSE = null; + await RefreshData(); + await CheckAttr(); + inAttr = true; + tcRichAttr = tmpTCR; + isProcessing = false; + await InvokeAsync(StateHasChanged); + } + + protected override async Task OnInitializedAsync() + { + //baseLang = SMServ.GetConf("baseLang"); + numDayOdl = SMServ.GetConfInt("numDaySelOdl"); + confRett = SMServ.GetConfBool("confRett"); + enableSplitODL = SMServ.GetConfBool("enableSplitODL"); + modoConfProd = SMServ.GetConfInt("modoConfProd"); + enableRPO = SMServ.GetConfBool("enableRPO"); + enableSchedaTecnica = SMServ.GetConfBool("enableSchedaTecnica"); + string rawEmailDest = SMServ.GetConf("_adminEmail"); + emailAdmDest = rawEmailDest.Split(',').ToList(); + if (RecMSE != null) + { + IdxMaccSel = RecMSE.IdxMacchina; + IdxMaccParent = getIdxMaccParent(); + // verifica stato inAttr + await CheckAttr(); + await ReloadData(true); + } + checkAll(); + } + + protected override async Task OnParametersSetAsync() + { + isMulti = SMServ.DictMacchMulti[RecMSE?.IdxMacchina] == 1; + await ReloadData(false); + } + + protected async Task ProdEnd() + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi fine produzione?")) + return; + + // preparo gestione progress display + MaxVal = 7; + isProcessing = true; + int currStep = 0; + await advStep(currStep); + // leggo idxOdl da ultimo odl attivo x macchina + var currOdl = await TabDServ.OdlCurrByMacc(IdxMaccSel, false); + int idxODLCurr = currOdl.IdxOdl; + int idxEvento = 7; // !!!HARD CODED + // confermo prod vecchio ODL + await confermaProdOdl(false); + await advStep(currStep++); + + // se chk flaggato ovvero richiesta di chiudere ODL procedo come prima (chiudendo ODL + // senza averne altri...) + if (forceCloseOdl) + { + // aggiungo try/catch x capire se sia qui che si "impasta" in chiusura ODL + try + { + // processo x macchina selezionata + await TabDServ.OdlFineProd(idxODLCurr, IdxMaccSel); + string evText = "Registrata fine produzione per ODL {0}"; + StringBuilder sb = new StringBuilder(); + sb.AppendLine(String.Format(evText, idxODLCurr)); + await processaEvento(IdxMaccSel, idxEvento, sb.ToString(), idxODLCurr); + await advStep(currStep++); + // se è multi processo ANCHE x altra tavola... + if (isMulti) + { + sb.AppendLine("---"); + var tabOdlAltra = await TabDServ.OdlCurrByMacc(idxMaccAltraTav, true); + int idxOdlAltra = tabOdlAltra.IdxOdl; + await TabDServ.OdlFineProd(idxOdlAltra, idxMaccAltraTav); + sb.AppendLine(String.Format(evText, idxOdlAltra)); + await processaEvento(idxMaccAltraTav, idxEvento, String.Format(evText, idxOdlAltra), idxOdlAltra); + } + await advStep(currStep++); + // se è master --> chiamo update child! + if (isMaster) + { + // hard coded 60gg last + await TabDServ.OdlFixMachineSlave(IdxMaccSel, 60, 1); + } + await advStep(currStep++); + // riporto stringa + lblOut = sb.ToString().Replace("---", "
"); + } + catch (Exception exc) + { + Log.Error($"Eccezione in operazione chiusura ODL!{Environment.NewLine}{exc}"); + // navigo! + NavMan.NavigateTo($"machine-detail"); + } + } + // altrimenti split ODL x completare IN FUTURO la produzione... + else + { + try + { + // effettuo split su nuovo ODL + await TabDServ.OdlSplit(idxODLCurr, MatrOpr, IdxMaccSel, currOdl.Tcassegnato, PzPallet, $"Fine Produzione, Sospensione ODL {idxODLCurr}, generato residuo con pari TCiclo: {currOdl.Tcassegnato}", false, 0); + // processo chiusura setup + await processaEvento(IdxMaccSel, idxEvento, $"Registrata fine produzione per ODL {idxODLCurr}, nuovo ODL per quantità residua", idxODLCurr); + + await advStep(currStep++); + // se è multi processo ANCHE x altra tavola... + if (isMulti) + { + var tabOdlAltra = await TabDServ.OdlCurrByMacc(idxMaccAltraTav, true); + int idxOdlAltra = tabOdlAltra.IdxOdl; + // effettuo split su nuovo ODL + await TabDServ.OdlSplit(idxOdlAltra, MatrOpr, idxMaccAltraTav, tabOdlAltra.Tcassegnato, PzPallet, $"Fine Produzione, Sospensione ODL {idxOdlAltra}, generato residuo con pari TCiclo: {tabOdlAltra.Tcassegnato}", false, 0); + // processo chiusura setup + await processaEvento(idxMaccAltraTav, idxEvento, $"Registrata fine produzione per ODL {idxOdlAltra}, nuovo ODL per quantità residua", idxOdlAltra); + } + await advStep(currStep++); + // se è master --> chiamo update child! + if (isMaster) + { + // hard coded 60gg last + await TabDServ.OdlFixMachineSlave(IdxMaccSel, 60, 1); + } + // sistemo buttons! + fixSplitBtn(false); + await advStep(currStep++); + } + catch (Exception exc) + { + Log.Error($"Eccezione in operazione Chiusura + Split ODL su nuovo! {Environment.NewLine}{exc}"); + // navigo! + NavMan.NavigateTo($"machine-detail"); + } + } + await advStep(currStep++); + // faccio refresh e riporto + IdxPOdlSel = 0; + RecMSE = null; + currOdl = new ODLExpModel(); + inAttr = false; + IdxPOdlSel = 0; + forceCloseOdl = true; + //await Task.Delay(250); + await RefreshData(); + await CheckAttr(); + await advStep(currStep++); + isProcessing = false; + await InvokeAsync(StateHasChanged); + //NavMan.NavigateTo(NavMan.Uri, true); + } + + protected async Task RefreshData() + { + // refresh tabella dati tablet... + RecMSE = null; + // rileggo e salvo.. + var ListMSE = await MDataService.MseGetAll(true); + if (ListMSE != null) + { + // salvo in LocalStorage... + await MServ.SaveMse(ListMSE); + // aggiorno MSE attuale + RecMSE = ListMSE.Find(x => x.IdxMacchina == IdxMaccSel); + await E_Updated.InvokeAsync(ListMSE); + } + // update dati liste ODL + await ReloadData(true); + } + + protected void SaveTCRich(decimal newTCRich) + { + tcRichAttr = newTCRich; + } + + protected async Task SendWarnTcChangeReq(int idxOdl, decimal tcAss, decimal tcRich) + { + // carico altri parametri email... + string oggetto = SMServ.GetConf("oggettoChgTc"); + string corpoChgTc = SMServ.GetConf("corpoChgTc"); + string mittente = SMServ.GetConf("_fromEmail"); + string baseUrlAdmin = SMServ.GetConf("baseUrlAdmin"); + string pageUrlApprODL = SMServ.GetConf("pageUrlApprODL"); + string pageUrl = $"{baseUrlAdmin}{pageUrlApprODL}"; + string corpo = $"ODL: {idxOdl} | TC Assegnato: {tcAss:N3} | TC Rich: {tcRich}{Environment.NewLine}{Environment.NewLine}"; + corpo += string.Format(corpoChgTc, Environment.NewLine, pageUrl); + corpo = corpo.Replace($"{Environment.NewLine}", "
"); + MailKitMailData mData = new MailKitMailData() + { + From = mittente, + To = emailAdmDest, + Subject = oggetto, + Body = corpo + }; + bool done = await MailServ.SendAsync(mData); + if (done) + { + Log.Info($"Inviata email notifica TC da approvare per ODL {idxOdl} inviato a {string.Join(",", emailAdmDest)}"); + } + else + { + Log.Error($"Errore in invio email notifica TC da approvare per ODL {idxOdl} | tentato invio a {string.Join(",", emailAdmDest)}"); + } + } + + protected async Task SetMacc(string selIdxMacc) + { + isProcessing = true; + await Task.Delay(10); + IdxMaccSel = selIdxMacc; + await DoUpdate(); + isProcessing = false; + await Task.Delay(10); + } + + protected async Task ToggleOdlDetail() + { + showOdlDetail = !showOdlDetail; + // se devo mostrare, carico dati ODL! + if (showOdlDetail) + { + await ReloadXDL(true); + } + } + + private string txtForceCloseOdl + { + get => forceCloseOdl ? Traduci("ForceCloseODL") : Traduci("SplitCurrODL"); + } + + private async Task ReloadXDL(bool reloadFromOdl) + { + int currIdxPOdl = IdxPOdlSel; + if (RecMSE != null) + { + if (reloadFromOdl) + { + currIdxPOdl = RecMSE.IdxPOdl ?? 0; + } + // se ho PODL valido... + if (currIdxPOdl > 0) + { + currPodl = await TabDServ.PODLExp_getByKey(currIdxPOdl); + } + else + { + currPodl = new PODLExpModel() + { + IdxOdl = RecMSE.IdxOdl ?? 0, + KeyRichiesta = "-", + CodArticolo = RecMSE.CodArticolo, + DescArticolo = RecMSE.CodArticolo, + NumPezzi = RecMSE.NumPezzi, + Tcassegnato = RecMSE.TCAssegnato + }; + } + } + // update a runtime dati ODL se assegnato + if (currPodl.IdxOdl > 0) + { + currOdl = await TabDServ.OdlByIdx(currPodl.IdxOdl, false); + } + } + + protected string Traduci(string lemma) + { + return SMServ.Traduci($"{baseLang}_{lemma}".ToUpper()); + } + + protected async Task SendFixEndSetup() + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi invio FIX chiusura atrtezzaggio ad impianto?")) + return; + + string ts = string.Format("{0:yyMMdd}T{0:HHmmss.fff}Z", DateTime.Now); + string outData = $"TS:{ts}|MATR:{MatrOpr}|ODL:{IdxOdl}"; + TabDServ.addTask4Machine(IdxMaccSel, taskType.fixStopSetup, outData); + outData = "Inserita richiesta invio Fix chiusura attrezzaggio " + outData; + lblOut = outData; + // se è master --> chiamo update child! + if (isMaster) + { + // invio eventi ad IOB slave... + var slaveList = SMServ.ListM2S + .Where(x => x.IdxMacchina.Equals(IdxMaccSel, StringComparison.InvariantCultureIgnoreCase)) + .ToList(); + foreach (var machine in slaveList) + { + // invio chiusura attrezzaggio + outData = $"TS:{ts}|MATR:{MatrOpr}|ODL:{idxOdl}|master machine:{IdxMaccSel}"; + TabDServ.addTask4Machine(machine.IdxMacchinaSlave, taskType.fixStopSetup, outData); + } + } + } + + #endregion Protected Methods + + #region Private Fields + + private static Logger Log = LogManager.GetCurrentClassLogger(); + + private bool cancelSetupEnabled = false; + + private bool confRett = true; + + private double currVal = 0; + + private List emailAdmDest = new List(); + + private bool enableRPO = true; + + private bool enableSchedaTecnica = false; + + private bool enableSplitODL = false; + + private int expTimeMsec = 500; + + private bool forceCloseOdl = true; + + private string IdxMaccSel = ""; + + private int idxOdl = 0; + + private int idxPOdlSel = 0; + + private bool inAttr = false; + + private bool isInProd = false; + + private bool isMaster = false; + + private bool isMulti = false; + + private bool isProcessing = false; + + private bool isSlave = false; + + private int lastIdxPOdl = 0; + + private string lblOut = ""; + + private int MaxVal = 10; + + private int modoConfProd = 0; + + private double nextVal = 0; + + private string noteAttr = ""; + + private int numDayOdl = 5; + + private int PzPallet = 1; + + private bool showAll = false; + + private bool showOdlDetail = false; + + private decimal tcRichAttr = 1; + + #endregion Private Fields + + #region Private Properties + + private string _baseLang { get; set; } = "IT"; + + private string baseLang + { + get => _baseLang; + set { MServ.UserPrefGet("Lang"); } + } + + private PODLExpModel currPodl { get; set; } = new PODLExpModel(); + private ODLExpModel currOdl { get; set; } = new ODLExpModel(); + + /// + /// Variabile idxMacc parent x selezione ODL + /// + private string IdxMaccParent { get; set; } = ""; + + private int IdxOdl + { + get => RecMSE != null ? RecMSE.IdxOdl ?? 0 : 0; + } + + private string lblWarnBody + { + get => odlOk ? Traduci("ConfProdBeforeContinueBody") : Traduci("setOdlBeforeContinueBody"); + } + + private string lblWarnHead + { + get => odlOk ? Traduci("ConfProdBeforeContinueHead") : Traduci("setOdlBeforeContinueHead"); + } + + + private int MatrOpr + { + get => MServ.MatrOpr; + } + + private bool needConfProd + { + get + { + bool answ = true; + if (prodMacchina != null) + { + answ = prodMacchina.pezziNonConfermati > 0 && !isSlave; + } + return answ; + } + } + + private bool endProdDisabled + { + get => !odlOk || needConfProd; + } + + private int numPz2Conf + { + get + { + int answ = -1; + if (prodMacchina != null) + { + answ = prodMacchina.pezziNonConfermati; + } + else + { + answ = RecMSE != null ? RecMSE.PezziProd - RecMSE.PezziConf : 0; + } + return answ; + } + } + + private string txtBtnOdlDetail + { + get => showOdlDetail ? "Nascondi Dettaglio ODL" : "MOSTRA Dettaglio ODL Corrente"; + } + private string titleOdlDetail + { + get => IdxPOdlSel > 0 ? "Verifica parametri attrezzaggio NUOVO PODL" : inAttr ? "Parametri PODL in Attrezzaggio" : "Parametri ODL Corrente"; + } + + private string cssDetailOdl + { + get => IdxPOdlSel > 0 ? "bg-primary text-light" : "bg-warning"; + } + + #endregion Private Properties + + #region Private Methods + + private void checkAll() + { + checkConfProd(); + } + + /// + /// controlla stato bottoni abilitato + /// + private void checkBtnStatus() + { +#if false + // di default rendo abilitato / disabilitato tutto in base al valore "isEnabled" + lbtShowSplitODL.Enabled = isEnabled && enableRiattrezzaggio; + lbtSplitODL.Enabled = isEnabled; + + fixWCtrStatus(lbtShowSplitODL); + fixWCtrStatus(lbtSplitODL); + + // condizioni booleane + bool inAttr = false; + bool currHasOdl = false; + // controllo se la macchina è in attrezzaggio... + DS_applicazione.StatoMacchineRow rigaStato = null; + try + { + // se è multi controllo parent... + if (isMulti) + { + rigaStato = selData.mng.rigaStato(idxMaccParent); + inAttr = (rigaStato.IdxStato == 2 && tavHasOdl); + } + else + { + rigaStato = selData.mng.rigaStato(idxMacchinaFix); + if (rigaStato != null) + { + inAttr = (rigaStato.IdxStato == 2); + } + } + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Eccezione in recupero dati rigaStato! {0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + } + + try + { + currHasOdl = DataLayerObj.taODL.getByMacchina(idxMacchinaFix)[0].IdxODL != 0; + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Eccezione in recupero dati currHasOdl! {0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + } + // deve controllare abbia ODL o PROMESSE odl... + bool hasNewOdl = DataLayerObj.taSelOdlFree.getUnused(idxMacchinaFix, cmp_selPODL.checkAll, numDaySelOdl).Rows.Count > 1; + // sistemo buttons! + lbtStartAttr.Enabled = (isEnabled && (!inAttr && hasNewOdl)); + lbtEndProd.Enabled = (isEnabled && (!inAttr && currHasOdl)); + + // verifico condizioni annullamento setup + lbtAnnullaSetup.Visible = false; + if (isEnabled && enableAnnullaSetup && inAttr && enableSchedaTecnica) + { + // verifico condizione pz da confermare + var tabProd = DataLayerObj.taStatoProd.GetData(idxMacchinaSel, DateTime.Now); + if (tabProd != null && tabProd.Rows.Count > 0) + { + var rigaProd = tabProd[0]; + lbtAnnullaSetup.Visible = rigaProd.PzTotODL == 0; + } + } + + // controllo se ci sia da verificare scheda tecnica + if (enableSchedaTecnica) + { + var tabRichieste = DataLayerObj.taSTAR.getPendingByOdl(idxOdl); + bool okCheckST = tabRichieste.Count == 0; + if (okCheckST) + { + hlNeedStar.Visible = false; + lbtStartProd.Enabled = (isEnabled && inAttr); + } + else + { + hlNeedStar.Visible = (isEnabled && inAttr); + lbtStartProd.Enabled = false; + } + } + else + { + lbtStartProd.Enabled = (isEnabled && inAttr); + } + cmp_selPODL.Enabled = (isEnabled && (!inAttr && hasNewOdl)); + // sistemo anche come css.. + fixWCtrStatus(lbtStartAttr); + fixWCtrStatus(lbtStartProd); + fixWCtrStatus(lbtEndProd); + // sistemo show tempo/note attrezzaggio.. + if (inAttr) + { + showNoteTC(true); + int idxOdl = 0; + try + { + idxOdl = DataLayerObj.taODL.getByMacchina(idxMacchinaFix)[0].IdxODL; + updateTempoTc(idxOdl, inAttr); + updateNoteTC(idxOdl); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Eccezione in recupero dati ODL! {0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + } + } + + // verifico se l'articolo corrente sia in revisione x mostrare conferma modifica revisione... + if (CodArtSel != "") + { + bool showWarn = false; + try + { + showWarn = DataLayerObj.taAnagArt.getByCod(CodArtSel)[0].FlagIsNew; + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Eccezione in recupero dati showWarn! {0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + } + divWarningArt.Visible = showWarn; + } +#endif + } + + /// + /// verifica se sia necessario confermare la produzione PRIMA di operare sull'ODL + /// + private void checkConfProd() + { +#if false + // verifica se sia necessario confermare produzione + int pz2conf = 0; + DS_ProdTempi.stp_PzProd_getByMacchinaRow rigaProd; + try + { + rigaProd = DataLayerObj.taPzProd2conf.GetData(idxMacchinaFix)[0]; + pz2conf = rigaProd.pezziNonConfermati; + needConfProd = (pz2conf > 0 && !isSlave); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore recupero pezzi da confermare per la macchina {0}{1}{2}", idxMacchinaFix, Environment.NewLine, exc), tipoLog.ERROR); + } + // se necessario mostro warning... + if (needConfProd) + { + // SE mancasse ODL mostro info x poter caricare ODL retrodatato + if (odlOk) + { + lblWarningHead.Text = traduci("ConfProdBeforeContinueHead"); + lblWarningBody.Text = traduci("ConfProdBeforeContinueBody"); + lblNumPz2Conf.Text = string.Format("{0} pz NC", pz2conf); + } + else + { + lblWarningHead.Text = traduci("setOdlBeforeContinueHead"); + lblWarningBody.Text = traduci("setOdlBeforeContinueBody"); + lblNumPz2Conf.Text = string.Format("{0} pz NC", pz2conf); + } + } + divPz2Conf.Visible = needConfProd; + divWarn.Visible = needConfProd; + lbtFixOdl.Visible = !odlOk; + mod_ODL1.isEnabled = !needConfProd; +#endif + } + + /// + /// verifica se sia necessario confermare la prod dell'ODL precedente prima di chiudere e lo + /// fa in automatico... + /// + /// boolean, true = deve confermare 0 pezzi (es. in setup) + private async Task confermaProdOdl(bool confZero) + { + // 2016.11.17 NOTA: introdotti scarti, li confermiamo SEMPRE a zero se in setup, per� da + // valutare SE a FINE ATTREZZAGGIO chiedere num pezzi e num scarti (saldo zero buoni) da inserire... + bool fatto = false; + DateTime adesso = DateTime.Now; + if (confZero) + { + // confermo produzione ZERO pezzi (in setup) + if (confRett) + { + // confermo al netto dei pezzi lasciati... + fatto = TabDServ.ConfermaProdMacchinaFull(IdxMaccSel, modoConfProd, 0, 0, 0, adesso, MatrOpr); + } + else + { + fatto = TabDServ.ConfermaProdMacchina(IdxMaccSel, modoConfProd, 0, 0, adesso, MatrOpr); + } + } + else // se NON sono in setup verifico se ho pz da confermare + { + // recupero pz da confermare + var rawData = await TabDServ.PezziProdMacchina(IdxMaccSel); + prodMacchina = rawData.FirstOrDefault() ?? new PzProdModel(); + if (prodMacchina.pezziNonConfermati > 0) + { + // confermo produzione ZERO pezzi (in setup) + if (confRett) + { + // confermo al netto dei pezzi lasciati... + fatto = TabDServ.ConfermaProdMacchinaFull(IdxMaccSel, modoConfProd, prodMacchina.pezziNonConfermati, 0, 0, adesso, MatrOpr); + } + else + { + fatto = TabDServ.ConfermaProdMacchina(IdxMaccSel, modoConfProd, prodMacchina.pezziNonConfermati, 0, adesso, MatrOpr); + } + } + } + } + + /// + /// sistema buttons split + /// + /// + private void fixSplitBtn(bool splitOdl) + { +#if false + lbtShowSplitODL.Visible = !splitOdl && enableRiattrezzaggio; + lbtSplitODL.Visible = splitOdl; + + chkCloseOdl.Visible = showChkCloseOdlVal && !splitOdl; + chkCloseOdl.Enabled = isEnabled; + fixWCtrStatus(chkCloseOdl); + + showNoteTC(splitOdl); + cmp_selPODL.CtrlVisible = !splitOdl; + lbtStartAttr.Visible = !splitOdl; + lbtShowOdlDet.Visible = !lbtStartAttr.Visible; + lbtStartProd.Visible = !splitOdl; + lbtEndProd.Visible = !splitOdl; +#endif + } + + /// + /// processa evento richiesto + /// + /// + /// + /// + /// + private async Task processaEvento(string idxMaccCurr, int idxEvento, string userMsg, int idxODL) + { + inputComandoMapo inCmd; + inputComandoMapo inCmd2; + DateTime adesso = DateTime.Now; + var rigaStato = TabDServ.StatoMacchina(idxMaccCurr); + // processo evento... + EventListModel newRec = new EventListModel() + { + IdxMacchina = idxMaccCurr, + InizioStato = adesso, + IdxTipo = idxEvento, + CodArticolo = rigaStato.CodArticolo, + Value = "", + MatrOpr = MatrOpr, + pallet = rigaStato.pallet + }; + // se realtime + inCmd = await TabDServ.EvListInsert(newRec, Enums.tipoInputEvento.barcode); + // se la macchina è MULTI (cod#tavola) e sonoa INIZIO/FINE attrezzaggio (idxEv <=2) + // oppure FINE PROD processo ANCHE per la macchina madre... + if (idxMaccCurr.IndexOf('#') > 0 && (idxEvento <= 2 || idxEvento == 7)) + { + EventListModel newRecParent = new EventListModel() + { + IdxMacchina = IdxMaccParent, + InizioStato = adesso, + IdxTipo = idxEvento, + CodArticolo = rigaStato.CodArticolo, + Value = "", + MatrOpr = MatrOpr, + pallet = rigaStato.pallet + }; + inCmd2 = await TabDServ.EvListInsert(newRecParent, Enums.tipoInputEvento.barcode); + } + // chiamo refresh MSE + await TabDServ.RicalcMse(idxMaccCurr, 0); + lblOut = userMsg; + // loggo USR MSG + Log.Info(userMsg); + checkBtnStatus(); + } + + private async Task ReloadData(bool forceReload) + { + Log.Trace("OdlMan.ReloadData"); + if (forceReload) + { + isMaster = SMServ.ListM2S + .Where(x => x.IdxMacchina.Equals(RecMSE?.IdxMacchina, StringComparison.InvariantCultureIgnoreCase)) + .ToList().Count > 0; + isSlave = SMServ.ListM2S + .Where(x => x.IdxMacchinaSlave.Equals(RecMSE?.IdxMacchina, StringComparison.InvariantCultureIgnoreCase)) + .ToList().Count > 0; + } + if (!string.IsNullOrEmpty(IdxMaccSel)) + { + ListODL = await TabDServ.VSOdlGetUnused(IdxMaccParent, ShowAll, numDayOdl); + Log.Trace($"found {ListODL.Count} rec"); + if (forceReload) + { + var rawData = await TabDServ.PezziProdMacchina(IdxMaccSel); + prodMacchina = rawData.FirstOrDefault() ?? new PzProdModel(); + } + } + // imposto tcRichAttr in base allo stato... + if (odlOk) + { + // prendo TCRich da ODL... + if (IdxOdl > 0) + { + tcRichAttr = currOdl.TCRichAttr; + } + else + { + tcRichAttr = currPodl.Tcassegnato; + } + } + } + + private async Task ReloadPOdlDetailData() + { + if (IdxPOdlSel > 0) + { + await ReloadXDL(false); + // controllo se � cambiato PODL + if (IdxPOdlSel != lastIdxPOdl) + { + lastIdxPOdl = IdxPOdlSel; + tcRichAttr = currPodl.Tcassegnato; + } + } + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/OdlProdFix.razor b/MP-TAB-SERV/Components/OdlProdFix.razor deleted file mode 100644 index 68d8acf5..00000000 --- a/MP-TAB-SERV/Components/OdlProdFix.razor +++ /dev/null @@ -1,5 +0,0 @@ -

OdlProdFix

- -@code { - -} diff --git a/MP-TAB-SERV/Components/OdlSetup.razor b/MP-TAB-SERV/Components/OdlSetup.razor deleted file mode 100644 index 1bcfd3cf..00000000 --- a/MP-TAB-SERV/Components/OdlSetup.razor +++ /dev/null @@ -1,5 +0,0 @@ -

OdlSetup

- -@code { - -} diff --git a/MP-TAB-SERV/Components/ParamsMan.razor b/MP-TAB-SERV/Components/ParamsMan.razor index 75592280..6f490e22 100644 --- a/MP-TAB-SERV/Components/ParamsMan.razor +++ b/MP-TAB-SERV/Components/ParamsMan.razor @@ -1,5 +1,139 @@ -

ParamsMan

- -@code { - -} + +
+
+
+
+ Gestione Parametri Macchina +
+
+ +
+
+
+
+ + + + + + + + + + + @if (ListRecord.Count == 0) + { + + + + } + else + { + @foreach (var item in ListRecord) + { + + + + + + + } + } + +
+ Parametro + + Valore + + DTime + +
+

No record found

+
+
+
+
+ @item.description +
+
+ @item.name +
+
+
+
+
+ @if (isSelected(item.uid)) + { +
+
+ + + +
+
+ } +
+
+ @item.value   +
+
+
+
+
+
+ + @item.reqValue   +
+
+
+
+
+
+
+ + @($"{item.lastRead:HH:mm:ss}") + + + @($"{item.lastRead:yyyy.MM.dd HH:mm:ss}") + +
+
+
+ @if (!string.IsNullOrEmpty(item.reqValue)) + { +
+
+
+ + @($"{item.lastRequest:HH:mm:ss}") + + + @($"{item.lastRequest:yyyy.MM.dd HH:mm:ss}") + +
+
+
+ } +
+ @if (item.writable) + { + @if (isSelected(item.uid)) + { + @*
+
+ + +
+
*@ + } + else + { + + } + } +
+
+
+
Elenco parametri di configurazione impianto
+
+
\ No newline at end of file diff --git a/MP-TAB-SERV/Components/ParamsMan.razor.cs b/MP-TAB-SERV/Components/ParamsMan.razor.cs new file mode 100644 index 00000000..7514b8c7 --- /dev/null +++ b/MP-TAB-SERV/Components/ParamsMan.razor.cs @@ -0,0 +1,174 @@ +using global::Microsoft.AspNetCore.Components; +using MP.Data.DatabaseModels; +using MP.Data.DTO; +using MP.Data.Services; +using NLog; + +namespace MP_TAB_SERV.Components +{ + public partial class ParamsMan : IDisposable + { + #region Public Properties + + [Parameter] + public MappaStatoExpl? RecMSE { get; set; } = null; + + #endregion Public Properties + + #region Public Methods + + public void Dispose() + { + if (aTimer != null) + { + aTimer.Elapsed -= ElapsedTimer; + aTimer.Stop(); + aTimer.Dispose(); + } + } + + #endregion Public Methods + + #region Protected Properties + + protected List ListRecord { get; set; } = new List(); + + [Inject] + protected MessageService MServ { get; set; } = null!; + + protected string reqVal { get; set; } = ""; + + [Inject] + protected TabDataService TabDServ { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected async Task DoCancel() + { + reqVal = ""; + currItem = null; + await ReloadData(); + } + + protected async Task DoSave() + { + if (currItem != null) + { + // invio richiesta e salvo... + updateParameter(currItem.uid, reqVal); + currItem = null; + } + await ReloadData(); + } + + protected void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e) + { + var pUpd = Task.Run(async () => + { + await ReloadData(); + await InvokeAsync(() => StateHasChanged()); + }); + pUpd.Wait(); + } + + protected async Task ForceReload() + { + currItem = null; + await ReloadData(); + } + + protected bool isSelected(string uid) + { + bool answ = false; + if (currItem != null) + { + answ = uid == currItem.uid; + } + return answ; + } + + protected override async Task OnInitializedAsync() + { + await Task.Delay(1); + setupConf(); + StartTimer(); + currItem = null; + if (RecMSE != null) + { + IdxMaccSel = RecMSE.IdxMacchina; + await ReloadData(); + } + await Task.Delay(1); + } + + protected string selectedCss(string uid) + { + string answ = ""; + if (currItem != null) + { + answ = uid == currItem.uid ? "table-info" : ""; + } + return answ; + } + + protected void SelRecord(ObjItemDTO newRec) + { + reqVal = newRec.value; + currItem = newRec; + } + + protected void StartTimer() + { + //int.TryParse(Configuration["ReloadStatusTimer"], out tOutPeriod); + aTimer = new System.Timers.Timer(dtTimerTabParam); + aTimer.Elapsed += ElapsedTimer; + aTimer.Enabled = true; + aTimer.Start(); + } + + protected void updateParameter(string uid, string reqValue) + { + Log.Info($"updateParameter | idxMacchina: {IdxMaccSel} | uid: {uid} | reqValue: {reqValue}"); + TabDServ.MachineParamUpdate(IdxMaccSel, uid, reqValue); + Log.Info($"updateParameter | idxMacchina: {IdxMaccSel} | uid: {uid} | done!"); + } + + #endregion Protected Methods + + #region Private Fields + + private static Logger Log = LogManager.GetCurrentClassLogger(); + private System.Timers.Timer aTimer = null!; + private int dtTimerTabParam = 5000; + private bool isProcessing = false; + + #endregion Private Fields + + #region Private Properties + + private ObjItemDTO? currItem { get; set; } = null; + + private string IdxMaccSel { get; set; } = ""; + + #endregion Private Properties + + #region Private Methods + + private async Task ReloadData() + { + isProcessing = true; + ListRecord = TabDServ.MachineParamList(IdxMaccSel); + await Task.Delay(1); + isProcessing = false; + } + + private void setupConf() + { + TabDServ.ConfigGetVal("dtTimerTabParam", ref dtTimerTabParam); + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/PrintMag.razor b/MP-TAB-SERV/Components/PrintMag.razor index 47392857..3499ac12 100644 --- a/MP-TAB-SERV/Components/PrintMag.razor +++ b/MP-TAB-SERV/Components/PrintMag.razor @@ -1,12 +1,12 @@ -
-
+
+ @*
Gestione stampa etichette
Gestione etichette per l'ODL con modulo MAG -
-
- MAG -
+
*@ + @*
+
*@ + MAG
diff --git a/MP-TAB-SERV/Components/ProdConfirm.razor b/MP-TAB-SERV/Components/ProdConfirm.razor index 6fefc1a7..27589b44 100644 --- a/MP-TAB-SERV/Components/ProdConfirm.razor +++ b/MP-TAB-SERV/Components/ProdConfirm.razor @@ -1,15 +1,20 @@  - -
-
+ +
+
+ +
+ +
+
+ +
@if (odlOk) { -
-
- -
+
+
} else @@ -17,141 +22,144 @@
MANCA ODL: conferma NON permessa
}
-
- @if (showInnov) - { -
-
- Dati Incrementali +
+ + +@if (showInnov) +{ +
+
+
+ +
+
Pezzi confermati
+ +
-
- - ultima conferma --> @dtReqUpdate.ToString() - -
-
- - -
-
-
-
- Pz Scarto - + - Pz Buoni -
-
-
-
-
- @lblPz2RecScarto - + - @lblPz2RecBuoni -
-
-
-
-
+ @*
+ + +
*@ + @*
+ + +
*@ +
+
+
@if (enablePzProdLasciati) { - - +
Lasciati
+ + } else { }
-
- @if (showConfirm) +
+
+
Pz Buoni @lblPz2RecBuoni
+
Pz scarto @lblPz2RecScarto
+
+
+ @if (showConfirm) + { + + } +
+
+ + +
+} +
+
+ Dati Globali ODL +
+
+
+ +
+
+ +
+
+
+ +
+
+
+ [A] NUOVI Pz.Prod +
+
+ @if (isProcessing) { - + + } + else + { + @($"{numPzProdotti2Rec:N0}") }
- } -
-
-
-
- Dati Globali ODL -
-
- - Periodo ODL calcolato: - @dtInizio - - - @dtFine - -
+
+
+
+
+ Pz Prodotti TOT [A+B+C] +
+
+ @if (isProcessing) + { + + } + else + { + @numPzProdotti.ToString("N0") + } +
+
+
+
+
+
+ [B] Scarti VERS. +
+
+ @if (isProcessing) + { + + } + else + { + @numPzScaConf.ToString("N0") + } +
+
+
+
+
+
+ [C] Pz Buoni VERS. +
+
+ @if (isProcessing) + { + + } + else + { + @numPzBuoniConf.ToString("N0") + } +
+
+
+ -
-
-
- [A] NUOVI Pz.Prod -
-
- @if (isProcessing) - { - - } - else - { - @numPz2Rec.ToString("N0") - } -
-
-
-
-
-
- Pz Prodotti TOT [A+B+C] -
-
- @if (isProcessing) - { - - } - else - { - @numPzProdotti.ToString("N0") - } -
-
-
-
-
-
- [B] Scarti VERS. -
-
- @if (isProcessing) - { - - } - else - { - @numPzScaConf.ToString("N0") - } -
-
-
-
-
-
- [C] Pz Buoni VERS. -
-
- @if (isProcessing) - { - - } - else - { - @numPzBuoniConf.ToString("N0") - } -
-
@if (!string.IsNullOrEmpty(lblOut)) diff --git a/MP-TAB-SERV/Components/ProdConfirm.razor.cs b/MP-TAB-SERV/Components/ProdConfirm.razor.cs index ae45be7b..b9867dc0 100644 --- a/MP-TAB-SERV/Components/ProdConfirm.razor.cs +++ b/MP-TAB-SERV/Components/ProdConfirm.razor.cs @@ -18,13 +18,13 @@ namespace MP_TAB_SERV.Components /// registrato nuovo valore /// [Parameter] - public EventCallback E_newVal { get; set; } + public EventCallback E_reset { get; set; } /// - /// registrato nuovo valore + /// Post update restituisco nuova lista dati /// [Parameter] - public EventCallback E_reset { get; set; } + public EventCallback> E_Updated { get; set; } /// /// Verifica ODL OK (ovvero caricato x macchina...) @@ -39,37 +39,16 @@ namespace MP_TAB_SERV.Components #endregion Public Properties - #region Public Methods - - /// - /// Aggiorno valori produzione alla data richiesta... - /// - /// - public async Task doUpdate() - { - isProcessing = true; - await Task.Delay(1); - datiProdAct = await TabDServ.StatoProdMacchina(IdxMaccSel, dtReqUpdate); - // aggiorno visualizzazione... - numPzProdotti = datiProdAct.PzTotODL; - numPz2Rec = datiProdAct.Pz2RecTot; - numPzScaConf = datiProdAct.PzConfScarto; - numPzBuoniConf = datiProdAct.PzConfBuoni; - numPzProdotti2Rec = datiProdAct.Pz2RecTot; - numPzScarto2Rec = datiProdAct.Pz2RecScarto; - dtInizio = RecMSE?.DataInizioOdl ?? DateTime.Today.AddMonths(-2); - dtFine = dtReqUpdate; - isProcessing = false; - await Task.Delay(1); - } - - #endregion Public Methods - #region Protected Properties + protected string ConfBg + { + get => showInnov ? "bg-warning text-dark" : "bg-success text-light"; + } + protected string ConfTitle { - get => showInnov ? "Nascondi Conferma" : "Mostra Conferma"; + get => showInnov ? "Nascondi conferma" : "Mostra conferma"; } /// @@ -126,8 +105,11 @@ namespace MP_TAB_SERV.Components } protected int numPzProdotti { get; set; } = 0; + protected int numPzProdotti2Rec { get; set; } = 0; + protected int numPzScaConf { get; set; } = 0; + protected int numPzScarto2Rec { get; set; } = 0; [Inject] @@ -140,6 +122,28 @@ namespace MP_TAB_SERV.Components #region Protected Methods + /// + /// Aggiorno valori produzione alla data richiesta... + /// + /// + protected async Task DoUpdate() + { + isProcessing = true; + await Task.Delay(1); + datiProdAct = await TabDServ.StatoProdMacchina(IdxMaccSel, dtReqUpdate); + // aggiorno visualizzazione... + numPzProdotti = datiProdAct.PzTotODL; + numPz2Rec = datiProdAct.Pz2RecTot; + numPzScaConf = datiProdAct.PzConfScarto; + numPzBuoniConf = datiProdAct.PzConfBuoni; + numPzProdotti2Rec = datiProdAct.Pz2RecTot; + numPzScarto2Rec = datiProdAct.Pz2RecScarto; + dtInizio = RecMSE?.DataInizioOdl ?? DateTime.Today.AddMonths(-2); + dtFine = dtReqUpdate; + isProcessing = false; + await Task.Delay(1); + } + protected override async Task OnInitializedAsync() { lblOut = ""; @@ -150,7 +154,7 @@ namespace MP_TAB_SERV.Components enablePzProdLasciati = SMServ.GetConfBool("enablePzProdLasciati"); confRett = SMServ.GetConfBool("confRett"); modoConfProd = SMServ.GetConfInt("modoConfProd"); - await doUpdate(); + await DoUpdate(); } } @@ -161,9 +165,9 @@ namespace MP_TAB_SERV.Components // effettua conferma con conf da DB del tipo (giorni / turni / periodo bool fatto = effettuaConfermaProd(); // refresh tabella dati tablet... - TabDServ.RicalcMse(IdxMaccSel, 0); + await TabDServ.RicalcMse(IdxMaccSel, 0); // rileggo e salvo.. - var ListMSE = await MDataService.MseGetAll(); + var ListMSE = await MDataService.MseGetAll(true); if (ListMSE != null) { // salvo in LocalStorage... @@ -178,10 +182,10 @@ namespace MP_TAB_SERV.Components // sollevo evento! dtReqUpdate = DateTime.Now; numPzLasciati = 0; - await doUpdate(); - isProcessing = false; + await DoUpdate(); await Task.Delay(1); - await E_newVal.InvokeAsync(true); + await RefreshData(); + isProcessing = false; } protected void setConfirmBtn(bool newVal) @@ -194,7 +198,7 @@ namespace MP_TAB_SERV.Components isProcessing = true; await Task.Delay(10); IdxMaccSel = selIdxMacc; - await doUpdate(); + await DoUpdate(); isProcessing = false; await Task.Delay(10); } @@ -213,8 +217,11 @@ namespace MP_TAB_SERV.Components #region Private Fields private bool confRett = false; + private bool enablePzProdLasciati = false; + private string lblOut = ""; + private int modoConfProd = 0; #endregion Private Fields @@ -222,7 +229,9 @@ namespace MP_TAB_SERV.Components #region Private Properties private DateTime dtReqUpdate { get; set; } = DateTime.Now; + private string IdxMaccSel { get; set; } = ""; + private bool isProcessing { get; set; } = false; private int MatrOpr @@ -231,6 +240,7 @@ namespace MP_TAB_SERV.Components } private int numPzLasc { get; set; } = 0; + private bool showConfirm { get; set; } = true; private bool showInnov { get; set; } = false; @@ -258,6 +268,13 @@ namespace MP_TAB_SERV.Components return fatto; } + private async Task RefreshData() + { + List ListMSE = await MDataService.MseGetAll(true); + await MServ.SaveMse(ListMSE); + await E_Updated.InvokeAsync(ListMSE); + } + #endregion Private Methods #if false diff --git a/MP-TAB-SERV/Components/ProdConfirm.razor.css b/MP-TAB-SERV/Components/ProdConfirm.razor.css new file mode 100644 index 00000000..d6cf0a36 --- /dev/null +++ b/MP-TAB-SERV/Components/ProdConfirm.razor.css @@ -0,0 +1,5 @@ +.cardBg { + border-radius: 0.9375rem; + background: linear-gradient(121deg, rgba(255, 255, 255, 0.2) -0.71%, rgba(255, 255, 255, 0.05) 97.66%); + box-shadow: 0px 4px 24px -1px rgba(0, 0, 0, 0.25); +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/ProdConfirm.razor.less b/MP-TAB-SERV/Components/ProdConfirm.razor.less new file mode 100644 index 00000000..e9da988b --- /dev/null +++ b/MP-TAB-SERV/Components/ProdConfirm.razor.less @@ -0,0 +1,6 @@ +.cardBg { + border-radius: 0.9375rem; + background: linear-gradient(121deg, rgba(255, 255, 255, 0.20) -0.71%, rgba(255, 255, 255, 0.05) 97.66%); + box-shadow: 0px 4px 24px -1px rgba(0, 0, 0, 0.25); + //backdrop-filter: blur(20px); +} diff --git a/MP-TAB-SERV/Components/ProdConfirm.razor.min.css b/MP-TAB-SERV/Components/ProdConfirm.razor.min.css new file mode 100644 index 00000000..8826886b --- /dev/null +++ b/MP-TAB-SERV/Components/ProdConfirm.razor.min.css @@ -0,0 +1 @@ +.cardBg{border-radius:.9375rem;background:linear-gradient(121deg,rgba(255,255,255,.2) -.71%,rgba(255,255,255,.05) 97.66%);box-shadow:0 4px 24px -1px rgba(0,0,0,.25);} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/ProdPlanMan.razor b/MP-TAB-SERV/Components/ProdPlanMan.razor index 30303658..cde2ec27 100644 --- a/MP-TAB-SERV/Components/ProdPlanMan.razor +++ b/MP-TAB-SERV/Components/ProdPlanMan.razor @@ -1,11 +1,11 @@  -
+
-

Piano Produzione - PODL

+

Piano Produzione - PODL

-
+
@@ -17,15 +17,15 @@ } else { -
-
+
+
@if (ListPodl.Count == 0) {
Nessun record trovato
} else { - +
@@ -81,33 +50,27 @@ else
Art: @item.CodArticolo
-
- ODL: @($"ODL{item.IdxOdl:000000000}") +
+ @item.Descrizione
- @if (item.EsitoOk) - { - - } - else - { - - } + @item.Qta pz
- @($"{item.DataOra:ddd dd.MM.yy HH:mm:ss}") + @($"{item.DataOra:ddd dd.MM.yy HH:mm:ss}") +
@item.Operatore
-
+
@if (!string.IsNullOrEmpty(item.Note)) { -
@item.Note
+ Nota: @item.Note }
@@ -119,7 +82,7 @@ else - \ No newline at end of file diff --git a/MP-TAB-SERV/Components/ScrapMan.razor.cs b/MP-TAB-SERV/Components/ScrapMan.razor.cs index 84c0e14c..dc8c5248 100644 --- a/MP-TAB-SERV/Components/ScrapMan.razor.cs +++ b/MP-TAB-SERV/Components/ScrapMan.razor.cs @@ -27,7 +27,7 @@ namespace MP_TAB_SERV.Components await Task.Delay(1); if (!string.IsNullOrEmpty(IdxMaccSel)) { - ListComplete = await TabDServ.RegControlliFilt(IdxMaccSel, IdxOdl, CurrPeriodo.Inizio, CurrPeriodo.Fine, false); + ListComplete = await TabDServ.RegScartiGetFilt(IdxMaccSel, IdxOdl, CurrPeriodo.Inizio, CurrPeriodo.Fine, false); TotalCount = ListComplete.Count; // esegue paginazione UpdateTable(); @@ -40,13 +40,10 @@ namespace MP_TAB_SERV.Components #region Protected Properties - protected string ConfTitle - { - get => showInsert ? "Nascondi Controllo" : "Registra Controllo"; - } + - protected List ListComplete { get; set; } = new List(); - protected List ListPaged { get; set; } = new List(); + protected List ListComplete { get; set; } = new List(); + protected List ListPaged { get; set; } = new List(); [Inject] protected MessageService MServ { get; set; } = null!; @@ -64,20 +61,14 @@ namespace MP_TAB_SERV.Components if (RecMSE != null) { IdxMaccSel = RecMSE.IdxMacchina; - CurrPeriodo = new Periodo(PeriodSet.ThisWeek); + DateTime fine = DateTime.Today.AddDays(1); + DateTime inizio = fine.AddDays(-8); + CurrPeriodo = new Periodo(inizio, fine); await doUpdate(); } } - protected async Task SaveKo() - { - isProcessing = true; - await TabDServ.RegControlliInsert(IdxMaccSel, MServ.MatrOpr, false, noteKo, DateTime.Now); - showInsert = false; - showNote = false; - await doUpdate(); - isProcessing = false; - } + protected void SaveNumRec(int newNum) { @@ -85,15 +76,7 @@ namespace MP_TAB_SERV.Components UpdateTable(); } - protected async Task SaveOk() - { - isProcessing = true; - await TabDServ.RegControlliInsert(IdxMaccSel, MServ.MatrOpr, true, noteKo, DateTime.Now); - showInsert = false; - showNote = false; - await doUpdate(); - isProcessing = false; - } + protected void SavePage(int newNum) { @@ -127,20 +110,7 @@ namespace MP_TAB_SERV.Components await doUpdate(); } - protected void ShowKo() - { - showNote = true; - } - - protected void ToggleBtn() - { - showInsert = !showInsert; - if (showInsert) - { - noteKo = ""; - showNote = false; - } - } + protected void UpdateTable() { @@ -161,11 +131,8 @@ namespace MP_TAB_SERV.Components private static Logger Log = LogManager.GetCurrentClassLogger(); private bool isProcessing = false; - private string noteKo = ""; private int NumRecPage = 10; private int PageNum = 1; - private bool showInsert = false; - private bool showNote = false; private int TotalCount = 0; private bool useOdl = false; diff --git a/MP-TAB-SERV/Components/SelTempoMSMC.razor b/MP-TAB-SERV/Components/SelTempoMSMC.razor new file mode 100644 index 00000000..76a84cea --- /dev/null +++ b/MP-TAB-SERV/Components/SelTempoMSMC.razor @@ -0,0 +1,28 @@ + +
+ @*
+
+ + +
+
*@ +
+ @if (tcMode == "mc") + { +
+ Tempo + +
+ } + else + { +
+ @labelTempoIN + +
+ } +
+
+ → @lblTempo +
+
diff --git a/MP-TAB-SERV/Components/SelTempoMSMC.razor.cs b/MP-TAB-SERV/Components/SelTempoMSMC.razor.cs new file mode 100644 index 00000000..19fdc160 --- /dev/null +++ b/MP-TAB-SERV/Components/SelTempoMSMC.razor.cs @@ -0,0 +1,276 @@ +using global::Microsoft.AspNetCore.Components; +using MP.Data.Services; + +namespace MP_TAB_SERV.Components +{ + public partial class SelTempoMSMC + { + #region Public Enums + + /// + /// modalità di visualizzazione ed interazione controllo tempo + /// + public enum timeControlMode + { + /// + /// controllo textbox + /// + testo = 0, + + /// + /// selettori dropdown list + /// + selettori = 1 + } + + /// + /// modalità tempo principale (Minuti Secondi o Minuti Centesimali= + /// + public enum timeMode + { + /// + /// Minuti Secondi + /// + MS = 0, + + /// + /// Minuti Centesimali + /// + MC = 1 + } + + #endregion Public Enums + + #region Public Properties + + [Parameter] + public EventCallback E_TCRich { get; set; } + + /// + /// modalità rendering controllo + /// + [Parameter] + public timeControlMode modoControllo { get; set; } = timeControlMode.testo; + +#if false + /// + /// modalità controllo tempo + /// + [Parameter] + public timeMode modoTempo { get; set; } = timeMode.MC; +#endif + + /// + /// Valore tempo (centesimale) + /// + [Parameter] + public decimal TempoMC + { + get => _tempoMC; + set + { + _tempoMC = value; + _tempoMS = minCent2Sec(value); + } + } + + #endregion Public Properties + + #region Protected Properties + + /// + /// tempo min.cent + /// + protected decimal _tempoMC { get; set; } = 0; + + //protected timeMode modoTempo + //{ + // get => ShowMS ? timeMode.MS : timeMode.MC; + //} + + [Inject] + protected MessageService MsgServ { get; set; } = null!; + + /// + /// tempo selezionato in formato Minuti Secondi + /// + protected DateTime selTempoMS + { + get => DateTime.Today.Add(TempoMS); + set + { + TempoMS = value.Subtract(value.Date); + E_TCRich.InvokeAsync(TempoMC); + } + } + + protected bool ShowMS { get; set; } = true; + + [Inject] + protected SharedMemService SMServ { get; set; } = null!; + + protected string tcMode + { + get => MsgServ.UserPrefGet("TcMode"); + } + + /// + /// tempo selezionato in formato Minuti Secondi + /// + protected TimeSpan TempoMS + { + get + { + return _tempoMS; + } + set + { + _tempoMS = value; + _tempoMC = minSec2Cent(value); + } + } + + protected string txtSelMS + { + get => ShowMS ? Traduci("ShowMS") : Traduci("ShowMC"); + } + + #endregion Protected Properties + + #region Protected Methods + + /// + /// conversione da tempo minuti centesimali a minuti/secondi + /// + /// + /// + protected TimeSpan minCent2Sec(decimal valore) + { + TimeSpan answ = TimeSpan.FromSeconds((double)valore * 60); + return answ; + } + + /// + /// conversione da tempo minuti/secondi a minuti centesimali + /// + /// + /// + protected decimal minSec2Cent(TimeSpan valore) + { + decimal answ = 0; + decimal.TryParse($"{Math.Floor(valore.TotalMinutes) + (double)valore.Seconds / 60}", out answ); + return answ; + } + + protected override void OnInitialized() + { + //baseLang = SMServ.GetConf("baseLang"); + } + + protected override void OnParametersSet() + { + showControls(); + } + + protected string Traduci(string lemma) + { + return SMServ.Traduci($"{baseLang}_{lemma}".ToUpper()); + } + + #endregion Protected Methods + + #region Private Properties + + private string _baseLang { get; set; } = "IT"; + + /// + /// tempo min:sec + /// + private TimeSpan _tempoMS { get; set; } = TimeSpan.FromSeconds(1); + + private string baseLang + { + get => _baseLang; + set { MsgServ.UserPrefGet("Lang"); } + } + + /// + /// INdica il formato del tempo IN INGRESSO (selezionato) + /// + private string labelTempoIN + { + get + { + string answ = ""; + if (tcMode == "mc") + { + answ = "min.cent"; + } + else + { + answ = "ore:min:sec"; + } + return answ; + } + } + + private string lblTempo + { + get + { + string answ = tcMode == "mc" ? $"{TempoMS.TotalMinutes:N0}:{TempoMS:ss} (min:sec)" : $"{TempoMC:0.000} (min.cent)"; + return answ; + } + } + + private string txtTempo + { + get + { + string answ = tcMode == "mc" ? $"{TempoMC:0.000}" : $"{TempoMS.TotalMinutes:N0}:{TempoMS:ss}"; + return answ; + } + set + { + if (tcMode == "mc") + { + decimal tMC = 1; + decimal.TryParse(value, out tMC); + TempoMC = tMC; + } + else + { + var tPart = value.Split(':'); + double min = 0; + double sec = 0; + double.TryParse((tPart[0]), out min); + double.TryParse((tPart[1]), out sec); + TimeSpan tMS = TimeSpan.FromMinutes(min).Add(TimeSpan.FromSeconds(sec)); + TempoMS = tMS; + } + } + } + + #endregion Private Properties + + #region Private Methods + + /// + /// mostra i controlli secondo richiesta + /// + private void showControls() + { + //ddlMinuti.SelectedValue = TempoMS.Minutes.ToString(); + //if (modoTempo == timeMode.MC) + //{ + // ddlSecondi.SelectedValue = Convert.ToInt32((tempoMC - Math.Floor(tempoMC)) * 100).ToString(); + //} + //else + //{ + // ddlSecondi.SelectedValue = TempoMS.Seconds.ToString(); + //} + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/SlideMenu.razor b/MP-TAB-SERV/Components/SlideMenu.razor index 7d5feb37..356d9208 100644 --- a/MP-TAB-SERV/Components/SlideMenu.razor +++ b/MP-TAB-SERV/Components/SlideMenu.razor @@ -2,17 +2,17 @@
-
+
-
- +
+
EgalWare
- Main Menu + MES Solutions
@@ -26,21 +26,30 @@
- @foreach (var item in MenuItems) { - @item.Testo + }
+
+
+
+ +
+
+
+ MAPO MES +
+
+ TAB Controller - MES Suite +
+
+
+
-@code { - - [Parameter] - public List MenuItems { get; set; } = new List(); -} diff --git a/MP-TAB-SERV/Components/SlideMenu.razor.cs b/MP-TAB-SERV/Components/SlideMenu.razor.cs new file mode 100644 index 00000000..b6b3766f --- /dev/null +++ b/MP-TAB-SERV/Components/SlideMenu.razor.cs @@ -0,0 +1,37 @@ +using global::Microsoft.AspNetCore.Components; +using MP.Data.DatabaseModels; + +namespace MP_TAB_SERV.Components +{ + public partial class SlideMenu + { + #region Public Properties + + [Parameter] + public List MenuItems { get; set; } = new List(); + + #endregion Public Properties + + #region Protected Properties + + [Inject] + protected NavigationManager navManager { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected string cssActive(string currUri) + { + return navManager.Uri.Contains(currUri) ? "bg-dark text-light" : ""; + } + + protected async Task SetPage(string tgtUrl) + { + await Task.Delay(1); + navManager.NavigateTo(tgtUrl); + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/TechSheetDetail.razor b/MP-TAB-SERV/Components/TechSheetDetail.razor deleted file mode 100644 index f654734d..00000000 --- a/MP-TAB-SERV/Components/TechSheetDetail.razor +++ /dev/null @@ -1,19 +0,0 @@ -
-
- Scheda Tecnica -
-
-
- -
-
- -
-
- -
-
- -
-
-
\ No newline at end of file diff --git a/MP-TAB-SERV/Components/TechSheetDetail.razor.cs b/MP-TAB-SERV/Components/TechSheetDetail.razor.cs deleted file mode 100644 index 885b880d..00000000 --- a/MP-TAB-SERV/Components/TechSheetDetail.razor.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace MP_TAB_SERV.Components -{ - public partial class TechSheetDetail - { - } -} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/TechSheetMan.razor b/MP-TAB-SERV/Components/TechSheetMan.razor new file mode 100644 index 00000000..d38a4e30 --- /dev/null +++ b/MP-TAB-SERV/Components/TechSheetMan.razor @@ -0,0 +1,44 @@ +
+
+
+
+

Scheda Tecnica

+
+
+ @if (inAttr) + { + + } +
+
+
+
+
+ +
+ @if (isProcessing) + { + + } + else if (ListGruppi.Count == 0) + { +
ST: Nessun Gruppo Trovato
+ } + else + { + foreach (var item in ListGruppi) + { +
+
+
+ @item.DescGruppo +
+
+ +
+
+
+ } + } +
+
\ No newline at end of file diff --git a/MP-TAB-SERV/Components/TechSheetMan.razor.cs b/MP-TAB-SERV/Components/TechSheetMan.razor.cs new file mode 100644 index 00000000..3bed500e --- /dev/null +++ b/MP-TAB-SERV/Components/TechSheetMan.razor.cs @@ -0,0 +1,113 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MP.Data.DatabaseModels; +using MP.Data.Services; + +namespace MP_TAB_SERV.Components +{ + public partial class TechSheetMan + { + #region Public Properties + + [Parameter] + public MappaStatoExpl? RecMSE { get; set; } = null; + + #endregion Public Properties + + #region Protected Properties + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + protected List ListGruppi { get; set; } = new List(); + + [Inject] + protected TabDataService TabDServ { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected async Task ClearOdl() + { + if (!await JSRuntime.InvokeAsync("confirm", $"Sicuro di voler resettare?")) + return; + if (IdxOdl > 0) + { + await TabDServ.ST_CheckCleanByOdl(IdxOdl); + } + checkReset(); + } + + protected async Task ForceRefresh() + { + isProcessing = true; + await InvokeAsync(StateHasChanged); + await ReloadData(); + isProcessing = false; + } + + protected override async Task OnParametersSetAsync() + { + if (RecMSE != null) + { + CodArticolo = RecMSE.CodArticolo; + IdxMaccSel = RecMSE.IdxMacchina; + IdxOdl = RecMSE.IdxOdl ?? 0; + } + await ReloadData(); + checkReset(); + } + + #endregion Protected Methods + + #region Private Fields + + private string CodArticolo = ""; + + private bool inAttr = false; + + private bool isProcessing = false; + + #endregion Private Fields + + #region Private Properties + + private string IdxMaccSel { get; set; } = ""; + + private int IdxOdl { get; set; } = 0; + + #endregion Private Properties + + #region Private Methods + + /// + /// Verifica visibilità reset + /// + private void checkReset() + { + // condizioni booleane + inAttr = false; + // SOLO SE ho articolo sennò niente reset... + if (!string.IsNullOrEmpty(CodArticolo)) + { + // controllo se la macchina è in attrezzaggio... + var rigaStato = TabDServ.StatoMacchina(IdxMaccSel); + if (rigaStato != null) + { + inAttr = (rigaStato.IdxStato == 2); + } + } +#if false + cmp_ST_objCheck.checkInputData(); +#endif + } + + private async Task ReloadData() + { + ListGruppi = await TabDServ.ST_AnagGruppiList(); + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/TechSheet_ST_Detail.razor b/MP-TAB-SERV/Components/TechSheet_ST_Detail.razor new file mode 100644 index 00000000..41019280 --- /dev/null +++ b/MP-TAB-SERV/Components/TechSheet_ST_Detail.razor @@ -0,0 +1,16 @@ +@if (showWarning) +{ +
@txtWarning
+} + +@if (ListRecord.Count == 0) +{ +
NO record found
+} +else +{ + foreach (var item in ListRecord) + { + + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/TechSheet_ST_Detail.razor.cs b/MP-TAB-SERV/Components/TechSheet_ST_Detail.razor.cs new file mode 100644 index 00000000..ddb43533 --- /dev/null +++ b/MP-TAB-SERV/Components/TechSheet_ST_Detail.razor.cs @@ -0,0 +1,62 @@ +using global::System; +using global::System.Collections.Generic; +using global::System.Linq; +using global::System.Threading.Tasks; +using global::Microsoft.AspNetCore.Components; +using System.Net.Http; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.AspNetCore.Components.Forms; +using Microsoft.AspNetCore.Components.Routing; +using Microsoft.AspNetCore.Components.Web; +using Microsoft.AspNetCore.Components.Web.Virtualization; +using Microsoft.JSInterop; +using MP_TAB_SERV; +using MP_TAB_SERV.Shared; +using MP_TAB_SERV.Components; +using MP.Data; +using MP.Data.DatabaseModels; +using MP.Data.DTO; +using MP.Data.Services; +using Newtonsoft.Json; +using NLog; +using Microsoft.Extensions.Primitives; + +namespace MP_TAB_SERV.Components +{ + public partial class TechSheet_ST_Detail + { + [Parameter] + public string CodArticolo { get; set; } = ""; + + [Parameter] + public string CodGruppo { get; set; } = ""; + + [Parameter] + public int IdxOdl { get; set; } = 0; + + + private bool showWarning = false; + private string txtWarning = ""; + + + protected override async Task OnParametersSetAsync() + { + if (IdxOdl > 0 && !string.IsNullOrEmpty(CodGruppo)) + { + await ReloadData(); + } + } + + [Inject] + protected TabDataService TabServ { get; set; } = null!; + + private async Task ReloadData() + { + await Task.Delay(1); + ListRecord = await TabServ.STAR_byGrpOdl(CodGruppo, IdxOdl); + } + + protected List ListRecord { get; set; } = new List(); + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/TechSheet_ST_ObjCheck.razor b/MP-TAB-SERV/Components/TechSheet_ST_ObjCheck.razor new file mode 100644 index 00000000..6c18d948 --- /dev/null +++ b/MP-TAB-SERV/Components/TechSheet_ST_ObjCheck.razor @@ -0,0 +1,16 @@ +@if (showChecks) +{ +
+ Verifica + + +
+ @if (!string.IsNullOrEmpty(MessageText)) + { +
+
+ @MessageText +
+
+ } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/TechSheet_ST_ObjCheck.razor.cs b/MP-TAB-SERV/Components/TechSheet_ST_ObjCheck.razor.cs new file mode 100644 index 00000000..73f02e3d --- /dev/null +++ b/MP-TAB-SERV/Components/TechSheet_ST_ObjCheck.razor.cs @@ -0,0 +1,222 @@ +using global::Microsoft.AspNetCore.Components; +using MP.Data.DatabaseModels; +using MP.Data.Objects; +using MP.Data.Services; + +namespace MP_TAB_SERV.Components +{ + public partial class TechSheet_ST_ObjCheck + { + #region Public Properties + + [Parameter] + public string CodArticolo { get; set; } = ""; + + [Parameter] + public EventCallback E_Updated { get; set; } + + [Parameter] + public int IdxOdl { get; set; } = 0; + + #endregion Public Properties + + #region Public Methods + + public void checkInputData() + { + if (IdxOdl > 0) + { + var rawData = TabDServ.STAR_pendByOdl(IdxOdl); + showChecks = rawData.Count > 0; + } + else + { + showChecks = false; + } + } + + #endregion Public Methods + + #region Protected Properties + + [Inject] + protected MessageService MServ { get; set; } = null!; + + protected string ScanValue + { + get => ""; + set + { + lastBCodeVal = value; + // processo input in async.... + var pUpd = Task.Run(async () => + { + await processInput(); + //await InvokeAsync(() => StateHasChanged()); + }); + pUpd.Wait(); + } + } + + [Inject] + protected SharedMemService SMServ { get; set; } = null!; + + [Inject] + protected TabDataService TabDServ { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected override void OnParametersSet() + { + checkInputData(); + } + + #endregion Protected Methods + + #region Private Fields + + private string lastBCodeVal = ""; + private string MessageCss = ""; + private string MessageText = ""; + private bool showChecks = false; + + #endregion Private Fields + + #region Private Properties + + private string CognomeNome + { + get => MServ.CognomeNome; + } + + #endregion Private Properties + + #region Private Methods + + /// + /// procedura pricipale decodifica Barcode + /// + private async Task processInput() + { + bool found = false; + bool batchOk = false; + + List tabRichieste = TabDServ.STAR_pendByOdl(IdxOdl); + List tabGiacenzeLotto = new List(); + + ST_ActRow? datiBatchCheck; + AnagLottiArca? datiLotto; + // per prima cosa recupero i valori "Pending" da leggere come candidati... + if (tabRichieste != null && tabRichieste.Count > 0) + { + // cerco per EQ come primo step... + var trovatoEq = tabRichieste.Where(x => x.CheckType == "EQ" && x.Value == lastBCodeVal); + if (trovatoEq != null && trovatoEq.Count() > 0) + { + // recupero record.. + var datiEqCheck = trovatoEq.FirstOrDefault(); + if (datiEqCheck != null) + { + // registro trovato + found = true; + MessageText = $"Parametro acquisito: {lastBCodeVal}"; + MessageCss = "text-success"; + // upsert controllo + await TabDServ.ST_CheckUpsert(IdxOdl, datiEqCheck.IdxST, datiEqCheck.Oggetto, datiEqCheck.Num, lastBCodeVal, lastBCodeVal, true, CognomeNome, false); + } + } + + // se non trovato + if (!found) + { + // recupero record.. cercando in giacenza il LOTTO... + tabGiacenzeLotto = await TabDServ.LottoEsterno("", lastBCodeVal, ""); + // controllo condizione tipo BATCH (speciale) - prima solo che CI SIA una + // richiesta di questo tipo + var trovatoBatch = tabRichieste.Where(x => x.CheckType == "BATCH"); + if (trovatoBatch != null && trovatoBatch.Count() > 0) + { + datiBatchCheck = trovatoBatch.FirstOrDefault(); + if (datiBatchCheck != null && tabGiacenzeLotto != null && tabGiacenzeLotto.Count > 0) + { + datiLotto = tabGiacenzeLotto.FirstOrDefault(); + if (datiLotto != null) + { + // registro trovato + found = true; + // upsert controllo + await TabDServ.ST_CheckUpsert(IdxOdl, datiBatchCheck.IdxST, datiBatchCheck.Oggetto, datiBatchCheck.Num, lastBCodeVal, datiLotto.Cd_AR, true, CognomeNome, false); + // conto quanti check ci sono dopo, se calati --> ok altrimenti errore + var tabRichiestePost = TabDServ.STAR_pendByOdl(IdxOdl); + if (tabRichiestePost.Count < tabRichieste.Count) + { + MessageText = $"Lotto riconosciuto: {lastBCodeVal} --> {datiLotto.Cd_AR} | Articolo acquisito"; + MessageCss = "text-success"; + batchOk = true; + } + else + { + MessageText = $"Lotto: {lastBCodeVal} --> {datiLotto.Cd_AR} | Articolo NON richiesto"; + MessageCss = "text-danger"; + } + } + } + } + + if (!batchOk) + { + var currDeroga = TabDServ.ST_DerogaGet(CognomeNome, tabRichieste[0].IdxST); + // ciclo tra TUTTE le richeiste attive + foreach (var item in tabRichieste) + { + // verifico EVENTUALI deroghe se è deroga x gruppo/tipo/num corretto... + if (currDeroga.CanForce && item.CodGruppo == currDeroga.CodGruppo && item.CodTipo == currDeroga.CodTipo && item.Num == currDeroga.Num && item.Oggetto == currDeroga.Oggetto) + { + // ... forzo accettazione deroga + await TabDServ.ST_CheckUpsert(IdxOdl, item.IdxST, item.Oggetto, item.Num, lastBCodeVal, item.Value, true, CognomeNome, true); + MessageText = $"Lotto/articolo non valido: {lastBCodeVal} --> Forzato a valido per articolo {item.Value}"; + MessageCss = "text-warning"; + TabDServ.ST_DerogaSet(new StCheckOverride() { IdxST = item.IdxST, CanForce = false }); + batchOk = true; + } + } + } + } + + // se non trovato + if (!found) + { + if (tabGiacenzeLotto != null && tabGiacenzeLotto.Count > 0) + { + datiLotto = tabGiacenzeLotto.FirstOrDefault(); + if (datiLotto != null) + { + MessageText = $"Lotto: {lastBCodeVal} --> {datiLotto.Cd_AR} | Articolo NON richiesto"; + MessageCss = "text-danger"; + } + } + else + { + MessageText = $"Parametro non riconosciuto: {lastBCodeVal}"; + MessageCss = "text-secondary"; + } + } + } + else + { + MessageText = $"Parametro non valido: {lastBCodeVal}"; + MessageCss = "text-secondary"; + } + + // sistemo visualizzaizone componente + lastBCodeVal = ""; + checkInputData(); + // sollevo evento + await E_Updated.InvokeAsync(true); + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor b/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor new file mode 100644 index 00000000..2c052e40 --- /dev/null +++ b/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor @@ -0,0 +1,48 @@ +@if (CurrRec.CodTipo == "IMG") +{ +
+
+ @(Traduci(CurrRec.Label)) +
+
+ +
+
+} +else +{ +
+
+ @(Traduci(CurrRec.Label)) +
+
+ @if (CurrRec.ShowMissingData && enableForceParamSchedaTecnica) + { + if (hasDeroga) + { + Deroga Attiva + } + else + { + + } + } + @if (!string.IsNullOrEmpty(CurrRec.ValueRead)) + { + (@CurrRec.ValueRead)  + } + @CurrRec.Value + + @if (CurrRec.ShowMissingData) + { + + } + @if (CurrRec.ShowCheckedData) + { + + } + +
+
+} + diff --git a/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor.cs b/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor.cs new file mode 100644 index 00000000..92c92b35 --- /dev/null +++ b/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor.cs @@ -0,0 +1,174 @@ +using global::Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MP.Data.DatabaseModels; +using MP.Data.Objects; +using MP.Data.Services; + +namespace MP_TAB_SERV.Components +{ + public partial class TechSheet_ST_ObjView + { + #region Public Properties + + [Parameter] + public ST_ActRow CurrRec { get; set; } = null!; + + /// + /// Url immagine SE richiesta + /// + public string imageUrl + { + get + { + string imgPath = ""; + string fullPath = ""; + //check type... + if (CurrRec.CodTipo == "IMG") + { + imgPath = CurrRec.Value; + if (!Path.IsPathRooted(imgPath)) + { + // aggiungo base path + imgPath = $"images/ST_img/{imgPath}"; + fullPath = Path.Combine(imgBasePath, "wwwroot", imgPath); + } + // verifico esistenza file... + if (!File.Exists(fullPath)) + { + // metto segnaposto empty + imgPath = "images/ST_img/Steamware.png"; + } + } + return imgPath; + } + } + + #endregion Public Properties + + #region Protected Properties + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + [Inject] + protected MessageService MServ { get; set; } = null!; + + [Inject] + protected NavigationManager NavMan { get; set; } = null!; + + [Inject] + protected SharedMemService SMServ { get; set; } = null!; + + [Inject] + protected TabDataService TabDServ { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected async Task ForceParam() + { + if (!await JSRuntime.InvokeAsync("confirm", Traduci("ConfirmForceParamST"))) + return; + + // registro abilitazione forzatura parametro per un periodo limitato + StCheckOverride newDeroga = new StCheckOverride() + { + CanForce = enableForceParamSchedaTecnica, + Num = CurrRec.Num, + Oggetto = CurrRec.Oggetto, + CodTipo = CurrRec.CodTipo, + CodGruppo = CurrRec.CodGruppo, + IdxST = CurrRec.IdxST, + Utente = CognomeNome + }; + // salvo + TabDServ.ST_DerogaSet(newDeroga); + // redirect + NavMan.NavigateTo(NavMan.Uri, true); + } + + protected override void OnInitialized() + { + imgBasePath = Environment.CurrentDirectory; + //baseLang = SMServ.GetConf("baseLang"); + enableForceParamSchedaTecnica = SMServ.GetConfBool("enableForceParamSchedaTecnica"); + } + + protected override void OnParametersSet() + { + if (CurrRec != null) + { + hasDeroga = false; + var currDeroga = TabDServ.ST_DerogaGet(CognomeNome, CurrRec.IdxST); + if (currDeroga != null) + { + hasDeroga = (currDeroga.IdxST == CurrRec.IdxST && currDeroga.CanForce && currDeroga.Num == CurrRec.Num && currDeroga.CodGruppo == CurrRec.CodGruppo && currDeroga.CodTipo == CurrRec.CodTipo && currDeroga.Oggetto == CurrRec.Oggetto); + } + } + } + + protected string Traduci(string lemma) + { + return SMServ.Traduci($"{baseLang}_{lemma}".ToUpper()); + } + + #endregion Protected Methods + + #region Private Fields + + private string _baseLang { get; set; } = "IT"; + private string baseLang + { + get => _baseLang; + set + { + MServ.UserPrefGet("Lang"); + } + } + private bool enableForceParamSchedaTecnica = false; + private bool hasDeroga = false; + private string imgBasePath = ""; + + #endregion Private Fields + + #region Private Properties + + private string dataCss + { + get + { + string answ = ""; + if (CurrRec.Required) + { + if (CurrRec.Value != CurrRec.ExtCode) + { + answ = " text-danger"; + } + else + { + answ = " text-success"; + } + } + return answ; + } + } + + private string derogaCss + { + get + { + string answ = enableForceParamSchedaTecnica && hasDeroga ? " bg-warning" : ""; + + return answ; + } + } + + private string CognomeNome + { + get => MServ.CognomeNome; + } + + #endregion Private Properties + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/MP-TAB-SERV.csproj b/MP-TAB-SERV/MP-TAB-SERV.csproj index f1c4f6a3..2a4052df 100644 --- a/MP-TAB-SERV/MP-TAB-SERV.csproj +++ b/MP-TAB-SERV/MP-TAB-SERV.csproj @@ -3,7 +3,7 @@ net6.0 enable - 6.16.2310.1614 + 6.16.2311.919 enable MP_TAB_SERV @@ -17,8 +17,8 @@ - - + + @@ -42,6 +42,18 @@ + + + Never + + + Never + + + Never + + + Always diff --git a/MP-TAB-SERV/Pages/Alarms.razor b/MP-TAB-SERV/Pages/Alarms.razor index f57a87a9..ff411c7a 100644 --- a/MP-TAB-SERV/Pages/Alarms.razor +++ b/MP-TAB-SERV/Pages/Alarms.razor @@ -1,5 +1,6 @@ @page "/alarms" + @if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null) { diff --git a/MP-TAB-SERV/Pages/Alarms.razor.cs b/MP-TAB-SERV/Pages/Alarms.razor.cs index 4e0ed46c..b5afe499 100644 --- a/MP-TAB-SERV/Pages/Alarms.razor.cs +++ b/MP-TAB-SERV/Pages/Alarms.razor.cs @@ -23,6 +23,24 @@ namespace MP_TAB_SERV.Pages await ReloadData(); } + protected async Task RefreshData(List newList) + { + var ListMSE = newList; + if (!string.IsNullOrEmpty(IdxMacc)) + { + var rawData = ListMSE.Find(x => x.IdxMacchina == IdxMacc); + if (rawData != null) + { + CurrMSE = rawData; + } + else + { + await ReloadData(); + } + } + await InvokeAsync(StateHasChanged); + } + #endregion Protected Methods #region Private Methods diff --git a/MP-TAB-SERV/Pages/Controls.razor b/MP-TAB-SERV/Pages/Controls.razor index f5c55bf1..21bef545 100644 --- a/MP-TAB-SERV/Pages/Controls.razor +++ b/MP-TAB-SERV/Pages/Controls.razor @@ -1,5 +1,6 @@ @page "/controls" + @if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null) { diff --git a/MP-TAB-SERV/Pages/Controls.razor.cs b/MP-TAB-SERV/Pages/Controls.razor.cs index 2add5b0a..e9449abd 100644 --- a/MP-TAB-SERV/Pages/Controls.razor.cs +++ b/MP-TAB-SERV/Pages/Controls.razor.cs @@ -23,6 +23,24 @@ namespace MP_TAB_SERV.Pages await ReloadData(); } + protected async Task RefreshData(List newList) + { + var ListMSE = newList; + if (!string.IsNullOrEmpty(IdxMacc)) + { + var rawData = ListMSE.Find(x => x.IdxMacchina == IdxMacc); + if (rawData != null) + { + CurrMSE = rawData; + } + else + { + await ReloadData(); + } + } + await InvokeAsync(StateHasChanged); + } + #endregion Protected Methods #region Private Methods diff --git a/MP-TAB-SERV/Pages/Declarations.razor b/MP-TAB-SERV/Pages/Declarations.razor index bf2b95b7..7be4b8f6 100644 --- a/MP-TAB-SERV/Pages/Declarations.razor +++ b/MP-TAB-SERV/Pages/Declarations.razor @@ -1,5 +1,6 @@ @page "/declarations" + @if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null) { @@ -7,5 +8,5 @@ else { - + } diff --git a/MP-TAB-SERV/Pages/Declarations.razor.cs b/MP-TAB-SERV/Pages/Declarations.razor.cs index 0816788c..b069e0fb 100644 --- a/MP-TAB-SERV/Pages/Declarations.razor.cs +++ b/MP-TAB-SERV/Pages/Declarations.razor.cs @@ -23,6 +23,24 @@ namespace MP_TAB_SERV.Pages await ReloadData(); } + protected async Task RefreshData(List newList) + { + var ListMSE = newList; + if (!string.IsNullOrEmpty(IdxMacc)) + { + var rawData = ListMSE.Find(x => x.IdxMacchina == IdxMacc); + if (rawData != null) + { + CurrMSE = rawData; + } + else + { + await ReloadData(); + } + } + await InvokeAsync(StateHasChanged); + } + #endregion Protected Methods #region Private Methods diff --git a/MP-TAB-SERV/Pages/IobInfo.razor b/MP-TAB-SERV/Pages/IobInfo.razor index dcf4d33a..c8e7575f 100644 --- a/MP-TAB-SERV/Pages/IobInfo.razor +++ b/MP-TAB-SERV/Pages/IobInfo.razor @@ -1,5 +1,6 @@ @page "/iob-info" + @if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null) { diff --git a/MP-TAB-SERV/Pages/IobInfo.razor.cs b/MP-TAB-SERV/Pages/IobInfo.razor.cs index 665bca5d..2ef216e4 100644 --- a/MP-TAB-SERV/Pages/IobInfo.razor.cs +++ b/MP-TAB-SERV/Pages/IobInfo.razor.cs @@ -1,24 +1,6 @@ -using global::System; -using global::System.Collections.Generic; -using global::System.Linq; -using global::System.Threading.Tasks; using global::Microsoft.AspNetCore.Components; -using System.Net.Http; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Components.Authorization; -using Microsoft.AspNetCore.Components.Forms; -using Microsoft.AspNetCore.Components.Routing; -using Microsoft.AspNetCore.Components.Web; -using Microsoft.AspNetCore.Components.Web.Virtualization; -using Microsoft.JSInterop; -using MP_TAB_SERV; -using MP_TAB_SERV.Shared; -using MP_TAB_SERV.Components; -using MP.Data; using MP.Data.DatabaseModels; -using MP.Data.DTO; using MP.Data.Services; -using NLog; namespace MP_TAB_SERV.Pages { @@ -41,6 +23,24 @@ namespace MP_TAB_SERV.Pages await ReloadData(); } + protected async Task RefreshData(List newList) + { + var ListMSE = newList; + if (!string.IsNullOrEmpty(IdxMacc)) + { + var rawData = ListMSE.Find(x => x.IdxMacchina == IdxMacc); + if (rawData != null) + { + CurrMSE = rawData; + } + else + { + await ReloadData(); + } + } + await InvokeAsync(StateHasChanged); + } + #endregion Protected Methods #region Private Methods diff --git a/MP-TAB-SERV/Pages/MachineDetail.razor b/MP-TAB-SERV/Pages/MachineDetail.razor index 200cfa74..ecda23b2 100644 --- a/MP-TAB-SERV/Pages/MachineDetail.razor +++ b/MP-TAB-SERV/Pages/MachineDetail.razor @@ -1,5 +1,7 @@ @page "/machine-detail" + + @if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null) { @@ -7,16 +9,6 @@ else { + - - - } - diff --git a/MP-TAB-SERV/Pages/MachineDetail.razor.cs b/MP-TAB-SERV/Pages/MachineDetail.razor.cs index 3f74f5cd..c5e36643 100644 --- a/MP-TAB-SERV/Pages/MachineDetail.razor.cs +++ b/MP-TAB-SERV/Pages/MachineDetail.razor.cs @@ -34,6 +34,24 @@ namespace MP_TAB_SERV.Pages } } + protected async Task RefreshData(List newList) + { + var ListMSE = newList; + if (!string.IsNullOrEmpty(IdxMacc)) + { + var rawData = ListMSE.Find(x => x.IdxMacchina == IdxMacc); + if (rawData != null) + { + CurrMSE = rawData; + } + else + { + await RefreshMBlock(); + } + } + await InvokeAsync(StateHasChanged); + } + protected async Task RefreshMBlock() { // recupero MSE macchina.... @@ -41,7 +59,6 @@ namespace MP_TAB_SERV.Pages { CurrMSE = await MsgServ.GetMachineMse(IdxMacc); } - await Task.Delay(1); } #endregion Protected Methods diff --git a/MP-TAB-SERV/Pages/Notes.razor b/MP-TAB-SERV/Pages/Notes.razor index 1362e15e..15e2b1a9 100644 --- a/MP-TAB-SERV/Pages/Notes.razor +++ b/MP-TAB-SERV/Pages/Notes.razor @@ -1,5 +1,6 @@ @page "/notes" + @if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null) { diff --git a/MP-TAB-SERV/Pages/Notes.razor.cs b/MP-TAB-SERV/Pages/Notes.razor.cs index e8b71a94..cff43b89 100644 --- a/MP-TAB-SERV/Pages/Notes.razor.cs +++ b/MP-TAB-SERV/Pages/Notes.razor.cs @@ -23,6 +23,24 @@ namespace MP_TAB_SERV.Pages await ReloadData(); } + protected async Task RefreshData(List newList) + { + var ListMSE = newList; + if (!string.IsNullOrEmpty(IdxMacc)) + { + var rawData = ListMSE.Find(x => x.IdxMacchina == IdxMacc); + if (rawData != null) + { + CurrMSE = rawData; + } + else + { + await ReloadData(); + } + } + await InvokeAsync(StateHasChanged); + } + #endregion Protected Methods #region Private Methods diff --git a/MP-TAB-SERV/Pages/ODL.razor b/MP-TAB-SERV/Pages/ODL.razor index a54dd156..8fdeb1fa 100644 --- a/MP-TAB-SERV/Pages/ODL.razor +++ b/MP-TAB-SERV/Pages/ODL.razor @@ -1,15 +1,12 @@ @page "/odl" + @if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null) { } else { -
- -
- - - + + } diff --git a/MP-TAB-SERV/Pages/ODL.razor.cs b/MP-TAB-SERV/Pages/ODL.razor.cs index 432a144f..6e382c7d 100644 --- a/MP-TAB-SERV/Pages/ODL.razor.cs +++ b/MP-TAB-SERV/Pages/ODL.razor.cs @@ -40,6 +40,35 @@ namespace MP_TAB_SERV.Pages } } + + + protected async Task RefreshData(List newList) + { + var ListMSE = newList; + if (!string.IsNullOrEmpty(IdxMacc)) + { + var rawData = ListMSE.Find(x => x.IdxMacchina == IdxMacc); + if (rawData != null) + { + CurrMSE = rawData; + } + else + { + await RefreshMBlock(); + } + } + await InvokeAsync(StateHasChanged); + } + + protected async Task RefreshMBlock() + { + // recupero MSE macchina.... + if (!string.IsNullOrEmpty(IdxMacc)) + { + CurrMSE = await MsgServ.GetMachineMse(IdxMacc); + } + } + #endregion Private Methods } } \ No newline at end of file diff --git a/MP-TAB-SERV/Pages/Parameters.razor b/MP-TAB-SERV/Pages/Parameters.razor index a889102f..16b8b68e 100644 --- a/MP-TAB-SERV/Pages/Parameters.razor +++ b/MP-TAB-SERV/Pages/Parameters.razor @@ -1,14 +1,14 @@ @page "/parameters" + + @if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null) { } else { -
- -
- + + } diff --git a/MP-TAB-SERV/Pages/Parameters.razor.cs b/MP-TAB-SERV/Pages/Parameters.razor.cs index 7be577ee..4bff0ffc 100644 --- a/MP-TAB-SERV/Pages/Parameters.razor.cs +++ b/MP-TAB-SERV/Pages/Parameters.razor.cs @@ -1,24 +1,6 @@ -using global::System; -using global::System.Collections.Generic; -using global::System.Linq; -using global::System.Threading.Tasks; using global::Microsoft.AspNetCore.Components; -using System.Net.Http; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Components.Authorization; -using Microsoft.AspNetCore.Components.Forms; -using Microsoft.AspNetCore.Components.Routing; -using Microsoft.AspNetCore.Components.Web; -using Microsoft.AspNetCore.Components.Web.Virtualization; -using Microsoft.JSInterop; -using MP_TAB_SERV; -using MP_TAB_SERV.Shared; -using MP_TAB_SERV.Components; -using MP.Data; using MP.Data.DatabaseModels; -using MP.Data.DTO; using MP.Data.Services; -using NLog; namespace MP_TAB_SERV.Pages { @@ -41,6 +23,24 @@ namespace MP_TAB_SERV.Pages await ReloadData(); } + protected async Task RefreshData(List newList) + { + var ListMSE = newList; + if (!string.IsNullOrEmpty(IdxMacc)) + { + var rawData = ListMSE.Find(x => x.IdxMacchina == IdxMacc); + if (rawData != null) + { + CurrMSE = rawData; + } + else + { + await ReloadData(); + } + } + await InvokeAsync(StateHasChanged); + } + #endregion Protected Methods #region Private Methods diff --git a/MP-TAB-SERV/Pages/ProdPlan.razor b/MP-TAB-SERV/Pages/ProdPlan.razor index 4664541b..8c0674dc 100644 --- a/MP-TAB-SERV/Pages/ProdPlan.razor +++ b/MP-TAB-SERV/Pages/ProdPlan.razor @@ -1,5 +1,6 @@ @page "/prod-plan" + @if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null) { diff --git a/MP-TAB-SERV/Pages/ProdPlan.razor.cs b/MP-TAB-SERV/Pages/ProdPlan.razor.cs index 35b6135a..bde8cf45 100644 --- a/MP-TAB-SERV/Pages/ProdPlan.razor.cs +++ b/MP-TAB-SERV/Pages/ProdPlan.razor.cs @@ -1,6 +1,7 @@ using global::Microsoft.AspNetCore.Components; using MP.Data.DatabaseModels; using MP.Data.Services; +using NLog; namespace MP_TAB_SERV.Pages { @@ -23,21 +24,47 @@ namespace MP_TAB_SERV.Pages await ReloadData(); } + protected async Task RefreshData(List newList) + { + var ListMSE = newList; + if (!string.IsNullOrEmpty(IdxMacc)) + { + var rawData = ListMSE.Find(x => x.IdxMacchina == IdxMacc); + if (rawData != null) + { + CurrMSE = rawData; + } + else + { + await ReloadData(); + } + } + await InvokeAsync(StateHasChanged); + } + #endregion Protected Methods #region Private Methods + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); private async Task ReloadData() { - if (string.IsNullOrEmpty(IdxMacc)) + try { - IdxMacc = await MsgServ.IdxMaccGet(); - // recupero MSE macchina.... - if (!string.IsNullOrEmpty(IdxMacc)) + if (string.IsNullOrEmpty(IdxMacc)) { - CurrMSE = await MsgServ.GetMachineMse(IdxMacc); + IdxMacc = await MsgServ.IdxMaccGet(); + // recupero MSE macchina.... + if (!string.IsNullOrEmpty(IdxMacc)) + { + CurrMSE = await MsgServ.GetMachineMse(IdxMacc); + } } } + catch (Exception exc) + { + Log.Error($"Eccerione in ReloadData{Environment.NewLine}{exc}"); + } } #endregion Private Methods diff --git a/MP-TAB-SERV/Pages/ProdStop.razor b/MP-TAB-SERV/Pages/ProdStop.razor index b94832a2..0f9b2505 100644 --- a/MP-TAB-SERV/Pages/ProdStop.razor +++ b/MP-TAB-SERV/Pages/ProdStop.razor @@ -1,5 +1,7 @@ @page "/prod-stop" + + @if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null) { diff --git a/MP-TAB-SERV/Pages/ProdStop.razor.cs b/MP-TAB-SERV/Pages/ProdStop.razor.cs index 89638727..e76ce62c 100644 --- a/MP-TAB-SERV/Pages/ProdStop.razor.cs +++ b/MP-TAB-SERV/Pages/ProdStop.razor.cs @@ -66,7 +66,7 @@ namespace MP_TAB_SERV.Pages protected SharedMemService SMServ { get; set; } = null!; [Inject] - protected TabDataService TabServ { get; set; } = null!; + protected TabDataService TabDServ { get; set; } = null!; #endregion Protected Properties @@ -87,7 +87,7 @@ namespace MP_TAB_SERV.Pages var rigaEvento = SMServ.GetEventRow(IdxEv); if (rigaEvento != null) { - var rigaStato = await TabServ.StatoMacchina(IdxMacc); + var rigaStato = TabDServ.StatoMacchina(IdxMacc); // processo evento... if (insRealtime) { @@ -103,14 +103,14 @@ namespace MP_TAB_SERV.Pages pallet = rigaStato.pallet }; // se realtime - await TabServ.EvListInsert(newRec, MP.Data.Objects.Enums.tipoInputEvento.barcode); + await TabDServ.EvListInsert(newRec, MP.Data.Objects.Enums.tipoInputEvento.barcode); // resetta il microstato in modo da ricevere successive info HW - TabServ.resetMicrostatoMacchina(IdxMacc); + TabDServ.resetMicrostatoMacchina(IdxMacc); } else { // in primis disabilito insert... - TabServ.MacchinaSetInsEnab(IdxMacc, false); + TabDServ.MacchinaSetInsEnab(IdxMacc, false); // calcolo evento string evento = $"{IdxEv}"; @@ -128,7 +128,7 @@ namespace MP_TAB_SERV.Pages try { // cerco da 1 sec DOPO evento... - var tabNext = TabServ.DDB_getNext(IdxMacc, DtRif.AddSeconds(1)); + var tabNext = TabDServ.DDB_getNext(IdxMacc, DtRif.AddSeconds(1)); DateTime nextEvDT = tabNext != null ? tabNext.InizioStato : DateTime.Now.AddMinutes(-1); @@ -145,7 +145,7 @@ namespace MP_TAB_SERV.Pages MatrOpr = MatrOpr, pallet = rigaStato.pallet }; - await TabServ.EvListInsert(newRec, MP.Data.Objects.Enums.tipoInputEvento.barcode); + await TabDServ.EvListInsert(newRec, MP.Data.Objects.Enums.tipoInputEvento.barcode); // update commento apertura! commento = $"999 - Dich StartEvt: {evento} [{codRich}]"; @@ -159,11 +159,11 @@ namespace MP_TAB_SERV.Pages MatrOpr = MatrOpr, pallet = rigaStato.pallet }; - await TabServ.EvListInsert(newRec, MP.Data.Objects.Enums.tipoInputEvento.barcode); + await TabDServ.EvListInsert(newRec, MP.Data.Objects.Enums.tipoInputEvento.barcode); // eseguo ricalcolo! DateTime startRicalcolo = DtRif.AddMinutes(minAnticipoRicalcolo); // eseguo ricalcolo periodo.. - await TabServ.DDB_DoRecalc(IdxMacc, startRicalcolo, 1, rdm_nEvStep, rdm_nEvCheck, rdm_ChkOnly); + await TabDServ.DDB_DoRecalc(IdxMacc, startRicalcolo, 1, rdm_nEvStep, rdm_nEvCheck, rdm_ChkOnly); // chiamo registrazione commento... if (noteEdit != null) { @@ -177,11 +177,11 @@ namespace MP_TAB_SERV.Pages } // riabilito insert... anche se non dovrebbe servire x stored ricalcolo precedente... - TabServ.MacchinaSetInsEnab(IdxMacc, true); + TabDServ.MacchinaSetInsEnab(IdxMacc, true); } // mostro esito alertCss = "alert-succes"; - lblOut = $"Registrata dichiarazione fermata alle {DateTime.Now:HH:mm:ss}"; + lblOut = $"Registrata dichiarazione fermata [{rigaEvento.Nome}] alle {DateTime.Now:HH:mm:ss}"; } else { @@ -190,9 +190,9 @@ namespace MP_TAB_SERV.Pages } } // faccio refresh x singola macchina 2019.03.26 - TabServ.RicalcMse(IdxMacc, 0); + await TabDServ.RicalcMse(IdxMacc, 0); // rileggo e salvo.. - var ListMSE = await MDataService.MseGetAll(); + var ListMSE = await MDataService.MseGetAll(true); if (ListMSE != null) { // salvo in LocalStorage... @@ -214,6 +214,24 @@ namespace MP_TAB_SERV.Pages await ReloadData(); } + protected async Task RefreshData(List newList) + { + var ListMSE = newList; + if (!string.IsNullOrEmpty(IdxMacc)) + { + var rawData = ListMSE.Find(x => x.IdxMacchina == IdxMacc); + if (rawData != null) + { + CurrMSE = rawData; + } + else + { + await ReloadData(); + } + } + await InvokeAsync(StateHasChanged); + } + protected void SetDate(DateTime newDate) { DtRif = newDate; @@ -250,7 +268,7 @@ namespace MP_TAB_SERV.Pages { CurrMSE = await MServ.GetMachineMse(IdxMacc); } - var eventsAll = await TabServ.AnagEventiGetByMacch(IdxMacc); + var eventsAll = await TabDServ.AnagEventiGetByMacch(IdxMacc); if (eventsAll != null) { events2show = eventsAll.Where(x => x.EventoTablet).OrderBy(x => x.Label).ToList(); diff --git a/MP-TAB-SERV/Pages/Scrap.razor b/MP-TAB-SERV/Pages/Scrap.razor index 68a54c91..64aa41ba 100644 --- a/MP-TAB-SERV/Pages/Scrap.razor +++ b/MP-TAB-SERV/Pages/Scrap.razor @@ -1,5 +1,6 @@ @page "/scrap" + @if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null) { diff --git a/MP-TAB-SERV/Pages/Scrap.razor.cs b/MP-TAB-SERV/Pages/Scrap.razor.cs index 8e864810..da784347 100644 --- a/MP-TAB-SERV/Pages/Scrap.razor.cs +++ b/MP-TAB-SERV/Pages/Scrap.razor.cs @@ -23,6 +23,24 @@ namespace MP_TAB_SERV.Pages await ReloadData(); } + protected async Task RefreshData(List newList) + { + var ListMSE = newList; + if (!string.IsNullOrEmpty(IdxMacc)) + { + var rawData = ListMSE.Find(x => x.IdxMacchina == IdxMacc); + if (rawData != null) + { + CurrMSE = rawData; + } + else + { + await ReloadData(); + } + } + await InvokeAsync(StateHasChanged); + } + #endregion Protected Methods #region Private Methods diff --git a/MP-TAB-SERV/Pages/StatusMap.razor b/MP-TAB-SERV/Pages/StatusMap.razor index 7852e3d7..250dd569 100644 --- a/MP-TAB-SERV/Pages/StatusMap.razor +++ b/MP-TAB-SERV/Pages/StatusMap.razor @@ -2,29 +2,29 @@ @page "/home" @page "/status-map" - +
- @if (ListMSE == null || ListMSE.Count == 0) + @if (ListMSE == null || ListMSE.Count == 0 || isCalcSize) { - @for (int i = 0; i < 10; i++) - { -
- -
- } + } else { -
-
- - + @if (Width < 640) + { + +
+ +
+ + +
-
+ } @foreach (var item in ListMSE) {
- +
} } diff --git a/MP-TAB-SERV/Pages/StatusMap.razor.cs b/MP-TAB-SERV/Pages/StatusMap.razor.cs index bea1d31c..cbc1c392 100644 --- a/MP-TAB-SERV/Pages/StatusMap.razor.cs +++ b/MP-TAB-SERV/Pages/StatusMap.razor.cs @@ -1,90 +1,55 @@ using global::Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; using MP.Data.Conf; using MP.Data.DatabaseModels; using MP.Data.Services; using NLog; -using System.Drawing.Imaging; -using System; +using System.Runtime.ExceptionServices; namespace MP_TAB_SERV.Pages { - public partial class StatusMap : IDisposable + public partial class StatusMap { #region Protected Fields - protected bool doAnimate = true; - protected int keepAliveMin = 1; + protected bool _showCard = false; + protected int maxCol = 6; + protected string showArt = ""; - protected int slowRefreshSec = 300; #endregion Protected Fields #region Protected Properties + [Inject] + protected IConfiguration config { get; set; } = null!; + [Inject] protected StatusData MDataService { get; set; } = null!; [Inject] protected MessageService MServ { get; set; } = null!; + [Inject] + protected IJSRuntime JSRuntime{ get; set; } = null!; - protected int slowRefreshMs + protected bool ShowCard { - get + get => _showCard; + set { - // tempo variabile tra +/- 10% del target - int answ = rnd.Next(900, 1100) * slowRefreshSec; - return answ; + _showCard = value; + StateHasChanged(); } } + [Inject] + protected TabDataService TabDServ { get; set; } = null!; + #endregion Protected Properties #region Protected Methods - /// - /// Recupera il valore e se trovato aggiorna - /// - /// Valore da cercare - /// String in cui salvare il valore se trovato - /// - protected bool getConfVal(string chiave, ref string varObj) - { - bool answ = false; - if (CurrConfig != null && CurrConfig.Count > 0) - { - // sistemo i parametri opzionali... - ConfigModel? risultato = CurrConfig.FirstOrDefault(x => x.Chiave == chiave); - if (risultato != null) - { - varObj = risultato.Valore; - answ = !string.IsNullOrEmpty(risultato.Valore); - } - } - return answ; - } - - /// - /// Recupera il valore e se trovato aggiorna - /// - /// Valore da cercare - /// Int in cui salvare il valore se trovato - /// - protected bool getConfValInt(string chiave, ref int varObj) - { - bool answ = false; - if (CurrConfig != null && CurrConfig.Count > 0) - { - // sistemo i parametri opzionali... - ConfigModel? risultato = CurrConfig.FirstOrDefault(x => x.Chiave == chiave); - if (risultato != null) - { - answ = int.TryParse(risultato.Valore, out varObj); - } - } - return answ; - } - /// /// Recupera da conf eventuale setup tag dell'IOB indicato /// @@ -123,8 +88,17 @@ namespace MP_TAB_SERV.Pages return answ; } + protected bool isCalcSize { get; set; } = false; + protected override async Task OnAfterRenderAsync(bool firstRender) { + if (firstRender) + { + await getWDim(); + isCalcSize = false; + ListMSE = await MDataService.MseGetAll(true); + await InvokeAsync(StateHasChanged); + } if (ListMSE != null) { // salvo in LocalStorage... @@ -132,49 +106,22 @@ namespace MP_TAB_SERV.Pages } } - protected override async Task OnInitializedAsync() + protected override void OnInitialized() { + var df = MServ.UserPrefGet("DefCardMode"); + ShowCard = df == "shrink" ? false : true; + isCalcSize = true; ListMSE = null; - await setupConf(); - StartTimer(); - await ReloadData(); + SetupConf(); } - public void StartTimer() + protected void SaveData(List newList) { - int tOutPeriod = 3000; - //int.TryParse(Configuration["ReloadStatusTimer"], out tOutPeriod); - aTimer = new System.Timers.Timer(tOutPeriod); - aTimer.Elapsed += ElapsedTimer; - aTimer.Enabled = true; - aTimer.Start(); - Log.Info("Timer started!"); + //await Task.Delay(1); + ListMSE = newList; + //await InvokeAsync(StateHasChanged); } - public void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e) - { - var pUpd = Task.Run(async () => - { - await ReloadData(); - await MServ.SaveMse(ListMSE); - await InvokeAsync(StateHasChanged); - Log.Debug("Timer elapsed"); - }); - pUpd.Wait(); - } - - private System.Timers.Timer aTimer = null!; - - public void Dispose() - { - if (aTimer != null) - { - aTimer.Elapsed -= ElapsedTimer; - aTimer.Stop(); - aTimer.Dispose(); - Log.Info("Timer Disposed!"); - } - } #endregion Protected Methods #region Private Fields @@ -183,10 +130,6 @@ namespace MP_TAB_SERV.Pages private static System.Timers.Timer slowTimer = new System.Timers.Timer(300000); - private List? CurrConfig = null; - - private Random rnd = new Random(); - #endregion Private Fields #region Private Properties @@ -197,39 +140,33 @@ namespace MP_TAB_SERV.Pages #region Private Methods - private async Task ReloadData() + private void SetupConf() { - ListMSE = await MDataService.MseGetAll(); - } - - //protected bool ShowCard { get; set; } = false; - protected bool _showCard = false; - protected bool ShowCard - { - get => _showCard; - set - { - _showCard = value; - StateHasChanged(); - } - } - private async Task setupConf() - { - CurrConfig = await MDataService.ConfigGetAll(); - if (CurrConfig != null && CurrConfig.Count > 0) - { - // sistemo i parametri opzionali... - getConfValInt("keepAliveMin", ref keepAliveMin); - getConfValInt("MON_maxCol", ref maxCol); - int intDoAnim = 0; - getConfValInt("doAnimate", ref intDoAnim); - doAnimate = intDoAnim == 1; - getConfValInt("pageRefreshSec", ref slowRefreshSec); - getConfVal("sART", ref showArt); - Log.Info($"setupConf | Effettuato setup parametri | keepAlive: {keepAliveMin} | MaxCol: {maxCol} | doAnimate: {doAnimate} | slowRefreshSec: {slowRefreshSec}"); - } + // sistemo i parametri opzionali... + TabDServ.ConfigGetVal("MON_maxCol", ref maxCol); + TabDServ.ConfigGetVal("sART", ref showArt); + Log.Info($"setupConf | Effettuato setup parametri | MaxCol: {maxCol}"); } #endregion Private Methods + + protected int Width { get; set; } = 0; + protected int Height { get; set; } = 0; + + public class WindowDimension + { + #region Public Properties + + public int Height { get; set; } + public int Width { get; set; } + + #endregion Public Properties + } + protected async Task getWDim() + { + var dimension = await JSRuntime.InvokeAsync("getWindowDimensions"); + Height = dimension.Height; + Width = dimension.Width; + } } } \ No newline at end of file diff --git a/MP-TAB-SERV/Pages/TCHistory.razor b/MP-TAB-SERV/Pages/TCHistory.razor index 6cc87a79..74855de1 100644 --- a/MP-TAB-SERV/Pages/TCHistory.razor +++ b/MP-TAB-SERV/Pages/TCHistory.razor @@ -10,9 +10,6 @@
- @* *@ - @* *@ - @* *@ @@ -30,7 +27,6 @@
- @* *@ - @* *@ } } diff --git a/MP-TAB-SERV/Pages/TechSheet.razor b/MP-TAB-SERV/Pages/TechSheet.razor index 060f0eed..612cfe71 100644 --- a/MP-TAB-SERV/Pages/TechSheet.razor +++ b/MP-TAB-SERV/Pages/TechSheet.razor @@ -1,15 +1,22 @@ @page "/tech-sheet" + + @if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null) { } else { -
-
- + @if (enableSchedaTecnica) + { + + } + else + { + + } } diff --git a/MP-TAB-SERV/Pages/TechSheet.razor.cs b/MP-TAB-SERV/Pages/TechSheet.razor.cs index ae2082f3..4a1fe840 100644 --- a/MP-TAB-SERV/Pages/TechSheet.razor.cs +++ b/MP-TAB-SERV/Pages/TechSheet.razor.cs @@ -14,6 +14,9 @@ namespace MP_TAB_SERV.Pages [Inject] protected MessageService MsgServ { get; set; } = null!; + [Inject] + protected TabDataService TabDServ { get; set; } = null!; + #endregion Protected Properties #region Protected Methods @@ -21,10 +24,37 @@ namespace MP_TAB_SERV.Pages protected override async Task OnInitializedAsync() { await ReloadData(); + SetupConf(); + } + + protected async Task RefreshData(List newList) + { + var ListMSE = newList; + if (!string.IsNullOrEmpty(IdxMacc)) + { + var rawData = ListMSE.Find(x => x.IdxMacchina == IdxMacc); + if (rawData != null) + { + CurrMSE = rawData; + } + } + await InvokeAsync(StateHasChanged); } #endregion Protected Methods + #region Private Fields + + private string disMessage = "Gestione schede tecniche di attrezzaggio, collaudo e verifica procedure di setup. Il modulo opzionale è attivabile su richiesta."; + + private string disSubtitle = "Funzionalità disattivata"; + + private string disTitle = "Scheda Tecnica"; + + private bool enableSchedaTecnica = false; + + #endregion Private Fields + #region Private Methods private async Task ReloadData() @@ -40,6 +70,11 @@ namespace MP_TAB_SERV.Pages } } + private void SetupConf() + { + TabDServ.ConfigGetVal("enableSchedaTecnica", ref enableSchedaTecnica); + } + #endregion Private Methods } } \ No newline at end of file diff --git a/MP-TAB-SERV/Pages/User.razor b/MP-TAB-SERV/Pages/User.razor index 69c0122d..bf09134d 100644 --- a/MP-TAB-SERV/Pages/User.razor +++ b/MP-TAB-SERV/Pages/User.razor @@ -43,6 +43,38 @@ +
+ Preferenze +
+
+
    +
  • +
    Modalità di inserimento del tempo ciclo
    +
    +
    + + +
    +
    +
  • +
  • +
    Lingua
    + +
  • +
  • +
    Modalità di visualizzazione delle macchine in 'Mappa Stato'
    +
    +
    + + +
    +
    +
  • +
+
@code { + [Inject] + private MessageService MsgServ { get; set; } = null!; + + protected async Task setTcMode(string tcMode) + { + await Task.Delay(1); + tcModIns = tcMode; + } + protected async Task setLang(string lang) + { + await Task.Delay(1); + langIns = lang; + } + protected async Task setDefCardMode(string defCardMode) + { + await Task.Delay(1); + defCardModeIns = defCardMode; + } + + protected string btnMsStyle + { + get + { + string answ = ""; + if (tcModIns == "ms") + { + answ = "btn-primary"; + } + else + { + answ = "btn-outline-secondary"; + } + return answ; + } + } + protected string btnMcStyle + { + get + { + string answ = ""; + if (tcModIns == "mc") + { + answ = "btn-primary"; + } + else + { + answ = "btn-outline-secondary"; + } + return answ; + } + } + protected string btnShrinkStyle + { + get + { + string answ = ""; + if (defCardModeIns == "shrink") + { + answ = "btn-primary"; + } + else + { + answ = "btn-outline-secondary"; + } + return answ; + } + } + protected string btnFullStyle + { + get + { + string answ = ""; + if (defCardModeIns == "full") + { + answ = "btn-primary"; + } + else + { + answ = "btn-outline-secondary"; + } + return answ; + } + } + + protected string _tcModIns { get; set; } = ""; + + protected string tcModIns + { + get => _tcModIns; + set + { + if (_tcModIns != value) + { + _tcModIns = value; + MsgServ.UserPrefSave("TcMode", value); + } + } + } + + protected string _langIns { get; set; } = ""; + + protected string langIns + { + get => _langIns; + set + { + if (_langIns != value) + { + _langIns = value; + MsgServ.UserPrefSave("Lang", value); + } + } + } + protected string _defCardMode { get; set; } = ""; + + protected string defCardModeIns + { + get => _defCardMode; + set + { + if (_defCardMode != value) + { + _defCardMode = value; + MsgServ.UserPrefSave("DefCardMode", value); + } + } + } + public int Height { get; set; } = 0; public int Width { get; set; } = 0; public string currIpv4 { get; set; } = ""; @@ -82,6 +242,21 @@ } protected async override Task OnInitializedAsync() { + var tcPrefItem = MsgServ.UserPrefGet("TcMode"); + if (tcPrefItem != null) + { + tcModIns = tcPrefItem; + } + var langPrefItem = MsgServ.UserPrefGet("Lang"); + if (langPrefItem != null) + { + langIns = langPrefItem; + } + var defCardPrefItem = MsgServ.UserPrefGet("DefCardMode"); + if (defCardPrefItem != null) + { + defCardModeIns = defCardPrefItem; + } await Task.Delay(1); if (string.IsNullOrEmpty(currIpv4)) { diff --git a/MP-TAB-SERV/Pages/WorkShift.razor b/MP-TAB-SERV/Pages/WorkShift.razor index 86a87cc4..ae0bd885 100644 --- a/MP-TAB-SERV/Pages/WorkShift.razor +++ b/MP-TAB-SERV/Pages/WorkShift.razor @@ -1,68 +1,55 @@ @page "/workshift" + @if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null) { } else { -
- -
-
-
-
-
- - + +

Gestione Turni

+
+
+
+
+

Stato Turni Attivi

+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
-
-
- - +
+
+
+ Turno Aperto +
+
+ Turno Chiuso +
-
-
- - -
-
-
-
-
-
-
-

Stato Turni Attivi

-
-
-
-
- Turno 1 -
-
-
-
- Turno 2 -
-
-
-
- Turno 3 -
-
-
-
-
-
- Turno Aperto -
-
- Turno Chiuso -
-
-
} diff --git a/MP-TAB-SERV/Pages/WorkShift.razor.cs b/MP-TAB-SERV/Pages/WorkShift.razor.cs index 605b1ee6..22e9e2bd 100644 --- a/MP-TAB-SERV/Pages/WorkShift.razor.cs +++ b/MP-TAB-SERV/Pages/WorkShift.razor.cs @@ -9,20 +9,86 @@ namespace MP_TAB_SERV.Pages #region Protected Properties protected MappaStatoExpl? CurrMSE { get; set; } = null; + protected TurniMaccModel currTurni { get; set; } = new TurniMaccModel(); protected string IdxMacc { get; set; } = ""; [Inject] protected MessageService MsgServ { get; set; } = null!; + protected bool T1 + { + get => currTurni.T1; + set + { + if (currTurni.T1 != value) + { + currTurni.T1 = value; + TabServ.TurnoMacchinaToggle(IdxMacc, 1); + } + } + } + + protected bool T2 + { + get => currTurni.T2; + set + { + if (currTurni.T2 != value) + { + currTurni.T2 = value; + TabServ.TurnoMacchinaToggle(IdxMacc, 2); + } + } + } + + protected bool T3 + { + get => currTurni.T3; + set + { + if (currTurni.T3 != value) + { + currTurni.T3 = value; + TabServ.TurnoMacchinaToggle(IdxMacc, 3); + } + } + } + + [Inject] + protected TabDataService TabServ { get; set; } = null!; + #endregion Protected Properties #region Protected Methods + protected string cssByState(bool isActive) + { + return isActive ? "bg-success text-warning" : "bg-secondary"; + } + protected override async Task OnInitializedAsync() { await ReloadData(); } + protected async Task RefreshData(List newList) + { + var ListMSE = newList; + if (!string.IsNullOrEmpty(IdxMacc)) + { + var rawData = ListMSE.Find(x => x.IdxMacchina == IdxMacc); + if (rawData != null) + { + CurrMSE = rawData; + } + else + { + await ReloadData(); + } + } + await InvokeAsync(StateHasChanged); + } + #endregion Protected Methods #region Private Methods @@ -42,52 +108,6 @@ namespace MP_TAB_SERV.Pages } } - protected bool T1 - { - get => currTurni.T1; - set - { - if (currTurni.T1 != value) - { - currTurni.T1 = value; - TabServ.TurnoMacchinaToggle(IdxMacc, 1); - } - } - } - protected bool T2 - { - get => currTurni.T2; - set - { - if (currTurni.T2 != value) - { - currTurni.T2 = value; - TabServ.TurnoMacchinaToggle(IdxMacc, 2); - } - } - } - protected bool T3 - { - get => currTurni.T3; - set - { - if (currTurni.T3 != value) - { - currTurni.T3 = value; - TabServ.TurnoMacchinaToggle(IdxMacc, 3); - } - } - } - - protected string cssByState(bool isActive) - { - return isActive ? "bg-success text-warning" : "bg-secondary"; - } - - [Inject] - protected TabDataService TabServ { get; set; } = null!; - protected TurniMaccModel currTurni { get; set; } = new TurniMaccModel(); - #endregion Private Methods } } \ No newline at end of file diff --git a/MP-TAB-SERV/Pages/_Layout.cshtml b/MP-TAB-SERV/Pages/_Layout.cshtml index e190a339..24f41386 100644 --- a/MP-TAB-SERV/Pages/_Layout.cshtml +++ b/MP-TAB-SERV/Pages/_Layout.cshtml @@ -7,19 +7,20 @@ - + @* *@ + + + - @* *@ - - + @* *@ diff --git a/MP-TAB-SERV/Resources/ChangeLog.html b/MP-TAB-SERV/Resources/ChangeLog.html index f6f6de29..cc1f4884 100644 --- a/MP-TAB-SERV/Resources/ChangeLog.html +++ b/MP-TAB-SERV/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2310.1614

+

Versione: 6.16.2311.919


Note di rilascio:
  • diff --git a/MP-TAB-SERV/Resources/VersNum.txt b/MP-TAB-SERV/Resources/VersNum.txt index 8bf83e7e..07056f18 100644 --- a/MP-TAB-SERV/Resources/VersNum.txt +++ b/MP-TAB-SERV/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2310.1614 +6.16.2311.919 diff --git a/MP-TAB-SERV/Resources/manifest.xml b/MP-TAB-SERV/Resources/manifest.xml index 8437644c..ab8d78fe 100644 --- a/MP-TAB-SERV/Resources/manifest.xml +++ b/MP-TAB-SERV/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2310.1614 + 6.16.2311.919 https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/MP-TAB-SERV.zip https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/ChangeLog.html false diff --git a/MP-TAB-SERV/Shared/MainLayout.razor.cs b/MP-TAB-SERV/Shared/MainLayout.razor.cs index bf283356..c20d5162 100644 --- a/MP-TAB-SERV/Shared/MainLayout.razor.cs +++ b/MP-TAB-SERV/Shared/MainLayout.razor.cs @@ -116,6 +116,10 @@ namespace MP_TAB_SERV.Shared // fix MSFD... var allMSFD = await TDataService.VMSFDGetAll(); MStor.SetMsfd(allMSFD); + // fix slave + var macSlave = await TDataService.Macchine2Slave(); + MStor.SetM2S(macSlave); + // fix elenco eventi var allEvents = await TDataService.AnagEventiGetAll(); MStor.SetEventi(allEvents); @@ -125,6 +129,15 @@ namespace MP_TAB_SERV.Shared // non da farsi globalmente // fix macchine var allMach = await // MDataService.MacchineByMatrOper(0); MStor.DictMacchine = allMach.ToDictionary(x => // x.IdxMacchina, x => $"{x.IdxMacchina} | {x.Nome}"); + + // fix vocabolario + var allVoc = TDataService.VocabolarioGetAll(); + MStor.SetVocab(allVoc); + + // resetto il tabDServ + await TDataService.FlushCache(); + // ricarica la config... + TDataService.SetupConfig(); } #endregion Protected Methods diff --git a/MP-TAB-SERV/Shared/NavMenu.razor b/MP-TAB-SERV/Shared/NavMenu.razor index da607ea3..9e64402e 100644 --- a/MP-TAB-SERV/Shared/NavMenu.razor +++ b/MP-TAB-SERV/Shared/NavMenu.razor @@ -2,34 +2,6 @@ @inject ListSelectDataSrv MDataService -@* - -
    - -
    *@ @@ -78,17 +28,4 @@ [Parameter] public List MenuItems { get; set; } = new List(); - - #if false - - private bool collapseNavMenu = true; - - private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; - - private void ToggleNavMenu() - { - collapseNavMenu = !collapseNavMenu; - } - - #endif } diff --git a/MP-TAB-SERV/_Imports.razor b/MP-TAB-SERV/_Imports.razor index 1d557bbf..8e3ed34c 100644 --- a/MP-TAB-SERV/_Imports.razor +++ b/MP-TAB-SERV/_Imports.razor @@ -15,3 +15,4 @@ @using MP.Data.Services @using Newtonsoft.Json @using NLog +@using EgwCoreLib.Razor diff --git a/MP-TAB-SERV/appsettings.json b/MP-TAB-SERV/appsettings.json index 0ac4ed8f..57300304 100644 --- a/MP-TAB-SERV/appsettings.json +++ b/MP-TAB-SERV/appsettings.json @@ -8,19 +8,20 @@ "AllowedHosts": "*", "CodApp": "MP.TAB", "ConnectionStrings": { - //"Redis": "iis01.egalware.com:6379,DefaultDatabase=1,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false", - "Redis": "localhost:6379,DefaultDatabase=1,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false", - "MP.All": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=Blazor.ServerApp;", - "MP.Mon": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=Blazor.ServerApp;", - "MP.Tab": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=Blazor.ServerApp;" - }, - "ServerConf": { - "maxAge": "2000" + "Redis": "iis01.egalware.com:6379,DefaultDatabase=1,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false", + //"Redis": "localhost:6379,DefaultDatabase=1,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false", + "MP.All": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.TAB3;", + "MP.Mon": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.TAB3;", + "Mp.IS": "Server=SQL2016DEV;Database=MoonPro_IS_EdilChim; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.INVE;", + "MP.Tab": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.TAB3;", + "MP.Mag": "Server=SQL2016DEV;Database=MoonPro_MAG; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.TAB3;" }, "OptConf": { + "msRefresh": "2000", "BaseAddr": "https://localhost:7295/MP/TAB3/", "BaseUrl": "/MP/TAB3", - "ImgBasePath": "C:\\Steamware\\macchine", + "ImgBasePath": "https://iis01.egalware.com/MP/images/macchine/small/", + "ImgStBasePath": "C:\\Steamware\\images\\ST", "CodModulo": "MoonPro" }, "AlarmDest": "samuele.locatelli@egalware.com, ceo@steamware.net", @@ -28,7 +29,7 @@ "DisplayName": "MAPO EgalWare Email BOT", "From": "steamwarebot@outlook.it", "Host": "smtp-mail.outlook.com", - "Password": "siamoInViaNazionale93", + "Password": "siamoInViaNazionale93!", "Port": 587, "UserName": "steamwarebot@outlook.it", "UseSSL": false, diff --git a/MP-TAB-SERV/compilerconfig.json b/MP-TAB-SERV/compilerconfig.json index 5610f4c9..81657133 100644 --- a/MP-TAB-SERV/compilerconfig.json +++ b/MP-TAB-SERV/compilerconfig.json @@ -10,5 +10,29 @@ { "outputFile": "wwwroot/css/font.css", "inputFile": "wwwroot/css/font.less" + }, + { + "outputFile": "Components/ProdConfirm.razor.css", + "inputFile": "Components/ProdConfirm.razor.less" + }, + { + "outputFile": "Components/ProdStat.razor.css", + "inputFile": "Components/ProdStat.razor.less" + }, + { + "outputFile": "Pages/IobInfo.razor.css", + "inputFile": "Pages/IobInfo.razor.less" + }, + { + "outputFile": "Components/IobInfoMan.razor.css", + "inputFile": "Components/IobInfoMan.razor.less" + }, + { + "outputFile": "Pages/WorkShift.razor.css", + "inputFile": "Pages/WorkShift.razor.less" + }, + { + "outputFile": "Components/ProdPlanMan.razor.css", + "inputFile": "Components/ProdPlanMan.razor.less" } ] \ No newline at end of file diff --git a/MP-TAB-SERV/wwwroot/css/site.css b/MP-TAB-SERV/wwwroot/css/site.css index 1d526090..924a71e9 100644 --- a/MP-TAB-SERV/wwwroot/css/site.css +++ b/MP-TAB-SERV/wwwroot/css/site.css @@ -3,9 +3,56 @@ html, body { /*font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;*/ font-family: 'Open Sans Condensed', sans-serif; - background-image: linear-gradient(#444, #222); + /*background-image: linear-gradient(#444,#222);*/ + background-color: #151321; color: #EDEDED; } +.cardObj { + border-radius: 0.375rem; + background: linear-gradient(121deg, rgba(255, 255, 255, 0.2) -0.71%, rgba(255, 255, 255, 0.05) 97.66%); + box-shadow: 0px 4px 24px -1px rgba(0, 0, 0, 0.25); + /*height: 100%;*/ + flex-shrink: 0; +} +.cardObjNoBL { + border-radius: 0.375rem 0 0 0.375rem; + background: linear-gradient(121deg, rgba(255, 255, 255, 0.2) -0.71%, rgba(255, 255, 255, 0.05) 97.66%); + box-shadow: 0px 4px 24px -1px rgba(0, 0, 0, 0.25); + /*height: 100%;*/ + flex-shrink: 0; +} +.cardFullHeight { + border-radius: 0.375rem; + background: linear-gradient(121deg, rgba(255, 255, 255, 0.2) -0.71%, rgba(255, 255, 255, 0.05) 97.66%); + box-shadow: 0px 4px 24px -1px rgba(0, 0, 0, 0.25); + /*height: 100%;*/ + flex-shrink: 0; + height: 100%; +} +.longStopListNotes { + height: 100%; +} +@media (max-width: 640.98px) { + .longStopListNotes { + max-height: 120px; + } +} +.borderStd { + border-radius: 0.375rem; +} +.table-dark { + --bs-table-color: #fff; + --bs-table-bg: transparent; + --bs-table-border-color: #4d5154; + --bs-table-striped-bg: #2c3034; + --bs-table-striped-color: #fff; + --bs-table-active-bg: #373b3e; + --bs-table-active-color: #fff; + --bs-table-hover-bg: #323539; + --bs-table-hover-color: #fff; + color: var(--bs-table-color); + border-color: var(--bs-table-border-color); +} h1:focus { outline: none; } diff --git a/MP-TAB-SERV/wwwroot/css/site.less b/MP-TAB-SERV/wwwroot/css/site.less index 14cf140a..f1f08aa8 100644 --- a/MP-TAB-SERV/wwwroot/css/site.less +++ b/MP-TAB-SERV/wwwroot/css/site.less @@ -3,51 +3,100 @@ html, body { /*font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;*/ font-family: 'Open Sans Condensed', sans-serif; - background-image: linear-gradient(#444,#222); + /*background-image: linear-gradient(#444,#222);*/ + background-color: #151321; color: #EDEDED; } -h1:focus { - outline: none; +.cardObj { + border-radius: 0.375rem; + background: linear-gradient(121deg, rgba(255, 255, 255, 0.20) -0.71%, rgba(255, 255, 255, 0.05) 97.66%); + box-shadow: 0px 4px 24px -1px rgba(0, 0, 0, 0.25); + /*height: 100%;*/ + flex-shrink: 0; +} +.cardObjNoBL { + border-radius: 0.375rem 0 0 0.375rem; + background: linear-gradient(121deg, rgba(255, 255, 255, 0.20) -0.71%, rgba(255, 255, 255, 0.05) 97.66%); + box-shadow: 0px 4px 24px -1px rgba(0, 0, 0, 0.25); + /*height: 100%;*/ + flex-shrink: 0; } -a, .btn-link { - color: #0071c1; +.cardFullHeight{ + .cardObj; + height: 100%; } -.btn-primary { - color: #fff; - background-color: #1b6ec2; - border-color: #1861ac; +.longStopListNotes{ + height: 100%; } -.content { - padding-top: 1.1rem; +@media (max-width: 640.98px) { + .longStopListNotes{ + max-height: 120px; + } } -.valid.modified:not([type=checkbox]) { - outline: 1px solid #26b050; -} + .borderStd { + border-radius: 0.375rem; + } -.invalid { - outline: 1px solid red; -} + .table-dark { + --bs-table-color: #fff; + --bs-table-bg: transparent; + --bs-table-border-color: #4d5154; + --bs-table-striped-bg: #2c3034; + --bs-table-striped-color: #fff; + --bs-table-active-bg: #373b3e; + --bs-table-active-color: #fff; + --bs-table-hover-bg: #323539; + --bs-table-hover-color: #fff; + color: var(--bs-table-color); + border-color: var(--bs-table-border-color); + } -.validation-message { - color: red; -} + h1:focus { + outline: none; + } -#blazor-error-ui { - background: lightyellow; - bottom: 0; - box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); - display: none; - left: 0; - padding: 0.6rem 1.25rem 0.7rem 1.25rem; - position: fixed; - width: 100%; - z-index: 1000; -} + a, .btn-link { + color: #0071c1; + } + + .btn-primary { + color: #fff; + background-color: #1b6ec2; + border-color: #1861ac; + } + + .content { + padding-top: 1.1rem; + } + + .valid.modified:not([type=checkbox]) { + outline: 1px solid #26b050; + } + + .invalid { + outline: 1px solid red; + } + + .validation-message { + color: red; + } + + #blazor-error-ui { + background: lightyellow; + bottom: 0; + box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); + display: none; + left: 0; + padding: 0.6rem 1.25rem 0.7rem 1.25rem; + position: fixed; + width: 100%; + z-index: 1000; + } #blazor-error-ui .dismiss { cursor: pointer; @@ -56,11 +105,11 @@ a, .btn-link { top: 0.5rem; } -.blazor-error-boundary { - background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; - padding: 1rem 1rem 1rem 3.7rem; - color: white; -} + .blazor-error-boundary { + background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; + padding: 1rem 1rem 1rem 3.7rem; + color: white; + } .blazor-error-boundary::after { content: "An error has occurred." diff --git a/MP-TAB-SERV/wwwroot/css/site.min.css b/MP-TAB-SERV/wwwroot/css/site.min.css index e6b09875..9ec2a048 100644 --- a/MP-TAB-SERV/wwwroot/css/site.min.css +++ b/MP-TAB-SERV/wwwroot/css/site.min.css @@ -1 +1 @@ -@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');html,body{font-family:'Open Sans Condensed',sans-serif;background-image:linear-gradient(#444,#222);color:#ededed;}h1:focus{outline:0;}a,.btn-link{color:#0071c1;}.btn-primary{color:#fff;background-color:#1b6ec2;border-color:#1861ac;}.content{padding-top:1.1rem;}.valid.modified:not([type=checkbox]){outline:1px solid #26b050;}.invalid{outline:1px solid #f00;}.validation-message{color:#f00;}#blazor-error-ui{background:#ffffe0;bottom:0;box-shadow:0 -1px 2px rgba(0,0,0,.2);display:none;left:0;padding:.6rem 1.25rem .7rem 1.25rem;position:fixed;width:100%;z-index:1000;}#blazor-error-ui .dismiss{cursor:pointer;position:absolute;right:.75rem;top:.5rem;}.blazor-error-boundary{background:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem,#b32121;padding:1rem 1rem 1rem 3.7rem;color:#fff;}.blazor-error-boundary::after{content:"An error has occurred.";} \ No newline at end of file +@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');html,body{font-family:'Open Sans Condensed',sans-serif;background-color:#151321;color:#ededed;}.cardObj{border-radius:.375rem;background:linear-gradient(121deg,rgba(255,255,255,.2) -.71%,rgba(255,255,255,.05) 97.66%);box-shadow:0 4px 24px -1px rgba(0,0,0,.25);flex-shrink:0;}.cardObjNoBL{border-radius:.375rem 0 0 .375rem;background:linear-gradient(121deg,rgba(255,255,255,.2) -.71%,rgba(255,255,255,.05) 97.66%);box-shadow:0 4px 24px -1px rgba(0,0,0,.25);flex-shrink:0;}.cardFullHeight{border-radius:.375rem;background:linear-gradient(121deg,rgba(255,255,255,.2) -.71%,rgba(255,255,255,.05) 97.66%);box-shadow:0 4px 24px -1px rgba(0,0,0,.25);flex-shrink:0;height:100%;}.longStopListNotes{height:100%;}@media(max-width:640.98px){.longStopListNotes{max-height:120px;}}.borderStd{border-radius:.375rem;}.table-dark{--bs-table-color:#fff;--bs-table-bg:transparent;--bs-table-border-color:#4d5154;--bs-table-striped-bg:#2c3034;--bs-table-striped-color:#fff;--bs-table-active-bg:#373b3e;--bs-table-active-color:#fff;--bs-table-hover-bg:#323539;--bs-table-hover-color:#fff;color:var(--bs-table-color);border-color:var(--bs-table-border-color);}h1:focus{outline:0;}a,.btn-link{color:#0071c1;}.btn-primary{color:#fff;background-color:#1b6ec2;border-color:#1861ac;}.content{padding-top:1.1rem;}.valid.modified:not([type=checkbox]){outline:1px solid #26b050;}.invalid{outline:1px solid #f00;}.validation-message{color:#f00;}#blazor-error-ui{background:#ffffe0;bottom:0;box-shadow:0 -1px 2px rgba(0,0,0,.2);display:none;left:0;padding:.6rem 1.25rem .7rem 1.25rem;position:fixed;width:100%;z-index:1000;}#blazor-error-ui .dismiss{cursor:pointer;position:absolute;right:.75rem;top:.5rem;}.blazor-error-boundary{background:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem,#b32121;padding:1rem 1rem 1rem 3.7rem;color:#fff;}.blazor-error-boundary::after{content:"An error has occurred.";} \ No newline at end of file diff --git a/MP-TAB-SERV/wwwroot/images/ST_img/Steamware.png b/MP-TAB-SERV/wwwroot/images/ST_img/Steamware.png new file mode 100644 index 00000000..5d4a75b1 Binary files /dev/null and b/MP-TAB-SERV/wwwroot/images/ST_img/Steamware.png differ diff --git a/MP-TAB-SERV/wwwroot/images/linuxLogo.png b/MP-TAB-SERV/wwwroot/images/linuxLogo.png new file mode 100644 index 00000000..2afbacf6 Binary files /dev/null and b/MP-TAB-SERV/wwwroot/images/linuxLogo.png differ diff --git a/MP-TAB-SERV/wwwroot/images/winLogo.png b/MP-TAB-SERV/wwwroot/images/winLogo.png new file mode 100644 index 00000000..92cab382 Binary files /dev/null and b/MP-TAB-SERV/wwwroot/images/winLogo.png differ diff --git a/MP.Data/Constants.cs b/MP.Data/Constants.cs index 0fde3879..9f43bd5b 100644 --- a/MP.Data/Constants.cs +++ b/MP.Data/Constants.cs @@ -17,6 +17,10 @@ // REDIS KEY Dati correnti public static readonly string CONF_MON_KEY = $"{BASE_HASH}:Conf:MonDispData"; + + + public static string redisMseKey = "MP:MON:Cache:MSE"; + #endregion Public Fields } } \ No newline at end of file diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index bfdc9cf0..2bb17d59 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -2,12 +2,16 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using MP.Data.DatabaseModels; +using MP.Data.DTO; +using MP.Data.Objects; using NLog; using System; using System.Collections.Generic; using System.Data; +using System.Diagnostics; using System.Linq; using System.Threading.Tasks; +using static EgwCoreLib.Utils.DtUtils; namespace MP.Data.Controllers { @@ -53,10 +57,10 @@ namespace MP.Data.Controllers using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx - .DbSetAnagGruppi - .AsNoTracking() - .OrderBy(x => x.CodGruppo) - .ToList(); + .DbSetAnagGruppi + .AsNoTracking() + .OrderBy(x => x.CodGruppo) + .ToList(); } return dbResult; } @@ -81,6 +85,24 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Elenco Gruppi + /// + /// + public List AnagKeyValGetAll() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetAKV + .AsNoTracking() + .OrderBy(x => x.nomeVar) + .ToList(); + } + return dbResult; + } + /// /// Elenco valori ammessi x Stati commessa (es Yacht Baglietto) /// @@ -519,6 +541,153 @@ namespace MP.Data.Controllers return fatto; } + /// + /// Funzione di Data Reduction x FluxLog + /// + /// + /// + /// + /// + /// + /// + /// Restitusice list dei record statistiche raccolti (da integrare a quelli rpesenti in Redis...) + /// + public async Task> FluxLogDataRedux(string idxMaccSel, List fluxList, Periodo currPeriodo, Enums.ValSelection valMode, Enums.DataInterval intReq, int maxItem) + { + List procStats = new List(); + Log.Info($"Inizio FluxLogDataRedux | idxMaccSel: {idxMaccSel} | periodo: {currPeriodo.Inizio} --> {currPeriodo.Fine}"); + TimeSpan step = TimeSpan.FromHours(1); + switch (intReq) + { + case Enums.DataInterval.minute: + step = TimeSpan.FromMinutes(1.00 / maxItem); + break; + + case Enums.DataInterval.hour: + step = TimeSpan.FromHours(1.00 / maxItem); + break; + + case Enums.DataInterval.day: + step = TimeSpan.FromDays(1.00 / maxItem); + break; + + default: + break; + } + + // setup parametri costanti x stored + var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMaccSel); + var pOnlyTest = new SqlParameter("@OnlyTest", false); + + // processo 1:1 ogni flusso + foreach (var item in fluxList) + { + Log.Info($"FluxLogDataRedux | Flux: {item}"); + int numRecProc = 0; + Stopwatch sw = new Stopwatch(); + sw.Start(); + // parametri x flusso + var pCodFlux = new SqlParameter("@CodFlux", item); + // inizializzo cursore timer + DateTime dtCursStart = currPeriodo.Inizio; + DateTime dtCursEnd = dtCursStart.Add(step); + bool setCompleted = false; + // dbContext x ogni singolo flusso + using (var dbCtx = new MoonProContext(_configuration)) + { + // li processo per intervallo richiesto, cercando dati nel periodo e + // selezionando VC + while (!setCompleted) + { + // ora recupero TUTTI i dati della macchina + var currFlux = await dbCtx + .DbSetFluxLog + .Where(x => (x.CodFlux == item) && (x.dtEvento >= dtCursStart && x.dtEvento < dtCursEnd) && (x.IdxMacchina == idxMaccSel)) + .ToListAsync(); + + int numRec = currFlux.Count; + numRecProc += numRec; + if (numRec > maxItem) + { + if (dtCursStart > currPeriodo.Fine) + { + setCompleted = true; + } + List listPeriodi = new List(); + + switch (valMode) + { + case Enums.ValSelection.First: + // recupero 2° item + var recStart = currFlux.Skip(1).FirstOrDefault(); + // salvo periodo! + listPeriodi.Add(new Periodo(recStart.dtEvento, dtCursEnd)); + break; + + case Enums.ValSelection.Last: + // recupero ultimo item + var recEnd = currFlux.LastOrDefault(); + // salvo periodo! + listPeriodi.Add(new Periodo(dtCursStart, recEnd.dtEvento)); + break; + + case Enums.ValSelection.Center: + int idx = 1; + // per iniziare mi metto a 1/(n+1) rec come step + var recCent = currFlux.Skip(idx / (maxItem + 1)).FirstOrDefault(); + listPeriodi.Add(new Periodo(dtCursStart, recCent.dtEvento)); + // salvo restanti periodi (se > 1)! + if (maxItem > 1) + { + for (int i = 2; i < maxItem; i++) + { + DateTime dtInizio = recCent.dtEvento; + recCent = currFlux.Skip(i / (maxItem + 1)).FirstOrDefault(); + listPeriodi.Add(new Periodo(dtInizio, recCent.dtEvento)); + } + } + // aggiungo ultimo... + listPeriodi.Add(new Periodo(recCent.dtEvento.AddSeconds(1), dtCursEnd)); + break; + + default: + break; + } + + // ciclo x tutti i periodi e chiamo stored... + foreach (var slot in listPeriodi) + { + // parametri x periodo (base) + var pDtStart = new SqlParameter("@DtStart", slot.Inizio); + var pDtEnd = new SqlParameter("@DtEnd", slot.Fine); + var dbResult = dbCtx + .Database + .ExecuteSqlRaw("EXEC man.stp_ReduceFluxLog @IdxMacchina, @CodFlux, @DtStart, @DtEnd, @OnlyTest", pIdxMacchina, pCodFlux, pDtStart, pDtEnd, pOnlyTest); + } + } + + // incremento dt fine periodo + dtCursStart = dtCursEnd; + dtCursEnd = dtCursStart.Add(step); + } + } + // fermo cronometro e salvo su DB... + sw.Stop(); + StatDedupDTO currStat = new StatDedupDTO() + { + IdxMacchina = idxMaccSel, + CodFlux = item, + Interval = intReq, + Num4Int = maxItem, + NumRec = numRecProc, + ProcTime = sw.Elapsed.TotalSeconds + }; + procStats.Add(currStat); + } + Log.Info($"FINE FluxLogDataRedux | idxMaccSel: {idxMaccSel} | periodo: {currPeriodo.Inizio} --> {currPeriodo.Fine}"); + return procStats; + } + /// /// Elenco ultimi n record flux log dato macchina e flusso (ordinato x data registrazione) /// @@ -544,6 +713,40 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Stored manutenzione del DB + /// + /// Esegue realmente il task + /// Aggiornamento statistiche + /// Salvataggio + /// def: 1000 + /// def: 10 + /// def: 50 + /// + public async Task ForceDbMaint(bool doExec, bool doUpdStat, bool doSave, int minPgCnt, int minAvgFrag, int maxAvgFragReb) + { + Log.Info($"Inizio ForceDbMaint on MoonProAdminContext"); + bool fatto = false; + // uso context admin x query lunghe + using (var dbCtx = new MoonProAdminContext(_configuration)) + { + var pFlgExec = new SqlParameter("@FlgExec", doExec ? "Y" : "N"); + var pFlgUpdStat = new SqlParameter("@FlgUpdStat", doUpdStat ? "Y" : "N"); + var pFlgSave = new SqlParameter("@FlgSave", doSave ? "Y" : "N"); + var pMinPgCnt = new SqlParameter("@min_page_count", minPgCnt); + var pMinAvgFrag = new SqlParameter("@min_avg_fragmentation_in_percent", minAvgFrag); + var pMaxAvgFrag = new SqlParameter("@max_avg_fragmentation_per_rebuild", maxAvgFragReb); + + var dbResult = await dbCtx + .Database + .ExecuteSqlRawAsync("EXEC man.stp_Utility_Maintanance"); + //.ExecuteSqlRaw("EXEC man.stp_Utility_Maintanance @FlgExec, @FlgUpdStat, @FlgSave, @min_page_count, @min_avg_fragmentation_in_percent, @max_avg_fragmentation_per_rebuild", pFlgExec, pFlgUpdStat, pFlgSave, pMinPgCnt, pMinAvgFrag, pMaxAvgFrag); + fatto = true; + } + Log.Info($"FINE ForceDbMaint on MoonProAdminContext"); + return fatto; + } + /// /// Elenco giacenze /// @@ -737,7 +940,7 @@ namespace MP.Data.Controllers } catch (Exception exc) { - Log.Error($"Eccezione in MacchineGetFilt{Environment.NewLine}{exc}"); + Log.Error($"Eccezione in MacchineByMatrOper{Environment.NewLine}{exc}"); } return dbResult; } @@ -1067,6 +1270,27 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Elenco Gruppi + /// + /// + public List ParetoFluxLog(string idxMacchina, DateTime dtFrom, DateTime dtTo) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetFluxLog + .Where(x => (string.IsNullOrEmpty(idxMacchina) || x.IdxMacchina == idxMacchina) && (dtFrom <= x.dtEvento && x.dtEvento <= dtTo)) + .AsNoTracking() + .GroupBy(x => x.CodFlux) + .Select(g => new ParetoFluxLogDTO() { IdxMacchina = idxMacchina, CodFlux = g.Key, Qty = g.Count() }) + .OrderByDescending(x => x.Qty) + .ToList(); + } + return dbResult; + } + /// /// Stato prod macchina /// diff --git a/MP.Data/Controllers/MpTabController.cs b/MP.Data/Controllers/MpTabController.cs index 4a9ab556..a3190441 100644 --- a/MP.Data/Controllers/MpTabController.cs +++ b/MP.Data/Controllers/MpTabController.cs @@ -2,9 +2,11 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using MP.Data.DatabaseModels; +using MP.Data.Objects; using NLog; using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Threading.Tasks; using static MP.Data.Objects.Enums; @@ -153,6 +155,25 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Restituisce l'anagrafica EVENTI per intero + /// + /// + public List AnagTagsOrd() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetAnagTags + .FromSqlRaw("exec dbo.stp_AT_getOrd") + .AsNoTracking() + .AsEnumerable() + .ToList(); + } + return dbResult; + } + /// /// Verifica se sia necessario inserire un cambio di stato impianto in modalità batch /// @@ -241,21 +262,21 @@ namespace MP.Data.Controllers /// Recupera elenco ultimi commenti x macchina /// /// Idx macchina, "*" = tutte - /// Num massimo di record da recuperare + /// Num massimo di record da recuperare /// - public List CommentiGetLastByMacc(string idxMacchina, int maxRec) + public List CommentiGetLastByMacc(string idxMacchina, int numDays) { List dbResult = new List(); using (var dbCtx = new MoonProContext(_configuration)) { var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina); - var MaxRec = new SqlParameter("@MaxRec", maxRec); + var NumDays = new SqlParameter("@NumDays", numDays); dbResult = dbCtx .DbSetCommenti - .FromSqlRaw("exec dbo.stp_Comm_getLastByMacchina @IdxMacchina, @MaxRec", IdxMacchina, MaxRec) + .FromSqlRaw("exec dbo.stp_Comm_getLastByMacchinaDays @IdxMacchina, @numDays", IdxMacchina, NumDays) .AsNoTracking() - .AsEnumerable() + //.AsEnumerable() .ToList(); } return dbResult; @@ -466,6 +487,34 @@ namespace MP.Data.Controllers _configuration = null; } + /// + /// Fix ODL per Elenco Lotti + /// + /// + /// + /// + public bool ElencoLottiUpsertByOdl(int idxOdl, bool flgStorico) + { + bool fatto = false; + using (var dbCtx = new MoonPro_MagContext(_configuration)) + { + try + { + var IdxOdl = new SqlParameter("@IdxOdl", idxOdl); + var FlgStorico = new SqlParameter("@flgStorico", flgStorico); + var result = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_EL_UpsertByOdl @IdxODL, @flgStorico", IdxOdl, FlgStorico); + fatto = result != 0; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante ElLottiUpsertByOdl{Environment.NewLine}{exc}"); + } + } + return fatto; + } + //stp_DDB_getNextByMacchinaFrom /// /// Eliminazione record EventList (SE trovato) @@ -625,6 +674,24 @@ namespace MP.Data.Controllers return fatto; } + /// + /// Intera tabella relazione master/slave in machine (gestione setup master --> slave) + /// + /// + public List Macchine2Slave() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetM2S + .AsNoTracking() + .OrderBy(x => x.IdxMacchina) + .ToList(); + } + return dbResult; + } + /// /// MicroStato macchina (da key) /// @@ -698,6 +765,435 @@ namespace MP.Data.Controllers return fatto; } + /// + /// ODL da key + /// + /// + /// + /// + public List OdlByIdx(int idxOdl, bool onlyUnused) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + var IdxOdl = new SqlParameter("@IdxOdl", idxOdl); + var OnlyUnused = new SqlParameter("@onlyUnused", onlyUnused); + dbResult = dbCtx + .DbSetODLExp + .FromSqlRaw("EXEC stp_ODL_getByIdx @IdxOdl, @onlyUnused", IdxOdl, OnlyUnused) + .AsNoTracking() + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Eccezione durante OdlByIdx{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + + /// + /// ODL corrente macchina + /// + /// + /// + public List OdlCurrByMacc(string idxMacchina) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina); + dbResult = dbCtx + .DbSetODLExp + .FromSqlRaw("EXEC stp_ODL_getByMacchina @IdxMacchina", IdxMacchina) + .AsNoTracking() + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Eccezione durante OdlCurrByMacc{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + + /// + /// Registro fine prod ODL + /// + /// + /// + /// + public bool OdlFineProd(int idxODL, string idxMacchina) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + var IdxODL = new SqlParameter("@IdxODL", idxODL); + var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina); + var result = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_ODL_fineProd @IdxODL, @IdxMacchina", IdxODL, IdxMacc); + fatto = result != 0; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante OdlFineProd{Environment.NewLine}{exc}"); + } + } + return fatto; + } + + /// + /// Fix ODL per macchine SLAVE + /// + /// + /// + /// + /// + public bool OdlFixMachineSlave(string idxMacchina, int numDayPrev, int doInsert) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina); + var NumDayPrev = new SqlParameter("@NumDayPrev", numDayPrev); + var DoInsert = new SqlParameter("@DoInsert", doInsert); + var result = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_ODL_fixMachineSlave @IdxMacchina, @NumDayPrev, @DoInsert", IdxMacc, NumDayPrev, DoInsert); + fatto = result != 0; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante OdlFixMachineSlave{Environment.NewLine}{exc}"); + } + } + return fatto; + } + + /// + /// Setup PODL Postumo + /// + /// + /// + /// + /// + /// + /// + /// + public bool OdlInizioSetup(int idxODL, int matrOpr, string idxMacchina, decimal tcRich, int pzPallet, string note) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + var IdxODL = new SqlParameter("@idxPromessa", idxODL); + var MatrOpr = new SqlParameter("@MatrOpr", matrOpr); + var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina); + var TCRichAttr = new SqlParameter("@TCRichAttr", tcRich); + var PzPallet = new SqlParameter("@PzPallet", pzPallet); + var Note = new SqlParameter("@Note", note); + var result = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_ODL_inizioSetup @idxODL, @MatrOpr, @IdxMacchina, @TCRichAttr, @PzPallet, @Note", IdxODL, MatrOpr, IdxMacc, TCRichAttr, PzPallet, Note); + fatto = result != 0; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante OdlInizioSetup{Environment.NewLine}{exc}"); + } + } + return fatto; + } + + /// + /// Elenco ODL data macchina e periodo + /// + /// + /// + /// + /// + public List OdlListByMaccPeriodo(string idxMacchina, DateTime dtStart, DateTime dtEnd) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina); + var DataFrom = new SqlParameter("@dataFrom", dtStart); + var DataTo = new SqlParameter("@dataTo", dtEnd); + dbResult = dbCtx + .DbSetODL + .FromSqlRaw("EXEC stp_ODL_getByMacchinaPeriodo @IdxMacchina, @dataFrom, @dataTo", IdxMacchina, DataFrom, DataTo) + .AsNoTracking() + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Eccezione durante OdlListByMaccPeriodo{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + + /// + /// Setup ODL Postumo + /// + /// + /// + /// + public bool OdlSetupPostumo(int idxODL, string idxMacchina) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + var IdxODL = new SqlParameter("@idxODL", idxODL); + var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina); + var result = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_ODL_insPostumo @idxODL, @IdxMacchina", IdxODL, IdxMacc); + fatto = result != 0; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante OdlSetupPostumo{Environment.NewLine}{exc}"); + } + } + return fatto; + } + + /// + /// Setup PODL Postumo + /// + /// + /// + /// + /// + public bool OdlSetupPromPostuma(int idxPromOdl, int matrOpr, string idxMacchina) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + var IdxPODL = new SqlParameter("@idxPromessa", idxPromOdl); + var MatrOpr = new SqlParameter("@MatrOpr", matrOpr); + var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina); + var result = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_ODL_inizioSetupPromessaPostuma @idxPromessa, @MatrOpr, @IdxMacchina", IdxPODL, MatrOpr, IdxMacc); + fatto = result != 0; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante OdlSetupPromPostuma{Environment.NewLine}{exc}"); + } + } + return fatto; + } + + /// + /// Split ODL + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public bool OdlSplit(int idxODL, int matrOpr, string idxMacchina, decimal TCRich, int pzPallet, string note, bool startNewOdl, int qtyRich) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + var IdxODL = new SqlParameter("@idxODL", idxODL); + var MatrOpr = new SqlParameter("@MatrOpr", matrOpr); + var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina); + var TCRichAttr = new SqlParameter("@TCRichAttr", TCRich); + var PzPallet = new SqlParameter("@PzPallet", pzPallet); + var Note = new SqlParameter("@Note", note); + var StartNewOdl = new SqlParameter("@StartNewOdl", startNewOdl); + var QtyRich = new SqlParameter("@QtyRich", qtyRich); + var result = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_ODL_split @idxODL, @MatrOpr, @IdxMacchina, @TCRichAttr, @PzPallet, @Note, @StartNewOdl, @QtyRich", IdxODL, MatrOpr, IdxMacc, TCRichAttr, PzPallet, Note, StartNewOdl, QtyRich); + fatto = result != 0; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante OdlSplit{Environment.NewLine}{exc}"); + } + } + return fatto; + } + + /// + /// Update ODL (es: in setup x chiusura attrezzaggio) + /// + /// + /// + /// + public bool OdlUpdate(int idxODL, int matrOpr, decimal tCRichAttr, int pzPallet, string note) + { + bool answ = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + var IdxODL = new SqlParameter("@idxODL", idxODL); + var MatrOpr = new SqlParameter("@MatrOpr", matrOpr); + var TCRichAttr = new SqlParameter("@TCRichAttr", tCRichAttr); + var PzPallet = new SqlParameter("@PzPallet", pzPallet); + var Note = new SqlParameter("@Note", note); + var result = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_ODL_updateSetup @IdxODL, @MatrOpr, @TCRichAttr, @PzPallet, @Note", IdxODL, MatrOpr, TCRichAttr, PzPallet, Note); + answ = result != 0; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante OdlUpdate{Environment.NewLine}{exc}"); + } + } + return answ; + } + + /// + /// Stato prod macchina + /// + /// + /// + public List PezziProdMacchina(string idxMacchina) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina); + dbResult = dbCtx + .DbSetPzProd + .FromSqlRaw("EXEC stp_PzProd_getByMacchina @IdxMacchina", IdxMacchina) + .AsNoTracking() + .ToList(); + } + return dbResult; + } + + /// + /// Avvio setup ODL da PODL + /// + /// + /// + /// + /// + /// + /// + /// + public bool PODL_startSetup(PODLExpModel editRec, int matrOpr, decimal tcRich, int pzPallet, string note, DateTime dtEvent) + { + bool answ = false; + + PODLModel recPODL = new PODLModel() + { + IdxPromessa = editRec.IdxPromessa, + KeyRichiesta = editRec.KeyRichiesta, + KeyBCode = editRec.KeyBCode, + IdxOdl = editRec.IdxOdl, + CodArticolo = editRec.CodArticolo, + CodGruppo = editRec.CodGruppo, + IdxMacchina = editRec.IdxMacchina, + NumPezzi = editRec.NumPezzi, + Tcassegnato = editRec.Tcassegnato, + DueDate = editRec.DueDate, + Priorita = editRec.Priorita, + PzPallet = editRec.PzPallet, + Note = editRec.Note, + CodCli = editRec.CodCli, + InsertDate = editRec.InsertDate + }; + + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + var currRec = dbCtx + .DbSetPODL + .AsNoTracking() + .Where(x => x.IdxPromessa == recPODL.IdxPromessa) + .FirstOrDefault(); + + if (currRec != null) + { + // eseguo stored attrezzaggio + var IdxPromessa = new SqlParameter("@idxPromessa", recPODL.IdxPromessa); + var MatrOpr = new SqlParameter("@MatrOpr", matrOpr); + var IdxMacchina = new SqlParameter("@IdxMacchina", recPODL.IdxMacchina); + var TCRichAttr = new SqlParameter("@TCRichAttr", tcRich); + var PzPallet = new SqlParameter("@PzPallet", pzPallet); + var Note = new SqlParameter("@Note", note); + var DtEvento = new SqlParameter("@dtEvento", dtEvent); + var callResult = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_ODL_inizioSetupPromessa @idxPromessa, @MatrOpr, @IdxMacchina, @TCRichAttr, @PzPallet, @Note, @dtEvento", IdxPromessa, MatrOpr, IdxMacchina, TCRichAttr, PzPallet, Note, DtEvento); + + answ = true; + } + } + catch (Exception exc) + { + Log.Error($"Eccezione durante PODL_doSetup{Environment.NewLine}{exc}"); + } + } + return answ; + } + + /// + /// Recupero PODL da chiave + /// + /// + /// + public PODLExpModel PODLExp_getByKey(int idxPODL) + { + PODLExpModel dbResult = new PODLExpModel(); + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + var IdxPromessa = new SqlParameter("@IdxPromessa", idxPODL); + var rawResult = dbCtx + .DbSetPODLExp + .FromSqlRaw("EXEC stp_PODL_getByIdx @IdxPromessa", IdxPromessa) + .AsNoTracking() + .ToList(); + if (rawResult != null && rawResult.Count > 0) + { + dbResult = rawResult.FirstOrDefault(); + } + } + catch (Exception exc) + { + Log.Error($"Eccezione durante PODL_getByKey{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + /// /// Restituisce elenco RC filtrato /// @@ -754,6 +1250,141 @@ namespace MP.Data.Controllers return fatto; } + /// + /// Aggiunta record RegistroScarti + /// + /// + /// + /// + /// + /// + /// + public List RegDichiarGetFilt(string idxMacchina, string tagCode, int matrOpr, int idxODL, DateTime dataFrom, DateTime dataTo) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + var TagCode = new SqlParameter("@TagCode", tagCode); + var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina); + var MatrOpr = new SqlParameter("@MatrOpr", matrOpr); + var IdxODL = new SqlParameter("@IdxODL", idxODL); + var DtFrom = new SqlParameter("@DataFrom", dataFrom); + var DtTo = new SqlParameter("@DataTo", dataTo); + + dbResult = dbCtx + .DbSetRegDich + .FromSqlRaw("EXEC stp_DD_getFilt @TagCode, @IdxMacchina, @MatrOpr, @IdxODL, @DataFrom, @DataTo", TagCode, IdxMacchina, MatrOpr, IdxODL, DtFrom, DtTo) + .AsNoTracking() + .ToList(); + } + return dbResult; + } + + /// + /// Aggiunta record Registro Dichiarazioni + /// + /// + /// + public async Task RegDichiarInsert(RegistroDichiarazioniModel newRec) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var TagCode = new SqlParameter("@TagCode", newRec.TagCode); + var IdxMacchina = new SqlParameter("@IdxMacchina", newRec.IdxMacchina); + var DtRec = new SqlParameter("@DtRec", newRec.DtRec); + var MatrOpr = new SqlParameter("@MatrOpr", newRec.MatrOpr); + var ValString = new SqlParameter("@ValString", newRec.ValString); + + var result = await dbCtx + .Database + .ExecuteSqlRawAsync("exec dbo.stp_DD_insertQuery @TagCode, @IdxMacchina, @DtRec, @MatrOpr, @ValString", TagCode, IdxMacchina, DtRec, MatrOpr, ValString); + // indico eseguito! + fatto = result > 0; + } + return fatto; + } + + /// + /// Update record Registro Dichiarazioni + /// + /// + /// + public async Task RegDichiarUpdate(RegistroDichiarazioniModel newRec) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var Original_IdxDich = new SqlParameter("@Original_IdxDich", newRec.IdxDich); + var DtRec = new SqlParameter("@DtRec", newRec.DtRec); + var TagCode = new SqlParameter("@TagCode", newRec.TagCode); + var ValString = new SqlParameter("@ValString", newRec.ValString); + var MatrOpr = new SqlParameter("@MatrOpr", newRec.MatrOpr); + + var result = await dbCtx + .Database + .ExecuteSqlRawAsync("exec dbo.stp_DD_updateQuery @Original_IdxDich, @DtRec, @TagCode, @ValString, @MatrOpr", Original_IdxDich, DtRec, TagCode, ValString, MatrOpr); + // indico eseguito! + fatto = result > 0; + } + return fatto; + } + + /// + /// Aggiunta record RegistroScarti + /// + /// + /// + /// + /// + /// + /// + public List RegScartiGetFilt(string idxMacchina, int idxODL, DateTime dataFrom, DateTime dataTo, bool showMulti) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina); + var IdxODL = new SqlParameter("@IdxODL", idxODL); + var DataFrom = new SqlParameter("@DataFrom", dataFrom); + var DataTo = new SqlParameter("@DataTo", dataTo); + var ShowMulti = new SqlParameter("@showMulti", showMulti); + + dbResult = dbCtx + .DbSetRegScarti + .FromSqlRaw("EXEC .stp_RS_getByFilt @IdxMacchina, @IdxODL, @DataFrom, @DataTo, @ShowMulti", IdxMacc, IdxODL, DataFrom, DataTo, ShowMulti) + .AsNoTracking() + .ToList(); + } + return dbResult; + } + + /// + /// Aggiunta record RegistroScarti + /// + /// + /// + public async Task RegScartiInsert(RegistroScartiModel newRec) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxMacchina = new SqlParameter("@idxMacchina", newRec.IdxMacchina); + var DataOra = new SqlParameter("@DataOra", newRec.DataOra); + var Causale = new SqlParameter("@Causale", newRec.Causale); + var Qta = new SqlParameter("@Qta", newRec.Qta); + var Note = new SqlParameter("@Note", newRec.Note); + var MatrOpr = new SqlParameter("@MatrOpr", newRec.MatrOpr); + + var result = await dbCtx + .Database + .ExecuteSqlRawAsync("exec dbo.stp_RS_insert @idxMacchina, @DataOra, @Causale, @Qta, @Note, @MatrOpr", IdxMacchina, DataOra, Causale, Qta, Note, MatrOpr); + // indico eseguito! + fatto = result > 0; + } + return fatto; + } + /// /// Effettua ricalcolo MSE x macchina indicata /// @@ -786,6 +1417,23 @@ namespace MP.Data.Controllers return answ; } + public bool SetDerogaSt(StCheckOverride deroga) + { + bool fatto = false; +#if false + try + { + string keyDerogaST = memLayer.ML.redHash($"DerogaSt:{user_std.UtSn.utente}:{deroga.IdxST:000}"); + string rawData = JsonConvert.SerializeObject(deroga); + memLayer.ML.setRSV(keyDerogaST, rawData, 60 * 2); + fatto = true; + } + catch + { } +#endif + return fatto; + } + /// /// Intera tabella state machine eventi 2 stati /// @@ -865,6 +1513,62 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Restituisce elenco gruppi Scheda tecnica + /// + /// + public List ST_AnagGruppiList() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetStAnagGruppi + .OrderBy(x => x.OrdVisual) + .AsNoTracking() + .ToList(); + } + return dbResult; + } + + public bool ST_CheckCleanByOdl(int idxOdl) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxOdl = new SqlParameter("@IdxOdl", idxOdl); + + var result = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_ST_CHK_cleanByOdl @IdxOdl", IdxOdl); + fatto = result != 0; + } + return fatto; + } + + public bool ST_CheckUpsert(int idxOdl, int idxST, int oggetto, int num, string valueRead, string extCode, bool checkOk, string userMod, bool forced) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxOdl = new SqlParameter("@IdxOdl", idxOdl); + var IdxST = new SqlParameter("@IdxST", idxST); + var Oggetto = new SqlParameter("@Oggetto", oggetto); + var Num = new SqlParameter("@Num", num); + var ValueRead = new SqlParameter("@ValueRead", valueRead); + var ExtCode = new SqlParameter("@ExtCode", extCode); + var CheckOk = new SqlParameter("@CheckOk", checkOk); + var UserMod = new SqlParameter("@UserMod", userMod); + var Forced = new SqlParameter("@Forced", forced); + + var result = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_ST_CHK_upsert @IdxOdl, @IdxST, @Oggetto, @Num, @ValueRead, @ExtCode, @CheckOk, @UserMod, @Forced", IdxOdl, IdxST, Oggetto, Num, ValueRead, ExtCode, CheckOk, UserMod, Forced); + fatto = result != 0; + } + return fatto; + } + /// /// Recupero Righe (Actual) della scheda tecnica da GRUPPO + ODL /// @@ -883,7 +1587,7 @@ namespace MP.Data.Controllers .DbSetStActRow .FromSqlRaw("exec dbo.stp_ST_AR_getByGrpOdl @CodGruppo, @IdxODL", CodGruppo, IdxODL) .AsNoTracking() - .AsEnumerable() + //.AsEnumerable() .ToList(); } return dbResult; @@ -909,7 +1613,29 @@ namespace MP.Data.Controllers .DbSetStActRow .FromSqlRaw("exec dbo.stp_ST_AR_getGrpOdlLabel @CodGruppo, @Label, @IdxODL", CodGruppo, Label, IdxODL) .AsNoTracking() - .AsEnumerable() + //.AsEnumerable() + .ToList(); + } + return dbResult; + } + + /// + /// Recupero Righe pending da ODL + /// + /// + /// + public List STAR_pendByOdl(int idxODL) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxODL = new SqlParameter("@IdxODL", idxODL); + + dbResult = dbCtx + .DbSetStActRow + .FromSqlRaw("exec dbo.stp_ST_AR_getPendingOdl @IdxODL", IdxODL) + .AsNoTracking() + //.AsEnumerable() .ToList(); } return dbResult; @@ -1042,6 +1768,41 @@ namespace MP.Data.Controllers return answ; } + /// + /// Elenco Vocabolario (completo) + /// + /// + public List VocabolarioGetAll() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetVocabolario + .AsNoTracking() + .OrderBy(x => x.Lemma) + .ToList(); + } + return dbResult; + } + + /// + /// Elenco causali scarto + /// + /// + public List VSCS_getAll() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetVSCS + .AsNoTracking() + .ToList(); + } + return dbResult; + } + /// /// Elenco ultimi ODL x macchina /// @@ -1065,6 +1826,31 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Elenco prossimi ODL/PODL x macchina + /// + /// Macchina + /// + /// + /// + public List VSOdlGetUnused(string idxMacchina, bool showAll, int numDayAdd) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina); + var ShowAll = new SqlParameter("@showAll", showAll); + var NumDayAdd = new SqlParameter("@numDayAdd", numDayAdd); + + dbResult = dbCtx + .DbSetVSODL + .FromSqlRaw("EXEC stp_vsODL_getUnused @IdxMacchina, @showAll, @numDayAdd", IdxMacc, ShowAll, NumDayAdd) + .AsNoTracking() + .ToList(); + } + return dbResult; + } + #endregion Public Methods #region Private Fields diff --git a/MP.Data/DTO/FermiCommentatiDTO.cs b/MP.Data/DTO/FermiCommentatiDTO.cs new file mode 100644 index 00000000..83294905 --- /dev/null +++ b/MP.Data/DTO/FermiCommentatiDTO.cs @@ -0,0 +1,15 @@ +using MP.Data.DatabaseModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MP.Data.DTO +{ + public class FermiCommentatiDTO + { + public FermiNonQualModel Fermata { get; set; } = null!; + public List CommentiFermata { get; set; } = new List(); + } +} diff --git a/MP.Data/DTO/ObjItemDTO.cs b/MP.Data/DTO/ObjItemDTO.cs new file mode 100644 index 00000000..f22c008a --- /dev/null +++ b/MP.Data/DTO/ObjItemDTO.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MP.Data.DTO +{ + /// + /// Classe gestione ITEM di un OBJ (machine) generico (read/write) + /// + public class ObjItemDTO + { + #region Public Properties + + /// + /// DESCRIZIONE item + /// + public string description { get; set; } = "-"; + + /// + /// Ultimo messaggio associato (conferma scrittura, errore, ...) + /// + public string lastMessage { get; set; } = ""; + + /// + /// DataOra ultima lettura + /// + public DateTime lastRead { get; set; } = DateTime.Now.AddHours(-1); + + /// + /// DataOra ultima richiesta scrittura + /// + public DateTime lastRequest { get; set; } = DateTime.Now.AddDays(-1); + + /// + /// NOME item + /// + public string name { get; set; } = "."; + + /// + /// Indica il NUOVO valore richiesto x l'item + /// + public string reqValue { get; set; } = ""; + + /// + /// UID univoco + /// + public string uid { get; set; } = ""; + + /// + /// Unità Misura parametro + /// + public string UM { get; set; } = "#"; + + /// + /// Valore MASSIMO (SE impostato) + /// + public int valMax { get; set; } + + /// + /// Valore minimo (SE impostato) + /// + public int valMin { get; set; } + + /// + /// Valore parametro (come stringa, decimali con ",", default VUOTO), sul CNC/PLC + /// + public string value { get; set; } = ""; + + /// + /// Indica se sia abilitato in scrittura (WRITE) + /// + public bool writable { get; set; } = false; + + /// + /// Valore per determinare Display Ordinal (es pagina TAB / invio parametri) + /// + public int displOrdinal { get; set; } = 0; + + #endregion Public Properties + } +} diff --git a/MP.Data/DTO/ParetoFluxLogDTO.cs b/MP.Data/DTO/ParetoFluxLogDTO.cs new file mode 100644 index 00000000..5367b141 --- /dev/null +++ b/MP.Data/DTO/ParetoFluxLogDTO.cs @@ -0,0 +1,11 @@ +using System; + +namespace MP.Data.DTO +{ + public class ParetoFluxLogDTO + { + public string IdxMacchina { get; set; } + public string CodFlux { get; set; } + public int Qty { get; set; } + } +} \ No newline at end of file diff --git a/MP.Data/DTO/StatDedupDTO.cs b/MP.Data/DTO/StatDedupDTO.cs new file mode 100644 index 00000000..7dd12b55 --- /dev/null +++ b/MP.Data/DTO/StatDedupDTO.cs @@ -0,0 +1,51 @@ +using System.ComponentModel.DataAnnotations.Schema; +using MP.Data.Objects; + + +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace MP.Data.DTO +{ + public class StatDedupDTO + { + /// + /// Macchina + /// + public string IdxMacchina { get; set; } = ""; + + /// + /// Cod Flusso interessato + /// + public string CodFlux { get; set; } = ""; + + /// + /// Tipo di intervallo richiesto + /// + public Enums.DataInterval Interval { get; set; } = Enums.DataInterval.hour; + + /// + /// num max di item per intervallo + /// + public int Num4Int { get; set; } = 1; + + /// + /// Num record processati (iniziali) + /// + public int NumRec { get; set; } = 1; + + /// + /// Tempo processing (secondi) + /// + public double ProcTime { get; set; } = 1; + + /// + /// Tempo processing atteso in ms per record + /// + [NotMapped] + public double ProcTimeMs + { + get => (ProcTime * 1000) / (NumRec > 1 ? NumRec : 1); + } + } +} diff --git a/MP.Data/DatabaseModels/AnagKeyValueModel.cs b/MP.Data/DatabaseModels/AnagKeyValueModel.cs new file mode 100644 index 00000000..22fbf280 --- /dev/null +++ b/MP.Data/DatabaseModels/AnagKeyValueModel.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +#nullable disable +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace MP.Data.DatabaseModels +{ + [Table("AnagKeyValue")] + public partial class AnagKeyValueModel + { + #region Public Properties + + [Key] + public string nomeVar { get; set; } = ""; + public int valInt { get; set; } = 0; + public double valFloat { get; set; } = 0; + public string valString { get; set; } = ""; + public string descrizione { get; set; } = ""; + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/DatabaseModels/AnagTagsModel.cs b/MP.Data/DatabaseModels/AnagTagsModel.cs new file mode 100644 index 00000000..46acfdc5 --- /dev/null +++ b/MP.Data/DatabaseModels/AnagTagsModel.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +#nullable disable +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace MP.Data.DatabaseModels +{ + [Table("AnagTags")] + public partial class AnagTagsModel + { + #region Public Properties + + [Key, DatabaseGenerated(DatabaseGeneratedOption.None), MaxLength(50)] + public string TagCode { get; set; } = ""; + + public string TagDescr { get; set; } = ""; + + public int DisplOrd { get; set; } = 0; + + public string CssClass { get; set; } = ""; + + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/DatabaseModels/ElencoLottiModel.cs b/MP.Data/DatabaseModels/ElencoLottiModel.cs new file mode 100644 index 00000000..509e8f61 --- /dev/null +++ b/MP.Data/DatabaseModels/ElencoLottiModel.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + + +#nullable disable +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace MP.Data.DatabaseModels +{ + [Table("ElencoLotti")] + public partial class ElencoLottiModel + { + #region Public Properties + + [Key] + public string Lotto { get; set; } = ""; + public int IdxODL { get; set; } = 0; + [MaxLength(50)] + public string RifExt { get; set; } = ""; + [MaxLength(50)] + public string TipoLotto { get; set; } = ""; + [MaxLength(50), Column("CodArt")] + public string CodArticolo { get; set; } = ""; + [MaxLength(50)] + public string CodStato { get; set; } = ""; + [MaxLength(50)] + public string Origine { get; set; } = ""; + public DateTime? DtCrea { get; set; } + [MaxLength(250)] + public string Note { get; set; } = ""; + public decimal QtaOrig { get; set; } = 0; + public int NumUdc { get; set; } = 1; + public decimal QtaCurr { get; set; } = 0; + public DateTime? DtMod { get; set; } + public bool Attivo { get; set; } = false; + [MaxLength(250)] + public string DescrArt { get; set; } = ""; + [MaxLength(50)] + public string CodArtExt { get; set; } = ""; + [MaxLength(50)] + public string DescStato { get; set; } = ""; + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/DatabaseModels/ODLExpModel.cs b/MP.Data/DatabaseModels/ODLExpModel.cs index dbfd429e..e2ed9a4b 100644 --- a/MP.Data/DatabaseModels/ODLExpModel.cs +++ b/MP.Data/DatabaseModels/ODLExpModel.cs @@ -21,6 +21,7 @@ namespace MP.Data.DatabaseModels public string IdxMacchina { get; set; } public int NumPezzi { get; set; } public decimal Tcassegnato { get; set; } + public decimal TCRichAttr { get; set; } public DateTime? DataInizio { get; set; } public DateTime? DataFine { get; set; } [MaxLength(2500)] diff --git a/MP.Data/DatabaseModels/PODLExpModel.cs b/MP.Data/DatabaseModels/PODLExpModel.cs index ff1c3cfc..018da8b1 100644 --- a/MP.Data/DatabaseModels/PODLExpModel.cs +++ b/MP.Data/DatabaseModels/PODLExpModel.cs @@ -47,10 +47,18 @@ namespace MP.Data.DatabaseModels get { string answ = "*"; - var allData = KeyRichiesta.Split('_'); - if (allData.Length > 0) + if (!string.IsNullOrEmpty(KeyRichiesta)) { - answ = allData[0]; + try + { + var allData = KeyRichiesta.Split('_'); + if (allData.Length > 0) + { + answ = allData[0]; + } + } + catch + { } } return answ; } diff --git a/MP.Data/DatabaseModels/RegistroDichiarazioniModel.cs b/MP.Data/DatabaseModels/RegistroDichiarazioniModel.cs new file mode 100644 index 00000000..3d3e800c --- /dev/null +++ b/MP.Data/DatabaseModels/RegistroDichiarazioniModel.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +#nullable disable +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace MP.Data.DatabaseModels +{ + //[Table("DiarioDichiarazioni")] + public partial class RegistroDichiarazioniModel + { + #region Public Properties + + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int IdxDich { get; set; } + + public DateTime DtRec { get; set; } = DateTime.Now; + public string IdxMacchina { get; set; } = ""; + public string TagCode { get; set; } = ""; + public int MatrOpr { get; set; } + public string ValString { get; set; } = ""; + public string CognNome { get; set; } = ""; + public string CssClass { get; set; } = ""; + + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/DatabaseModels/RegistroScartiModel.cs b/MP.Data/DatabaseModels/RegistroScartiModel.cs new file mode 100644 index 00000000..2082712d --- /dev/null +++ b/MP.Data/DatabaseModels/RegistroScartiModel.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; + + +#nullable disable +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace MP.Data.DatabaseModels +{ + public partial class RegistroScartiModel + { + #region Public Properties + + public string IdxMacchina { get; set; } = ""; + public DateTime DataOra { get; set; } = DateTime.Now; + public string Causale { get; set; } = ""; + public string Operatore { get; set; } = ""; + + public int Qta { get; set; } = 0; + public string Note { get; set; } = ""; + public string CodArticolo { get; set; } = ""; + public int MatrOpr { get; set; } = 0; + public DateTime? DataOraProdRec { get; set; } = null; + public string Descrizione { get; set; } = ""; + public string cssClass { get; set; } = ""; + public string icona { get; set; } = ""; + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/DatabaseModels/ST_ActRow.cs b/MP.Data/DatabaseModels/ST_ActRow.cs index 7248effa..beb6bc23 100644 --- a/MP.Data/DatabaseModels/ST_ActRow.cs +++ b/MP.Data/DatabaseModels/ST_ActRow.cs @@ -27,5 +27,16 @@ namespace MP.Data.DatabaseModels public string ValueRead { get; set; } = ""; public string Note { get; set; } = ""; + [NotMapped] + public bool ShowMissingData + { + get => Required && (Value != ExtCode); + } + + [NotMapped] + public bool ShowCheckedData + { + get => Required && (Value == ExtCode); + } } } \ No newline at end of file diff --git a/MP.Data/DatabaseModels/vSelCauScartoModel.cs b/MP.Data/DatabaseModels/vSelCauScartoModel.cs new file mode 100644 index 00000000..05b41c1a --- /dev/null +++ b/MP.Data/DatabaseModels/vSelCauScartoModel.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +#nullable disable +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace MP.Data.DatabaseModels +{ + public partial class vSelCauScartoModel + { + [Key] + public string value { get; set; } = ""; + public string label { get; set; } = ""; + public string cssClass { get; set; } = ""; + public string icona { get; set; } = ""; + } +} diff --git a/MP.Data/DatabaseModels/vSelOdlModel.cs b/MP.Data/DatabaseModels/vSelOdlModel.cs index 8485d869..72e8ede8 100644 --- a/MP.Data/DatabaseModels/vSelOdlModel.cs +++ b/MP.Data/DatabaseModels/vSelOdlModel.cs @@ -14,6 +14,6 @@ namespace MP.Data.DatabaseModels [Key] public int value { get; set; } = 0; public string label { get; set; } = ""; - public DateTime conditio { get; set; } = DateTime.Now; + public DateTime? conditio { get; set; } = DateTime.Now; } } diff --git a/MP.Data/MP.Data.csproj b/MP.Data/MP.Data.csproj index 457668ad..93a7fb20 100644 --- a/MP.Data/MP.Data.csproj +++ b/MP.Data/MP.Data.csproj @@ -20,8 +20,9 @@ + - + diff --git a/MP.Data/MailKitMailData.cs b/MP.Data/MailKitMailData.cs index 286c54d8..82a3cbc0 100644 --- a/MP.Data/MailKitMailData.cs +++ b/MP.Data/MailKitMailData.cs @@ -29,7 +29,7 @@ namespace MP.Data public string? Body { get; set; } - // Attach (opzionale) - public IFormFileCollection? Attachments { get; set; } + //// Attach (opzionale) + //public IFormFileCollection? Attachments { get; set; } } } diff --git a/MP.Data/MoonProAdminContext.cs b/MP.Data/MoonProAdminContext.cs new file mode 100644 index 00000000..4e9b8ecd --- /dev/null +++ b/MP.Data/MoonProAdminContext.cs @@ -0,0 +1,75 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.Extensions.Configuration; +using MP.Data.DatabaseModels; +using MP.Data.DTO; +using NLog; + +#nullable disable +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace MP.Data +{ + public partial class MoonProAdminContext : DbContext + { + #region Private Fields + + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + private IConfiguration _configuration; + + #endregion Private Fields + + #region Public Constructors + + public MoonProAdminContext(IConfiguration configuration) + { + _configuration = configuration; + // timeout esecuzione a 5 min (std: 30 sec)... + Database.SetCommandTimeout(TimeSpan.FromSeconds(300)); + } + + public MoonProAdminContext(DbContextOptions options) : base(options) + { + } + + #endregion Public Constructors + + #region Private Methods + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); + + #endregion Private Methods + + #region Protected Methods + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (!optionsBuilder.IsConfigured) + { + string connString = _configuration.GetConnectionString("Mp.Data"); + if (string.IsNullOrEmpty(connString)) + { + connString = _configuration.GetConnectionString("Mp.Mon"); + } + if (string.IsNullOrEmpty(connString)) + { + connString = _configuration.GetConnectionString("Mp.STATS"); + } + + optionsBuilder.UseSqlServer(connString); + } + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS"); + + OnModelCreatingPartial(modelBuilder); + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/MP.Data/MoonProContext.cs b/MP.Data/MoonProContext.cs index 4368603a..43503dc5 100644 --- a/MP.Data/MoonProContext.cs +++ b/MP.Data/MoonProContext.cs @@ -37,12 +37,14 @@ namespace MP.Data #region Public Properties - + public virtual DbSet DbSetAlarmLog { get; set; } + public virtual DbSet DbSetAKV { get; set; } public virtual DbSet DbSetStatArticoli { get; set; } public virtual DbSet DbSetArticoli { get; set; } public virtual DbSet DbSetAnagEventi { get; set; } public virtual DbSet DbSetAnagStati { get; set; } + public virtual DbSet DbSetAnagTags { get; set; } public virtual DbSet DbSetMacchine { get; set; } public virtual DbSet DbSetMSE { get; set; } public virtual DbSet DbSetConfig { get; set; } @@ -58,7 +60,7 @@ namespace MP.Data public virtual DbSet DbSetStatOdl { get; set; } public virtual DbSet DbSetPzProd { get; set; } public virtual DbSet DbSetEvList { get; set; } - public virtual DbSet DbSetDDB { get; set; } + public virtual DbSet DbSetDDB { get; set; } public virtual DbSet DbSetVocabolario { get; set; } public virtual DbSet DbOperatori { get; set; } public virtual DbSet DbSetGrp2Oper { get; set; } @@ -74,6 +76,8 @@ namespace MP.Data public virtual DbSet DbSetStatoProd { get; set; } public virtual DbSet DbSetTurniMacc { get; set; } public virtual DbSet DbSetRegControlli { get; set; } + public virtual DbSet DbSetRegScarti { get; set; } + public virtual DbSet DbSetRegDich { get; set; } public virtual DbSet DbSetStAct { get; set; } @@ -85,11 +89,12 @@ namespace MP.Data public virtual DbSet DbSetStTemplateRows { get; set; } public virtual DbSet DbSetCommenti { get; set; } - public virtual DbSet DbSetFNQ { get; set; } - + public virtual DbSet DbSetFNQ { get; set; } public virtual DbSet DbSetVSEB { get; set; } public virtual DbSet DbSetVSODL { get; set; } + public virtual DbSet DbSetVSCS { get; set; } + public virtual DbSet DbSetParetoFluxLog { get; set; } #endregion Public Properties @@ -541,6 +546,10 @@ namespace MP.Data { entity.HasKey(e => new { e.IdxMacchina, e.InizioStato }); }); + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.IdxMacchina, e.DataOra, e.Causale}); + }); modelBuilder.Entity(entity => { @@ -548,10 +557,20 @@ namespace MP.Data }); modelBuilder.Entity(entity => { - //entity.HasKey(e => e.value); entity.ToView("v_selODL"); }); - + modelBuilder.Entity(entity => + { + entity.ToView("v_selCauScarto"); + }); + modelBuilder.Entity(entity => + { + entity.ToView("v_DD_exp"); + }); + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.IdxMacchina, e.CodFlux }); + }); OnModelCreatingPartial(modelBuilder); } diff --git a/MP.Data/MoonPro_MagContext.cs b/MP.Data/MoonPro_MagContext.cs new file mode 100644 index 00000000..84436a9a --- /dev/null +++ b/MP.Data/MoonPro_MagContext.cs @@ -0,0 +1,86 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.Extensions.Configuration; +using MP.Data.DatabaseModels; +using NLog; + +#nullable disable +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace MP.Data +{ + public partial class MoonPro_MagContext : DbContext + { + #region Private Fields + + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + private IConfiguration _configuration; + + #endregion Private Fields + + #region Public Constructors + + /// + /// Indispensabile x prima generazione migrations EFCore + /// + + [Obsolete("This constructor should never be used directly, and is only needed to generate entityframework stuff. Connection string can be adapted as pleased.")] + public MoonPro_MagContext() + { + } + + public MoonPro_MagContext(IConfiguration configuration) + { + _configuration = configuration; + } + + public MoonPro_MagContext(DbContextOptions options) : base(options) + { + } + + #endregion Public Constructors + + #region Public Properties + + + public virtual DbSet DbSetElLotti { get; set; } + + #endregion Public Properties + + #region Private Methods + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); + + #endregion Private Methods + + #region Protected Methods + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (!optionsBuilder.IsConfigured) + { + string connString = _configuration.GetConnectionString("Mp.Mag"); + if (!string.IsNullOrEmpty(connString)) + { + optionsBuilder.UseSqlServer(connString); + } + else + { + optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=MoonPro_MAG;Trusted_Connection=True;"); + } + } + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS"); + + OnModelCreatingPartial(modelBuilder); + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/MP.Data/Objects/Enums.cs b/MP.Data/Objects/Enums.cs index c2b61cb2..7e9428af 100644 --- a/MP.Data/Objects/Enums.cs +++ b/MP.Data/Objects/Enums.cs @@ -1,15 +1,22 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MP.Data.Objects { public class Enums { + #region Public Enums + + /// + /// Intervallo dati (es per definizione quanti dati FluxLog tenere x intervallo + /// + public enum DataInterval + { + minute, + hour, + day + } + public enum DataItemCategory { CONDITION = 0, @@ -138,29 +145,29 @@ namespace MP.Data.Objects /// /// Tipo FLOAT 32 bit con endiannes standard (es modbus) - /// https://www.scadacore.com/tools/programming-calculators/online-hex-converter/ Float - - /// Big Endian (ABCD) + /// https://www.scadacore.com/tools/programming-calculators/online-hex-converter/ Float + /// - Big Endian (ABCD) /// FloatABCD, /// /// Tipo FLOAT 32 bit con endiannes NON standard (es modbus) - /// https://www.scadacore.com/tools/programming-calculators/online-hex-converter/ Float - - /// Mid-Big Endian (BADC) + /// https://www.scadacore.com/tools/programming-calculators/online-hex-converter/ Float + /// - Mid-Big Endian (BADC) /// FloatBADC, /// /// Tipo FLOAT 32 bit con endiannes NON standard (es modbus) - /// https://www.scadacore.com/tools/programming-calculators/online-hex-converter/ Float - - /// Mid-Little Endian (CDAB) + /// https://www.scadacore.com/tools/programming-calculators/online-hex-converter/ Float + /// - Mid-Little Endian (CDAB) /// FloatCDAB, /// /// Tipo FLOAT 32 bit con endiannes NON standard (es modbus) - /// https://www.scadacore.com/tools/programming-calculators/online-hex-converter/ Float - - /// Little Endian (DCBA) + /// https://www.scadacore.com/tools/programming-calculators/online-hex-converter/ Float + /// - Little Endian (DCBA) /// FloatDCBA, @@ -426,6 +433,27 @@ namespace MP.Data.Objects articoli } + /// + /// Trasformazione VC da effettuare + /// + public enum ValSelection + { + /// + /// Selezione PRIMO valore del set + /// + First, + + /// + /// Selezione Moda (norma) = elemento centrale + /// + Center, + + /// + /// Selezione ULTIMO valore del set + /// + Last + } + /// /// Tipologia di elaborazione/funzione da applicare a VC /// @@ -456,5 +484,7 @@ namespace MP.Data.Objects /// MEDIAN } + + #endregion Public Enums } -} +} \ No newline at end of file diff --git a/MP.Data/Objects/StCheckOverride.cs b/MP.Data/Objects/StCheckOverride.cs new file mode 100644 index 00000000..71c381f8 --- /dev/null +++ b/MP.Data/Objects/StCheckOverride.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MP.Data.Objects +{ + public class StCheckOverride + { + #region Public Properties + + public bool CanForce { get; set; } = false; + public string CodGruppo { get; set; } = ""; + public string CodTipo { get; set; } = ""; + public int IdxST { get; set; } = 0; + public int Num { get; set; } = 0; + public int Oggetto { get; set; } = 0; + public string Utente { get; set; } = ""; + + #endregion Public Properties + } +} diff --git a/MP.Data/Services/MailService.cs b/MP.Data/Services/MailService.cs index 9c8d6d2c..ff5735cc 100644 --- a/MP.Data/Services/MailService.cs +++ b/MP.Data/Services/MailService.cs @@ -74,28 +74,28 @@ namespace MP.Data.Services body.HtmlBody = mailData.Body; mail.Body = body.ToMessageBody(); - // Check if we got any attachments and add the to the builder for our message - if (mailData.Attachments != null) - { - byte[] attachmentFileByteArray; + //// Check if we got any attachments and add the to the builder for our message + //if (mailData.Attachments != null) + //{ + // byte[] attachmentFileByteArray; - foreach (IFormFile attachment in mailData.Attachments) - { - // Check if length of the file in bytes is larger than 0 - if (attachment.Length > 0) - { - // Create a new memory stream and attach attachment to mail body - using (MemoryStream memoryStream = new MemoryStream()) - { - // Copy the attachment to the stream - attachment.CopyTo(memoryStream); - attachmentFileByteArray = memoryStream.ToArray(); - } - // Add the attachment from the byte array - body.Attachments.Add(attachment.FileName, attachmentFileByteArray, ContentType.Parse(attachment.ContentType)); - } - } - } + // foreach (IFormFile attachment in mailData.Attachments) + // { + // // Check if length of the file in bytes is larger than 0 + // if (attachment.Length > 0) + // { + // // Create a new memory stream and attach attachment to mail body + // using (MemoryStream memoryStream = new MemoryStream()) + // { + // // Copy the attachment to the stream + // attachment.CopyTo(memoryStream); + // attachmentFileByteArray = memoryStream.ToArray(); + // } + // // Add the attachment from the byte array + // body.Attachments.Add(attachment.FileName, attachmentFileByteArray, ContentType.Parse(attachment.ContentType)); + // } + // } + //} #endregion Content diff --git a/MP.Data/Services/MessageService.cs b/MP.Data/Services/MessageService.cs index 62301baa..6d751191 100644 --- a/MP.Data/Services/MessageService.cs +++ b/MP.Data/Services/MessageService.cs @@ -1,10 +1,13 @@ using Blazored.LocalStorage; using Blazored.SessionStorage; +using Microsoft.Extensions.Configuration; using MP.Data.DatabaseModels; using Newtonsoft.Json; using NLog; +using StackExchange.Redis; using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; namespace MP.Data.Services @@ -13,16 +16,25 @@ namespace MP.Data.Services { #region Public Fields + public const string KeyCommDtRif = "DtRifComm"; + public const string KeyCommText = "ValComm"; public int orarioDip = 0; #endregion Public Fields #region Public Constructors - public MessageService(ILocalStorageService genLocalStorage, ISessionStorageService sessStore) + public MessageService(IConfiguration configuration, ILocalStorageService genLocalStorage, ISessionStorageService sessStore) { + _configuration = configuration; + + // gestione sessioni in browser localStorage = genLocalStorage; sessionStore = sessStore; + + // setup compoenti REDIS + redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis")); + redisDb = redisConn.GetDatabase(); } #endregion Public Constructors @@ -35,32 +47,21 @@ namespace MP.Data.Services #endregion Public Events -#if false - public event Action EA_DateChanged = null!; - public event Action EA_CalModeChanged = null!; + #region Public Properties - public event Action EA_TimbUpd = null!; -#endif - -#if false - public RegAttivitaModel? clonedRA { get; set; } = null; - - /// - /// Calcola HASH del codice impiego = payload utente - /// - /// - public string HashDip + public string CognomeNome { get { - DataValidator cDV = new DataValidator(_rigaOper); - string hash = cDV.HashDip; - return hash; + string answ = ""; + //int answ = -1; + if (_rigaOper != null) + { + answ = $"{_rigaOper.Cognome} {_rigaOper.Nome}"; + } + return answ; } } -#endif - - #region Public Properties /// /// Dizionario macchine @@ -100,19 +101,6 @@ namespace MP.Data.Services return answ; } } - public string CognomeNome - { - get - { - string answ = ""; - //int answ = -1; - if (_rigaOper != null) - { - answ = $"{_rigaOper.Cognome} {_rigaOper.Nome}"; - } - return answ; - } - } public AnagOperatoriModel? RigaOper { @@ -141,6 +129,15 @@ namespace MP.Data.Services } } + /// + /// Dizionario totale preferenze utente + /// + public Dictionary UsersPrefDict + { + get => redisHashDictGet((RedisKey)$"{redisBaseKey}:{MatrOpr}"); + set => redisHashDictSet((RedisKey)$"{redisBaseKey}:{MatrOpr}", value); + } + #endregion Public Properties #region Public Methods @@ -184,18 +181,6 @@ namespace MP.Data.Services await sessionStore.SetItemAsync(KeyCommDtRif, DtRif); } - - /// - /// Verifico esistenza chiave in session store - /// - /// - /// - public async Task SessHasVal(string keyName) - { - bool hasKey = await sessionStore.ContainKeyAsync(keyName); - return hasKey; - } - /// /// Commento fermata x recupero in editing /// @@ -261,13 +246,13 @@ namespace MP.Data.Services /// /// /// - public async Task GetMachineMse(string idxMacchina) + public async Task GetMachineMse(string idxMacchina) { - MappaStatoExpl answ = new MappaStatoExpl(); - string tryString = await localStorage.GetItemAsync(machineMse(idxMacchina)); - if (tryString != "") + MappaStatoExpl answ = null; + string rawData = await localStorage.GetItemAsync(machineMse(idxMacchina)); + if (rawData != "") { - answ = JsonConvert.DeserializeObject(tryString); + answ = JsonConvert.DeserializeObject(rawData); } return answ; } @@ -303,6 +288,17 @@ namespace MP.Data.Services } } + /// + /// Verifico esistenza chiave in session store + /// + /// + /// + public async Task SessHasVal(string keyName) + { + bool hasKey = await sessionStore.ContainKeyAsync(keyName); + return hasKey; + } + /// /// Scrive il valore di IPV4 del device nel localstoragee /// @@ -343,6 +339,44 @@ namespace MP.Data.Services return answ; } + /// + /// Recupero singola preferenza utente + /// + /// + /// + public string UserPrefGet(string chiave) + { + string answ = ""; + var currDict = UsersPrefDict; + if (currDict.ContainsKey(chiave)) + { + answ = currDict[chiave]; + } + return answ; + } + + /// + /// Salvo singola rpeferenza utente + /// + /// + /// + /// + public bool UserPrefSave(string chiave, string valore) + { + bool done = false; + var currDict = UsersPrefDict; + if (currDict.ContainsKey(chiave)) + { + currDict[chiave] = valore; + } + else + { + currDict.Add(chiave, valore); + } + UsersPrefDict = currDict; + return done; + } + #endregion Public Methods #region Protected Fields @@ -350,20 +384,130 @@ namespace MP.Data.Services protected const string KeyDevIp4 = "DevIpv4"; protected const string KeyDevSec = "DevSec"; protected const string KeyMacDict = "MachineDict"; + protected static IConfiguration _configuration = null!; + + /// + /// Oggetto per connessione a REDIS + /// + protected ConnectionMultiplexer redisConn = null!; + + /// + /// Oggetto DB redis da impiegare x chiamate R/W + /// + protected IDatabase redisDb = null!; #endregion Protected Fields #region Protected Properties protected ILocalStorageService localStorage { get; set; } = null!; + protected ISessionStorageService sessionStore { get; set; } = null!; #endregion Protected Properties #region Private Fields - public const string KeyCommDtRif = "DtRifComm"; - public const string KeyCommText = "ValComm"; + private AnagOperatoriModel? _rigaOper; + + /// + /// Durata cache lunga IN SECONDI + /// + private int cacheTtlLong = 60 * 5; + + /// + /// Durata cache breve IN SECONDI + /// + private int cacheTtlShort = 60 * 1; + + private Logger Log = LogManager.GetCurrentClassLogger(); + private string redisBaseKey = "MP:TAB:User"; + private Random rnd = new Random(); + + #endregion Private Fields + + #region Private Methods + + private string machineMse(string idxMacc) + { + return $"MSE_{idxMacc}"; + } + + /// + /// Recupero HashSet redis come Dictionary + /// + /// + /// + private Dictionary redisHashDictGet(RedisKey currKey) + { + Dictionary answ = new Dictionary(); + try + { + answ = redisDb + .HashGetAll(currKey) + .ToDictionary(x => $"{x.Name}", x => $"{x.Value}"); + } + catch (Exception exc) + { + Log.Info($"Errore redisHashDictGet | currKey: {currKey}{Environment.NewLine}{exc}"); + } + return answ; + } + + /// + /// Salvataggio Dictionary come HashSet Redis + /// + /// + /// + private bool redisHashDictSet(RedisKey currKey, Dictionary dict) + { + bool fatto = false; + try + { + HashEntry[] data2ins = new HashEntry[dict.Count]; + int i = 0; + foreach (KeyValuePair kvp in dict) + { + data2ins[i] = new HashEntry(kvp.Key, kvp.Value); + i++; + } + // salvo! + redisDb.HashSet(currKey, data2ins); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione in redisHashDictSet | currKey: {currKey}{Environment.NewLine}{exc}"); + } + return fatto; + } + + #endregion Private Methods + +#if false + public event Action EA_DateChanged = null!; + public event Action EA_CalModeChanged = null!; + + public event Action EA_TimbUpd = null!; +#endif + +#if false + public RegAttivitaModel? clonedRA { get; set; } = null; + + /// + /// Calcola HASH del codice impiego = payload utente + /// + /// + public string HashDip + { + get + { + DataValidator cDV = new DataValidator(_rigaOper); + string hash = cDV.HashDip; + return hash; + } + } +#endif #if false public bool IsActive { @@ -546,21 +690,6 @@ namespace MP.Data.Services } } #endif - private AnagOperatoriModel? _rigaOper; - - private Logger Log = LogManager.GetCurrentClassLogger(); - - #endregion Private Fields - - #region Private Methods - - private string machineMse(string idxMacc) - { - return $"MSE_{idxMacc}"; - } - - #endregion Private Methods - #if false private string _pageIcon = ""; private string _pageName = ""; diff --git a/MP.Data/Services/SharedMemService.cs b/MP.Data/Services/SharedMemService.cs index b0cece8a..c5a84399 100644 --- a/MP.Data/Services/SharedMemService.cs +++ b/MP.Data/Services/SharedMemService.cs @@ -45,6 +45,11 @@ namespace MP.Data.Services /// public Dictionary DictStati { get; set; } = new Dictionary(); + /// + /// Dizionario globale (key: lingua_lemma, lowercase) + /// + public Dictionary DictVocab { get; set; } = new Dictionary(); + /// /// Lista completa eventi /// @@ -60,6 +65,18 @@ namespace MP.Data.Services /// public List ListStati { get; set; } = new List(); + /// + /// Lista macchine master2slave stati + /// + public List ListM2S { get; set; } = new List(); + + + + /// + /// Lista completa stati + /// + public List ListVocab { get; set; } = new List(); + public bool MenuOk { get => AllMenuData.Count > 0; @@ -81,6 +98,7 @@ namespace MP.Data.Services DictConfig = new Dictionary(); DictEventi = new Dictionary(); DictStati = new Dictionary(); + DictVocab = new Dictionary(); Log.Info("SharedMemService | Cache resetted!"); } @@ -183,11 +201,17 @@ namespace MP.Data.Services public void SetMsfd(List newList) { ListMSFD = newList ?? new List(); - // salvo dizionario + // salvo dizionario MULTI DictMacchMulti = ListMSFD.ToDictionary(x => x.IdxMacchina, x => x.Multi); Log.Info("SharedMemService | SetMsfd executed!"); } + public void SetM2S(List newList) + { + ListM2S = newList ?? new List(); + Log.Info("SharedMemService | SetM2S executed!"); + } + public void SetStati(List allStati) { ListStati = allStati ?? new List(); @@ -224,12 +248,49 @@ namespace MP.Data.Services Log.Info("SharedMemService | SetupMenu executed!"); } + /// + /// Effettua setup vocabolario + /// + /// + public void SetVocab(List allVoc) + { + ListVocab = allVoc ?? new List(); + // salvo dizionario + DictVocab = ListVocab.ToDictionary(x => $"{x.Lingua}_{x.Lemma.ToUpper()}", x => x.Traduzione); + Log.Info("SharedMemService | SetVocab executed!"); + } + + public string Traduci(string lingua, string lemma) + { + return Traduci($"{lingua}_{lemma}".ToUpper()); + } + + /// + /// Traduzione diretta vocabolario + /// + /// Formato {lingua}_{lemma}, lowercase + /// + public string Traduci(string lingua_lemma) + { + string answ = $"[{lingua_lemma}]"; + if (DictVocab.ContainsKey(lingua_lemma)) + { + answ = DictVocab[lingua_lemma]; + } + return answ; + } + #endregion Public Methods #region Private Fields private static Logger Log = LogManager.GetCurrentClassLogger(); + /// + /// Oggetto vocabolario x uso continuo traduzione + /// + private List ObjVocabolario = new List(); + #endregion Private Fields #region Private Properties diff --git a/MP.Data/Services/StatusData.cs b/MP.Data/Services/StatusData.cs index 30696304..3c1782c9 100644 --- a/MP.Data/Services/StatusData.cs +++ b/MP.Data/Services/StatusData.cs @@ -41,6 +41,16 @@ namespace MP.Data.Services Log.Info(sb.ToString()); } + // setup time refresh + if (!string.IsNullOrEmpty(_configuration.GetValue("ServerConf:maxAge"))) + { + maxAge = _configuration.GetValue("ServerConf:maxAge"); + } + else if (!string.IsNullOrEmpty(_configuration.GetValue("OptConf:msRefresh"))) + { + maxAge = _configuration.GetValue("OptConf:msRefresh"); + } + // setup conf IOB da dizionario tryLoadIobTags(); } @@ -102,16 +112,14 @@ namespace MP.Data.Services return Task.FromResult(dbController.MacchineGetAll()); } - public async Task> MseGetAll() + public async Task> MseGetAll(bool forceDb = false) { - int maxAge = 2000; - int.TryParse(_configuration.GetValue("ServerConf:maxAge"), out maxAge); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); List? result = new List(); // cerco in redis... - RedisValue rawData = redisDb.StringGet(redisMseKey); - if (rawData.HasValue) + RedisValue rawData = redisDb.StringGet(Constants.redisMseKey); + if (rawData.HasValue && !forceDb) { result = JsonConvert.DeserializeObject>($"{rawData}"); stopWatch.Stop(); @@ -123,7 +131,7 @@ namespace MP.Data.Services result = await Task.FromResult(dbController.MseGetAll(maxAge)); // serializzp e salvo... rawData = JsonConvert.SerializeObject(result); - await redisDb.StringSetAsync(redisMseKey, rawData, TimeSpan.FromMilliseconds(maxAge)); + await redisDb.StringSetAsync(Constants.redisMseKey, rawData, TimeSpan.FromMilliseconds(maxAge)); stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; Log.Debug($"Read from DB: {ts.TotalMilliseconds}ms"); @@ -155,9 +163,11 @@ namespace MP.Data.Services #region Private Fields private static IConfiguration _configuration = null!; - private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); - private string redisMseKey = "MP:MON:Cache:MSE"; + private int maxAge = 2000; +#if false + private string redisMseKey = "MP:MON:Cache:MSE"; +#endif #endregion Private Fields diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs index 2949513d..191de962 100644 --- a/MP.Data/Services/TabDataService.cs +++ b/MP.Data/Services/TabDataService.cs @@ -1,16 +1,18 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using MP.Data.DatabaseModels; +using MP.Data.DTO; using MP.Data.Objects; using Newtonsoft.Json; using NLog; using StackExchange.Redis; using System; using System.Collections.Generic; +using System.Data; using System.Diagnostics; +using System.Linq; using System.Text; using System.Threading.Tasks; -using static MP.Data.Objects.Enums; namespace MP.Data.Services { @@ -43,6 +45,8 @@ namespace MP.Data.Services sb.AppendLine($"TabDataService | MpTabController OK"); dbIocController = new Controllers.MpIocController(configuration); sb.AppendLine($"TabDataService | MpIocController OK"); + dbInveController = new Controllers.MpInveController(configuration); + sb.AppendLine($"TabDataService | MpInveController OK"); Log.Info(sb.ToString()); // sistemo i parametri x redHas... CodModulo = _configuration.GetValue("OptConf:CodModulo"); @@ -66,8 +70,73 @@ namespace MP.Data.Services #endregion Public Constructors + #region Public Properties + + /// + /// Conmfig attivo da DB + /// + public List CurrConfig { get; set; } = new List(); + + #endregion Public Properties + #region Public Methods + /// + /// Aggiunge un task all'elenco di quelli salvati (in modalità upsert) + /// + /// + /// + /// + /// + public bool addTask4Machine(string idxMacchina, Enums.taskType taskKey, string taskVal) + { + bool answ = false; + string currHash = exeTaskHash(idxMacchina); + string currSavedParHash = savedTaskHash(idxMacchina); + Dictionary currTask = new Dictionary(); + Dictionary savedTask = new Dictionary(); + try + { + //Log.Info($"Request: idxMacchina: {idxMacchina} | taskKey: {taskKey} | taskVal: {taskVal}"); + // leggo task attuali... + currTask = mTaskMacchina(idxMacchina); + if (currTask.ContainsKey($"{taskKey}")) + { + currTask[$"{taskKey}"] = taskVal; + } + else + { + currTask.Add($"{taskKey}", taskVal); + } + answ = redisHashDictSet(currHash, currTask); + Log.Info($"Task ADD - idxMacchina: {idxMacchina} | taskKey: {taskKey} | taskVal: {taskVal}"); + } + catch { } + // verifico in base al tipo di task se fare backup... + switch (taskKey) + { + case Enums.taskType.setArt: + case Enums.taskType.setComm: + case Enums.taskType.setPzComm: + case Enums.taskType.setProg: + // leggo task SALVATI attuali... + savedTask = mSavedTaskMacchina(idxMacchina); + savedTask[taskKey.ToString()] = taskVal; + answ = redisHashDictSet(currSavedParHash, savedTask); + break; + + case Enums.taskType.endProd: + // salvo un DICT vuoto x resettare + savedTask = new Dictionary(); + answ = redisHashDictSet(currSavedParHash, savedTask); + break; + + default: + break; + } + return answ; + } + /// /// Elenco allarmi macchina /// @@ -204,6 +273,41 @@ namespace MP.Data.Services return result; } + /// + /// Restituisce l'anagrafica EVENTI per intero + /// + /// + public async Task> AnagTagsOrd() + { + // setup parametri costanti + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:AnagTags"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbTabController.AnagTagsOrd(); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"AnagTagsOrd | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + /// /// Elenco completo STATI /// @@ -246,17 +350,18 @@ namespace MP.Data.Services /// Recupera elenco ultimi commenti /// /// Idx macchina, "*" = tutte - /// Num massimo di record da recuperare + /// Num di giorni da recuperare da adesso /// - public async Task> CommentiGetLastByMacc(string idxMacchina, int maxRec) + public async Task> CommentiGetLastByMacc(string idxMacchina, int numDays) { // setup parametri costanti string source = "DB"; Stopwatch sw = new Stopwatch(); sw.Start(); List result = new List(); + DateTime adesso = DateTime.Now; // cerco in redis... - string currKey = $"{redisBaseKey}:Commenti:{idxMacchina}:{maxRec}"; + string currKey = $"{redisBaseKey}:Commenti:{idxMacchina}:{adesso:yyMMdd-HHmm}:{numDays}"; RedisValue rawData = await redisDb.StringGetAsync(currKey); //if (!string.IsNullOrEmpty($"{rawData}")) if (rawData.HasValue) @@ -266,7 +371,7 @@ namespace MP.Data.Services } else { - result = dbTabController.CommentiGetLastByMacc(idxMacchina, maxRec); + result = dbTabController.CommentiGetLastByMacc(idxMacchina, numDays); // serializzp e salvo... rawData = JsonConvert.SerializeObject(result); await redisDb.StringSetAsync(currKey, rawData, FastCache); @@ -323,7 +428,7 @@ namespace MP.Data.Services /// Config values attivi /// /// - public async Task> ConfigGetAll() + public List ConfigGetAll() { string source = "DB"; Stopwatch sw = new Stopwatch(); @@ -331,7 +436,7 @@ namespace MP.Data.Services List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:Conf"; - RedisValue rawData = await redisDb.StringGetAsync(currKey); + RedisValue rawData = redisDb.StringGet(currKey); //if (!string.IsNullOrEmpty($"{rawData}")) if (rawData.HasValue) { @@ -340,10 +445,10 @@ namespace MP.Data.Services } else { - result = await Task.FromResult(dbTabController.ConfigGetAll()); + result = dbTabController.ConfigGetAll(); // serializzp e salvo... rawData = JsonConvert.SerializeObject(result); - await redisDb.StringSetAsync(currKey, rawData, LongCache); + redisDb.StringSet(currKey, rawData, LongCache); } if (result == null) { @@ -354,6 +459,85 @@ namespace MP.Data.Services return result; } + /// + /// Recupera il valore in formato STRING + /// + /// Valore da cercare + /// String in cui salvare il valore se trovato + /// + public bool ConfigGetVal(string chiave, ref string varObj) + { + bool answ = false; + // se mancasse provo a configurare.. + if (CurrConfig == null || CurrConfig.Count == 0) + { + SetupConfig(); + } + if (CurrConfig != null && CurrConfig.Count > 0) + { + // sistemo i parametri opzionali... + ConfigModel? risultato = CurrConfig.FirstOrDefault(x => x.Chiave == chiave); + if (risultato != null) + { + varObj = risultato.Valore; + answ = !string.IsNullOrEmpty(risultato.Valore); + } + } + return answ; + } + + /// + /// Recupera il valore in formato INT + /// + /// Valore da cercare + /// Int in cui salvare il valore se trovato + /// + public bool ConfigGetVal(string chiave, ref int varObj) + { + bool answ = false; + // se mancasse provo a configurare.. + if (CurrConfig == null || CurrConfig.Count == 0) + { + SetupConfig(); + } + if (CurrConfig != null && CurrConfig.Count > 0) + { + // sistemo i parametri opzionali... + ConfigModel? risultato = CurrConfig.FirstOrDefault(x => x.Chiave == chiave); + if (risultato != null) + { + answ = int.TryParse(risultato.Valore, out varObj); + } + } + return answ; + } + + /// + /// Recupera il valore in formato BOOL + /// + /// Valore da cercare + /// Boolean in cui salvare il valore se trovato + /// + public bool ConfigGetVal(string chiave, ref bool varObj) + { + bool answ = false; + // se mancasse provo a configurare.. + if (CurrConfig == null || CurrConfig.Count == 0) + { + SetupConfig(); + } + if (CurrConfig != null && CurrConfig.Count > 0) + { + // sistemo i parametri opzionali... + ConfigModel? risultato = CurrConfig.FirstOrDefault(x => x.Chiave == chiave); + if (risultato != null) + { + answ = bool.TryParse(risultato.Valore, out varObj); + } + } + return answ; + } + /// /// Inserimento record in DDB /// @@ -387,6 +571,30 @@ namespace MP.Data.Services // Clear database controller dbTabController.Dispose(); dbIocController.Dispose(); + dbInveController.Dispose(); + } + + /// + /// Fix ODL per Elenco Lotti + /// + /// + /// + /// + public async Task ElencoLottiUpsertByOdl(int idxOdl, bool flgStorico) + { + bool answ = false; + try + { + // inserisco evento + answ = dbTabController.ElencoLottiUpsertByOdl(idxOdl, flgStorico); + await FlushCache("EL"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in ElencoLottiUpsertByOdl | idxOdl: {idxOdl} | flgStorico: {flgStorico}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; } /// @@ -460,7 +668,7 @@ namespace MP.Data.Services /// /// Record da registrare /// - public async Task EvListInsert(EventListModel newRec, tipoInputEvento tipoEv) + public async Task EvListInsert(EventListModel newRec, Enums.tipoInputEvento tipoEv) { bool inserito = false; try @@ -477,7 +685,7 @@ namespace MP.Data.Services Log.Error(logMsg); } // se non è un commento... - if (tipoEv != tipoInputEvento.commento) + if (tipoEv != Enums.tipoInputEvento.commento) { try { @@ -486,7 +694,7 @@ namespace MP.Data.Services } catch (Exception exc) { - string logMsg = $"Eccezione in checkCambiaStatoBatch(6) | tipoInputEvento: {tipoEv} |macchina: {newRec.IdxMacchina} | IdxTipo: {newRec.IdxTipo} | CodArticolo: {newRec.CodArticolo} | Value {newRec.Value} | MatrOpr {newRec.MatrOpr} | Pallet {newRec.pallet}{Environment.NewLine}{exc}"; + string logMsg = $"Eccezione in checkCambiaStatoBatch(6) | tipoInputEvento: {tipoEv} |macchina: {newRec.IdxMacchina} | IdxTipo: {newRec.IdxTipo} | CodArticolo: {newRec.CodArticolo} | Value: {newRec.Value} | MatrOpr: {newRec.MatrOpr} | Pallet: {newRec.pallet}{Environment.NewLine}{exc}"; Log.Error(logMsg); } } @@ -619,6 +827,44 @@ namespace MP.Data.Services return result; } + /// + /// Elenco lotti esterni presenti sul db di ARCA + /// + /// Codice articolo + /// Codice lotto + /// Codice magazzino + /// + public async Task> LottoEsterno(string codArt, string codLotto, string codMagazzino) + { + // setup parametri costanti + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:LottoExt:{codMagazzino}:{codArt}:{codLotto}"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbInveController.LottoEsterno(codArt, codLotto, codMagazzino); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"LottoEsterno | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + /// /// Effettua ricalcolo MSE x macchina indicata /// @@ -631,6 +877,681 @@ namespace MP.Data.Services return answ; } + /// + /// Intera tabella relazione master/slave in machine (gestione setup master --> slave) + /// + /// + public async Task> Macchine2Slave() + { + // setup parametri costanti + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:Mach2Slave"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + //if (!string.IsNullOrEmpty($"{rawData}")) + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbTabController.Macchine2Slave(); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, UltraFastCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"Macchine2Slave | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + + /// + /// Lista parametri correnti (ObjItemDTO) della macchina + /// + /// + /// + public List MachineParamList(string idxMacchina) + { + // setup parametri costanti + string source = "NA"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = redHash($"CurrentParameters:{idxMacchina}"); + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + var rawVal = JsonConvert.DeserializeObject>($"{rawData}"); + // ordino! + result = rawVal + .OrderBy(x => x.displOrdinal) + .ThenBy(x => x.description) + .ToList(); + source = "REDIS"; + } + if (result == null) + { + result = new List(); + source = "NONE"; + } + sw.Stop(); + Log.Debug($"CurrParamList | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + + /// + /// Aggiornamento parametro per macchina + /// + /// + /// UID del parametro macchina come definito in file json + /// + /// + public bool MachineParamUpdate(string idxMacchina, string uid, string reqValue) + { + bool answ = false; + // recupero items... + List dcList = MachineParamList(idxMacchina); + List list2Update = new List(); + // cerco quello da aggiornare + var trovato = dcList.Find(obj => obj.uid == uid); + // se non trova --> crea ed aggiunge... + if (trovato == null) + { + dcList.Add(new ObjItemDTO() { uid = uid }); + trovato = dcList.Find(obj => obj.uid == uid); + } + + // se trovato procedo + if (trovato != null) + { + // aggiorno valore richiesto + dt richiesta + trovato.reqValue = reqValue; + trovato.lastRequest = DateTime.Now; + list2Update.Add(trovato); + MachineParamUpsert(idxMacchina, list2Update); + + // accodo in task 2 exe la richiesta di processing + addTask4Machine(idxMacchina, Enums.taskType.setParameter, trovato.uid); + + // salvo ANCHE il valore di setup ASSOCIATO... + System.Enum.TryParse(trovato.uid, out Enums.taskType currTask); + //taskType currTask = (taskType)System.Enum.Parse(typeof(taskType), trovato.uid); + addTask4Machine(idxMacchina, currTask, reqValue); + + answ = true; + } + return answ; + } + + /// + /// Effettua UPSERT elenco parametri correnti x IOB (se c'è UPDATE, se manca ADD) + /// + /// + /// + /// + public bool MachineParamUpsert(string idxMacchina, List innovations) + { + bool answ = false; + if (innovations != null) + { + Log.Info($"upsertCurrObjItems | idxMacchina: {idxMacchina} | {innovations.Count} innovations"); + // leggo i valori attuali... + List actValues = MachineParamList(idxMacchina); + // per ogni valore passatomi faccio insert o update rispetto elenco valori correnti + // in REDIS + foreach (var item in actValues) + { + // cerco nelle innovazioni SE CI SIA il valore... + var trovato = innovations.Find(obj => obj.uid == item.uid); + // se non trovato nelle innovazioni... + if (trovato == null) + { + // lo ri-aggiungo x non perderlo + innovations.Add(item); + Log.Trace($"innovations | add | item.uid: {item.uid} | item.value: {item.value}"); + } + // altrimenti aggiorno campo (non trasmesso) name e tengo il resto... + else + { + trovato.name = item.name; + Log.Info($"innovations | update | item.uid: {item.uid} | item.value: {item.value} --> {trovato.value} "); + } + } + // serializzo e salvo + string serVal = JsonConvert.SerializeObject(innovations); + string currKey = redHash($"CurrentParameters:{idxMacchina}"); + RedisValue rawData = redisDb.StringSet(currKey, serVal); + } + return answ; + } + + /// + /// Restitusice elenco KVP dei TASK SALVATI (da passare a IOB-WIN) per l'impianto indicato + /// + /// + /// + public Dictionary mSavedTaskMacchina(string idxMacchina) + { + // hard coded dimensione vettore DatiMacchine + Dictionary answ = new Dictionary(); + // ORA recupero da memoria redis... + try + { + var currKey = (RedisKey)savedTaskHash(idxMacchina); + answ = redisHashDictGet(currKey); + } + catch (Exception exc) + { + Log.Info($"Errore in recupero dati SAVED TASK x Redis mSavedTaskMacchina | idxMacchina {idxMacchina}{Environment.NewLine}{exc}"); + } + return answ; + } + + /// + /// ODL da key + /// + /// + /// + /// + public async Task OdlByIdx(int idxOdl, bool onlyUnused) + { + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + ODLExpModel result = new ODLExpModel(); + // cerco in redis... + string currKey = $"{redisBaseKey}:ODL:{idxOdl}:{onlyUnused}"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject($"{rawData}"); + source = "REDIS"; + } + else + { + var listRes = await Task.FromResult(dbTabController.OdlByIdx(idxOdl, onlyUnused)); + result = listRes.FirstOrDefault(); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, FastCache); + } + if (result == null) + { + result = new ODLExpModel(); + } + sw.Stop(); + Log.Debug($"OdlByIdx | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + + /// + /// ODL corrente macchina + /// + /// + /// + public async Task OdlCurrByMacc(string idxMacchina, bool forceDb) + { + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + ODLExpModel result = new ODLExpModel(); + // cerco in redis... + string currKey = $"{redisBaseKey}:ODL:{idxMacchina}:CURR"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue && !forceDb) + { + result = JsonConvert.DeserializeObject($"{rawData}"); + source = "REDIS"; + } + else + { + var listRes = await Task.FromResult(dbTabController.OdlCurrByMacc(idxMacchina)); + result = listRes.FirstOrDefault(); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, FastCache); + } + if (result == null) + { + result = new ODLExpModel(); + } + sw.Stop(); + Log.Debug($"OdlCurrByMacc | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + + /// + /// Registro fine prod ODL + /// + /// + /// + /// + public async Task OdlFineProd(int idxODL, string idxMacchina) + { + bool answ = false; + try + { + // inserisco evento + answ = dbTabController.OdlFineProd(idxODL, idxMacchina); + await FlushCache("ODL"); + await FlushCache("PODL"); + await FlushCache("VSODL"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in OdlFineProd | idxODL: {idxODL} | idxMacchina: {idxMacchina}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + + /// + /// Fix ODL per macchine SLAVE + /// + /// + /// + /// + /// + public async Task OdlFixMachineSlave(string idxMacchina, int numDayPrev, int doInsert) + { + bool answ = false; + try + { + // inserisco evento + answ = dbTabController.OdlFixMachineSlave(idxMacchina, numDayPrev, doInsert); + await FlushCache("ODL"); + await FlushCache("PODL"); + await FlushCache("VSODL"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in ODLfixMachineSlave | idxMacchina: {idxMacchina} | numDayPrev: {numDayPrev} | doInsert: {doInsert}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + + /// + /// Setup PODL Postumo + /// + /// + /// + /// + /// + /// + /// + /// + public async Task OdlInizioSetup(int idxODL, int matrOpr, string idxMacchina, decimal tcRich, int pzPallet, string note) + { + bool answ = false; + try + { + // inserisco evento + answ = dbTabController.OdlInizioSetup(idxODL, matrOpr, idxMacchina, tcRich, pzPallet, note); + await FlushCache("ODL"); + await FlushCache("PODL"); + await FlushCache("VSODL"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in OdlInizioSetup | matrOpr: {matrOpr} | idxODL: {idxODL} | idxMacchina: {idxMacchina}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + + /// + /// Elenco ODL data macchina e periodo + /// + /// + /// + /// + /// + public async Task> OdlListByMaccPeriodo(string idxMacchina, DateTime dtStart, DateTime dtEnd) + { + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:ODL:{idxMacchina}:{dtStart:yyyyMMdd-HHmmss}:{dtEnd:yyyyMMdd-HHmmss}"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = await Task.FromResult(dbTabController.OdlListByMaccPeriodo(idxMacchina, dtStart, dtEnd)); + // riordino + result = result.OrderByDescending(x => x.DataInizio).ToList(); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"OdlListByMaccPeriodo | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + + /// + /// Setup ODL Postumo + /// + /// + /// + /// + public async Task OdlSetupPostumo(int idxODL, string idxMacchina) + { + bool answ = false; + try + { + // inserisco evento + answ = dbTabController.OdlSetupPostumo(idxODL, idxMacchina); + await FlushCache("ODL"); + await FlushCache("PODL"); + await FlushCache("VSODL"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in OdlSetupPostumo | macchina: {idxMacchina} | idxODL: {idxODL}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + + /// + /// Setup ODL Postumo + /// + /// + /// + /// + /// + public async Task OdlSetupPromPostuma(int idxPromOdl, int matrOpr, string idxMacchina) + { + bool answ = false; + try + { + // inserisco evento + answ = dbTabController.OdlSetupPromPostuma(idxPromOdl, matrOpr, idxMacchina); + await FlushCache("ODL"); + await FlushCache("PODL"); + await FlushCache("VSODL"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in OdlSetupPromPostuma | macchina: {idxMacchina} | idxPromOdl: {idxPromOdl} | MatrOpr: {matrOpr}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + + /// + /// Split ODL + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public async Task OdlSplit(int idxODL, int matrOpr, string idxMacchina, decimal TCRich, int pzPallet, string note, bool startNewOdl, int qtyRich) + { + bool answ = false; + try + { + // inserisco evento + answ = dbTabController.OdlSplit(idxODL, matrOpr, idxMacchina, TCRich, pzPallet, note, startNewOdl, qtyRich); + await FlushCache("ODL"); + await FlushCache("PODL"); + await FlushCache("VSODL"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in OdlSplit | macchina: {idxMacchina} | idxODL: {idxODL}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + + /// + /// Update ODL (es: in setup x chiusura attrezzaggio) + /// + /// + /// + /// + public async Task OdlUpdate(int idxODL, int matrOpr, decimal tCRichAttr, int pzPallet, string note) + { + bool answ = false; + try + { + // inserisco evento + answ = dbTabController.OdlUpdate(idxODL, matrOpr, tCRichAttr, pzPallet, note); + await FlushCache("ODL"); + await FlushCache("PODL"); + await FlushCache("VSODL"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in OdlUpdate | idxODL: {idxODL} | matrOpr: {matrOpr} | tCRichAttr: {tCRichAttr} | pzPallet: {pzPallet} | note: {note}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + + /// + /// Stato prod macchina + /// + /// + /// + public async Task> PezziProdMacchina(string idxMacchina) + { + // setup parametri costanti + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:PzProd:{idxMacchina}"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + //if (!string.IsNullOrEmpty($"{rawData}")) + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbTabController.PezziProdMacchina(idxMacchina); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, UltraFastCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"PezziProdMacchina | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + + /// + /// Avvio setup ODL da PODL + /// + /// + /// + /// + /// + /// + /// + public async Task PODL_startSetup(PODLExpModel editRec, int matrOpr, decimal tcRich, int pzPallet, string note, DateTime dtEvent) + { + bool answ = false; + try + { + // inserisco evento + answ = dbTabController.PODL_startSetup(editRec, matrOpr, tcRich, pzPallet, note, dtEvent); + await FlushCache("ODL"); + await FlushCache("PODL"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in PODL_startSetup | matrOpr: {matrOpr} | idxPODL: {editRec.IdxPromessa}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + + /// + /// Recupero PODL da chiave + /// + /// + /// + public async Task PODLExp_getByKey(int idxPODL) + { + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + PODLExpModel result = new PODLExpModel(); + // cerco in redis... + string currKey = $"{redisBaseKey}:PODL:{idxPODL}"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject($"{rawData}"); + source = "REDIS"; + } + else + { + result = await Task.FromResult(dbTabController.PODLExp_getByKey(idxPODL)); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (result == null) + { + result = new PODLExpModel(); + } + sw.Stop(); + Log.Debug($"PODL_getByKey | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + + /// + /// Restituisce il contapezzi salvato per la macchina + /// + /// + /// + public async Task pzCounter(string idxMacchina) + { + int answ = -1; + string rCall = ""; + saveCallRec("getCounter"); + try + { + rCall = redisDb.StringGet(redHash($"PzCount:{idxMacchina}")); + if (rCall != "" && rCall != null) + { + int.TryParse(rCall, out answ); + } + else + { + answ = await pzCounterTC(idxMacchina); + // salvo in redis... + await saveCounter(idxMacchina, answ.ToString()); + } + } + catch (Exception exc) + { + Log.Error($"Eccezione in pzCounter{Environment.NewLine}{exc}"); + } + return answ; + } + + /// + /// Restituisce il contapezzi come CONTEGGIO da TCRilevati per la macchina + /// + /// + /// + public async Task pzCounterTC(string idxMacchina) + { + int answ = -1; + saveCallRec("getCounterTC"); + // 2023.11.08 versione originale con tentativi reiterati, eliminata +#if false + // variabile x controllo dati recuperati + DS_ProdTempi.StatoProdDataTable datiProdAct = null; + bool okDatiProd = false; + int taSP_ms_ant = memLayer.ML.cdvi("taStatoProd_ms_anticipo"); + DateTime dataRif = DateTime.Now.AddMilliseconds(-taSP_ms_ant); + okDatiProd = getStatoProd(idxMacchina, ref datiProdAct, dataRif); + // se NON avesse recuperato --> aspetto taSP_ms_ant e poi RICHIAMO procedura... + int maxTry = 3; + while (!okDatiProd && maxTry > 0) + { + Log.Info(string.Format("[pzCounterTC] Impossibile recuperare dati ODL x idxMacchina {0}", idxMacchina), tipoLog.WARNING); + // sleep... + Thread.Sleep(taSP_ms_ant * 2); + // riprovo lettura... + okDatiProd = getStatoProd(idxMacchina, ref datiProdAct, dataRif); + maxTry--; + } + + // ora proseguo SE ho trovato i dati... + if (okDatiProd) + { + if (datiProdAct != null) + { + if (datiProdAct.Count > 0) + { + if (!datiProdAct[0].IsPzTotODLNull()) + { + // ...a questo punto recupero DAVVERO i dati (o almeno ci provo...) + try + { + // controllo + answ = datiProdAct[0].PzTotODL; + } + catch (Exception exc) + { + Log.Info(string.Format("[pzCounterTC] Eccezione in recupero PzTotODL x idxMacchina {0}{1}{2}", idxMacchina, Environment.NewLine, exc), tipoLog.EXCEPTION); + } + } + } + } + } + else + { + Log.Info(string.Format("[pzCounterTC] Dati ODL x idxMacchina {0} non recuperati dopo tentativi reiterati...", idxMacchina), tipoLog.WARNING); + } +#endif + + DateTime dataRif = DateTime.Now; + var datiProd = await StatoProdMacchina(idxMacchina, dataRif); + if (datiProd != null) + { + answ = datiProd.PzTotODL; + } + return answ; + } + /// /// Restituisce elenco RC filtrato /// @@ -681,8 +1602,167 @@ namespace MP.Data.Services /// public async Task RegControlliInsert(string idxMacchina, int matrOpr, bool esitoOk, string note, DateTime dataOra) { - bool answ = dbTabController.RegControlliInsert(idxMacchina, matrOpr, esitoOk, note, dataOra); - await FlushCache("RecContr"); + bool answ = false; + try + { + // inserisco evento + answ = dbTabController.RegControlliInsert(idxMacchina, matrOpr, esitoOk, note, dataOra); + await FlushCache("RecContr"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in RegControlliInsert | macchina: {idxMacchina} | DataOra: {dataOra} | MatrOpr: {matrOpr} | Qta {esitoOk} | Note: {note}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + + /// + /// Aggiunta record RegistroScarti + /// + /// + /// + /// + /// + /// + /// + public async Task> RegDichiarGetFilt(string idxMacchina, string tagCode, int matrOpr, int idxODL, DateTime dataFrom, DateTime dataTo) + { + // setup parametri costanti + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:RegDichiar:{idxMacchina}:{tagCode}:{matrOpr}:{idxODL}:{dataFrom:yyyyyMMdd-HHmm}:{dataTo:yyyyyMMdd-HHmm}"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbTabController.RegDichiarGetFilt(idxMacchina, tagCode, matrOpr, idxODL, dataFrom, dataTo); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, FastCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"RegDichiarGetFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + + /// + /// Aggiunta record Registro Dichiarazioni + /// + /// + /// + public async Task RegDichiarInsert(RegistroDichiarazioniModel newRec) + { + bool answ = false; + try + { + // inserisco evento + answ = await dbTabController.RegDichiarInsert(newRec); + // reset cache eventi/commenti + await FlushCache("RegDichiar"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in RegDichiarInsert | macchina: {newRec.IdxMacchina} | DtRec: {newRec.DtRec} | TagCode: {newRec.TagCode} | MatrOpr: {newRec.MatrOpr} | ValString {newRec.ValString}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + + /// + /// Aggiunta record Registro Dichiarazioni + /// + /// + /// + public async Task RegDichiarUpdate(RegistroDichiarazioniModel newRec) + { + bool answ = false; + try + { + // inserisco evento + answ = await dbTabController.RegDichiarUpdate(newRec); + // reset cache eventi/commenti + await FlushCache("RegDichiar"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in RegDichiarUpdate | macchina: {newRec.IdxMacchina} | DtRec: {newRec.DtRec} | TagCode: {newRec.TagCode} | MatrOpr: {newRec.MatrOpr} | ValString {newRec.ValString}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + + /// + /// Restituisce elenco RS filtrato + /// + /// + /// + /// + /// + /// + /// + public async Task> RegScartiGetFilt(string idxMacchina, int idxODL, DateTime dataFrom, DateTime dataTo, bool showMulti) + { + // setup parametri costanti + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:RegScarti:{idxMacchina}:{idxODL}:{dataFrom:yyyyyMMdd-HHmm}:{dataTo:yyyyyMMdd-HHmm}:{showMulti}"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbTabController.RegScartiGetFilt(idxMacchina, idxODL, dataFrom, dataTo, showMulti); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, FastCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"RegScartiGetFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + + /// + /// Aggiunta record RegistroScarti + /// + /// + /// + public async Task RegScartiInsert(RegistroScartiModel newRec) + { + bool answ = false; + try + { + // inserisco evento + answ = await dbTabController.RegScartiInsert(newRec); + // reset cache eventi/commenti + await FlushCache("RegScarti"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in RegScartiInsert | macchina: {newRec.IdxMacchina} | DataOra: {newRec.DataOra} | Causale: {newRec.Causale} | MatrOpr: {newRec.MatrOpr} | Qta {newRec.Qta} | Note: {newRec.Note}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } return answ; } @@ -813,13 +1893,231 @@ namespace MP.Data.Services /// idx macchina da confermare /// Num massimo secondi di "vecchiaia" del dato /// - public bool RicalcMse(string idxMacchina, int maxAgeSec) + public async Task RicalcMse(string idxMacchina, int maxAgeSec) { bool answ = false; answ = dbTabController.RicalcMse(idxMacchina, maxAgeSec); + await FlushCache(Constants.redisMseKey); return answ; } + /// + /// Processa registrazione di un counter x una data macchina IOB + /// + /// + /// contapezzi + /// + public async Task saveCounter(string idxMacchina, string counter) + { + // registro conteggio impiego chiamate REDIS + saveCallRec("saveCounter"); + string answ = "0"; + // inizio processing vero e proprio INPUT... + if (!string.IsNullOrEmpty(idxMacchina)) + { + if (!string.IsNullOrEmpty(counter)) + { + int newCounter = -1; + int.TryParse(counter, out newCounter); + // se il conteggio è >= 0 SALVO come nuovo conteggio... + if (newCounter >= 0) + { + string redKey = redHash($"PzCount:{idxMacchina}"); + // verifico SE ci sia chiave in redis (ALTRIMENTI rileggo da DB) + string redVal = redisDb.StringGet(redKey); + if (!string.IsNullOrEmpty(redVal)) + { + // salvo in Redis nell'area corretta il valore richiesto + redisDb.StringSet(redKey, counter); + // imposto risposta... + answ = counter; + } + else + { + // rileggo da DB e salvo e poi restituisco questo... + int currCount = await pzCounterTC(idxMacchina); + redisDb.StringSet(redKey, $"{currCount}"); + // imposto risposta... + answ = currCount.ToString(); + } + } + } + else + { + string errore = "Errore: parametro counter vuoto"; + Log.Error(errore); + answ = errore; + } + } + else + { + string errore = "Errore: parametro macchina vuoto"; + Log.Error(errore); + answ = errore; + } + return answ; + } + + /// + /// Processa registrazione ODL corrente x macchina + /// + /// + /// cod ODL in produzione, se 0 > vuoto + /// + public string saveCurrODL(string idxMacchina, int currIdxOdl) + { + // registro conteggio impiego chiamate REDIS + saveCallRec("saveCurrODL"); + int currOdlCacheDur = 500; + ConfigGetVal("currOdlCacheDur", ref currOdlCacheDur); + string answ = ""; + // inizio processing vero e proprio INPUT... + if (idxMacchina != null) + { + if (idxMacchina != "") + { + // se ODL fosse 0 USO DURATA CACHE 1/4... + if (currIdxOdl == 0) + { + currOdlCacheDur = currOdlCacheDur / 4; + } + redisDb.StringSet(redHash($"CurrODL:{idxMacchina}"), currIdxOdl, TimeSpan.FromSeconds(currOdlCacheDur)); + // registro in risposta che è andato tutto bene... + answ = "OK"; + } + else + { + string errore = $"Errore: parametri macchina vuoto (idxMacchina: {idxMacchina} | currIdxOdl: {currIdxOdl})"; + Log.Error(errore); + answ = errore; + } + } + else + { + string errore = "Errore: mancano parametri macchina"; + Log.Error(errore); + answ = errore; + } + return answ; + } + + /// + /// Setup oggetto config con lettura da DB + /// + /// + public void SetupConfig() + { + CurrConfig = ConfigGetAll(); + } + + /// + /// Restituisce elenco gruppi Scheda tecnica + /// + /// + public async Task> ST_AnagGruppiList() + { + // setup parametri costanti + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:ST:AnagGruppi"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbTabController.ST_AnagGruppiList(); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"ST_AnagGruppiList | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + + public async Task ST_CheckCleanByOdl(int idxOdl) + { + bool answ = false; + try + { + // inserisco evento + answ = dbTabController.ST_CheckCleanByOdl(idxOdl); + await FlushCache("ST"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in ST_CheckCleanByOdl | idxOdl: {idxOdl}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + + public async Task ST_CheckUpsert(int idxOdl, int idxST, int oggetto, int num, string valueRead, string extCode, bool checkOk, string userMod, bool forced) + { + bool answ = false; + try + { + // inserisco evento + answ = dbTabController.ST_CheckUpsert(idxOdl, idxST, oggetto, num, valueRead, extCode, checkOk, userMod, forced); + await FlushCache("ST"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in ST_CheckUpsert | idxOdl: {idxOdl}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + + /// + /// Dati deroga SchedaTecnica serializzati in REDIS + /// + public StCheckOverride ST_DerogaGet(string Utente, int IdxST) + { + StCheckOverride answ = new StCheckOverride() { IdxST = 0 }; + string keyDerogaST = redHash($"DerogaSt:{Utente}:{IdxST:000}"); + string rawData = redisDb.StringGet(keyDerogaST); + if (!string.IsNullOrEmpty(rawData)) + { + try + { + answ = JsonConvert.DeserializeObject(rawData); + } + catch (Exception exc) + { + Log.Error($"Eccezione in ST_DerogaSet | Utente: {Utente} | IdxST: {IdxST}{Environment.NewLine}{exc}"); + } + } + return answ; + } + + public bool ST_DerogaSet(StCheckOverride deroga) + { + bool fatto = false; + try + { + string keyDerogaST = redHash($"DerogaSt:{deroga.Utente}:{deroga.IdxST:000}"); + string rawData = JsonConvert.SerializeObject(deroga); + redisDb.StringSet(keyDerogaST, rawData, TimeSpan.FromMinutes(2)); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione in ST_DerogaSet | Utente: {deroga.Utente} | IdxST: {deroga.IdxST}{Environment.NewLine}{exc}"); + } + return fatto; + } + /// /// Recupero Righe (Actual) della scheda tecnica da GRUPPO + ODL /// @@ -834,7 +2132,7 @@ namespace MP.Data.Services sw.Start(); List? result = new List(); // cerco in redis... - string currKey = $"{redisBaseKey}:START:{codGruppo}:{idxODL}"; + string currKey = $"{redisBaseKey}:STAR:{codGruppo}:{idxODL}"; RedisValue rawData = await redisDb.StringGetAsync(currKey); //if (!string.IsNullOrEmpty($"{rawData}")) if (rawData.HasValue) @@ -873,7 +2171,7 @@ namespace MP.Data.Services sw.Start(); List? result = new List(); // cerco in redis... - string currKey = $"{redisBaseKey}:START:{codGruppo}:{label}:{idxODL}"; + string currKey = $"{redisBaseKey}:STAR:{codGruppo}:{label}:{idxODL}"; RedisValue rawData = await redisDb.StringGetAsync(currKey); //if (!string.IsNullOrEmpty($"{rawData}")) if (rawData.HasValue) @@ -897,12 +2195,48 @@ namespace MP.Data.Services return result; } + /// + /// Recupero Righe pending da ODL + /// + /// + /// + public List STAR_pendByOdl(int idxODL) + { + // setup parametri costanti + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:STAR:Pend:{idxODL}"; + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbTabController.STAR_pendByOdl(idxODL); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(5)); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"STAR_pendByOdl | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + /// /// Stato macchina /// /// /// - public async Task StatoMacchina(string idxMacchina) + public StatoMacchineModel StatoMacchina(string idxMacchina) { // setup parametri costanti string source = "DB"; @@ -911,8 +2245,7 @@ namespace MP.Data.Services StatoMacchineModel? result = new StatoMacchineModel(); // cerco in redis... string currKey = $"{redisBaseKey}:StatoMacc:{idxMacchina}"; - RedisValue rawData = await redisDb.StringGetAsync(currKey); - //if (!string.IsNullOrEmpty($"{rawData}")) + RedisValue rawData = redisDb.StringGet(currKey); if (rawData.HasValue) { result = JsonConvert.DeserializeObject($"{rawData}"); @@ -923,7 +2256,7 @@ namespace MP.Data.Services result = dbTabController.StatoMacchina(idxMacchina); // serializzp e salvo... rawData = JsonConvert.SerializeObject(result); - await redisDb.StringSetAsync(currKey, rawData, TimeSpan.FromSeconds(2)); + redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(2)); } if (result == null) { @@ -1054,6 +2387,18 @@ namespace MP.Data.Services return answ; } + /// + /// OVERLOAD vecchio nome function per MachineParamUpsert: Effettua UPSERT elenco parametri + /// correnti x IOB (se c'è UPDATE, se manca ADD) + /// + /// + /// + /// + public bool upsertCurrObjItems(string idxMacchina, List innovations) + { + return MachineParamUpsert(idxMacchina, innovations); + } + /// /// Intera vista v_MSFD /// @@ -1163,6 +2508,71 @@ namespace MP.Data.Services return result; } + public List VocabolarioGetAll() + { + // setup parametri costanti + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:Vocab"; + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbTabController.VocabolarioGetAll(); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSet(currKey, rawData, UltraLongCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"VocabolarioGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + + /// + /// Elenco causali scarto + /// + /// + public async Task> VSCS_getAll() + { + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:VSCS"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = await Task.FromResult(dbTabController.VSCS_getAll()); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"VSCS_getAll | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + /// /// Elenco ultimi ODL x macchina /// @@ -1199,6 +2609,43 @@ namespace MP.Data.Services return result; } + /// + /// Elenco prossimi ODL/PODL x macchina + /// + /// Macchina + /// + /// + /// + public async Task> VSOdlGetUnused(string idxMacchina, bool showAll, int numDayAdd) + { + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:VSODL:{idxMacchina}:ALL_{showAll}:{numDayAdd}"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = await Task.FromResult(dbTabController.VSOdlGetUnused(idxMacchina, showAll, numDayAdd)); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, LongCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"VSOdlGetUnused | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + #endregion Public Methods #region Protected Fields @@ -1235,6 +2682,8 @@ namespace MP.Data.Services #region Private Properties + private static Controllers.MpInveController dbInveController { get; set; } = null!; + private static Controllers.MpIocController dbIocController { get; set; } = null!; private static Controllers.MpTabController dbTabController { get; set; } = null!; @@ -1270,6 +2719,38 @@ namespace MP.Data.Services return answ; } + /// + /// Hash dati EXE TASK x la macchina specificata + /// + /// + /// + private string exeTaskHash(string idxMacchina) + { + return redHash($"ExeTask:{idxMacchina}"); + } + + /// + /// Restitusice elenco KVP dei TASK (da passare a IOB-WIN) per l'impianto indicato + /// + /// + /// + private Dictionary mTaskMacchina(string idxMacchina) + { + // hard coded dimensione vettore DatiMacchine + Dictionary answ = new Dictionary(); + // ORA recupero da memoria redis... + try + { + var currKey = (RedisKey)exeTaskHash(idxMacchina); + answ = redisHashDictGet(currKey); + } + catch (Exception exc) + { + Log.Info(string.Format("Errore in recupero dati EXE TASK x Redis mTaskMacchina - idxMacchina {2}:{0}{1}", Environment.NewLine, exc, idxMacchina)); + } + return answ; + } + private string redHash(string keyName) { string result = keyName; @@ -1285,6 +2766,87 @@ namespace MP.Data.Services return result; } + /// + /// Recupero HashSet redis come Dictionary + /// + /// + /// + private Dictionary redisHashDictGet(RedisKey currKey) + { + Dictionary answ = new Dictionary(); + try + { + answ = redisDb + .HashGetAll(currKey) + .ToDictionary(x => $"{x.Name}", x => $"{x.Value}"); + } + catch (Exception exc) + { + Log.Info($"Errore redisHashDictGet | currKey: {currKey}{Environment.NewLine}{exc}"); + } + return answ; + } + + /// + /// Salvataggio Dictionary come HashSet Redis + /// + /// + /// + private bool redisHashDictSet(RedisKey currKey, Dictionary dict) + { + bool fatto = false; + try + { + HashEntry[] data2ins = new HashEntry[dict.Count]; + int i = 0; + foreach (KeyValuePair kvp in dict) + { + data2ins[i] = new HashEntry(kvp.Key, kvp.Value); + i++; + } + // salvo! + redisDb.HashSet(currKey, data2ins); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione in redisHashDictSet | currKey: {currKey}{Environment.NewLine}{exc}"); + } + return fatto; + } + + /// + /// registra su REDIS eventuale superamento numero limite di call x il metodo in oggetto + /// + /// + private void saveCallRec(string callCountKey) + { + // conto la richiesta nel contatore REDIS + long nCall = redisDb.StringIncrement(redHash($"COUNT:pCall:{callCountKey}")); + //... se == nCall2Log scrivo su log e resetto + int nCall2Log = 10; + ConfigGetVal("nCall2Log", ref nCall2Log); + + if (nCall >= nCall2Log) + { + // loggo + Log.Info($"{callCountKey}: {nCall} call received"); + // resetto! + redisDb.StringSet(redHash($"COUNT:pCall:{callCountKey}"), "0"); + } + } + + /// + /// Hash dati SAVED (EXE) TASK x la macchina specificata x poter ripristinare in caso di + /// perdita valore WRITE + /// + /// + /// + private string savedTaskHash(string idxMacchina) + { + return redHash($"SavedTask:{idxMacchina}"); + } + #endregion Private Methods } } \ No newline at end of file diff --git a/MP.Data/Utils.cs b/MP.Data/Utils.cs index 77f04a19..a0960900 100644 --- a/MP.Data/Utils.cs +++ b/MP.Data/Utils.cs @@ -230,6 +230,10 @@ namespace MP.Data public const string redisArtList = redisBaseAddr + "Cache:ArtList"; public const string redisBaseAddr = "MP:"; public const string redisConfKey = redisBaseAddr + "Cache:Config"; + public const string redisAKVKey = redisBaseAddr + "Cache:AKV"; + public const string redisParetoFLKey = redisBaseAddr + "Cache:ParetoFL"; + public const string redisStatsProcFL = redisBaseAddr + "Stats:ProcessFL"; + public const string redisStatsDbMaint = redisBaseAddr + "Stats:DbMaint"; public const string redisDossByMac = redisBaseAddr + "Cache:DossByMac"; public const string redisFluxByMac = redisBaseAddr + "Cache:FluxByMac"; public const string redisFluxLogFilt = redisBaseAddr + "Cache:FluxLogFilt"; diff --git a/MP.INVE/MP.INVE.csproj b/MP.INVE/MP.INVE.csproj index c3d99f3d..5baf9457 100644 --- a/MP.INVE/MP.INVE.csproj +++ b/MP.INVE/MP.INVE.csproj @@ -5,7 +5,7 @@ enable enable MP.INVE - 6.16.2310.308 + 6.16.2311.1009 diff --git a/MP.INVE/Resources/ChangeLog.html b/MP.INVE/Resources/ChangeLog.html index 70a2d92f..7e65988e 100644 --- a/MP.INVE/Resources/ChangeLog.html +++ b/MP.INVE/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOINVE -

    Versione: 6.16.2310.308

    +

    Versione: 6.16.2311.1009


    Note di rilascio:
    • diff --git a/MP.INVE/Resources/VersNum.txt b/MP.INVE/Resources/VersNum.txt index f08bb28c..cf39a0ed 100644 --- a/MP.INVE/Resources/VersNum.txt +++ b/MP.INVE/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2310.308 +6.16.2311.1009 diff --git a/MP.INVE/Resources/manifest.xml b/MP.INVE/Resources/manifest.xml index ac1073d8..17c95f0b 100644 --- a/MP.INVE/Resources/manifest.xml +++ b/MP.INVE/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2310.308 + 6.16.2311.1009 https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/MP.INVE.zip https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/ChangeLog.html false diff --git a/MP.Land/MP.Land.csproj b/MP.Land/MP.Land.csproj index 33bbb0e9..2cc99106 100644 --- a/MP.Land/MP.Land.csproj +++ b/MP.Land/MP.Land.csproj @@ -3,7 +3,7 @@ net6.0 MP.Land - 6.16.2310.1615 + 6.16.2311.1009 diff --git a/MP.Land/Resources/ChangeLog.html b/MP.Land/Resources/ChangeLog.html index 5fb28cd2..2076f49f 100644 --- a/MP.Land/Resources/ChangeLog.html +++ b/MP.Land/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo gestione Programmi MAPO -

      Versione: 6.16.2310.1615

      +

      Versione: 6.16.2311.1009


      Note di rilascio:
        diff --git a/MP.Land/Resources/VersNum.txt b/MP.Land/Resources/VersNum.txt index 1dd72699..cf39a0ed 100644 --- a/MP.Land/Resources/VersNum.txt +++ b/MP.Land/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2310.1615 +6.16.2311.1009 diff --git a/MP.Land/Resources/manifest.xml b/MP.Land/Resources/manifest.xml index fd7a9843..e09e8ed5 100644 --- a/MP.Land/Resources/manifest.xml +++ b/MP.Land/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2310.1615 + 6.16.2311.1009 https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/MP.Land.zip https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/ChangeLog.html false diff --git a/MP.Mon/MP.Mon.csproj b/MP.Mon/MP.Mon.csproj index 6a6c7d78..da0d3b9d 100644 --- a/MP.Mon/MP.Mon.csproj +++ b/MP.Mon/MP.Mon.csproj @@ -4,7 +4,7 @@ net6.0 enable enable - 6.16.2309.2613 + 6.16.2311.1009 diff --git a/MP.Mon/Resources/ChangeLog.html b/MP.Mon/Resources/ChangeLog.html index b01f63a6..84b1ad62 100644 --- a/MP.Mon/Resources/ChangeLog.html +++ b/MP.Mon/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MON MAPO -

        Versione: 6.16.2309.2613

        +

        Versione: 6.16.2311.1009


        Note di rilascio:
        • diff --git a/MP.Mon/Resources/VersNum.txt b/MP.Mon/Resources/VersNum.txt index 1ab5b9e0..cf39a0ed 100644 --- a/MP.Mon/Resources/VersNum.txt +++ b/MP.Mon/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2309.2613 +6.16.2311.1009 diff --git a/MP.Mon/Resources/manifest.xml b/MP.Mon/Resources/manifest.xml index 0848489c..7f9f2b8b 100644 --- a/MP.Mon/Resources/manifest.xml +++ b/MP.Mon/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2309.2613 + 6.16.2311.1009 https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/MP.Mon.zip https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/ChangeLog.html false diff --git a/MP.Prog/MP.Prog.csproj b/MP.Prog/MP.Prog.csproj index b14be2a3..b174b88b 100644 --- a/MP.Prog/MP.Prog.csproj +++ b/MP.Prog/MP.Prog.csproj @@ -3,7 +3,7 @@ net6.0 MP.Prog - 6.16.2304.0419 + 6.16.2311.1009 diff --git a/MP.Prog/Resources/ChangeLog.html b/MP.Prog/Resources/ChangeLog.html index efe63704..2076f49f 100644 --- a/MP.Prog/Resources/ChangeLog.html +++ b/MP.Prog/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo gestione Programmi MAPO -

          Versione: 6.16.2304.0419

          +

          Versione: 6.16.2311.1009


          Note di rilascio:
            diff --git a/MP.Prog/Resources/VersNum.txt b/MP.Prog/Resources/VersNum.txt index 4bc5312b..cf39a0ed 100644 --- a/MP.Prog/Resources/VersNum.txt +++ b/MP.Prog/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2306.0612 +6.16.2311.1009 diff --git a/MP.Prog/Resources/manifest.xml b/MP.Prog/Resources/manifest.xml index 1ffe0627..c58eb5ec 100644 --- a/MP.Prog/Resources/manifest.xml +++ b/MP.Prog/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2304.0419 + 6.16.2311.1009 https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/MP.Prog.zip https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/ChangeLog.html false diff --git a/MP.SPEC/Components/FLStatusList.razor b/MP.SPEC/Components/FLStatusList.razor new file mode 100644 index 00000000..ac7918be --- /dev/null +++ b/MP.SPEC/Components/FLStatusList.razor @@ -0,0 +1,40 @@ +@if (isProcessing) +{ + +} +else +{ +
@@ -78,9 +78,9 @@ else
- TC: @($"{item.Tcassegnato:N2}") + TC: @($"{item.Tcassegnato:N2}") (min)
- @TCMinSec(item.Tcassegnato) (min:sec) + @TCMinSec(item.Tcassegnato)
diff --git a/MP-TAB-SERV/Components/ProdPlanMan.razor.cs b/MP-TAB-SERV/Components/ProdPlanMan.razor.cs index 8cd2cf11..9c7a4962 100644 --- a/MP-TAB-SERV/Components/ProdPlanMan.razor.cs +++ b/MP-TAB-SERV/Components/ProdPlanMan.razor.cs @@ -93,7 +93,14 @@ namespace MP_TAB_SERV.Components if (fatto) { TimeSpan ts = TimeSpan.FromMinutes(TC); - TC_MinSec = $"{ts.TotalMinutes}:{ts.Seconds:00}"; + if (ts.TotalHours > 1) + { + TC_MinSec = $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00} (h:m:s)"; + } + else + { + TC_MinSec = $"{ts.Minutes:00}:{ts.Seconds:00} (m:s)"; + } } } return TC_MinSec; diff --git a/MP-TAB-SERV/Components/ProdStat.razor b/MP-TAB-SERV/Components/ProdStat.razor index 53ccb6ae..e425aa5e 100644 --- a/MP-TAB-SERV/Components/ProdStat.razor +++ b/MP-TAB-SERV/Components/ProdStat.razor @@ -1,130 +1,215 @@ -
-
-

- -

-
-
+ +
+
+ Statistiche di produzione +
+
+ @if (RecMSE != null) + { + @($"ODL: {RecMSE.IdxOdl}") + } +
+
+ +
+
+
+
+ Data di inizio +
+
@if (RecMSE != null) { -
-
- @($"ODL num: {RecMSE.IdxOdl}, iniziato {RecMSE.DataInizioOdl:ddd yyyy.MM.dd, HH:mm}") -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @* - - - - - *@ -
- Cod articolo - - Nr pezzi lanciati - - Nr pezzi confermati - - Nr pezzi fatti -
- @RecMSE.CodArticolo - - @($"{RecMSE.NumPezzi:N0}") pz. - - @RecMSE.PezziConf pz. - - (@($"{RecMSE.PezziProd:N0}") pz.) -
- Efficienza Globale - - Efficienza Lavoro - - Efficienza Teorica -
-
- @RecMSE.OEE_tot -
- (@RecMSE.OEE_RT_tot) -
-
- @RecMSE.OEE_wrk -
- (@RecMSE.OEE_RT_wrk) -
-
- @RecMSE.OEE_run -
- (@RecMSE.OEE_RT_run) -
- Tc Medio - - Tc Lavoro - - Tc Tecnico - - Tc impostato -
-
- @($"{RecMSE.TCMedio:0.###}") -
- (@($"{RecMSE.TCMedioRt:0.###}")) -
-
- @($"{RecMSE.TCLav:0.###}") -
- (@($"{RecMSE.TCLavRT:0.###}")) -
-
- @($"{RecMSE.TCEff:0.###}") -
- (@($"{RecMSE.TCEffRT:0.###}")) -
-
- @($"{RecMSE.TCAssegnato:0.###}") -
-
- + @($"{RecMSE.DataInizioOdl:yyyy/MM/dd}") }
+
+ @if (RecMSE != null) + { + @($"{RecMSE.DataInizioOdl:HH: mm}") + } +
+
+
+
+
+
+ Cod Articolo +
+
+ @RecMSE.CodArticolo +
+
+
+
+
+
+
+
+ Nr Pezzi lanciati +
+
+ @($"{RecMSE.NumPezzi:N0}") pz. +
+
+
+
+
+
+
+
+ Nr Pezzi confermati +
+
+ @($"{RecMSE.PezziConf}") pz. +
+
+
+ + + + + + + + + + + + + + +
+
+
+
+ Nr pezzi fatti +
+
+ (@($"{RecMSE.PezziProd:N0}") pz.) +
+
+
+
+
+
+
+
+ Efficienza globale +
+
+ @RecMSE.OEE_tot +
+
+ + (@RecMSE.OEE_RT_tot) + +
+
+
+
+
+
+ Efficienza lavoro +
+
+ @RecMSE.OEE_wrk +
+
+ + (@RecMSE.OEE_RT_wrk) + +
+
+
+
+
+
+ Efficienza teorica +
+
+ @RecMSE.OEE_run +
+
+ + (@RecMSE.OEE_RT_run) + +
+
+
+
+ + + + + + + + + +
+
+
+
+ Tc medio +
+
+ + @($"{RecMSE.TCMedio:0.###}") + +
+
+ + (@($"{RecMSE.TCMedioRt:0.###}")) + +
+
+
+
+
+
+ Tc lavoro +
+
+ @($"{RecMSE.TCLav:0.###}") +
+
+ + (@($"{RecMSE.TCLavRT:0.###}")) + +
+
+
+
+
+
+ Tc tecnico +
+
+ @($"{RecMSE.TCEff:0.###}") +
+
+ + (@($"{RecMSE.TCEffRT:0.###}")) + +
+
+
+
+
+
+ Tc impostato +
+
+ @($"{RecMSE.TCAssegnato:0.###}") +
+
+
+
+
+
\ No newline at end of file diff --git a/MP-TAB-SERV/Components/ProdStopMan.razor b/MP-TAB-SERV/Components/ProdStopMan.razor index c03861f1..fc8b18af 100644 --- a/MP-TAB-SERV/Components/ProdStopMan.razor +++ b/MP-TAB-SERV/Components/ProdStopMan.razor @@ -1,10 +1,12 @@ -
-
-
- -
- \ No newline at end of file diff --git a/MP-TAB-SERV/Components/ScrapEditor.razor b/MP-TAB-SERV/Components/ScrapEditor.razor index b064ca35..14b63d93 100644 --- a/MP-TAB-SERV/Components/ScrapEditor.razor +++ b/MP-TAB-SERV/Components/ScrapEditor.razor @@ -1,39 +1,53 @@ -
-
+
+
-
@if (ShowDetail) { -
+
-
+
- Data Ora - + Num Pz + +
-
- +
+
+ Data Ora + + +
- - + +
- @if (CanSave) - { - - } +
+ @foreach (var item in ListComplete) + { +
+ + + + +
+ } +
diff --git a/MP-TAB-SERV/Components/ScrapEditor.razor.cs b/MP-TAB-SERV/Components/ScrapEditor.razor.cs index bf5f0bb8..14d2d7e7 100644 --- a/MP-TAB-SERV/Components/ScrapEditor.razor.cs +++ b/MP-TAB-SERV/Components/ScrapEditor.razor.cs @@ -1,25 +1,7 @@ -using global::System; -using global::System.Collections.Generic; -using global::System.Linq; -using global::System.Threading.Tasks; -using global::Microsoft.AspNetCore.Components; -using System.Net.Http; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Components.Authorization; -using Microsoft.AspNetCore.Components.Forms; -using Microsoft.AspNetCore.Components.Routing; -using Microsoft.AspNetCore.Components.Web; -using Microsoft.AspNetCore.Components.Web.Virtualization; -using Microsoft.JSInterop; -using MP_TAB_SERV; -using MP_TAB_SERV.Shared; -using MP_TAB_SERV.Components; +using global::Microsoft.AspNetCore.Components; using MP.Data; using MP.Data.DatabaseModels; -using MP.Data.DTO; using MP.Data.Services; -using Newtonsoft.Json; -using NLog; namespace MP_TAB_SERV.Components { @@ -27,39 +9,12 @@ namespace MP_TAB_SERV.Components { #region Public Properties - [Parameter] - public bool CanSave { get; set; } = false; - - [Parameter] - public EventCallback E_CommRec { get; set; } - - [Parameter] - public EventCallback E_DateSel { get; set; } - [Parameter] public EventCallback E_Updated { get; set; } [Parameter] public MappaStatoExpl? RecMSE { get; set; } = null; - protected string Title - { - get => ShowDetail? "Nascondi Registrazione Scarti": "Mostra Registrazione Scarti"; - } - [Parameter] - public EventListModel? CurrRecord - { - set - { - if (value != null) - { - DateSel = value.InizioStato ?? DateTime.Now; - UserComment = value.Value; - ShowDetail = false; - } - } - } - #endregion Public Properties #region Protected Properties @@ -72,20 +27,38 @@ namespace MP_TAB_SERV.Components if (dateSel != value) { dateSel = value; - E_DateSel.InvokeAsync(value).ConfigureAwait(false); } } } + protected List ListComplete { get; set; } = new List(); + [Inject] protected MessageService MServ { get; set; } = null!; + protected int NumPz + { + get => numPz; + set + { + if (numPz != value) + { + numPz = value; + } + } + } + [Inject] protected SharedMemService SMServ { get; set; } = null!; [Inject] protected TabDataService TabServ { get; set; } = null!; + protected string Title + { + get => ShowDetail ? "Nascondi Registrazione Scarti" : "Mostra Registrazione Scarti"; + } + #endregion Protected Properties #region Protected Methods @@ -95,83 +68,45 @@ namespace MP_TAB_SERV.Components DoReset(); } - /// - /// Forza salvataggio impostando data-ora - /// - /// - /// - public async Task ForceSave(DateTime dtRif) + protected async Task doSave(vSelCauScartoModel currCau) { - DateSel = dtRif; - // ora salvo - await doSave(); - } - - protected async Task doSave() - { - // registro evento - EventListModel newRec = new EventListModel() + // registro scarto + RegistroScartiModel newRec = new RegistroScartiModel() { IdxMacchina = IdxMacc, - InizioStato = DateSel, - IdxTipo = idxTipoCommento, - CodArticolo = CodArt, - Value = UserComment, + DataOra = DateSel, + Causale = currCau.value, + Qta = NumPz, MatrOpr = MatrOpr, - pallet = "-" + Note = UserComment }; - // elimino vecchio se c'è... - await TabServ.EvListDelete(IdxMacc, DateSel, idxTipoCommento); // inserisco - await TabServ.EvListInsert(newRec, MP.Data.Objects.Enums.tipoInputEvento.commento); + await TabServ.RegScartiInsert(newRec); + // reset DoReset(); //ToggleCtrl(); await E_Updated.InvokeAsync(true); } - protected override void OnInitialized() + protected override async Task OnInitializedAsync() { - idxTipoCommento = SMServ.GetConfInt("idxTipoCommento"); - dltMinRealtime = SMServ.GetConfInt("dltMinRealtime"); + await ReloadData(); } - protected override async Task OnAfterRenderAsync(bool firstRender) + protected async Task ReloadData() { - // verifico SE ci sia una data da usare... - bool hasDtRif = await MServ.SessHasVal(MessageService.KeyCommDtRif); - if (hasDtRif) - { - await Task.Delay(1); - ShowDetail = false; - UserComment = await MServ.CommentoValGet(true); - DateSel = await MServ.CommentoDtRifGet(true); - await InvokeAsync(StateHasChanged); - } + ListComplete = await TabServ.VSCS_getAll(); } - - protected int dltMinRealtime = 1; - /// - /// Determina se insert sia Realtime o batch con DataOra (in base a diff tra DataOra - /// selezionata e realtime, se superiore ad X minuti NON � realtime) - /// - protected bool insRealtime + protected void resetDate() { - get - { - bool answ = true; - try - { - if (Math.Abs(DateSel.Subtract(DateTime.Now).TotalMinutes) > dltMinRealtime) - { - answ = false; - } - } - catch - { } - return answ; - } + DateSel = DateTime.Now; + } + + protected void resetNumPz() + { + NumPz = 1; } protected void ToggleCtrl() @@ -185,12 +120,6 @@ namespace MP_TAB_SERV.Components #endregion Protected Methods - #region Private Fields - - private int idxTipoCommento = 0; - - #endregion Private Fields - #region Private Properties private string CodArt @@ -210,7 +139,10 @@ namespace MP_TAB_SERV.Components get => MServ.MatrOpr; } + private int numPz { get; set; } = 1; + private bool ShowDetail { get; set; } = true; + private string userComment { get; set; } = ""; private string UserComment @@ -221,7 +153,6 @@ namespace MP_TAB_SERV.Components if (userComment != value) { userComment = value; - E_CommRec.InvokeAsync(value).ConfigureAwait(false); } } } diff --git a/MP-TAB-SERV/Components/ScrapMan.razor b/MP-TAB-SERV/Components/ScrapMan.razor index 08297ecd..9d18452a 100644 --- a/MP-TAB-SERV/Components/ScrapMan.razor +++ b/MP-TAB-SERV/Components/ScrapMan.razor @@ -1,5 +1,4 @@  -
@@ -20,46 +19,16 @@ } else { - +
+ +
} -
-
- - @if (showInsert) - { - @if (showNote) - { -
-
-
- @*
-
*@ - - -
-
-
- -
-
- } - else - { -
-
- -
-
- -
-
- } - } +
+
+
-
+
@@ -67,7 +36,7 @@ else
- Elenco Controlli + Registro Scarti
Articolo InformazioniTCicloNoteImpiantoPeriodo
@@ -81,8 +77,6 @@ Fine: @item.DataFine
-
+ + + + + + + + + + + @foreach (var item in ListPaged) + { + + + + + + + + } + +
MacchinaKeyQty#/gg#/h
+ @item.IdxMacchina + + @item.CodFlux + + @($"{item.Qty:N0}") + + @($"{((float)item.Qty / numDay):N1}") + + @($"{((float)item.Qty / numHour):N2}") +
+} diff --git a/MP.SPEC/Components/FLStatusList.razor.cs b/MP.SPEC/Components/FLStatusList.razor.cs new file mode 100644 index 00000000..f25e8b8c --- /dev/null +++ b/MP.SPEC/Components/FLStatusList.razor.cs @@ -0,0 +1,162 @@ +using global::Microsoft.AspNetCore.Components; +using MP.Data.DTO; +using MP.SPEC.Data; +using NLog; +using static EgwCoreLib.Utils.DtUtils; + +namespace MP.SPEC.Components +{ + public partial class FLStatusList + { + #region Public Properties + + [Parameter] + public Periodo CurrPeriodo { get; set; } = new Periodo(); + + [Parameter] + public EventCallback> E_FluxSel { get; set; } + + [Parameter] + public EventCallback E_TotalCount { get; set; } + [Parameter] + public EventCallback E_TotalRec { get; set; } + + [Parameter] + public string IdxMaccSel { get; set; } = ""; + + [Parameter] + public int NumRecPage { get; set; } + + [Parameter] + public int PageNum { get; set; } + + #endregion Public Properties + + #region Protected Properties + + protected List FluxList + { + get => fluxList; + set + { + fluxList = value; + E_FluxSel.InvokeAsync(value).ConfigureAwait(false); + } + } + + protected List ListComplete { get; set; } = new List(); + protected List ListPaged { get; set; } = new List(); + + [Inject] + protected MpDataService MDataServ { get; set; } = null!; + + protected int numDay + { + get + { + var numRaw = (int)CurrPeriodo.Fine.Subtract(CurrPeriodo.Inizio).TotalDays; + int answ = numRaw > 1 ? numRaw : 1; + return answ; + } + } + + protected int numHour + { + get + { + var numRaw = (int)CurrPeriodo.Fine.Subtract(CurrPeriodo.Inizio).TotalHours; + int answ = numRaw > 1 ? numRaw : 1; + return answ; + } + } + + protected int TotalCount + { + get => totalCount; + set + { + if (totalCount != value) + { + totalCount = value; + E_TotalCount.InvokeAsync(value).ConfigureAwait(false); + } + } + } + protected int TotalRecords + { + get => totRecords; + set + { + if (totRecords != value) + { + totRecords = value; + E_TotalRec.InvokeAsync(value).ConfigureAwait(false); + } + } + } + + #endregion Protected Properties + + #region Protected Methods + + protected override async Task OnParametersSetAsync() + { + await ReloadData(); + } + + /// + /// Aggiorno valori produzione alla data richiesta... + /// + /// + protected async Task ReloadData() + { + isProcessing = true; + await Task.Delay(1); + if (!string.IsNullOrEmpty(IdxMaccSel) && (!IdxMaccSel.Equals(idxMaccLast) || !CurrPeriodo.Equals(lastPeriodo))) + { + idxMaccLast = IdxMaccSel; + lastPeriodo = CurrPeriodo; + ListComplete = await MDataServ.ParetoFluxLog(IdxMaccSel, CurrPeriodo.Inizio, CurrPeriodo.Fine); + TotalCount = ListComplete.Count; + TotalRecords = ListComplete.Sum(x => x.Qty); + FluxList = ListComplete.Select(x => x.CodFlux).ToList(); + } + // esegue paginazione + UpdateTable(); + isProcessing = false; + await Task.Delay(1); + } + + protected void UpdateTable() + { + // esegue paginazione + if (TotalCount > NumRecPage) + { + ListPaged = ListComplete.Skip((PageNum - 1) * NumRecPage).Take(NumRecPage).ToList(); + } + else + { + ListPaged = ListComplete; + } + } + + #endregion Protected Methods + + #region Private Fields + + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + private string idxMaccLast = ""; + private bool isProcessing = false; + private int totalCount = 0; + private int totRecords = 0; + + #endregion Private Fields + + #region Private Properties + + private List fluxList { get; set; } = new List(); + private Periodo lastPeriodo { get; set; } = new Periodo(); + + #endregion Private Properties + } +} \ No newline at end of file diff --git a/MP.SPEC/Components/ODLPlot.razor b/MP.SPEC/Components/ODLPlot.razor index a304ea42..0dc85fef 100644 --- a/MP.SPEC/Components/ODLPlot.razor +++ b/MP.SPEC/Components/ODLPlot.razor @@ -3,7 +3,7 @@
@if (isLoading) { - + } else { diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index 9176fd47..509f488a 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -1,8 +1,10 @@ -using MP.Data; +using EgwCoreLib.Utils; +using MP.Data; using MP.Data.Conf; using MP.Data.DatabaseModels; using MP.Data.DTO; using MP.Data.MgModels; +using MP.Data.Objects; using Newtonsoft.Json; using NLog; using StackExchange.Redis; @@ -119,6 +121,40 @@ namespace MP.SPEC.Data return fatto; } + /// + /// Elenco Gruppi + /// + /// + public async Task> AnagKeyValGetAll() + { + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string source = "DB"; + List? result = new List(); + // cerco in redis... + RedisValue rawData = await redisDb.StringGetAsync(Utils.redisAKVKey); + if (!string.IsNullOrEmpty($"{rawData}")) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = await Task.FromResult(dbController.AnagKeyValGetAll()); + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(Utils.redisConfKey, rawData, getRandTOut(redisLongTimeCache)); + } + if (result == null) + { + result = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"AnagKeyValGetAll Read from {source}: {ts.TotalMilliseconds}ms"); + return result; + } + public async Task> AnagStatiComm() { Stopwatch stopWatch = new Stopwatch(); @@ -389,6 +425,25 @@ namespace MP.SPEC.Data await redisDb.StringSetAsync(Utils.redisConfKey, ""); } + /// + /// Restituisce valore della stringa (SE disponibile) + /// + /// + /// + public async Task ConfigTryGet(string keyName) + { + string answ = ""; + // preselezione valori + var configData = await ConfigGetAll(); + var currRec = configData.FirstOrDefault(x => x.Chiave == keyName); + if (currRec != null) + { + answ = currRec.Valore; + } + + return answ; + } + /// /// Update chiave config /// @@ -398,6 +453,27 @@ namespace MP.SPEC.Data return await Task.FromResult(dbController.ConfigUpdate(updRec)); } + /// + /// Restituisce le statistiche di DB maintenance eseguite + /// + /// + public Dictionary DbDedupStats() + { + Dictionary actStats = new Dictionary(); + string currKey = $"{Utils.redisStatsDbMaint}"; + // recupero i record statistiche correnti + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + var rawStats = JsonConvert.DeserializeObject>($"{rawData}"); + if (rawStats != null) + { + actStats = rawStats; + } + } + return actStats; + } + /// /// Dispose del connettore ai dati /// @@ -609,6 +685,15 @@ namespace MP.SPEC.Data return fatto; } + public async Task FlushCacheFluxLog() + { + bool answ = false; + RedisValue pattern = new RedisValue($"{Utils.redisParetoFLKey}:*"); + answ = await RedisFlushPatternAsync(pattern); + + return answ; + } + public async Task FlushRedisCache() { await Task.Delay(1); @@ -627,6 +712,25 @@ namespace MP.SPEC.Data return answ; } + /// + /// Funzione di Data Reduction x FluxLog + /// + /// Macchina + /// Elenco FL da processare + /// Periodo + /// modalità sel valore + /// intervallo di analisi + /// max num per intervallo + /// + public async Task FluxLogDataRedux(string idxMaccSel, List fluxList, DtUtils.Periodo currPeriodo, Enums.ValSelection valMode, Enums.DataInterval intReq, int maxItem) + { + List procStats = await dbController.FluxLogDataRedux(idxMaccSel, fluxList, currPeriodo, valMode, intReq, maxItem); + // effettuo merge statistiche... + ProcDedupStatMerge(procStats); + // svuoto cache + await FlushCacheFluxLog(); + } + public List FluxLogDtoGetByFlux(string Valore) { List answ = new List(); @@ -696,6 +800,27 @@ namespace MP.SPEC.Data return result; } + /// + /// Stored manutenzione del DB + /// + /// Esegue realmente il task + /// Aggiornamento statistiche + /// Salvataggio + /// def: 1000 + /// def: 10 + /// def: 50 + /// + public async Task ForceDbMaint(bool doExec = true, bool doUpdStat = true, bool doSave = true, int minPgCnt = 1000, int minAvgFrag = 10, int maxAvgFragReb = 50) + { + Stopwatch sw = Stopwatch.StartNew(); + await dbController.ForceDbMaint(doExec, doUpdStat, doSave, minPgCnt, minAvgFrag, maxAvgFragReb); + sw.Stop(); + // registro statistiche esecuzione + RecDbMaintStat(sw.Elapsed); + // svuoto cache + await FlushCacheFluxLog(); + } + /// /// Init ricetta /// @@ -1123,6 +1248,41 @@ namespace MP.SPEC.Data return result; } + /// + /// Elenco Gruppi + /// + /// + public async Task> ParetoFluxLog(string idxMacchina, DateTime dtFrom, DateTime dtTo) + { + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string source = "DB"; + List? result = new List(); + // cerco in redis... + string redKey = $"{Utils.redisParetoFLKey}:{idxMacchina}:{dtFrom:yyyyMMdd}:{dtTo:yyyyMMdd}"; + RedisValue rawData = await redisDb.StringGetAsync(redKey); + if (!string.IsNullOrEmpty($"{rawData}")) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = await Task.FromResult(dbController.ParetoFluxLog(idxMacchina, dtFrom, dtTo)); + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(redKey, rawData, getRandTOut(redisLongTimeCache)); + } + if (result == null) + { + result = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"ParetoFluxLog Read from {source}: {ts.TotalMilliseconds}ms"); + return result; + } + /// /// Eliminazione record selezionato /// @@ -1317,6 +1477,27 @@ namespace MP.SPEC.Data return dbResult; } + /// + /// Restituisce le statistiche di processo correnti x depluplica FluxLog + /// + /// + public List ProcFLStats() + { + List actStats = new List(); + string currKey = $"{Utils.redisStatsProcFL}"; + // recupero i record statistiche correnti + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + var rawStats = JsonConvert.DeserializeObject>($"{rawData}"); + if (rawStats != null) + { + actStats = rawStats; + } + } + return actStats; + } + /// /// Ricerca ricetta su MongoDB dato PODL /// @@ -1511,25 +1692,6 @@ namespace MP.SPEC.Data return answ; } - /// - /// Restituisce valore della stringa (SE disponibile) - /// - /// - /// - public async Task ConfigTryGet(string keyName) - { - string answ = ""; - // preselezione valori - var configData = await ConfigGetAll(); - var currRec = configData.FirstOrDefault(x => x.Chiave == keyName); - if (currRec != null) - { - answ = currRec.Valore; - } - - return answ; - } - public async Task updateDossierValue(DossierModel currDoss, FluxLogDTO editFL) { bool answ = false; @@ -1631,6 +1793,68 @@ namespace MP.SPEC.Data return TimeSpan.FromMinutes(rndValue); } + /// + /// Merge statistiche Dedup + /// + /// + /// + protected bool ProcDedupStatMerge(List procStats) + { + bool answ = false; + List actStats = ProcFLStats(); + // se fosse vuoto --> add diretto + if (actStats.Count == 0) + { + actStats.AddRange(procStats); + } + else + { + // aggiorno su redis i record statistiche 1:1... + foreach (var recStat in procStats) + { + // cerco se ci fosse x aggiornare + var currRec = actStats.Where(x => x.IdxMacchina == recStat.IdxMacchina + && x.CodFlux == recStat.CodFlux + && x.Interval == recStat.Interval + && x.Num4Int == recStat.Num4Int).FirstOrDefault(); + // se trovato aggiorno + if (currRec != null) + { + currRec.ProcTime += recStat.ProcTime; + currRec.NumRec += recStat.NumRec; + } + // altrimenti aggiungo + else + { + actStats.Add(recStat); + } + } + } + // salvo record statistiche + var rawData = JsonConvert.SerializeObject(actStats); + string currKey = $"{Utils.redisStatsProcFL}"; + redisDb.StringSet(currKey, rawData); + return answ; + } + + /// + /// Merge statistiche DB Maintenance + /// + /// + /// + protected bool RecDbMaintStat(TimeSpan duration) + { + bool answ = false; + Dictionary actStats = DbDedupStats(); + // aggiungo record! + actStats.Add(DateTime.Now, duration.TotalSeconds); + // salvo NUOVO record statistiche + string currKey = $"{Utils.redisStatsDbMaint}"; + var rawData = JsonConvert.SerializeObject(actStats); + redisDb.StringSet(currKey, rawData); + return answ; + } + #endregion Protected Methods #region Private Fields diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index 5c7a8ef1..f3196714 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 6.16.2310.411 + 6.16.2310.2609 @@ -39,7 +39,8 @@ - + + diff --git a/MP.SPEC/Pages/DOSS.razor b/MP.SPEC/Pages/DOSS.razor index edbc2926..5bbd452b 100644 --- a/MP.SPEC/Pages/DOSS.razor +++ b/MP.SPEC/Pages/DOSS.razor @@ -9,7 +9,7 @@
@if (isFiltering) { - + filtro x macchina / periodo } else diff --git a/MP.SPEC/Pages/FluxLogStatus.razor b/MP.SPEC/Pages/FluxLogStatus.razor new file mode 100644 index 00000000..8a81ea96 --- /dev/null +++ b/MP.SPEC/Pages/FluxLogStatus.razor @@ -0,0 +1,98 @@ +@page "/FluxLogStatus" +
+
+
+
+

Status

+
+
+
+ Macc + +
+
+
+ +
+
+
+
+ + @if (isProcessing) + { + + + } + else if (isReindexing) + { + + } + else + { + + + } +
+ +
\ No newline at end of file diff --git a/MP.SPEC/Pages/FluxLogStatus.razor.cs b/MP.SPEC/Pages/FluxLogStatus.razor.cs new file mode 100644 index 00000000..54fa4511 --- /dev/null +++ b/MP.SPEC/Pages/FluxLogStatus.razor.cs @@ -0,0 +1,278 @@ +using global::Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MP.Data.Objects; +using MP.SPEC.Data; +using NLog; +using System.Diagnostics; +using static EgwCoreLib.Utils.DtUtils; + +namespace MP.SPEC.Pages +{ + public partial class FluxLogStatus + { + #region Protected Fields + + protected double currVal = 0; + protected Enums.DataInterval IntReq = Enums.DataInterval.hour; + protected double nextVal = 0; + protected int numRecPage = 10; + protected int pageNum = 1; + protected int totalCount = 0; + protected int totRecords = 0; + + protected Enums.ValSelection ValMode = Enums.ValSelection.First; + + #endregion Protected Fields + + #region Protected Properties + + protected Dictionary actDbMaintStats { get; set; } = new Dictionary(); + protected List actProcDedupStats { get; set; } = new List(); + protected List fluxList { get; set; } = new List(); + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + protected Dictionary ListMacchineAll { get; set; } = new Dictionary(); + + protected int MaxVal + { + get => fluxList.Count; + } + + [Inject] + protected MpDataService MDataServ { get; set; } = null!; + + protected int NumItem + { + get => numItem; + set + { + if (numItem != value) + { + // controllo valori ammissibili + numItem = value >= 1 ? value : 1; + // aggiorno tempi + updateExpTime(); + } + } + } + + protected string strDbMaintTimeExp { get; set; } = "-"; + protected string strPrTimeExp { get; set; } = "-"; + + #endregion Protected Properties + + #region Protected Methods + + /// + /// Esegue cleanup dati + /// + /// + protected async Task DoCleanup() + { + if (!await JSRuntime.InvokeAsync("confirm", "Attenzione! il task di Data Cleanup eliminerà in modo definitivo i dati in eccesso secondo lo schema impostato, sei sicuro di voler procedere?")) + return; + + isProcessing = true; + lastDedupExecTime = "..."; + Stopwatch sw = Stopwatch.StartNew(); + int currStep = 1; + int stepVal = 1; + foreach (var item in fluxList) + { + // aggiorno valori + currVal = (currStep - 1) * stepVal; + nextVal = currStep * stepVal; + await InvokeAsync(StateHasChanged); + // processo i flussi 1:1 x mandare update ad avanzamento + await MDataServ.FluxLogDataRedux(idxMaccSel, new List { item }, CurrPeriodo, ValMode, IntReq, NumItem); + currStep++; + } + //await MDataServ.FluxLogDataRedux(idxMaccSel, fluxList, CurrPeriodo, ValMode, IntReq, maxItem); + sw.Stop(); + lastDedupExecTime = $"{sw.Elapsed.Minutes}m {sw.Elapsed.Seconds}s"; + isProcessing = false; + } + + /// + /// Esegue cleanup dati + /// + /// + protected async Task IdxRebuild() + { + if (!await JSRuntime.InvokeAsync("confirm", "Manutenzione Database: si tratta di un operazione che può richiedere un tempo levato sei sicuro di voler procedere?")) + return; + + isReindexing = true; + Stopwatch sw = Stopwatch.StartNew(); + lastDbMaintTime = "..."; + await InvokeAsync(StateHasChanged); + await MDataServ.ForceDbMaint(true, true, true, 1000, 10, 50); + sw.Stop(); + lastDbMaintTime = $"{sw.Elapsed.Minutes}m {sw.Elapsed.Seconds}s"; + isReindexing = false; + } + + protected override async Task OnInitializedAsync() + { + ReloadStats(); + await ReloadData(); + } + + protected async Task ReloadMacchine() + { + if (ListMacchineAll == null || ListMacchineAll.Count == 0) + { + var rawData = await MDataServ.MacchineGetFilt("*"); + // trasformo! + if (rawData != null) + { + ListMacchineAll = rawData.ToDictionary(x => x.IdxMacchina, x => $"{x.IdxMacchina} | {x.Nome}"); + } + } + } + + protected async Task SaveFluxList(List newList) + { + fluxList = newList; + await Task.Delay(1); + } + + protected void SaveNumRec(int newNum) + { + if (numRecPage != newNum) + { + numRecPage = newNum; + } + } + + protected void SavePage(int newNum) + { + if (pageNum != newNum) + { + pageNum = newNum; + } + } + + protected async Task SetPeriodo(Periodo newPeriodo) + { + if (!CurrPeriodo.Equals(newPeriodo)) + { + CurrPeriodo = newPeriodo; + } + await Task.Delay(1); + } + + protected async Task SetTotCount(int numRec) + { + totalCount = numRec; + await Task.Delay(1); + } + + protected async Task SetTotRec(int numRec) + { + totRecords = numRec; + await Task.Delay(1); + updateExpTime(); + } + + #endregion Protected Methods + + #region Private Fields + + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + /// + /// Tempo atteso processing + /// - da calcolare in base al num eventi e alla tab logProcessing... + /// + private int expTimeMsec = 3000; + + private string lastDbMaintTime = ""; + private string lastDedupExecTime = ""; + + #endregion Private Fields + + #region Private Properties + + private Periodo CurrPeriodo { get; set; } = new Periodo(); + + private string idxMaccSel { get; set; } = ""; + + private bool isProcessing { get; set; } = false; + + private bool isReindexing { get; set; } = false; + + private double msProcEst { get; set; } = 0.2; + + private int numItem { get; set; } = 1; + + #endregion Private Properties + + #region Private Methods + + private async Task ReloadData() + { + await ReloadMacchine(); + DateTime dtEnd = DateTime.Today.AddDays(1); + DateTime dtStart = dtEnd.AddMonths(-1); + CurrPeriodo = new Periodo(dtStart, dtEnd); + } + + private void ReloadStats() + { + actProcDedupStats = MDataServ.ProcFLStats(); + actDbMaintStats = MDataServ.DbDedupStats(); + } + + private void updateExpTime() + { + // calcolo tempo stimato e mostro... + double msProcEst = 0.15 * numItem; + // recupero statistiche x tipoInt e num eventi... + var calcStats = actProcDedupStats.Where(x => x.Interval == IntReq && x.Num4Int == numItem); + //var calcStats = actStats.Where(x => x.IdxMacchina == idxMaccSel && x.Interval == IntReq && x.Num4Int == numItem); + if (calcStats != null && calcStats.Count() > 0) + { + var totSec = calcStats.Sum(x => x.ProcTime); + var totalRec = calcStats.Sum(x => x.NumRec); + msProcEst = totSec * 1000 / (totalRec > 1 ? totalRec : 1); + } + int numFlux = fluxList.Count > 1 ? fluxList.Count : 1; + expTimeMsec = (int)Math.Ceiling(msProcEst * totRecords / numFlux); + strPrTimeExp = "-"; + if (totRecords > 0) + { + var TotalTime = TimeSpan.FromMilliseconds(msProcEst * totRecords); + if (TotalTime.TotalMinutes > 60) + { + strPrTimeExp = $"{TotalTime.Hours}h {TotalTime.Minutes}m"; + } + else + { + strPrTimeExp = $"{TotalTime.Minutes}m {TotalTime.Seconds}s"; + } + } + // ora sistemo le statistiche DB maintenance + double estimDbMaintSec = 150; + var dbTotSec = actDbMaintStats.Sum(x => x.Value); + var dbNumItem = actDbMaintStats.Count(); + if (dbNumItem > 0) + { + estimDbMaintSec = dbTotSec / dbNumItem; + } + var TotalTimeDb = TimeSpan.FromSeconds(estimDbMaintSec); + if (TotalTimeDb.TotalMinutes > 60) + { + strDbMaintTimeExp = $"{TotalTimeDb.Hours}h {TotalTimeDb.Minutes}m"; + } + else + { + strDbMaintTimeExp = $"{TotalTimeDb.Minutes}m {TotalTimeDb.Seconds}s"; + } + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP.SPEC/Pages/Giacenze.razor b/MP.SPEC/Pages/Giacenze.razor index 6405b8bb..7970bc22 100644 --- a/MP.SPEC/Pages/Giacenze.razor +++ b/MP.SPEC/Pages/Giacenze.razor @@ -14,7 +14,7 @@ else
@if (odlExp == null) { - + } else { diff --git a/MP.SPEC/Pages/PARAMS.razor b/MP.SPEC/Pages/PARAMS.razor index b7f55739..ef91f391 100644 --- a/MP.SPEC/Pages/PARAMS.razor +++ b/MP.SPEC/Pages/PARAMS.razor @@ -9,7 +9,7 @@
@if (isFiltering) { - + } else { diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index 9d10fe0a..4dc4e658 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2310.411

+

Versione: 6.16.2310.2609


Note di rilascio:
  • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index e1d45667..2468fb4d 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2310.411 +6.16.2310.2609 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index e89e8d38..78903994 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2310.411 + 6.16.2310.2609 https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html false diff --git a/MP.SPEC/Shared/NavMenu.razor b/MP.SPEC/Shared/NavMenu.razor index f0496859..1bee2d32 100644 --- a/MP.SPEC/Shared/NavMenu.razor +++ b/MP.SPEC/Shared/NavMenu.razor @@ -32,7 +32,7 @@
@if (ElencoLink == null) { - + } else { diff --git a/MP.SPEC/_Imports.razor b/MP.SPEC/_Imports.razor index 944f4f17..fe303e7b 100644 --- a/MP.SPEC/_Imports.razor +++ b/MP.SPEC/_Imports.razor @@ -6,7 +6,8 @@ @using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.Web.Virtualization @using Microsoft.JSInterop +@using MP.Data.Objects @using MP.SPEC @using MP.SPEC.Shared @using MP.SPEC.Components -@using EgwCoreLib.Razor +@using EgwCoreLib.Razor \ No newline at end of file diff --git a/MP.SPEC/wwwroot/images/LogoEgw.png b/MP.SPEC/wwwroot/images/LogoEgw.png new file mode 100644 index 00000000..f65c23ca Binary files /dev/null and b/MP.SPEC/wwwroot/images/LogoEgw.png differ diff --git a/MP.Stats/MP.Stats.csproj b/MP.Stats/MP.Stats.csproj index 467d18d6..c653bf46 100644 --- a/MP.Stats/MP.Stats.csproj +++ b/MP.Stats/MP.Stats.csproj @@ -4,8 +4,8 @@ net6.0 MP.Stats 826e877c-ba70-4253-84cb-d0b1cafd4440 - 6.16.2307.0515 - 6.16.2307.0515 + 6.16.2311.1009 + 6.16.2311.1009 diff --git a/MP.Stats/Resources/ChangeLog.html b/MP.Stats/Resources/ChangeLog.html index 9c312fc0..fc337935 100644 --- a/MP.Stats/Resources/ChangeLog.html +++ b/MP.Stats/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo statistiche MAPO -

Versione: 6.16.2307.0515

+

Versione: 6.16.2311.1009


Note di rilascio:
    diff --git a/MP.Stats/Resources/VersNum.txt b/MP.Stats/Resources/VersNum.txt index b889c064..cf39a0ed 100644 --- a/MP.Stats/Resources/VersNum.txt +++ b/MP.Stats/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2307.0515 +6.16.2311.1009 diff --git a/MP.Stats/Resources/manifest.xml b/MP.Stats/Resources/manifest.xml index b31b6727..39ed393f 100644 --- a/MP.Stats/Resources/manifest.xml +++ b/MP.Stats/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2307.0515 + 6.16.2311.1009 https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/MP.Stats.zip https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/ChangeLog.html false diff --git a/images/macchine/FOV001.png b/images/macchine/FOV001.png new file mode 100644 index 00000000..4d2c5a3f Binary files /dev/null and b/images/macchine/FOV001.png differ diff --git a/images/macchine/FOV002.png b/images/macchine/FOV002.png new file mode 100644 index 00000000..1faecb4d Binary files /dev/null and b/images/macchine/FOV002.png differ diff --git a/images/macchine/FOV003.png b/images/macchine/FOV003.png new file mode 100644 index 00000000..3ca99784 Binary files /dev/null and b/images/macchine/FOV003.png differ diff --git a/images/macchine/FOV004.png b/images/macchine/FOV004.png new file mode 100644 index 00000000..0dd4dbd1 Binary files /dev/null and b/images/macchine/FOV004.png differ diff --git a/images/macchine/FOV005.png b/images/macchine/FOV005.png new file mode 100644 index 00000000..bfd8c5ab Binary files /dev/null and b/images/macchine/FOV005.png differ diff --git a/images/macchine/FOV006.png b/images/macchine/FOV006.png new file mode 100644 index 00000000..8ff117c3 Binary files /dev/null and b/images/macchine/FOV006.png differ diff --git a/images/macchine/FOV008.png b/images/macchine/FOV008.png new file mode 100644 index 00000000..209c974a Binary files /dev/null and b/images/macchine/FOV008.png differ diff --git a/images/macchine/FOV009.png b/images/macchine/FOV009.png new file mode 100644 index 00000000..65b9ba97 Binary files /dev/null and b/images/macchine/FOV009.png differ diff --git a/images/macchine/FOV010.png b/images/macchine/FOV010.png new file mode 100644 index 00000000..cd68c880 Binary files /dev/null and b/images/macchine/FOV010.png differ diff --git a/images/macchine/FOV011.png b/images/macchine/FOV011.png new file mode 100644 index 00000000..b4e9b24e Binary files /dev/null and b/images/macchine/FOV011.png differ diff --git a/images/macchine/FOV012.png b/images/macchine/FOV012.png new file mode 100644 index 00000000..1ccd635e Binary files /dev/null and b/images/macchine/FOV012.png differ diff --git a/images/macchine/FOV013.png b/images/macchine/FOV013.png new file mode 100644 index 00000000..acf63163 Binary files /dev/null and b/images/macchine/FOV013.png differ diff --git a/images/macchine/FOV014.png b/images/macchine/FOV014.png new file mode 100644 index 00000000..a88af15a Binary files /dev/null and b/images/macchine/FOV014.png differ diff --git a/images/macchine/FOV015.png b/images/macchine/FOV015.png new file mode 100644 index 00000000..5bf2369c Binary files /dev/null and b/images/macchine/FOV015.png differ diff --git a/images/macchine/FOV062.png b/images/macchine/FOV062.png new file mode 100644 index 00000000..850433f5 Binary files /dev/null and b/images/macchine/FOV062.png differ diff --git a/images/macchine/FOV090.png b/images/macchine/FOV090.png new file mode 100644 index 00000000..283367de Binary files /dev/null and b/images/macchine/FOV090.png differ diff --git a/images/macchine/Steamware.png b/images/macchine/Steamware.png new file mode 100644 index 00000000..1326fad9 Binary files /dev/null and b/images/macchine/Steamware.png differ diff --git a/images/macchine/small/FOV001.png b/images/macchine/small/FOV001.png new file mode 100644 index 00000000..3a931f02 Binary files /dev/null and b/images/macchine/small/FOV001.png differ diff --git a/images/macchine/small/FOV002.png b/images/macchine/small/FOV002.png new file mode 100644 index 00000000..37d8fa4a Binary files /dev/null and b/images/macchine/small/FOV002.png differ diff --git a/images/macchine/small/FOV003.png b/images/macchine/small/FOV003.png new file mode 100644 index 00000000..3e8246d3 Binary files /dev/null and b/images/macchine/small/FOV003.png differ diff --git a/images/macchine/small/FOV004.png b/images/macchine/small/FOV004.png new file mode 100644 index 00000000..b75da879 Binary files /dev/null and b/images/macchine/small/FOV004.png differ diff --git a/images/macchine/small/FOV005.png b/images/macchine/small/FOV005.png new file mode 100644 index 00000000..93a1e7be Binary files /dev/null and b/images/macchine/small/FOV005.png differ diff --git a/images/macchine/small/FOV006.png b/images/macchine/small/FOV006.png new file mode 100644 index 00000000..cf49c884 Binary files /dev/null and b/images/macchine/small/FOV006.png differ diff --git a/images/macchine/small/FOV008.png b/images/macchine/small/FOV008.png new file mode 100644 index 00000000..87f86786 Binary files /dev/null and b/images/macchine/small/FOV008.png differ diff --git a/images/macchine/small/FOV009.png b/images/macchine/small/FOV009.png new file mode 100644 index 00000000..f2759003 Binary files /dev/null and b/images/macchine/small/FOV009.png differ diff --git a/images/macchine/small/FOV010.png b/images/macchine/small/FOV010.png new file mode 100644 index 00000000..6096c034 Binary files /dev/null and b/images/macchine/small/FOV010.png differ diff --git a/images/macchine/small/FOV011.png b/images/macchine/small/FOV011.png new file mode 100644 index 00000000..6b298e43 Binary files /dev/null and b/images/macchine/small/FOV011.png differ diff --git a/images/macchine/small/FOV012.png b/images/macchine/small/FOV012.png new file mode 100644 index 00000000..62d2085a Binary files /dev/null and b/images/macchine/small/FOV012.png differ diff --git a/images/macchine/small/FOV013.png b/images/macchine/small/FOV013.png new file mode 100644 index 00000000..eb565d7e Binary files /dev/null and b/images/macchine/small/FOV013.png differ diff --git a/images/macchine/small/FOV014.png b/images/macchine/small/FOV014.png new file mode 100644 index 00000000..0a83502d Binary files /dev/null and b/images/macchine/small/FOV014.png differ diff --git a/images/macchine/small/FOV015.png b/images/macchine/small/FOV015.png new file mode 100644 index 00000000..593e29ae Binary files /dev/null and b/images/macchine/small/FOV015.png differ diff --git a/images/macchine/small/FOV062.png b/images/macchine/small/FOV062.png new file mode 100644 index 00000000..02397935 Binary files /dev/null and b/images/macchine/small/FOV062.png differ diff --git a/images/macchine/small/FOV090.png b/images/macchine/small/FOV090.png new file mode 100644 index 00000000..2ff8b044 Binary files /dev/null and b/images/macchine/small/FOV090.png differ diff --git a/images/macchine/small/Steamware.png b/images/macchine/small/Steamware.png new file mode 100644 index 00000000..572efa5c Binary files /dev/null and b/images/macchine/small/Steamware.png differ