diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 783b7936..72610636 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -699,6 +699,28 @@ INVE:installer: - *hashBuild - *nexusUpload +TAB3:installer: + stage: installer + tags: + - win + variables: + APP_NAME: MP-TAB-SERV + SOL_NAME: MP-TAB3 + NEXUS_PATH: MP-TAB3 + before_script: + - *nuget-fix + - dotnet restore "$env:SOL_NAME.sln" + rules: + - if: $CI_COMMIT_BRANCH == 'master' + - if: $CI_COMMIT_BRANCH == 'develop' + needs: ["TAB3:build"] + script: + - dotnet build $env:APP_NAME/$env:APP_NAME.csproj + - dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release $env:APP_NAME/$env:APP_NAME.csproj -o:publish -p:verbosity=quiet + # qui il deploy su nexus... + - *hashBuild + - *nexusUpload + # CONF:installer: # stage: installer # tags: diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..e051a0d8 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "cweijan.dbclient-jdbc" + ] +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/CheckControls.razor b/MP-TAB-SERV/Components/CheckControls.razor new file mode 100644 index 00000000..c839d79a --- /dev/null +++ b/MP-TAB-SERV/Components/CheckControls.razor @@ -0,0 +1,8 @@ +@if (ShowInsFermata) +{ + +} +@if (ShowReqControls) +{ + +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/CheckControls.razor.cs b/MP-TAB-SERV/Components/CheckControls.razor.cs new file mode 100644 index 00000000..0019ed32 --- /dev/null +++ b/MP-TAB-SERV/Components/CheckControls.razor.cs @@ -0,0 +1,136 @@ +using Microsoft.AspNetCore.Components; +using MP.Data.DatabaseModels; +using MP.Data.Services; +using MP_TAB_SERV.Shared; + +namespace MP_TAB_SERV.Components +{ + public partial class CheckControls + { + #region Public Properties + + [Parameter] + public MappaStatoExpl? RecMSE { get; set; } = null; + + #endregion Public Properties + + #region Protected Properties + + /// + /// Determina se dato lo stato dell'impianto si debba mostrare btn fermata perché + /// - fermo > xx min (da web.config, es 20') + /// - impianto fermo (controllando idxStato: priorità > 1) + /// + protected bool CheckShowInsFermata + { + get + { + bool answ = false; + int idxStato = 0; + double durata = 0; + int durMinWarning = SMServ.GetConfInt("durMinWarning"); + if (RecMSE != null) + { + idxStato = RecMSE.IdxStato ?? 0; + durata = RecMSE.Durata ?? 0; + if (durata >= durMinWarning) + { + try + { + // in questo caso controllo idxStato... e recupero priorità se > 1 --> + // richiesta qualifica + answ = SMServ.GetStateRow(idxStato).Priorita > 1; + } + catch + { } + } + } + return answ; + } + } + + /// + /// Verifica necessità visualizzare il check controlli + /// + protected async Task CheckShowReqControls() + { + bool answ = false; + if (RecMSE != null) + { + // SE abilitata gestione controlli... + bool enableCtrl = SMServ.GetConfBool("enableControlli"); + if (enableCtrl) + { + int intervalloControlli = SMServ.GetConfInt("intervalloControlli"); + // cerco ultimo controllo fatto + DateTime lastControl = DateTime.Now.AddYears(-1); + try + { + var tabCtrls = await TabDServ.RegControlliLast(RecMSE.IdxMacchina); + if (tabCtrls != null && tabCtrls.Count > 0) + { + var thisRec = tabCtrls.FirstOrDefault(); + if (thisRec != null) + { + lastControl = thisRec.DataOra; + if (Math.Abs(DateTime.Now.Subtract(lastControl).TotalMinutes) >= intervalloControlli) + { + answ = true; + } + } + } + } + catch + { } + } + } + return answ; + } + + [Inject] + protected NavigationManager NavMan { get; set; } = null!; + + protected bool ShowInsFermata { get; set; } = false; + + protected bool ShowReqControls { get; set; } = false; + + [Inject] + protected SharedMemService SMServ { get; set; } = null!; + + [Inject] + protected TabDataService TabDServ { get; set; } = null!; + + protected DateTime lastCheck = DateTime.Today; + protected string lastIdxMacc = ""; + #endregion Protected Properties + + #region Protected Methods + + protected void GoToControls() + { + NavMan.NavigateTo("controls"); + } + + protected void GoToFermate() + { + NavMan.NavigateTo("prod-stop"); + } + + protected override async Task OnParametersSetAsync() + { + if (RecMSE != null) + { + DateTime adesso = DateTime.Now; + if (adesso.Subtract(lastCheck).TotalSeconds > 15 || lastIdxMacc != RecMSE.IdxMacchina) + { + ShowInsFermata = CheckShowInsFermata; + ShowReqControls = await CheckShowReqControls(); + lastIdxMacc = RecMSE.IdxMacchina; + lastCheck = adesso; + } + } + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/CheckControls.razor.css b/MP-TAB-SERV/Components/CheckControls.razor.css new file mode 100644 index 00000000..a7a1bb2c --- /dev/null +++ b/MP-TAB-SERV/Components/CheckControls.razor.css @@ -0,0 +1,63 @@ +.flashingPurple { + animation-duration: 0.75s; + animation-timing-function: steps(2); + animation-iteration-count: infinite; + animation-direction: alternate; + animation-play-state: running; + animation-name: flsBlue; + transform: translateZ(0); +} +@keyframes flsBlue { + from { + color: #ffc107; + background-color: #7623c8; + /*border: 5px solid #dc3545;*/ + } + to { + color: #FFF; + background-color: #00b1ec; + /*border: 5px solid #ffc107;*/ + } +} +.flashingRed { + animation-duration: 0.75s; + animation-timing-function: steps(2); + animation-iteration-count: infinite; + animation-direction: alternate; + animation-play-state: running; + animation-name: flsRed; + transform: translateZ(0); +} +@keyframes flsRed { + from { + color: #ffc107; + background-color: #c82332; + /*border: 5px solid #dc3545;*/ + } + to { + color: #FFF; + background-color: #ecb100; + /*border: 5px solid #ffc107;*/ + } +} +.flashingBlue { + animation-duration: 0.75s; + animation-timing-function: steps(2); + animation-iteration-count: infinite; + animation-direction: alternate; + animation-play-state: running; + animation-name: flsBlue; + transform: translateZ(0); +} +@keyframes flsBlue { + from { + color: #ffc107; + background-color: #2323c8; + /*border: 5px solid #dc3545;*/ + } + to { + color: #FFF; + background-color: #00b1ec; + /*border: 5px solid #ffc107;*/ + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/CheckControls.razor.less b/MP-TAB-SERV/Components/CheckControls.razor.less new file mode 100644 index 00000000..92d27830 --- /dev/null +++ b/MP-TAB-SERV/Components/CheckControls.razor.less @@ -0,0 +1,71 @@ + +.flashingPurple { + animation-duration: 0.75s; + animation-timing-function: steps(2); + animation-iteration-count: infinite; + animation-direction: alternate; + animation-play-state: running; + animation-name: flsBlue; + transform: translateZ(0); +} + +@keyframes flsBlue { + from { + color: #ffc107; + background-color: #7623c8; + /*border: 5px solid #dc3545;*/ + } + + to { + color: #FFF; + background-color: #00b1ec; + /*border: 5px solid #ffc107;*/ + } +} +.flashingRed { + animation-duration: 0.75s; + animation-timing-function: steps(2); + animation-iteration-count: infinite; + animation-direction: alternate; + animation-play-state: running; + animation-name: flsRed; + transform: translateZ(0); +} + +@keyframes flsRed { + from { + color: #ffc107; + background-color: #c82332; + /*border: 5px solid #dc3545;*/ + } + + to { + color: #FFF; + background-color: #ecb100; + /*border: 5px solid #ffc107;*/ + } +} + +.flashingBlue { + animation-duration: 0.75s; + animation-timing-function: steps(2); + animation-iteration-count: infinite; + animation-direction: alternate; + animation-play-state: running; + animation-name: flsBlue; + transform: translateZ(0); +} + +@keyframes flsBlue { + from { + color: #ffc107; + background-color: #2323c8; + /*border: 5px solid #dc3545;*/ + } + + to { + color: #FFF; + background-color: #00b1ec; + /*border: 5px solid #ffc107;*/ + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/CheckControls.razor.min.css b/MP-TAB-SERV/Components/CheckControls.razor.min.css new file mode 100644 index 00000000..71fb7b6d --- /dev/null +++ b/MP-TAB-SERV/Components/CheckControls.razor.min.css @@ -0,0 +1 @@ +.flashingPurple{animation-duration:.75s;animation-timing-function:steps(2);animation-iteration-count:infinite;animation-direction:alternate;animation-play-state:running;animation-name:flsBlue;transform:translateZ(0);}@keyframes flsBlue{from{color:#ffc107;background-color:#7623c8;}to{color:#fff;background-color:#00b1ec;}}.flashingRed{animation-duration:.75s;animation-timing-function:steps(2);animation-iteration-count:infinite;animation-direction:alternate;animation-play-state:running;animation-name:flsRed;transform:translateZ(0);}@keyframes flsRed{from{color:#ffc107;background-color:#c82332;}to{color:#fff;background-color:#ecb100;}}.flashingBlue{animation-duration:.75s;animation-timing-function:steps(2);animation-iteration-count:infinite;animation-direction:alternate;animation-play-state:running;animation-name:flsBlue;transform:translateZ(0);}@keyframes flsBlue{from{color:#ffc107;background-color:#2323c8;}to{color:#fff;background-color:#00b1ec;}} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/CmpFooter.razor b/MP-TAB-SERV/Components/CmpFooter.razor index a2a15e70..f9c7b5a6 100644 --- a/MP-TAB-SERV/Components/CmpFooter.razor +++ b/MP-TAB-SERV/Components/CmpFooter.razor @@ -1,9 +1,23 @@ -
-
- MP-TAB2 @(DateTime.Today.Year) | v.@version +
+
+ MP-TAB2 @(DateTime.Today.Year) v.@version
-
- @($"{DateTime.Now:HH:mm:ss}") | Egalware +
+ @if (typeScadLogin > 0) + { + @if (CurrExpVal < 0) + { +
TIMER SCADUTO!
+ } + else + { + + } + } + +
+
+ @($"{DateTime.Now:HH:mm:ss}") | Egalware
diff --git a/MP-TAB-SERV/Components/CmpFooter.razor.cs b/MP-TAB-SERV/Components/CmpFooter.razor.cs index da0756bb..9dea76d4 100644 --- a/MP-TAB-SERV/Components/CmpFooter.razor.cs +++ b/MP-TAB-SERV/Components/CmpFooter.razor.cs @@ -6,13 +6,6 @@ namespace MP_TAB_SERV.Components { public partial class CmpFooter : IDisposable { - [Inject] - protected SharedMemService SMServ { get; set; } = null!; - [Inject] - protected MessageService MsgServ { get; set; } = null!; - [Inject] - protected NavigationManager NavMan { get; set; } = null!; - #region Public Methods public void Dispose() @@ -25,26 +18,47 @@ namespace MP_TAB_SERV.Components } } + public double CurrExpVal { get; set; } = 50; + public double MaxExpVal { get; set; } = 100; + public double yLimit { get; set; } = 30; + public double rLimit { get; set; } = 10; + + public string timeUm + { + get + { + string answ = "m"; + if (CurrExpVal > 60) + { + answ = "h"; + } + else if (CurrExpVal > 1440) + { + answ = "gg"; + } + return answ; + } + } + public void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e) { - var diffOfTime = DateTime.Now - MsgServ.dtLastAction; var pUpd = Task.Run(async () => + { + if (typeScadLogin > 0) { - await Task.Delay(1); - await InvokeAsync(() => StateHasChanged()); - if(diffOfTime.Minutes >= dtTimerScadenzaLogin) - { - NavMan.NavigateTo("logout"); - } - //Log.Trace("CmpFooter Timer elapsed"); - }); + var diffOfTime = DateTime.Now.Subtract(MsgServ.dtLastAction); + CurrExpVal = MaxExpVal - diffOfTime.TotalMinutes; + + } + await InvokeAsync(() => StateHasChanged()); + }); pUpd.Wait(); } public void StartTimer() { - int tOutPeriod = dtTimerScadenzaLogin * 60000; + int tOutPeriod = 1000; aTimer = new System.Timers.Timer(tOutPeriod); aTimer.Elapsed += ElapsedTimer; aTimer.Enabled = true; @@ -53,37 +67,51 @@ namespace MP_TAB_SERV.Components #endregion Public Methods + #region Protected Properties + + protected int dtScadLogin { get; set; } = 0; + + [Inject] + protected MessageService MsgServ { get; set; } = null!; + + [Inject] + protected NavigationManager NavMan { get; set; } = null!; + + [Inject] + protected SharedMemService SMServ { get; set; } = null!; + + #endregion Protected Properties + #region Protected Methods - int dtTimerScadenzaLogin { get; set; } = 0; - + protected int typeScadLogin { get; set; } = 0; protected override async Task OnInitializedAsync() { await Task.Delay(1); var rawVers = typeof(Program).Assembly.GetName().Version; version = rawVers != null ? rawVers : new Version("0.0.0.0"); - //dtTimerScadenzaLogin = SMServ.GetConfInt("TAB_dtTimerScadLogin"); - //dtTimerScadenzaLogin = SMServ.GetConfInt("TAB_dtTimerScadLogin"); - - //if (dtTimerScadenzaLogin > 0) - //{ - // //StartTimer(); - //} - + typeScadLogin = SMServ.GetConfInt("TAB_TypeScadLogin"); + dtScadLogin = SMServ.GetConfInt("TAB_dtTimerScadLogin"); + MaxExpVal = dtScadLogin; + yLimit = MaxExpVal * 0.3; + rLimit = MaxExpVal * 0.1; + StartTimer(); } - //protected override void OnInitialized() - //{ - - //} #endregion Protected Methods #region Private Fields - private System.Timers.Timer aTimer = null!; private static Logger Log = LogManager.GetCurrentClassLogger(); + private System.Timers.Timer aTimer = null!; private Version version = null!; #endregion Private Fields + + #region Private Properties + + private int dtTimerScadenzaLogin { get; set; } = 0; + + #endregion Private Properties } } \ No newline at end of file diff --git a/MP-TAB-SERV/Components/CmpTop.razor b/MP-TAB-SERV/Components/CmpTop.razor index bde404e3..d9c9f8af 100644 --- a/MP-TAB-SERV/Components/CmpTop.razor +++ b/MP-TAB-SERV/Components/CmpTop.razor @@ -1,17 +1,18 @@ 
-
- +
+
- @UserName - - [@MatrOpr] +
+
+
@UserName
+ @MatrOpr +
-
-
-   +
+
+ MapoTAB2 -   - +
diff --git a/MP-TAB-SERV/Components/CmpTop.razor.cs b/MP-TAB-SERV/Components/CmpTop.razor.cs index 8f465e08..3f0abd3b 100644 --- a/MP-TAB-SERV/Components/CmpTop.razor.cs +++ b/MP-TAB-SERV/Components/CmpTop.razor.cs @@ -15,6 +15,8 @@ namespace MP_TAB_SERV.Components [Parameter] public List CurrMenuItems { get; set; } = new List(); + [Parameter] + public EventCallback EA_UserIsOk { get; set; } #endregion Public Properties @@ -27,12 +29,13 @@ namespace MP_TAB_SERV.Components #region Protected Properties protected string CurrOprTknLS { get; set; } = null!; + //protected Guid CurrDevGuid { get; set; } protected string LastOpenedPage { get; set; } = null!; protected string CurrMacc { get; set; } = null!; protected string CurrOprTknRedis { get; set; } = null!; - protected DateTime expDT { get; set; } = DateTime.Now; + protected int expLoginType { get; set; } = 0; protected bool HideMenu { @@ -63,7 +66,15 @@ namespace MP_TAB_SERV.Components protected async Task RefreshLogIn(string decodValue) { - bool done = await MsgServ.DoLogIn(decodValue); + bool done = false; + if (expLoginType == 0) + { + done = await MsgServ.DoLogIn(decodValue, false); + } + else + { + done = await MsgServ.DoLogIn(decodValue, true); + } if (done) { if (!string.IsNullOrEmpty(LastOpenedPage) && !string.IsNullOrEmpty(CurrMacc)) @@ -84,7 +95,7 @@ namespace MP_TAB_SERV.Components Log.Info("Start ForceReload"); ResetClass = "btn-warning"; await InvokeAsync(StateHasChanged); - var currToken = await MsgServ.GetCurrOperDtoAsync(); + var currToken = await MsgServ.GetCurrOperDtoLSAsync(); var lastOpr = await MsgServ.GetLastMatrOprAsync(); // reset cache varie await MsgServ.ClearLocalStor(); @@ -92,7 +103,7 @@ namespace MP_TAB_SERV.Components await MDataService.FlushCache(); // salvo di nuovo opr await MsgServ.SetLastMatrOprAsync(lastOpr); - await MsgServ.SetCurrOperDtoAsync(currToken); + await MsgServ.SetCurrOperDtoLSAsync(currToken); // reload MStor await ReloadMemStor(); // calcolo tempo esecuzione @@ -121,46 +132,49 @@ namespace MP_TAB_SERV.Components protected override async Task OnInitializedAsync() { await Task.Delay(1); - int expDays = SMServ.GetConfInt("cookieDayExpire"); - expDT = DateTime.Now.AddDays(expDays); + expLoginType = SMServ.GetConfInt("TAB_TypeScadLogin"); + var CurrDevGuid = await MsgServ.GetCurrDevGuidLSAsync(); - CurrOprTknLS = await MsgServ.GetCurrOperDtoAsync(); - LastOpenedPage = await MsgServ.LastOpenedPageGet(); - CurrMacc = await MsgServ.IdxMaccGet(); - var decodedUrl = Uri.UnescapeDataString(CurrOprTknLS); - - // verifico se non avessi dati operatore - //var diffOfTime = DateTime.Now - MsgServ.dtLastAction; - - //if (diffOfTime.Minutes >= 1) - //{ - // NavMan.NavigateTo("logout"); - //} - //else - if (MsgServ.RigaOper == null) + //if (string.IsNullOrEmpty(CurrDevGuid.ToString())) + if (CurrDevGuid == Guid.Empty) { - await RefreshLogIn(decodedUrl); + CurrDevGuid = Guid.NewGuid(); + await MsgServ.SetCurrDevGuidLSAsync(CurrDevGuid); } - CurrOprTknRedis = await TDService.OperatoreGetRedis(MatrOpr); + LastOpenedPage = await MsgServ.LastOpenedPageGet(); + CurrMacc = await MsgServ.IdxMaccGet(); + + CurrOprTknLS = await MsgServ.GetCurrOperDtoLSAsync(); + var decodedUrl = Uri.UnescapeDataString(CurrOprTknLS); + if (!string.IsNullOrEmpty(CurrOprTknLS)) + { + var decryptedData = MsgServ.DecryptData(CurrOprTknLS); + if (!string.IsNullOrEmpty(decryptedData)) + { + var oprObj = JsonConvert.DeserializeObject(decryptedData); + if (oprObj != null) + { + MsgServ.RigaOper = oprObj.currOpr; + } + } + } - if (CurrOprTknRedis == "") + CurrOprTknRedis = await TDService.OperatoreGetRedis(MatrOpr, CurrDevGuid); + + + if (string.IsNullOrEmpty(CurrOprTknRedis)) { if (!NavMan.Uri.Contains("reg-new-device")) { NavMan.NavigateTo("reg-new-device", true); } } - else if (CurrOprTknRedis != "") + else if (!string.IsNullOrEmpty(CurrOprTknRedis) && CurrOprTknRedis == CurrOprTknLS) { - //if (!NavMan.Uri.Contains("status-map")) - //{ - //} - //if (LastOpenedPage != "") - //{ - // NavMan.NavigateTo(LastOpenedPage, true); - //} + await RefreshLogIn(decodedUrl); + await EA_UserIsOk.InvokeAsync(true); } } diff --git a/MP-TAB-SERV/Components/ControlsMan.razor.cs b/MP-TAB-SERV/Components/ControlsMan.razor.cs index 83d548d4..d2f37dfd 100644 --- a/MP-TAB-SERV/Components/ControlsMan.razor.cs +++ b/MP-TAB-SERV/Components/ControlsMan.razor.cs @@ -10,6 +10,9 @@ namespace MP_TAB_SERV.Components { #region Public Properties + [Parameter] + public EventCallback E_Updated { get; set; } + [Parameter] public MappaStatoExpl? RecMSE { get; set; } = null; @@ -45,28 +48,28 @@ namespace MP_TAB_SERV.Components get => showInsert ? "Nascondi Controllo" : "Registra Controllo"; } + protected bool enableControlli { get; set; } = true; protected List ListComplete { get; set; } = new List(); protected List ListPaged { get; set; } = new List(); [Inject] protected MessageService MServ { get; set; } = null!; - [Inject] - protected TabDataService TabDServ { get; set; } = null!; [Inject] protected SharedMemService SMServ { get; set; } = null!; + [Inject] + protected TabDataService TabDServ { get; set; } = null!; + #endregion Protected Properties #region Protected Methods - protected bool enableControlli { get; set; } = true; protected override async Task OnInitializedAsync() { await Task.Delay(1); if (RecMSE != null) { - enableControlli = SMServ.GetConfBool("enableControlli"); IdxMaccSel = RecMSE.IdxMacchina; DateTime fine = DateTime.Today.AddDays(1); @@ -83,6 +86,7 @@ namespace MP_TAB_SERV.Components showInsert = false; showNote = false; await doUpdate(); + await E_Updated.InvokeAsync(false); isProcessing = false; } @@ -99,6 +103,7 @@ namespace MP_TAB_SERV.Components showInsert = false; showNote = false; await doUpdate(); + await E_Updated.InvokeAsync(true); isProcessing = false; } diff --git a/MP-TAB-SERV/Components/MachSel.razor.cs b/MP-TAB-SERV/Components/MachSel.razor.cs index b328ed09..2c154c7a 100644 --- a/MP-TAB-SERV/Components/MachSel.razor.cs +++ b/MP-TAB-SERV/Components/MachSel.razor.cs @@ -1,6 +1,7 @@ using global::Microsoft.AspNetCore.Components; using MP.Data.DatabaseModels; using MP.Data.Services; +using MP_TAB_SERV.Shared; using System; using System.Reflection.Metadata; @@ -28,43 +29,68 @@ namespace MP_TAB_SERV.Components if (idxMaccSel != value) { idxMaccSel = value; + MsgServ.UserPrefSet(idxMaccCurr, value); E_MachSel.InvokeAsync(value).ConfigureAwait(false); } } } private string idxMaccSel { get; set; } = ""; + [Inject] + protected MessageService MsgServ { get; set; } = null!; + protected Dictionary? ListMacchine { get; set; } = null; [Inject] - protected SharedMemService MServ { get; set; } = null!; + protected SharedMemService SMServ { get; set; } = null!; #endregion Protected Properties #region Protected Methods + protected string idxMaccCurr + { + get + { + string answ = ""; + if (RecMSE != null) + { + answ = RecMSE?.IdxMacchina ?? ""; + } + return answ; + } + } + protected override async Task OnParametersSetAsync() { // inizilamente riporto machcina corrente da MSE if (RecMSE != null) { // verifico se la macchina sia configurata tra le MSFD... - if (MServ.DictMacchMulti.ContainsKey(RecMSE?.IdxMacchina)) + if (SMServ.DictMacchMulti.ContainsKey(RecMSE.IdxMacchina)) { - isMulti = MServ.DictMacchMulti[RecMSE?.IdxMacchina] == 1; + isMulti = SMServ.DictMacchMulti[RecMSE.IdxMacchina] == 1; } if (isMulti) { var listMulti = await TDataService.VMSFDGetAll(); ListMacchine = listMulti - .Where(x => x.IdxMacchina.Contains($"{RecMSE?.IdxMacchina}#")) + .Where(x => x.IdxMacchina.Contains($"{RecMSE.IdxMacchina}#")) .ToDictionary(x => x.IdxMacchina, x => x.CodMaccArticolo); if (ListMacchine.Count > 0 && string.IsNullOrEmpty(idxMaccSel)) { - IdxMaccSel = ListMacchine.FirstOrDefault().Key; - //await E_MachSel.InvokeAsync(idxMaccSel); + // cerco se ho in storage la macchina selezionata... + var idxMSel = MsgServ.UserPrefGet(idxMaccCurr); + if (!string.IsNullOrEmpty(idxMSel)) + { + idxMaccSel = idxMSel; + } + else + { + IdxMaccSel = ListMacchine.FirstOrDefault().Key; + } } } } diff --git a/MP-TAB-SERV/Components/MachineBlock.razor.cs b/MP-TAB-SERV/Components/MachineBlock.razor.cs index 493cf73a..1cf8f397 100644 --- a/MP-TAB-SERV/Components/MachineBlock.razor.cs +++ b/MP-TAB-SERV/Components/MachineBlock.razor.cs @@ -1,5 +1,6 @@ using EgwCoreLib.Razor; using global::Microsoft.AspNetCore.Components; +using Microsoft.EntityFrameworkCore.SqlServer.Query.Internal; using Microsoft.JSInterop; using MP.Data.DatabaseModels; using MP.Data.Services; @@ -118,6 +119,11 @@ namespace MP_TAB_SERV.Components } } + /// + /// Dati produzioen rilevati + /// + protected StatoProdModel? datiProdAct { get; set; } = null; + [Inject] protected IJSRuntime JSRuntime { get; set; } = null!; @@ -127,6 +133,9 @@ namespace MP_TAB_SERV.Components [Inject] protected NavigationManager NavMan { get; set; } = null!; + [Inject] + protected StatusData SDService { get; set; } = null!; + [Inject] protected TabDataService TabDServ { get; set; } = null!; @@ -159,15 +168,9 @@ namespace MP_TAB_SERV.Components { imgBasePath = $"{Environment.CurrentDirectory}/images/"; } - - - + await Task.Delay(1); } - /// - /// Dati produzioen rilevati - /// - protected StatoProdModel? datiProdAct { get; set; } = null; protected override async Task OnParametersSetAsync() { DateTime adesso = DateTime.Now; @@ -175,7 +178,16 @@ namespace MP_TAB_SERV.Components // controllo SE avessi idxMacchSub --> rileggo! if (RecMSE != null) { - datiProdAct = await TabDServ.StatoProdMacchina(RecMSE.IdxMacchina, adesso); + if (SDService.MachNumPzGet(RecMSE.IdxMacchina) != RecMSE.NumPezzi) + { + datiProdAct = await TabDServ.StatoProdMacchina(RecMSE.IdxMacchina, adesso); + SDService.MachProdStSet(RecMSE.IdxMacchina, datiProdAct); + SDService.MachNumPzSet(RecMSE.IdxMacchina, RecMSE.NumPezzi); + } + else + { + datiProdAct = SDService.MachProdStGet(RecMSE.IdxMacchina); + } } if (!string.IsNullOrEmpty(IdxMacchSub) && RecMSE != null) { diff --git a/MP-TAB-SERV/Components/MseSampler.razor.cs b/MP-TAB-SERV/Components/MseSampler.razor.cs index 0f96ac5a..788802a9 100644 --- a/MP-TAB-SERV/Components/MseSampler.razor.cs +++ b/MP-TAB-SERV/Components/MseSampler.razor.cs @@ -57,7 +57,7 @@ namespace MP_TAB_SERV.Components } [Inject] - protected StatusData MDataService { get; set; } = null!; + protected StatusData SDService { get; set; } = null!; [Inject] protected MessageService MServ { get; set; } = null!; @@ -68,13 +68,19 @@ namespace MP_TAB_SERV.Components protected void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e) { - var pUpd = Task.Run(async () => - { - aTimer.Interval = fastRefreshMs; - await InvokeAsync(RefreshData); - //Log.Trace("MseSampler Timer elapsed"); - }); - pUpd.Wait(); + try + { + var pUpd = Task.Run(async () => + { + aTimer.Interval = fastRefreshMs; + await InvokeAsync(RefreshData); + }); + pUpd.Wait(); + } + catch (Exception exc) + { + Log.Error($"Eccezione durante MseSampler.ElapsedTimer{Environment.NewLine}{exc}"); + } } protected override void OnInitialized() @@ -107,7 +113,7 @@ namespace MP_TAB_SERV.Components private async Task RefreshData() { - List ListMSE = await MDataService.MseGetAll(); + List ListMSE = await SDService.MseGetAll(); await MServ.SaveMse(ListMSE); await E_Updated.InvokeAsync(ListMSE); } diff --git a/MP-TAB-SERV/Components/OdlMan.razor b/MP-TAB-SERV/Components/OdlMan.razor index b3ce4602..37d69700 100644 --- a/MP-TAB-SERV/Components/OdlMan.razor +++ b/MP-TAB-SERV/Components/OdlMan.razor @@ -225,17 +225,18 @@
- + + -
+
-
diff --git a/MP-TAB-SERV/Components/OdlMan.razor.cs b/MP-TAB-SERV/Components/OdlMan.razor.cs index 6d084393..b39e23e5 100644 --- a/MP-TAB-SERV/Components/OdlMan.razor.cs +++ b/MP-TAB-SERV/Components/OdlMan.razor.cs @@ -86,6 +86,7 @@ namespace MP_TAB_SERV.Components protected IJSRuntime JSRuntime { get; set; } = null!; protected List ListODL { get; set; } = new List(); + protected List ListODLAll { get; set; } = new List(); [Inject] protected MailService MailServ { get; set; } = null!; @@ -107,6 +108,23 @@ namespace MP_TAB_SERV.Components get => IdxOdl > 0; } + protected string SearchPodl + { + get => searchPodl; + set + { + if (searchPodl != value) + { + searchPodl = value; + var pUpd = Task.Run(async () => + { + await ReloadData(true); + }); + pUpd.Wait(); + } + } + } + protected bool ShowAll { get => showAll; @@ -130,6 +148,25 @@ namespace MP_TAB_SERV.Components [Inject] protected TabDataService TabDServ { get; set; } = null!; + /// + /// Verifica se la tavola SIA in fase di attrezzaggio, ovvero SE: + /// - sia un impianto MULTI (= con + tavole) + /// - sia già attrezzata + /// + protected bool tavHasOdl + { + get + { + bool answ = false; + // se è multi controllo + if (isMulti) + { + answ = !emptyOdlMacc; + } + return answ; + } + } + #endregion Protected Properties #region Protected Methods @@ -150,8 +187,15 @@ namespace MP_TAB_SERV.Components // 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); + // calcolo stato attrezzaggio, hard coded!!! + if (isMulti) + { + inAttr = (rigaStato.IdxStato == 2 && tavHasOdl); + } + else + { + inAttr = rigaStato.IdxStato == 2; + } // se in attr --> carico podlCurr... if (inAttr && RecMSE != null) { @@ -242,7 +286,7 @@ namespace MP_TAB_SERV.Components await advStep(currStep++); // cancella dati correnti ODL - DoRemoveCurrOdlData(); + DoRemoveCurrOdlData(false); await advStep(currStep++); } catch @@ -423,15 +467,15 @@ namespace MP_TAB_SERV.Components inAttr = false; IdxPOdlSel = 0; RecMSE = null; - await advStep(currStep++); // faccio refresh e riporto await RefreshData(); await CheckAttr(); + await advStep(currStep++); // chiudo update... isProcessing = false; - //await InvokeAsync(StateHasChanged); + await InvokeAsync(StateHasChanged); // qui rimando a pag principale... - NavMan.NavigateTo("status-map", true); + //NavMan.NavigateTo("status-map", true); } /// @@ -454,6 +498,18 @@ namespace MP_TAB_SERV.Components // preparo gestione progress display MaxVal = 11; int currStep = 0; + + if (isMulti) + { + try + { + StatoMacchineModel rigaStato = TabDServ.StatoMacchina(IdxMaccParent); + // controllo se NON SONO già in attrezzaggio... + inAttr = (rigaStato.IdxStato == 2); + } + catch + { } + } await advStep(currStep); isProcessing = true; DateTime adesso = DateTime.Now; @@ -493,13 +549,6 @@ namespace MP_TAB_SERV.Components } } await advStep(currStep++); -#if false - // se fosse multi cambio dati di promODL x successivo setup... - if (isMulti) - { - currPodl.IdxMacchina = IdxMaccSel; - } -#endif // fix idxmacchina selezionata (x ogni macchina, singola o multi...) currPodl.IdxMacchina = IdxMaccSel; // 2018.07.24 verifico se devo lavorare come ODL classico o come RPO (Richiesta / @@ -630,7 +679,7 @@ namespace MP_TAB_SERV.Components checkBtnStatus(); fixSplitBtn(false); // faccio refresh e riporto - await TabDServ.FlushCache("ODL"); + await TabDServ.FlushOdlCache(); IdxPOdlSel = 0; RecMSE = null; await RefreshData(); @@ -663,7 +712,19 @@ namespace MP_TAB_SERV.Components emailAdmDest = rawEmailDest.Split(',').ToList(); if (RecMSE != null) { - IdxMaccSel = RecMSE.IdxMacchina; + if (string.IsNullOrEmpty(IdxMaccSel)) + { + IdxMaccSel = RecMSE.IdxMacchina; + } + isMulti = SMServ.DictMacchMulti[RecMSE.IdxMacchina] == 1; + if (isMulti) + { + var idxMSel = MServ.UserPrefGet(IdxMaccSel); + if (!string.IsNullOrEmpty(idxMSel)) + { + IdxMaccSel = idxMSel; + } + } IdxMaccParent = getIdxMaccParent(); // verifica stato inAttr await CheckAttr(); @@ -672,12 +733,6 @@ namespace MP_TAB_SERV.Components 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?")) @@ -817,6 +872,11 @@ namespace MP_TAB_SERV.Components tcRichAttr = newTCRich; } + protected void SearchPodlReset() + { + SearchPodl = ""; + } + protected async Task SendFixEndSetup() { if (!await JSRuntime.InvokeAsync("confirm", $"Confermi invio FIX chiusura attrezzaggio ad impianto?")) @@ -879,6 +939,7 @@ namespace MP_TAB_SERV.Components IdxMaccSel = selIdxMacc; // recupero dati RecMSE = TabDServ.MseGetSub(IdxMaccParent, selIdxMacc, true); + await CheckAttr(); await ReloadData(true); await DoUpdate(); if (showOdlDetail || inAttr) @@ -933,6 +994,9 @@ namespace MP_TAB_SERV.Components private int gPeriodReopenOdlTav = 1; private string IdxMaccSel = ""; +#if false + private string IdxMaccSelLast = ""; +#endif private int idxPOdlSel = 0; @@ -964,6 +1028,7 @@ namespace MP_TAB_SERV.Components private int PzPallet = 1; + private string searchPodl = ""; private bool showAll = false; private bool showChkCloseOdlVal = false; @@ -972,7 +1037,6 @@ namespace MP_TAB_SERV.Components private bool showOdlProvv = false; private bool showReopenOdlTav = false; private bool showSplitOdlOnTav = false; - private decimal tcRichAttr = 1; #endregion Private Fields @@ -990,11 +1054,10 @@ namespace MP_TAB_SERV.Components private string cssDetailOdl { - get => IdxPOdlSel > 0 ? "bg-primary text-light" : "bg-warning"; + get => IdxPOdlSel > 0 ? "bg-info text-light" : "bg-warning"; } private ODLExpModel currOdl { get; set; } = new ODLExpModel(); - private PODLExpModel currPodl { get; set; } = new PODLExpModel(); /// @@ -1138,14 +1201,18 @@ namespace MP_TAB_SERV.Components { } // ora verifico SE E SOLO SE è ANCORA in attrezzaggio +#if false if (inAttr) { - // ora verifico SE ALTRA TAVOLA ha ODL... - if (dtChiusura.AddMinutes(gPeriodReopenOdlTav) > adesso) - { - answ = showReopenOdlTav; - } +#endif + // ora verifico SE ALTRA TAVOLA ha ODL... + if (dtChiusura.AddMinutes(gPeriodReopenOdlTav) > adesso) + { + answ = showReopenOdlTav; } +#if false + } +#endif } } return answ; @@ -1173,11 +1240,15 @@ namespace MP_TAB_SERV.Components // ora verifico SE ALTRA TAVOLA ha ODL... if (!emptyOdlAltraMacc) { +#if false // ora verifico SE E SOLO SE è ANCORA in attrezzaggio if (inAttr) { - answ = showSplitOdlOnTav; - } +#endif + answ = showSplitOdlOnTav; +#if false + } +#endif } } } @@ -1185,6 +1256,8 @@ namespace MP_TAB_SERV.Components } } + private decimal tcRichAttr { get; set; } = 1; + private string titleOdlDetail { get => IdxPOdlSel > 0 ? "Verifica parametri attrezzaggio NUOVO PODL" : inAttr ? "Parametri PODL in Attrezzaggio" : "Parametri ODL Corrente"; @@ -1206,6 +1279,17 @@ namespace MP_TAB_SERV.Components private void checkAll() { + if (string.IsNullOrEmpty(IdxMaccParent)) + { + if (isMulti) + { + IdxMaccParent = getIdxMaccParent(); + } + else + { + IdxMaccParent = IdxMaccSel; + } + } checkConfProd(); } @@ -1426,7 +1510,7 @@ namespace MP_TAB_SERV.Components /// /// Rimozione dati e parametri (TAB e su PLC) x ODL corrente /// - private void DoRemoveCurrOdlData() + private void DoRemoveCurrOdlData(bool nav2detail) { // invio task x end produzione... string setArtVal = "NO ART"; @@ -1453,8 +1537,11 @@ namespace MP_TAB_SERV.Components TabDServ.addTask4Machine(machine.IdxMacchinaSlave, taskType.setComm, setCommVal); } } - // rimando a pagina dettaglio... - NavMan.NavigateTo("machine-detail", true); + // se richiesto rimando a pagina dettaglio... + if (nav2detail) + { + NavMan.NavigateTo("machine-detail", true); + } } #if false @@ -1550,7 +1637,15 @@ namespace MP_TAB_SERV.Components } if (!string.IsNullOrEmpty(IdxMaccSel)) { - ListODL = await TabDServ.VSOdlGetUnused(IdxMaccParent, ShowAll, numDayOdl); + ListODLAll = await TabDServ.VSOdlGetUnused(IdxMaccParent, ShowAll, numDayOdl); + if (string.IsNullOrEmpty(SearchPodl)) + { + ListODL = ListODLAll; + } + else + { + ListODL = ListODLAll.Where(x => x.label.Contains(SearchPodl, StringComparison.InvariantCultureIgnoreCase) || x.value == 0).ToList(); + } Log.Trace($"found {ListODL.Count} rec"); if (forceReload) { @@ -1564,14 +1659,14 @@ namespace MP_TAB_SERV.Components // imposto tcRichAttr in base allo stato... if (odlOk) { - // prendo TCRich da ODL... - if (IdxOdl > 0) + // prendo TCRich da PODL... + if (IdxPOdlSel > 0) { - tcRichAttr = currOdl.TCRichAttr; + tcRichAttr = currPodl.Tcassegnato; } else { - tcRichAttr = currPodl.Tcassegnato; + tcRichAttr = currOdl.TCRichAttr; } } } diff --git a/MP-TAB-SERV/Components/PrintMag.razor b/MP-TAB-SERV/Components/PrintMag.razor index b86176d8..cc5f06db 100644 --- a/MP-TAB-SERV/Components/PrintMag.razor +++ b/MP-TAB-SERV/Components/PrintMag.razor @@ -1,12 +1,5 @@ 
- @*
- 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 d98992c6..a3252d8b 100644 --- a/MP-TAB-SERV/Components/ProdConfirm.razor +++ b/MP-TAB-SERV/Components/ProdConfirm.razor @@ -3,18 +3,17 @@
-
- -
+
+
@if (enableMagPrint) { -
+
} @if (odlOk) { -
+
@@ -30,7 +29,6 @@ @if (showInnov) { - @*class="d-flex justify-content-between"*@
@@ -80,11 +78,11 @@ } else if (showConfirm && lblPz2RecBuoni < 0 && chkPzBuoniNeg) { -
Pezzi buoni negativi!
+
Pezzi buoni negativi!
} else { -
Completare le modifiche!
+ Completare le modifiche! }
@@ -95,91 +93,87 @@
}
-
- Dati Globali ODL +
+ Dati Globali ODL
- -
- -
-
-
- [A] NUOVI Pz.Prod -
-
- @if (isProcessing) - { - - } - else - { - @numPzProdotti2Rec - } -
+
+
+
+ [A] NUOVI Pz.Prod +
+
+ @if (isProcessing) + { + + } + else + { + @numPzProdotti2Rec + }
-
-
-
- Pz Prodotti TOT [A+B+C] -
-
- @if (isProcessing) - { - - } - else - { - @numPzProdotti - } -
-
-
-
-
-
- [B] Scarti VERS. -
-
- @if (isProcessing) - { - - } - else - { - @numPzScaConf - } -
-
-
-
-
-
- [C] Pz Buoni VERS. -
-
- @if (isProcessing) - { - - } - else - { - @numPzBuoniConf - } -
-
-
- -
-
+
+
+
+ Pz Prodotti TOT [A+B+C] +
+
+ @if (isProcessing) + { + + } + else + { + @numPzProdotti + } +
+
+
+
+
+
+ [B] Scarti VERS. +
+
+ @if (isProcessing) + { + + } + else + { + @numPzScaConf + } +
+
+
+
+
+
+ [C] Pz Buoni VERS. +
+
+ @if (isProcessing) + { + + } + else + { + @numPzBuoniConf + } +
+
+
+
+ @if (!string.IsNullOrEmpty(lblOut)) { diff --git a/MP-TAB-SERV/Components/ProdConfirm.razor.cs b/MP-TAB-SERV/Components/ProdConfirm.razor.cs index 50763870..b2e7cc9c 100644 --- a/MP-TAB-SERV/Components/ProdConfirm.razor.cs +++ b/MP-TAB-SERV/Components/ProdConfirm.razor.cs @@ -82,7 +82,7 @@ namespace MP_TAB_SERV.Components protected StatusData MDataService { get; set; } = null!; [Inject] - protected MessageService MServ { get; set; } = null!; + protected MessageService MsgServ { get; set; } = null!; protected int numPz2Rec { get; set; } = 0; @@ -151,18 +151,37 @@ namespace MP_TAB_SERV.Components await Task.Delay(1); } - protected override async Task OnInitializedAsync() + protected override void OnInitialized() + { + enablePzProdLasciati = SMServ.GetConfBool("enablePzProdLasciati"); + chkPzBuoniNeg = SMServ.GetConfBool("TAB_ChkConfPz"); + confRett = SMServ.GetConfBool("confRett"); + enableMagPrint = SMServ.GetConfBool("enableMagPrint"); + modoConfProd = SMServ.GetConfInt("modoConfProd"); + } + + protected override async Task OnParametersSetAsync() { lblOut = ""; numPzLasciati = 0; - if (RecMSE != null) + if (RecMSE != null && string.IsNullOrEmpty(IdxMaccSel)) { + // verifico SE fosse doppia... + bool isMulti = false; + // verifico se la macchina sia configurata tra le MSFD... + if (SMServ.DictMacchMulti.ContainsKey(RecMSE.IdxMacchina)) + { + isMulti = SMServ.DictMacchMulti[RecMSE.IdxMacchina] == 1; + } IdxMaccSel = RecMSE.IdxMacchina; - enablePzProdLasciati = SMServ.GetConfBool("enablePzProdLasciati"); - chkPzBuoniNeg = SMServ.GetConfBool("TAB_ChkConfPz"); - confRett = SMServ.GetConfBool("confRett"); - enableMagPrint = SMServ.GetConfBool("enableMagPrint"); - modoConfProd = SMServ.GetConfInt("modoConfProd"); + if (isMulti) + { + var idxMSel = MsgServ.UserPrefGet(IdxMaccSel); + if (!string.IsNullOrEmpty(idxMSel)) + { + IdxMaccSel = idxMSel; + } + } await DoUpdate(); } } @@ -170,9 +189,9 @@ namespace MP_TAB_SERV.Components protected async Task SalvaConfPz() { isProcessing = true; - await Task.Delay(1); // effettua conferma con conf da DB del tipo (giorni / turni / periodo bool fatto = effettuaConfermaProd(); + await TabDServ.FlushCache("StatoProd"); // refresh tabella dati tablet... await TabDServ.RicalcMse(IdxMaccSel, 0); // rileggo e salvo.. @@ -180,7 +199,7 @@ namespace MP_TAB_SERV.Components if (ListMSE != null) { // salvo in LocalStorage... - await MServ.SaveMse(ListMSE); + await MsgServ.SaveMse(ListMSE); // aggiorno MSE attuale RecMSE = ListMSE.Find(x => x.IdxMacchina == IdxMaccSel); } @@ -188,8 +207,6 @@ namespace MP_TAB_SERV.Components lblOut = $"Confermata produzione {numPzConfermati - numPzLasciati} pezzi (+{numPzLasciati} pz lasciati, +{numPzScarto2Rec} pz scarto) |{dtReqUpdate:HH:mm:ss} | {dtReqUpdate:ddd yyyy.MM.dd}"; // cambio button conferma... showInnov = false; - // sollevo evento! - //dtReqUpdate = DateTime.Now; numPzLasciati = 0; await DoUpdate(); await Task.Delay(1); @@ -250,7 +267,7 @@ namespace MP_TAB_SERV.Components private int MatrOpr { - get => MServ.MatrOpr; + get => MsgServ.MatrOpr; } private int numPzLasc { get; set; } = 0; @@ -285,451 +302,12 @@ namespace MP_TAB_SERV.Components private async Task RefreshData() { List ListMSE = await MDataService.MseGetAll(true); - await MServ.SaveMse(ListMSE); + await MsgServ.SaveMse(ListMSE); await E_Updated.InvokeAsync(ListMSE); } #endregion Private Methods -#if false - /// - /// restituisce css disabled SE odl NON OK... - /// - public string cssBtnConf - { - get - { - return odlOk ? "" : "disabled"; - } - } - - /// - /// Data-Ora ultimo update valori produzione - /// - public DateTime dtReqUpdate - { - get - { - DateTime answ = DateTime.Now; - DateTime.TryParse(hfDtReqUpdate.Value, out answ); - return answ; - } - set - { - hfDtReqUpdate.Value = $"{value}"; - } - } - - protected DateTime dtFine - { - set - { - lblFine.Text = value.ToString(); - } - } - - /// - /// Numero pezzi PRODOTTI da ultima conferma - /// - protected DateTime dtInizio - { - set - { - lblInizio.Text = value.ToString(); - } - } - - /// - /// Numero pezzi PRODOTTI da ultima conferma - /// - protected int numPz2Rec - { - set - { - lblPz2RecTot.Text = value.ToString(); - } - } - - /// - /// Numero pezzi BUONI già confermati - /// - protected int numPzBuoniConf - { - set - { - lblPzConfBuoni.Text = value.ToString(); - } - } - - /// - /// Numero pezzi confermati (buoni - scarto) - /// - protected int numPzConfermati - { - get - { - return numPzProdotti2Rec - numPzScarto2Rec; - } - } - - /// - /// Numero pezzi da LASCIARE non dichiarati - /// - protected int numPzLasciati - { - set - { - txtNumLasciati.Text = value.ToString(); - } - get - { - int answ = 0; - try - { - answ = Convert.ToInt32(txtNumLasciati.Text); - } - catch - { } - return answ; - } - } - - /// - /// Numero pezzi PRODOTTI GLOBALI - /// - protected int numPzProdotti - { - set - { - lblPzTotODL.Text = value.ToString(); - } - } - - /// - /// Numero pezzi PRODOTTI da registrare - /// - /// da ultima conferma - protected int numPzProdotti2Rec - { - set - { - txtNumPezzi.Text = value.ToString(); - } - get - { - int answ = 0; - try - { - answ = Convert.ToInt32(txtNumPezzi.Text); - } - catch - { } - return answ; - } - } - - /// - /// Numero pezzi SCARTO già confermati - /// - protected int numPzScaConf - { - set - { - lblPzConfScarto.Text = value.ToString(); - } - } - - /// - /// Numero pezzi SCARTATI da registrare - /// - protected int numPzScarto2Rec - { - set - { - lblPz2RecScarto.Text = value.ToString(); - memLayer.ML.setSessionVal("lblPz2RecScarto", value); - } - get - { - int answ = 0; - try - { - answ = memLayer.ML.IntSessionObj("lblPz2RecScarto"); - } - catch - { } - return answ; - } - } - - protected void ddlSubMacc_DataBound(object sender, EventArgs e) - { - // se ho in memoria un valore LO REIMPOSTO... - if (!string.IsNullOrEmpty(subMaccSel)) - { - // se è una SUB machcina (contiene "#") - if (subMaccSel.Contains("#")) - { - // provo a preselezionare... - try - { - ddlSubMacc.SelectedValue = subMaccSel; - } - catch - { } - } - // altrimenti salvo! - else - { - subMaccSel = ddlSubMacc.SelectedValue; - } - } - } - - protected void ddlSubMacc_SelectedIndexChanged(object sender, EventArgs e) - { - subMaccSel = ddlSubMacc.SelectedValue; - // salvo ODL - DataLayerObj.taMSE.getByIdxMaccAndSub(idxMacchinaSel, subMaccSel); - //altri controlli - checkAll(); - } - - /// - /// salvo produzione - /// - /// - /// - protected void lbtSalva_Click(object sender, EventArgs e) - { - // effettua conferma con conf da DB del tipo (giorni / turni / periodo - bool fatto = effettuaConfermaProd(); - // refresh tabella dati tablet... - DataLayerObj.taMSE.forceRecalc(0, idxMacchinaSel); - // mostro output - lblOut.Text = string.Format("Confermata la produzione per {0} pezzi! (+{1} pz scarto) alle {2:yyyy-MM-dd HH:mm:ss}", numPzConfermati, numPzScarto2Rec, dtReqUpdate); - // cambio button conferma... - switchBtnConferma(!txtNumPezzi.Enabled); - // sollevo evento! - if (eh_newVal != null) - { - eh_newVal(this, new EventArgs()); - } - dtReqUpdate = DateTime.Now; - doUpdate(); - } - - /// - /// caricamento pagina - /// - /// - /// - protected void Page_Load(object sender, EventArgs e) - { - if (!Page.IsPostBack) - { - checkAll(); - if (isMulti) - { - // sollevo evento! - if (eh_reset != null) - { - eh_reset(this, new EventArgs()); - } - } - } - } - - /// - /// Update pz lasciati --> aggiorno! - /// - /// - /// - protected void txtNumLasciati_TextChanged(object sender, EventArgs e) - { - lblOut.Text = ""; - updatePzBuoni(); - } - - /// - /// update post modifica pz buoni - /// - /// - /// - protected void txtNumPezzi_TextChanged(object sender, EventArgs e) - { - lblOut.Text = ""; - updatePzBuoni(); - } - - /// - /// ODL correntemente sulla macchina - /// - cerca in Redis (TTL 5 sec) - /// - altrimenti recupera da DB... - /// - protected void updateOdl() - { - // userò ODL del turno - int answ = 0; - // cerco da redis... - int.TryParse(DataLayerObj.currODL(idxMacchinaSel, true), out answ); - // salvo! - idxOdl = answ; - } - - private void checkAll() - { - updateOdl(); - checkConfig(); - fixSelMacc(); - checkOdl(); - lblOut.Text = ""; - switchBtnConferma(false); - lbtShowConfProd.Visible = odlOk; - lblConfProd.Visible = !odlOk; - } - - /// - /// verifica config x modalità permesse - /// - private void checkConfig() - { - // verifico SE sia permesso gestire i "Pezzi lasciati" in macchina... - lblNumLasciati.Visible = enablePzProdLasciati; - txtNumLasciati.Visible = enablePzProdLasciati; - lblEmptyNumLasciati.Visible = !enablePzProdLasciati; - } - - /// - /// Verifica se abbia un ODL ATTIVO - /// - private void checkOdl() - { - lbtShowConfProd.Visible = odlOk; - lblConfProd.Visible = !odlOk; - lblMancaODL.Visible = !odlOk; - } - - /// - /// Registra conferma produzione in modalità nuova (con rettifica pezzi lasciati) o legacy - /// (con anticipo periodo) - /// - private bool effettuaConfermaProd() - { - bool fatto = false; - if (confRett) - { - // confermo al netto dei pezzi lasciati... - fatto = DataLayerObj.confermaProdMacchinaFull(idxMacchinaSel, memLayer.ML.CRI("modoConfProd"), numPzConfermati - numPzLasciati, numPzLasciati, numPzScarto2Rec, dtReqUpdate); - } - else - { - fatto = DataLayerObj.confermaProdMacchina(idxMacchinaSel, memLayer.ML.CRI("modoConfProd"), numPzConfermati, numPzScarto2Rec, dtReqUpdate); - } - return fatto; - } - - /// - /// Se la machcina è MULTI --> mostro selettore - /// - private void fixSelMacc() - { - divSelMacc.Visible = isMulti; - if (isMulti) - { - try - { - // salvo selezione submacc - ddlSubMacc.DataBind(); - subMaccSel = ddlSubMacc.SelectedValue; - } - catch - { } - } - updateOdl(); - } - - /// - /// Reset parametri x calcolo pezzi (no pezzi lasciati, dataora attuale...) - /// - private void resetParam() - { - dtReqUpdate = DateTime.Now; - numPzLasciati = 0; - } - - /// - /// determina comportamento btn conferma - /// - private void switchBtnConferma(bool showConf) - { - // aggiorno valori rilevati - resetParam(); - doUpdate(); - divInnovazioni.Visible = showConf; - if (showConf) - { - try - { - updatePzBuoni(); - // sollevo evento! - if (eh_inserting != null) - { - eh_inserting(this, new EventArgs()); - } - } - catch - { - txtNumPezzi.Text = "0"; - logger.lg.scriviLog(string.Format("Errore recupero pezzi da confermare per la macchina {0}", idxMacchinaSel), tipoLog.ERROR); - } - } - if (showConf) - { - lblShowConfProd.Text = "Nascondi Conferma"; - } - else - { - lblShowConfProd.Text = "Mostra Conferma"; - // sollevo evento! - if (eh_reset != null) - { - eh_reset(this, new EventArgs()); - } - } - } - - /// - /// aggiorna visualizzazione pz buoni /prodotti - scarti) - /// - private void updatePzBuoni() - { - if (confRett) - { - // cambio le qta di pezzi confermati... - lblPz2RecBuoni.Text = (numPzConfermati - numPzLasciati).ToString(); - } - else - { - // se ho dei pezzi lasciati RICALCOLO la data... - if (numPzLasciati > 0) - { - // calcolo la data.. - DS_ProdTempi.TempiCicloRilevatiDataTable tab = DataLayerObj.taTempiCicloRilevati.getLastPzByMaccQta(idxMacchinaSel, DateTime.Now, numPzLasciati); - if (tab.Rows.Count > 0) - { - dtReqUpdate = tab[0].DataOraRif.AddSeconds(1); - } - // aggiorno - doUpdate(); - } - lblPz2RecBuoni.Text = numPzConfermati.ToString(); - } - // aggiorno la data calcolo + pezzi buoni... - lblDtRec.Text = dtReqUpdate.ToString(); - } - -#endif } } \ No newline at end of file diff --git a/MP-TAB-SERV/Components/ProdStat.razor b/MP-TAB-SERV/Components/ProdStat.razor index 90b8fd52..e8e36b83 100644 --- a/MP-TAB-SERV/Components/ProdStat.razor +++ b/MP-TAB-SERV/Components/ProdStat.razor @@ -1,9 +1,9 @@  -
-
+
+
Statistiche di produzione
-
+
@if (RecMSE != null) { @($"ODL: {RecMSE.IdxOdl}") diff --git a/MP-TAB-SERV/Components/ScrapKitMan.razor b/MP-TAB-SERV/Components/ScrapKitMan.razor new file mode 100644 index 00000000..2fe85349 --- /dev/null +++ b/MP-TAB-SERV/Components/ScrapKitMan.razor @@ -0,0 +1,82 @@ + + +
+
+
+ + + + + + + + @if (TotalCount == 0) + { + + + + } + else + { + @foreach (var item in ListPaged) + { + + + + } + } + +
+
+ Esplosione scarti KIT +
+
+ +
+
+
No record found
+
+
+
+
+ Art: @item.CodArticolo +
+
+
+
+ @if (item.Qta <= 0) + { + + } + else + { + + } +
+
+ @item.Qta +
+
+ ×pz +
+
+ @if (item.Qta >= item.QtaMax) + { + + } + else + { + + } +
+
+
+
+
+
+
+
+ +
+ + diff --git a/MP-TAB-SERV/Components/ScrapKitMan.razor.cs b/MP-TAB-SERV/Components/ScrapKitMan.razor.cs new file mode 100644 index 00000000..6d554b82 --- /dev/null +++ b/MP-TAB-SERV/Components/ScrapKitMan.razor.cs @@ -0,0 +1,114 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MP.Data.DatabaseModels; +using MP.Data.Services; +using NLog; + +namespace MP_TAB_SERV.Components +{ + public partial class ScrapKitMan + { + #region Public Properties + + [Parameter] + public EventCallback E_Updated { get; set; } + + [Parameter] + public RegistroScartiModel ParentKit { get; set; } = null!; + + #endregion Public Properties + + #region Protected Properties + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + protected List ListComplete { get; set; } = new List(); + + protected List ListPaged { get; set; } = new List(); + + [Inject] + protected TabDataService TabDServ { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected async Task DeleteKitSplit() + { + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare il dettaglio del KIT scartato?")) + return; + + if (ParentKit != null) + { + await TabDServ.RegScartiKitDelete(ParentKit); + await ReloadData(); + await E_Updated.InvokeAsync(true); + } + } + + protected override async Task OnParametersSetAsync() + { + await ReloadData(); + } + + protected void UpdateTable() + { + // esegue paginazione + if (TotalCount > NumRecPage) + { + ListPaged = ListComplete.Skip((PageNum - 1) * NumRecPage).Take(NumRecPage).ToList(); + } + else + { + ListPaged = ListComplete; + } + } + /// + /// Modifica qty del record + /// + /// + /// + /// + protected async Task modQty(RegistroScartiKitModel currItem, int delta) + { + currItem.Qta += delta; + await TabDServ.RegScartiKitUpdateQty(currItem); + } + + #endregion Protected Methods + + #region Private Fields + + private static Logger Log = LogManager.GetCurrentClassLogger(); + + private bool isProcessing = false; + + private int NumRecPage = 10; + + private int PageNum = 1; + + private int TotalCount = 0; + + #endregion Private Fields + + #region Private Methods + + private async Task ReloadData() + { + isProcessing = true; + await Task.Delay(1); + if (ParentKit != null) + { + ListComplete = await TabDServ.RegScartiKitGetFilt(ParentKit); + TotalCount = ListComplete.Count; + // esegue paginazione + UpdateTable(); + } + isProcessing = false; + await Task.Delay(1); + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/ScrapMan.razor b/MP-TAB-SERV/Components/ScrapMan.razor index d7eed171..8b27c012 100644 --- a/MP-TAB-SERV/Components/ScrapMan.razor +++ b/MP-TAB-SERV/Components/ScrapMan.razor @@ -8,7 +8,7 @@ @if (enableScarti) {
- +
} else @@ -49,42 +49,92 @@ - @foreach (var item in ListPaged) + @if (TotalCount == 0) { - -
-
-
- Art: @item.CodArticolo -
-
- @item.Descrizione -
-
-
- @item.Qta pz -
-
-
- @($"{item.DataOra:ddd dd.MM.yy HH:mm:ss}") - -
-
- @item.Operatore - -
-
-
- @if (!string.IsNullOrEmpty(item.Note)) - { - Nota: @item.Note - } -
-
+ +
No record found
} + else + { + @foreach (var item in ListPaged) + { + + +
+
+
+ Art: @item.CodArticolo +
+
+ @item.Descrizione +
+
+
+
+ @item.Qta +
+
+ + @if (item.Tipo == "KIT") + { +
+ × + @if (item.KitSplit) + { + + } + else + { + + } +
+ } + else + { + + + × + pz + + } +
+
+
+
+ @($"{item.DataOra:ddd dd.MM.yy HH:mm:ss}") + +
+
+ @item.Operatore + +
+
+
+ @if (!string.IsNullOrEmpty(item.Note)) + { + Nota: @item.Note + } +
+
+ + + @if (item.Equals(selItem)) + { + + + + + + } + } + }
diff --git a/MP-TAB-SERV/Components/ScrapMan.razor.cs b/MP-TAB-SERV/Components/ScrapMan.razor.cs index 022eb904..6128ee3c 100644 --- a/MP-TAB-SERV/Components/ScrapMan.razor.cs +++ b/MP-TAB-SERV/Components/ScrapMan.razor.cs @@ -21,7 +21,7 @@ namespace MP_TAB_SERV.Components /// Aggiorno valori produzione alla data richiesta... ///
/// - public async Task doUpdate() + protected async Task ReloadData() { isProcessing = true; await Task.Delay(1); @@ -36,29 +36,36 @@ namespace MP_TAB_SERV.Components await Task.Delay(1); } + protected async Task ForceReload(bool DoClose) + { + if (DoClose) + { + selItem = null; + } + await ReloadData(); + } + #endregion Public Methods #region Protected Properties - - + protected bool enableScarti { get; set; } = true; protected List ListComplete { get; set; } = new List(); protected List ListPaged { get; set; } = new List(); [Inject] protected MessageService MServ { get; set; } = null!; - [Inject] - protected TabDataService TabDServ { get; set; } = null!; [Inject] protected SharedMemService SMServ { get; set; } = null!; + [Inject] + protected TabDataService TabDServ { get; set; } = null!; + #endregion Protected Properties #region Protected Methods - protected bool enableScarti { get; set; } = true; - protected override async Task OnInitializedAsync() { await Task.Delay(1); @@ -69,32 +76,33 @@ namespace MP_TAB_SERV.Components DateTime fine = DateTime.Today.AddDays(1); DateTime inizio = fine.AddDays(-8); CurrPeriodo = new Periodo(inizio, fine); - await doUpdate(); + await ReloadData(); } } - - protected void SaveNumRec(int newNum) { NumRecPage = newNum; UpdateTable(); } - - protected void SavePage(int newNum) { PageNum = newNum; UpdateTable(); } + protected string selectedCss(RegistroScartiModel currItem) + { + return currItem.Equals(selItem) ? "table-info" : ""; + } + protected async Task SetMacc(string selIdxMacc) { isProcessing = true; await Task.Delay(1); IdxMaccSel = selIdxMacc; - await doUpdate(); + await ReloadData(); isProcessing = false; await Task.Delay(1); } @@ -104,7 +112,7 @@ namespace MP_TAB_SERV.Components isProcessing = true; await Task.Delay(1); IdxOdl = selIdxOdl; - await doUpdate(); + await ReloadData(); isProcessing = false; await Task.Delay(1); } @@ -112,10 +120,33 @@ namespace MP_TAB_SERV.Components protected async Task SetPeriodo(Periodo newPeriodo) { CurrPeriodo = newPeriodo; - await doUpdate(); + await ReloadData(); } - + protected async Task ShowKitDetail(RegistroScartiModel currItem) + { + isProcessing = true; + // deve essere != null in primis... + if (currItem != null) + { + // verifico se serve creare split dell'oggetto (hard coded!!!) + if (currItem.Tipo == "KIT" && !currItem.KitSplit) + { + await TabDServ.RegScartiKitSplit(currItem); + } + // faccio toggle show item (se era già selezionato --> null!) + if (!currItem.Equals(selItem)) + { + selItem = currItem; + } + else + { + selItem = null; + } + } + await ReloadData(); + isProcessing = false; + } protected void UpdateTable() { @@ -138,6 +169,7 @@ namespace MP_TAB_SERV.Components private bool isProcessing = false; private int NumRecPage = 10; private int PageNum = 1; + private RegistroScartiModel? selItem = null; private int TotalCount = 0; private bool useOdl = false; diff --git a/MP-TAB-SERV/Components/SlideMenu.razor b/MP-TAB-SERV/Components/SlideMenu.razor index 356d9208..2cadef9a 100644 --- a/MP-TAB-SERV/Components/SlideMenu.razor +++ b/MP-TAB-SERV/Components/SlideMenu.razor @@ -37,12 +37,13 @@
-
- +
+
-
+
MAPO MES +
v.@version
TAB Controller - MES Suite diff --git a/MP-TAB-SERV/Components/SlideMenu.razor.cs b/MP-TAB-SERV/Components/SlideMenu.razor.cs index 0e102d29..860e420b 100644 --- a/MP-TAB-SERV/Components/SlideMenu.razor.cs +++ b/MP-TAB-SERV/Components/SlideMenu.razor.cs @@ -15,11 +15,12 @@ namespace MP_TAB_SERV.Components #region Protected Properties - [Inject] - protected NavigationManager navManager { get; set; } = null!; [Inject] protected MessageService MsgServ { get; set; } = null!; + [Inject] + protected NavigationManager navManager { get; set; } = null!; + #endregion Protected Properties #region Protected Methods @@ -29,6 +30,12 @@ namespace MP_TAB_SERV.Components return navManager.Uri.Contains(currUri) ? "bg-dark text-light" : ""; } + protected override void OnInitialized() + { + var rawVers = typeof(Program).Assembly.GetName().Version; + version = rawVers != null ? rawVers : new Version("0.0.0.0"); + } + protected async Task SetPage(string tgtUrl) { await Task.Delay(1); @@ -41,5 +48,11 @@ namespace MP_TAB_SERV.Components } #endregion Protected Methods + + #region Private Fields + + private Version version = null!; + + #endregion Private Fields } } \ 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 9fd21e92..3bba47c7 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.2312.1115 + 6.16.2312.1810 enable MP_TAB_SERV @@ -14,11 +14,12 @@ <_WebToolingArtifacts Remove="Properties\PublishProfiles\IIS01.pubxml" /> + <_WebToolingArtifacts Remove="Properties\PublishProfiles\IISProfile.pubxml" /> - - + + diff --git a/MP-TAB-SERV/Pages/Alarms.razor b/MP-TAB-SERV/Pages/Alarms.razor index ff411c7a..cba45328 100644 --- a/MP-TAB-SERV/Pages/Alarms.razor +++ b/MP-TAB-SERV/Pages/Alarms.razor @@ -7,6 +7,7 @@ } else { + } diff --git a/MP-TAB-SERV/Pages/Controls.razor b/MP-TAB-SERV/Pages/Controls.razor index 21bef545..8f7e5fe9 100644 --- a/MP-TAB-SERV/Pages/Controls.razor +++ b/MP-TAB-SERV/Pages/Controls.razor @@ -1,12 +1,13 @@ @page "/controls" -@if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null) +@if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null || IsLoading) { } else { + - + } diff --git a/MP-TAB-SERV/Pages/Controls.razor.cs b/MP-TAB-SERV/Pages/Controls.razor.cs index e9449abd..d03f3572 100644 --- a/MP-TAB-SERV/Pages/Controls.razor.cs +++ b/MP-TAB-SERV/Pages/Controls.razor.cs @@ -41,6 +41,14 @@ namespace MP_TAB_SERV.Pages await InvokeAsync(StateHasChanged); } + protected async Task ForceReload() + { + IsLoading = true; + await Task.Delay(50); + IsLoading = false; + } + private bool IsLoading = false; + #endregion Protected Methods #region Private Methods diff --git a/MP-TAB-SERV/Pages/Declarations.razor b/MP-TAB-SERV/Pages/Declarations.razor index 7be4b8f6..5a45a974 100644 --- a/MP-TAB-SERV/Pages/Declarations.razor +++ b/MP-TAB-SERV/Pages/Declarations.razor @@ -7,6 +7,7 @@ } else { + } diff --git a/MP-TAB-SERV/Pages/Index.razor b/MP-TAB-SERV/Pages/Index.razor index b5d0a9fb..c7d708b6 100644 --- a/MP-TAB-SERV/Pages/Index.razor +++ b/MP-TAB-SERV/Pages/Index.razor @@ -1,7 +1,7 @@ @page "/" @page "/home" - + @code { protected override async Task OnInitializedAsync() diff --git a/MP-TAB-SERV/Pages/IobInfo.razor b/MP-TAB-SERV/Pages/IobInfo.razor index c8e7575f..35077c37 100644 --- a/MP-TAB-SERV/Pages/IobInfo.razor +++ b/MP-TAB-SERV/Pages/IobInfo.razor @@ -7,8 +7,7 @@ } else { -
- -
+ + } diff --git a/MP-TAB-SERV/Pages/Logout.razor.cs b/MP-TAB-SERV/Pages/Logout.razor.cs index 81f91ac5..97d3b851 100644 --- a/MP-TAB-SERV/Pages/Logout.razor.cs +++ b/MP-TAB-SERV/Pages/Logout.razor.cs @@ -39,10 +39,26 @@ namespace MP_TAB_SERV.Pages protected override async Task OnInitializedAsync() { await Task.Delay(1); - await localStorage.SetItemAsync("currTkn", ""); - await TDService.OperatoreDeleteRedis(MsgServ.MatrOpr); + await localStorage.SetItemAsync("currTkn", ""); + await localStorage.SetItemAsync("CurrMach", ""); + await localStorage.SetItemAsync("LastPage", ""); + var CurrOprTknLS = await MsgServ.GetCurrOperDtoLSAsync(); + var CurrDevGuid = await MsgServ.GetCurrDevGuidLSAsync(); + if (!string.IsNullOrEmpty(CurrOprTknLS)) + { + var decryptedData = MsgServ.DecryptData(CurrOprTknLS); + if (!string.IsNullOrEmpty(decryptedData)) + { + var oprObj = JsonConvert.DeserializeObject(decryptedData); + if (oprObj != null) + { + MsgServ.RigaOper = oprObj.currOpr; + } + } + } + await TDService.OperatoreDeleteRedis(MsgServ.MatrOpr, CurrDevGuid); MsgServ.RigaOper = null; - NavMan.NavigateTo("reg-new-device"); + NavMan.NavigateTo("reg-new-device", true); } } } \ No newline at end of file diff --git a/MP-TAB-SERV/Pages/MachineDetail.razor b/MP-TAB-SERV/Pages/MachineDetail.razor index fd965bef..a068cce3 100644 --- a/MP-TAB-SERV/Pages/MachineDetail.razor +++ b/MP-TAB-SERV/Pages/MachineDetail.razor @@ -8,6 +8,7 @@ } else { + diff --git a/MP-TAB-SERV/Pages/MachineDetail.razor.cs b/MP-TAB-SERV/Pages/MachineDetail.razor.cs index 67275899..883ccf3d 100644 --- a/MP-TAB-SERV/Pages/MachineDetail.razor.cs +++ b/MP-TAB-SERV/Pages/MachineDetail.razor.cs @@ -49,7 +49,7 @@ namespace MP_TAB_SERV.Pages await RefreshMBlock(); } } - await InvokeAsync(StateHasChanged); + //await InvokeAsync(StateHasChanged); } protected async Task RefreshMBlock() diff --git a/MP-TAB-SERV/Pages/Notes.razor b/MP-TAB-SERV/Pages/Notes.razor index 15e2b1a9..de63c2db 100644 --- a/MP-TAB-SERV/Pages/Notes.razor +++ b/MP-TAB-SERV/Pages/Notes.razor @@ -7,6 +7,7 @@ } else { + } diff --git a/MP-TAB-SERV/Pages/ODL.razor b/MP-TAB-SERV/Pages/ODL.razor index cea8d71f..85cdcb6b 100644 --- a/MP-TAB-SERV/Pages/ODL.razor +++ b/MP-TAB-SERV/Pages/ODL.razor @@ -1,12 +1,13 @@ @page "/odl" - + @if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null) { } else { + } diff --git a/MP-TAB-SERV/Pages/Parameters.razor b/MP-TAB-SERV/Pages/Parameters.razor index 16b8b68e..3ecd6b07 100644 --- a/MP-TAB-SERV/Pages/Parameters.razor +++ b/MP-TAB-SERV/Pages/Parameters.razor @@ -8,6 +8,7 @@ } else { + } diff --git a/MP-TAB-SERV/Pages/ProdPlan.razor b/MP-TAB-SERV/Pages/ProdPlan.razor index 8c0674dc..4130f6ac 100644 --- a/MP-TAB-SERV/Pages/ProdPlan.razor +++ b/MP-TAB-SERV/Pages/ProdPlan.razor @@ -7,6 +7,7 @@ } else { + } diff --git a/MP-TAB-SERV/Pages/ProdStop.razor b/MP-TAB-SERV/Pages/ProdStop.razor index 0f9b2505..12aa29a2 100644 --- a/MP-TAB-SERV/Pages/ProdStop.razor +++ b/MP-TAB-SERV/Pages/ProdStop.razor @@ -8,9 +8,8 @@ } else { -
- -
+ + @@ -24,7 +23,7 @@ else } @foreach (var item in events2show) { - + }
} diff --git a/MP-TAB-SERV/Pages/ProdStop.razor.cs b/MP-TAB-SERV/Pages/ProdStop.razor.cs index e76ce62c..66c8a6bb 100644 --- a/MP-TAB-SERV/Pages/ProdStop.razor.cs +++ b/MP-TAB-SERV/Pages/ProdStop.razor.cs @@ -105,7 +105,7 @@ namespace MP_TAB_SERV.Pages // se realtime await TabDServ.EvListInsert(newRec, MP.Data.Objects.Enums.tipoInputEvento.barcode); // resetta il microstato in modo da ricevere successive info HW - TabDServ.resetMicrostatoMacchina(IdxMacc); + await TabDServ.resetMicrostatoMacchina(IdxMacc); } else { @@ -211,7 +211,7 @@ namespace MP_TAB_SERV.Pages rdm_nEvCheck = SMServ.GetConfInt("rdm_nEvCheck"); rdm_ChkOnly = SMServ.GetConfBool("rdm_ChkOnly"); // leggo gli altri dati - await ReloadData(); + await ReloadData(); } protected async Task RefreshData(List newList) @@ -229,7 +229,6 @@ namespace MP_TAB_SERV.Pages await ReloadData(); } } - await InvokeAsync(StateHasChanged); } protected void SetDate(DateTime newDate) @@ -271,12 +270,13 @@ namespace MP_TAB_SERV.Pages var eventsAll = await TabDServ.AnagEventiGetByMacch(IdxMacc); if (eventsAll != null) { - events2show = eventsAll.Where(x => x.EventoTablet).OrderBy(x => x.Label).ToList(); + events2show = eventsAll.Where(x => x.EventoTablet).OrderBy(x => x.label).ToList(); } } - catch + catch(Exception exc) { - NavMan.NavigateTo("/", true); + Log.Error($"ProdStop: Eccezione in reloadData {Environment.NewLine}{exc}"); + await MServ.LastOpenedPageSet("/"); } } } diff --git a/MP-TAB-SERV/Pages/RegNewDevice.razor.cs b/MP-TAB-SERV/Pages/RegNewDevice.razor.cs index 993a095c..1f8d1cde 100644 --- a/MP-TAB-SERV/Pages/RegNewDevice.razor.cs +++ b/MP-TAB-SERV/Pages/RegNewDevice.razor.cs @@ -45,8 +45,6 @@ namespace MP_TAB_SERV.Pages protected string CurrOprTknRedis { get; set; } = null!; - protected DateTime expDT { get; set; } = DateTime.Now; - protected int matrOpr { get @@ -90,6 +88,7 @@ namespace MP_TAB_SERV.Pages protected async Task FirstLogIn() { rigaOpr = await TDService.OperatoreSearch(matrOpr, authKey); + var devGuid = await MsgServ.GetCurrDevGuidLSAsync(); if (rigaOpr == null) { var deHash = TDService.DecryptData(authKey); @@ -100,16 +99,16 @@ namespace MP_TAB_SERV.Pages userTknDTO newUserTkn = new userTknDTO() { currOpr = rigaOpr, - expTime = expDT + DevGuid = devGuid }; var jsonTkn = JsonConvert.SerializeObject(newUserTkn); string hash = TDService.EncryptData(jsonTkn); MsgServ.RigaOper = rigaOpr; - await MsgServ.SetCurrOperDtoAsync(hash); + await MsgServ.SetCurrOperDtoLSAsync(hash); await MsgServ.SetLastMatrOprAsync(rigaOpr.MatrOpr); - await TDService.OperatoreSetRedis(matrOpr, hash); - NavMan.NavigateTo("status-map"); + await TDService.OperatoreSetRedis(matrOpr, hash, devGuid); + NavMan.NavigateTo("status-map", true); } else { @@ -124,7 +123,6 @@ namespace MP_TAB_SERV.Pages matrOpr = await MsgServ.GetLastMatrOprAsync(); TDService.ConfigGetVal("cookieDayExpire", ref expDays); ShowScanBarcode = !SMServ.GetConfBool("TAB_WebCamHide"); - expDT = DateTime.Now.AddDays(expDays); oprsList = await TDService.ElencoOperatori(); } diff --git a/MP-TAB-SERV/Pages/Scrap.razor b/MP-TAB-SERV/Pages/Scrap.razor index 64aa41ba..65c20614 100644 --- a/MP-TAB-SERV/Pages/Scrap.razor +++ b/MP-TAB-SERV/Pages/Scrap.razor @@ -1,12 +1,13 @@ @page "/scrap" - + @if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null) { } else { + } diff --git a/MP-TAB-SERV/Pages/TechSheet.razor b/MP-TAB-SERV/Pages/TechSheet.razor index 612cfe71..5c37ccea 100644 --- a/MP-TAB-SERV/Pages/TechSheet.razor +++ b/MP-TAB-SERV/Pages/TechSheet.razor @@ -8,6 +8,7 @@ } else { + @if (enableSchedaTecnica) { diff --git a/MP-TAB-SERV/Pages/User.razor b/MP-TAB-SERV/Pages/User.razor index d23fee31..370ef7a8 100644 --- a/MP-TAB-SERV/Pages/User.razor +++ b/MP-TAB-SERV/Pages/User.razor @@ -60,9 +60,13 @@
    +
  • +
    Prossima disconnessione:
    +
    @($"{DateTime.Now.AddMinutes(dtScadLogin)}")
    +
  • User
    -
    USERNAME[999]
    +
    @($"{UserName}[{MatrOpr}]")
  • Server Time
    @@ -116,6 +120,16 @@ defCardModeIns = defCardMode; } + private int MatrOpr + { + get => MsgServ.MatrOpr; + } + + private string UserName + { + get => MsgServ.CognomeNome; + } + protected string btnMsStyle { get @@ -191,7 +205,7 @@ if (_tcModIns != value) { _tcModIns = value; - MsgServ.UserPrefSave("TcMode", value); + MsgServ.UserPrefSet("TcMode", value); } } } @@ -206,7 +220,7 @@ if (_langIns != value) { _langIns = value; - MsgServ.UserPrefSave("Lang", value); + MsgServ.UserPrefSet("Lang", value); } } } @@ -220,7 +234,7 @@ if (_defCardMode != value) { _defCardMode = value; - MsgServ.UserPrefSave("DefCardMode", value); + MsgServ.UserPrefSet("DefCardMode", value); } } } @@ -244,11 +258,16 @@ Log.Debug($"Dimensioni schermo: {Width}x{Height}"); } } + + [Inject] + protected SharedMemService MStor { get; set; } = null!; + protected int dtScadLogin { get; set; } = 0; protected async override Task OnInitializedAsync() { tcModIns = MsgServ.UserPrefSetup("TcMode", "ms"); langIns = MsgServ.UserPrefSetup("Lang", "IT"); defCardModeIns = MsgServ.UserPrefSetup("DefCardMode", "full"); + dtScadLogin = MStor.GetConfInt("TAB_dtTimerScadLogin"); 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 ae0bd885..f6e8f517 100644 --- a/MP-TAB-SERV/Pages/WorkShift.razor +++ b/MP-TAB-SERV/Pages/WorkShift.razor @@ -7,6 +7,7 @@ } else { +

    Gestione Turni

    diff --git a/MP-TAB-SERV/Pages/_Layout.cshtml b/MP-TAB-SERV/Pages/_Layout.cshtml index 0a7d54c9..6691bfc3 100644 --- a/MP-TAB-SERV/Pages/_Layout.cshtml +++ b/MP-TAB-SERV/Pages/_Layout.cshtml @@ -38,14 +38,7 @@ 🗙
    - @* - *@ - @**@ - @* - *@ - @**@ - - + @**@ diff --git a/MP-TAB-SERV/Properties/PublishProfiles/IISProfile.pubxml b/MP-TAB-SERV/Properties/PublishProfiles/IISProfile.pubxml new file mode 100644 index 00000000..1e9feb4c --- /dev/null +++ b/MP-TAB-SERV/Properties/PublishProfiles/IISProfile.pubxml @@ -0,0 +1,20 @@ + + + + + Package + Release + Any CPU + + True + False + e7a7c262-7807-4503-949d-5a6fe3df4400 + bin\publish\MP.TAB3.zip + true + Default Web Site/MP/TAB3 + net6.0 + false + + \ No newline at end of file diff --git a/MP-TAB-SERV/Resources/ChangeLog.html b/MP-TAB-SERV/Resources/ChangeLog.html index aa25c504..aa583c30 100644 --- a/MP-TAB-SERV/Resources/ChangeLog.html +++ b/MP-TAB-SERV/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

    Versione: 6.16.2312.1115

    +

    Versione: 6.16.2312.1810


    Note di rilascio:
    • diff --git a/MP-TAB-SERV/Resources/VersNum.txt b/MP-TAB-SERV/Resources/VersNum.txt index ea217199..77bd36bf 100644 --- a/MP-TAB-SERV/Resources/VersNum.txt +++ b/MP-TAB-SERV/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2312.1115 +6.16.2312.1810 diff --git a/MP-TAB-SERV/Resources/manifest.xml b/MP-TAB-SERV/Resources/manifest.xml index 5c669432..b19da4d0 100644 --- a/MP-TAB-SERV/Resources/manifest.xml +++ b/MP-TAB-SERV/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2312.1115 + 6.16.2312.1810 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 b/MP-TAB-SERV/Shared/MainLayout.razor index df3d355f..13589b1e 100644 --- a/MP-TAB-SERV/Shared/MainLayout.razor +++ b/MP-TAB-SERV/Shared/MainLayout.razor @@ -6,8 +6,8 @@
      - - @if (MsgServ.RigaOper != null || NavMan.Uri.Contains("reg-new-device")) + + @if (userIsOk || NavMan.Uri.Contains("reg-new-device")) {
      diff --git a/MP-TAB-SERV/Shared/MainLayout.razor.cs b/MP-TAB-SERV/Shared/MainLayout.razor.cs index 8e4c9e6d..c702c78c 100644 --- a/MP-TAB-SERV/Shared/MainLayout.razor.cs +++ b/MP-TAB-SERV/Shared/MainLayout.razor.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Components.Routing; using Microsoft.JSInterop; using MP.Data.DatabaseModels; using MP.Data.Services; +using MP_TAB_SERV.Components; using NLog; namespace MP_TAB_SERV.Shared @@ -65,14 +66,26 @@ namespace MP_TAB_SERV.Shared protected string bodyTipe { - get => NavMan.Uri.Contains("reg-new-device") ? "mainBodyNoSide" : "mainBody"; + get => pageOk ? "mainBodyNoSide" : "mainBody"; + } + + protected bool pageOk + { + get + { + string currPage = NavMan.Uri; + return currPage.Contains("logout") || currPage.Contains("reg-new-device"); + } } protected async Task handleBodyClick() { await Task.Delay(1); - await checkDtDiff2Logout(); + if (!pageOk) + { + await checkDtDiff2Logout(); + } } private int MatrOpr @@ -81,32 +94,49 @@ namespace MP_TAB_SERV.Shared } protected int typeScadLogin { get; set; } = 0; protected int dtScadLogin { get; set; } = 0; + protected Guid currDevGuid { get; set; } = new Guid(); protected async Task checkDtDiff2Logout() { - var diffOfTime = DateTime.Now - MsgServ.dtLastAction; + TimeSpan tsDeltaAct = DateTime.Now.Subtract(MsgServ.dtLastAction); + TimeSpan tsDeltaSave = DateTime.Now.Subtract(MsgServ.dtLastSave); switch (typeScadLogin) { case 0: - if (diffOfTime.Minutes >= dtScadLogin) + if (tsDeltaAct.Minutes >= dtScadLogin) { NavMan.NavigateTo("logout"); } break; case 1: - if (diffOfTime.Minutes >= dtScadLogin) + if (tsDeltaAct.Minutes >= dtScadLogin) { - var userTkn = await TDataService.OperatoreGetRedis(MatrOpr); + var userTkn = await TDataService.OperatoreGetRedis(MatrOpr, currDevGuid); if (!string.IsNullOrEmpty(userTkn)) { - await MsgServ.DoLogIn(userTkn); + await MsgServ.DoLogIn(userTkn, true); MsgServ.dtLastAction = DateTime.Now; + MsgServ.dtLastSave = DateTime.Now; } else { NavMan.NavigateTo("logout"); } } + else + { + // se fosse oltre 1 minuto da ultimo save --> salvo! + if (tsDeltaSave.TotalMinutes > 1) + { + var userTkn = await TDataService.OperatoreGetRedis(MatrOpr, currDevGuid); + if (!string.IsNullOrEmpty(userTkn)) + { + await MsgServ.DoLogIn(userTkn, true); + MsgServ.dtLastAction = DateTime.Now; + MsgServ.dtLastSave = DateTime.Now; + } + } + } break; } } @@ -120,6 +150,9 @@ namespace MP_TAB_SERV.Shared typeScadLogin = MStor.GetConfInt("TAB_TypeScadLogin"); dtScadLogin = MStor.GetConfInt("TAB_dtTimerScadLogin"); NavMan.LocationChanged += HandleLocationChanged; + + currDevGuid = await MsgServ.GetCurrDevGuidLSAsync(); + // verifica preliminare setup mdati if (!MStor.MenuOk) { @@ -136,6 +169,13 @@ namespace MP_TAB_SERV.Shared await Task.Delay(1); } + protected bool userIsOk { get; set; } = false; + protected async Task checkIfUserOk(bool isOk) + { + await Task.Delay(1); + userIsOk = isOk; + } + protected async Task ReloadMemStor() { // in primis svuoto... diff --git a/MP-TAB-SERV/Shared/NavMenu.razor b/MP-TAB-SERV/Shared/NavMenu.razor index a3cfec58..2bdf92e1 100644 --- a/MP-TAB-SERV/Shared/NavMenu.razor +++ b/MP-TAB-SERV/Shared/NavMenu.razor @@ -14,9 +14,18 @@ foreach (var item in MenuItems) { } } @@ -34,6 +43,16 @@ [Inject] protected NavigationManager navManager { get; set; } = null!; + protected bool linkActive(string objUrl) + { + bool answ = false; + if (navManager.Uri.Contains(objUrl)) + { + answ = true; + } + return answ; + } + protected async Task SetPage(string tgtUrl) { await Task.Delay(1); diff --git a/MP-TAB-SERV/appsettings.json b/MP-TAB-SERV/appsettings.json index 57300304..1878bfb3 100644 --- a/MP-TAB-SERV/appsettings.json +++ b/MP-TAB-SERV/appsettings.json @@ -17,7 +17,7 @@ "MP.Mag": "Server=SQL2016DEV;Database=MoonPro_MAG; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.TAB3;" }, "OptConf": { - "msRefresh": "2000", + "msRefresh": "4000", "BaseAddr": "https://localhost:7295/MP/TAB3/", "BaseUrl": "/MP/TAB3", "ImgBasePath": "https://iis01.egalware.com/MP/images/macchine/small/", diff --git a/MP-TAB-SERV/compilerconfig.json b/MP-TAB-SERV/compilerconfig.json index 81657133..0ae6cb7f 100644 --- a/MP-TAB-SERV/compilerconfig.json +++ b/MP-TAB-SERV/compilerconfig.json @@ -34,5 +34,9 @@ { "outputFile": "Components/ProdPlanMan.razor.css", "inputFile": "Components/ProdPlanMan.razor.less" + }, + { + "outputFile": "Components/CheckControls.razor.css", + "inputFile": "Components/CheckControls.razor.less" } ] \ No newline at end of file diff --git a/MP.Data/Controllers/MpTabController.cs b/MP.Data/Controllers/MpTabController.cs index e7311b81..fd04d925 100644 --- a/MP.Data/Controllers/MpTabController.cs +++ b/MP.Data/Controllers/MpTabController.cs @@ -54,51 +54,6 @@ namespace MP.Data.Controllers return dbResult; } - - /// - /// Elenco operatori - /// - /// - public List ElencoOperatori() - { - List dbResult = new List(); - using (var dbCtx = new MoonProContext(_configuration)) - { - dbResult = dbCtx - .DbOperatori - .Where(s => s.MatrOpr > 0) - .AsNoTracking() - .OrderBy(x => x.MatrOpr) - .ToList(); - } - return dbResult; - } - - /// - /// login operatori - /// - /// /// - /// /// - /// - public AnagOperatoriModel OperatoreSearch(int matrOpr, string authKey) - { - AnagOperatoriModel dbResult = null; - AnagOperatoriModel answ = new AnagOperatoriModel(); - using (var dbCtx = new MoonProContext(_configuration)) - { - dbResult = dbCtx - .DbOperatori - .Where(s => (s.MatrOpr > 0) && (s.MatrOpr == matrOpr) && (s.authKey == authKey)) - .AsNoTracking() - .FirstOrDefault(); - if (dbResult != null) - { - answ = dbResult; - } - } - return answ; - } - /// /// Registrato ACK allarme /// @@ -560,6 +515,25 @@ namespace MP.Data.Controllers return fatto; } + /// + /// Elenco operatori + /// + /// + public List ElencoOperatori() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbOperatori + .Where(s => s.MatrOpr > 0) + .AsNoTracking() + .OrderBy(x => x.MatrOpr) + .ToList(); + } + return dbResult; + } + //stp_DDB_getNextByMacchinaFrom /// /// Eliminazione record EventList (SE trovato) @@ -1264,6 +1238,33 @@ namespace MP.Data.Controllers return answ; } + /// + /// login operatori + /// + /// /// + /// + /// /// + /// + /// + public AnagOperatoriModel OperatoreSearch(int matrOpr, string authKey) + { + AnagOperatoriModel dbResult = null; + AnagOperatoriModel answ = new AnagOperatoriModel(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbOperatori + .Where(s => (s.MatrOpr > 0) && (s.MatrOpr == matrOpr) && (s.authKey == authKey)) + .AsNoTracking() + .FirstOrDefault(); + if (dbResult != null) + { + answ = dbResult; + } + } + return answ; + } + /// /// Stato prod macchina /// @@ -1444,6 +1445,25 @@ namespace MP.Data.Controllers return fatto; } + /// Restituisce elenco Ultimi RC macchina + /// + public List RegControlliLast(string idxMacchina) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina); + + dbResult = dbCtx + .DbSetRegControlli + .FromSqlRaw("EXEC stp_RC_getLast @IdxMacchina", IdxMacc) + .AsNoTracking() + .ToList(); + } + return dbResult; + } + /// /// Aggiunta record RegistroScarti /// @@ -1558,9 +1578,8 @@ namespace MP.Data.Controllers /// /// /// - public async Task RegScartiInsert(RegistroScartiModel newRec) + public bool RegScartiInsert(RegistroScartiModel newRec) { - await Task.Delay(1); bool fatto = false; using (var dbCtx = new MoonProContext(_configuration)) { @@ -1583,6 +1602,104 @@ namespace MP.Data.Controllers return fatto; } + /// + /// Elimina scarti KIT dato record parent (e lo resetta) + /// + /// + /// + public bool RegScartiKitDelete(RegistroScartiModel parentRec) + { + bool answ = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxMacc = new SqlParameter("@IdxMacchina", parentRec.IdxMacchina); + var DtRif = new SqlParameter("@DataOra", parentRec.DataOra); + var Causale = new SqlParameter("@Causale", parentRec.Causale); + + var dbResult = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_RSK_Delete @IdxMacchina, @DataOra, @Causale", IdxMacc, DtRif, Causale); + + answ = dbResult != 0; + } + return answ; + } + /// + /// Aggiorna un record scarti KIT ( SE ESISTE...) + /// + /// + /// + public bool RegScartiKitUpdateQty(RegistroScartiKitModel currRec) + { + bool answ = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxMacc = new SqlParameter("@IdxMacchina", currRec.IdxMacchina); + var DtRif = new SqlParameter("@DataOra", currRec.DataOra); + var Causale = new SqlParameter("@Causale", currRec.Causale); + var CodArticolo = new SqlParameter("@CodArticolo", currRec.CodArticolo); + var Qty = new SqlParameter("@Qty", currRec.Qta); + + var dbResult = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_RSK_UpdateQty @IdxMacchina, @DataOra, @Causale, @CodArticolo, @Qty", IdxMacc, DtRif, Causale, CodArticolo, Qty); + + answ = dbResult != 0; + } + return answ; + } + + /// + /// Elenco scarti KIT dato record parent + /// + /// + /// + public List RegScartiKitGetFilt(RegistroScartiModel parentRec) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxMacc = new SqlParameter("@IdxMacchina", parentRec.IdxMacchina); + var DtRif = new SqlParameter("@DataRif", parentRec.DataOra); + var Causale = new SqlParameter("@Causale", parentRec.Causale); + + dbResult = dbCtx + .DbSetRegScartiKit + .FromSqlRaw("EXEC stp_RSK_getByFilt @IdxMacchina, @DataRif, @Causale", IdxMacc, DtRif, Causale) + .AsNoTracking() + .ToList(); + } + return dbResult; + } + + /// + /// Aggiunta record RegistroScartiKit in tab RSK esplodendo x kit + /// + /// + /// + public async Task RegScartiKitSplit(RegistroScartiModel newRec) + { + await Task.Delay(1); + 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 CodArt = new SqlParameter("@CodArticolo", newRec.CodArticolo); + var Qta = new SqlParameter("@QtyKit", newRec.Qta); + + var result = dbCtx + .DbSetRegWithCheck + .FromSqlRaw("exec dbo.stp_RSK_Split @idxMacchina, @DataOra, @Causale, @CodArticolo, @QtyKit", IdxMacchina, DataOra, Causale, CodArt, Qta) + .AsNoTracking() + .ToList(); + // indico eseguito! + fatto = result.Count != 0; + } + return fatto; + } + /// /// Effettua ricalcolo MSE x macchina indicata /// diff --git a/MP.Data/DTO/userTknDTO.cs b/MP.Data/DTO/userTknDTO.cs index bc9a8db5..4ff3b3bd 100644 --- a/MP.Data/DTO/userTknDTO.cs +++ b/MP.Data/DTO/userTknDTO.cs @@ -10,6 +10,7 @@ namespace MP.Data.DTO public class userTknDTO { public AnagOperatoriModel currOpr { get; set; } = null; - public DateTime expTime { get; set; } = DateTime.Now; + //public DateTime expTime { get; set; } = DateTime.Now; + public Guid DevGuid { get; set; } } } diff --git a/MP.Data/DatabaseModels/RegistroScartiKitModel.cs b/MP.Data/DatabaseModels/RegistroScartiKitModel.cs new file mode 100644 index 00000000..14dc8de3 --- /dev/null +++ b/MP.Data/DatabaseModels/RegistroScartiKitModel.cs @@ -0,0 +1,38 @@ +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("RegistroScartiKit")] + public partial class RegistroScartiKitModel + { + #region Public Properties + + public string IdxMacchina { get; set; } = ""; + public DateTime DataOra { get; set; } = DateTime.Now; + public string Causale { get; set; } = ""; + public string CodArticoloKit { get; set; } = ""; + public string CodArticolo { get; set; } = ""; + public string Operatore { get; set; } = ""; + + public int Qta { get; set; } = 0; + public int QtaMax { get; set; } = 0; + public string Note { 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; } = ""; + public string DescArticolo { get; set; } = ""; + public string Tipo { 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 index 2082712d..a0829887 100644 --- a/MP.Data/DatabaseModels/RegistroScartiModel.cs +++ b/MP.Data/DatabaseModels/RegistroScartiModel.cs @@ -1,5 +1,7 @@ -using System; +using Microsoft.EntityFrameworkCore.Metadata.Internal; +using System; using System.Collections.Generic; +using static MP.Data.MgModels.RecipeModel; #nullable disable @@ -22,10 +24,35 @@ namespace MP.Data.DatabaseModels public string CodArticolo { get; set; } = ""; public int MatrOpr { get; set; } = 0; public DateTime? DataOraProdRec { get; set; } = null; + public bool KitSplit { get; set; } = false; public string Descrizione { get; set; } = ""; public string cssClass { get; set; } = ""; public string icona { get; set; } = ""; + public string DescArticolo { get; set; } = ""; + public string Tipo { get; set; } = ""; #endregion Public Properties + + public override bool Equals(object obj) + { + if (!(obj is RegistroScartiModel item)) + return false; + + if (IdxMacchina != item.IdxMacchina) + return false; + + if (DataOra != item.DataOra) + return false; + + if (Causale != item.Causale) + return false; + + return true; + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } } } \ No newline at end of file diff --git a/MP.Data/DatabaseModels/vSelEventiBCodeModel.cs b/MP.Data/DatabaseModels/vSelEventiBCodeModel.cs index caa0b4d9..f0b44ae0 100644 --- a/MP.Data/DatabaseModels/vSelEventiBCodeModel.cs +++ b/MP.Data/DatabaseModels/vSelEventiBCodeModel.cs @@ -11,8 +11,8 @@ namespace MP.Data.DatabaseModels public class vSelEventiBCodeModel { [Key] - public int IdxTipo { get; set; } = 0; - public string Label { get; set; } = ""; + public int value { get; set; } = 0; + public string label { get; set; } = ""; public bool EventoTablet { get; set; } = true; public string CssClass { get; set; } = ""; public string Icon { get; set; } = ""; diff --git a/MP.Data/MoonProContext.cs b/MP.Data/MoonProContext.cs index b36b607f..bcda74b5 100644 --- a/MP.Data/MoonProContext.cs +++ b/MP.Data/MoonProContext.cs @@ -77,6 +77,7 @@ namespace MP.Data public virtual DbSet DbSetTurniMacc { get; set; } public virtual DbSet DbSetRegControlli { get; set; } public virtual DbSet DbSetRegScarti { get; set; } + public virtual DbSet DbSetRegScartiKit { get; set; } public virtual DbSet DbSetRegDich { get; set; } public virtual DbSet DbSetRegWithCheck { get; set; } @@ -538,7 +539,7 @@ namespace MP.Data modelBuilder.Entity(entity => { - entity.HasKey(e => e.IdxTipo); + entity.HasKey(e => e.value); entity.ToView("v_selEventiBCode"); }); @@ -549,7 +550,11 @@ namespace MP.Data }); modelBuilder.Entity(entity => { - entity.HasKey(e => new { e.IdxMacchina, e.DataOra, e.Causale}); + entity.HasKey(e => new { e.IdxMacchina, e.DataOra, e.Causale }); + }); + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.IdxMacchina, e.DataOra, e.Causale, e.CodArticolo }); }); modelBuilder.Entity(entity => diff --git a/MP.Data/Services/MessageService.cs b/MP.Data/Services/MessageService.cs index cd063eb6..000f9e77 100644 --- a/MP.Data/Services/MessageService.cs +++ b/MP.Data/Services/MessageService.cs @@ -53,8 +53,6 @@ namespace MP.Data.Services #endregion Public Events - #region Public Properties - #if false protected bool _tReset { get; set; } = false; protected bool tReset @@ -76,10 +74,10 @@ namespace MP.Data.Services { EA_ResetFooterTimer?.Invoke(); } - } + } #endif - public DateTime dtLastAction { get; set; } = DateTime.Now; + #region Public Properties public string CognomeNome { @@ -120,6 +118,9 @@ namespace MP.Data.Services } } + public DateTime dtLastAction { get; set; } = DateTime.Now; + public DateTime dtLastSave { get; set; } = DateTime.Now; + public int MatrOpr { get @@ -247,22 +248,70 @@ namespace MP.Data.Services return SteamCrypto.DecryptString(encData, Constants.passPhrase); } + public async Task DoLogIn(string decodValue, bool saveOpr) + { + bool answ = false; + //expDays = SMService.GetConfInt("cookieDayExpire"); + //var expDT = DateTime.Now.AddDays(expDays); + var devGuid = await GetCurrDevGuidLSAsync(); + // decifro i valori.. + var decrVal = DecryptData(decodValue); + var opData = JsonConvert.DeserializeObject(decrVal); + if (opData != null) + { + var rigaOpr = await TDService.OperatoreSearch(opData.currOpr.MatrOpr, opData.currOpr.authKey); + if (rigaOpr != null) + { + userTknDTO newUserTkn = new userTknDTO() + { + currOpr = rigaOpr, + DevGuid = devGuid + }; + + var jsonTkn = JsonConvert.SerializeObject(newUserTkn); + string hash = TDService.EncryptData(jsonTkn); + RigaOper = rigaOpr; + await SetLastMatrOprAsync(rigaOpr.MatrOpr); + await SetCurrOperDtoLSAsync(hash); + if (saveOpr) + { + await TDService.OperatoreSetRedis(rigaOpr.MatrOpr, hash, devGuid); + } + answ = true; + } + } + return answ; + } + public string EncryptData(string rawData) { return SteamCrypto.EncryptString(rawData, Constants.passPhrase); } + /// + /// Restituisce il record device GUID da localstorage + /// + /// + public async Task GetCurrDevGuidLSAsync() + { + Guid answ = new Guid(); + var result = await localStorage.GetItemAsync("devGuid"); + if (result != null) + { + answ = Guid.Parse(result); + } + return answ; + } /// /// Restituisce il record OperatoreDTO da localstorage /// /// - public async Task GetCurrOperDtoAsync() + public async Task GetCurrOperDtoLSAsync() { string answ = ""; var result = await localStorage.GetItemAsync("currTkn"); if (result != null) { - //var data = JsonConvert.DeserializeObject(result); answ = result; } return answ; @@ -344,6 +393,7 @@ namespace MP.Data.Services { await localStorage.SetItemAsync("CurrMach", machSel); } + /// /// Scrive sul local storage pagina corrente /// @@ -390,13 +440,24 @@ namespace MP.Data.Services /// scrive il record OperatoreDTO nel localstorage /// /// - public async Task SetCurrOperDtoAsync(string currTkn) + public async Task SetCurrOperDtoLSAsync(string currTkn) { bool answ = false; await localStorage.SetItemAsync("currTkn", currTkn); answ = true; return answ; } + /// + /// scrive il record Device GUID nel localstorage + /// + /// + public async Task SetCurrDevGuidLSAsync(Guid currDevGuid) + { + bool answ = false; + await localStorage.SetItemAsync("devGuid", currDevGuid.ToString()); + answ = true; + return answ; + } /// /// Scrive il valore di IPV4 del device nel localstoragee @@ -438,48 +499,6 @@ namespace MP.Data.Services return answ; } - protected int expDays { get; set; } = 0; - - public async Task DoLogIn(string decodValue) - { - bool answ = false; - expDays = SMService.GetConfInt("cookieDayExpire"); - var expDT = DateTime.Now.AddDays(expDays); - // decifro i valori.. - var decrVal = DecryptData(decodValue); - var opData = JsonConvert.DeserializeObject(decrVal); - if (opData != null) - { - var rigaOpr = await TDService.OperatoreSearch(opData.currOpr.MatrOpr, opData.currOpr.authKey); - if (rigaOpr != null) - { - userTknDTO newUserTkn = new userTknDTO() - { - currOpr = rigaOpr, - expTime = expDT - }; - - var jsonTkn = JsonConvert.SerializeObject(newUserTkn); - string hash = TDService.EncryptData(jsonTkn); - RigaOper = rigaOpr; - await SetLastMatrOprAsync(rigaOpr.MatrOpr); - await SetCurrOperDtoAsync(hash); - await TDService.OperatoreSetRedis(rigaOpr.MatrOpr, hash); - answ = true; - //if (LastOpenedPage != "" && CurrMacc != "") - //{ - // NavMan.NavigateTo(LastOpenedPage); - //} - //else - //{ - // NavMan.NavigateTo("status-map"); - //} - } - } - return answ; - } - - /// /// Salva matrOpr nel localstorage /// @@ -492,6 +511,7 @@ namespace MP.Data.Services return answ; } + /// /// Recupero singola preferenza utente /// @@ -509,12 +529,12 @@ namespace MP.Data.Services } /// - /// Salvo singola rpeferenza utente + /// Salvo singola preferenza utente /// /// /// /// - public bool UserPrefSave(string chiave, string valore) + public bool UserPrefSet(string chiave, string valore) { bool done = false; var currDict = UsersPrefDict; @@ -548,7 +568,7 @@ namespace MP.Data.Services { if (MatrOpr > 0) { - UserPrefSave(chiave, defValue); + UserPrefSet(chiave, defValue); } } return answ; @@ -577,11 +597,11 @@ namespace MP.Data.Services #region Protected Properties + protected int expDays { get; set; } = 0; protected ILocalStorageService localStorage { get; set; } = null!; - protected TabDataService TDService { get; set; } = null!; - protected SharedMemService SMService { get; set; } = null!; - protected ISessionStorageService sessionStore { get; set; } = null!; + protected SharedMemService SMService { get; set; } = null!; + protected TabDataService TDService { get; set; } = null!; #endregion Protected Properties @@ -605,6 +625,12 @@ namespace MP.Data.Services #endregion Private Fields + #region Private Properties + + private Dictionary UserPrefs { get; set; } = new Dictionary(); + + #endregion Private Properties + #region Private Methods private string machineMse(string idxMacc) diff --git a/MP.Data/Services/StatusData.cs b/MP.Data/Services/StatusData.cs index 3c1782c9..3ac19b84 100644 --- a/MP.Data/Services/StatusData.cs +++ b/MP.Data/Services/StatusData.cs @@ -35,7 +35,7 @@ namespace MP.Data.Services } else { - dbController = new MP.Data.Controllers.MpMonController(configuration); + dbController = new Controllers.MpMonController(configuration); StringBuilder sb = new StringBuilder(); sb.AppendLine($"StatusData | MpMonController OK"); Log.Info(sb.ToString()); @@ -59,7 +59,7 @@ namespace MP.Data.Services #region Public Properties - public static MP.Data.Controllers.MpMonController dbController { get; set; } = null!; + public static Controllers.MpMonController dbController { get; set; } = null!; /// /// Dizionario dei tag configurati per IOB @@ -114,17 +114,16 @@ namespace MP.Data.Services public async Task> MseGetAll(bool forceDb = false) { - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); + Stopwatch sw = new Stopwatch(); + string source = "DB"; + sw.Start(); List? result = new List(); // cerco in redis... RedisValue rawData = redisDb.StringGet(Constants.redisMseKey); if (rawData.HasValue && !forceDb) { result = JsonConvert.DeserializeObject>($"{rawData}"); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"Read from REDIS: {ts.TotalMilliseconds}ms"); + source = "REDIS"; } else { @@ -132,17 +131,89 @@ namespace MP.Data.Services // serializzp e salvo... rawData = JsonConvert.SerializeObject(result); await redisDb.StringSetAsync(Constants.redisMseKey, rawData, TimeSpan.FromMilliseconds(maxAge)); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"Read from DB: {ts.TotalMilliseconds}ms"); } if (result == null) { result = new List(); } + sw.Stop(); + Log.Debug($"MseGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms"); return result; } + /// + /// Restituisce numPezzi (ultimo) x macchina + /// + /// + /// + public int MachNumPzGet(string idxMacchina) + { + int answ = 0; + if (MachineNumPz.ContainsKey(idxMacchina)) + { + answ = MachineNumPz[idxMacchina]; + } + return answ; + } + /// + /// Salva numPezzi x macchina + /// + /// + /// + /// + public bool MachNumPzSet(string idxMacchina, int numPz) + { + bool answ = false; + if (MachineNumPz.ContainsKey(idxMacchina)) + { + MachineNumPz[idxMacchina] = numPz; + } + else + { + MachineNumPz.Add(idxMacchina, numPz); + } + answ = true; + return answ; + } + + /// + /// Restituisce numPezzi (ultimo) x macchina + /// + /// + /// + public StatoProdModel MachProdStGet(string idxMacchina) + { + StatoProdModel answ = new StatoProdModel(); + if (MachineProdStatus.ContainsKey(idxMacchina)) + { + answ = MachineProdStatus[idxMacchina]; + } + return answ; + } + /// + /// Salva numPezzi x macchina + /// + /// + /// + /// + public bool MachProdStSet(string idxMacchina, StatoProdModel currStatus) + { + bool answ = false; + if (MachineProdStatus.ContainsKey(idxMacchina)) + { + MachineProdStatus[idxMacchina] = currStatus; + } + else + { + MachineProdStatus.Add(idxMacchina, currStatus); + } + answ = true; + return answ; + } + + private Dictionary MachineNumPz { get; set; } = new Dictionary(); + private Dictionary MachineProdStatus { get; set; } = new Dictionary(); + #endregion Public Methods #region Protected Fields diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs index baa9cbb9..fc1d6702 100644 --- a/MP.Data/Services/TabDataService.cs +++ b/MP.Data/Services/TabDataService.cs @@ -6,6 +6,7 @@ using MP.Data.DTO; using MP.Data.Objects; using Newtonsoft.Json; using NLog; +using Org.BouncyCastle.Asn1.IsisMtt.Ocsp; using StackExchange.Redis; using System; using System.Collections.Generic; @@ -253,7 +254,6 @@ namespace MP.Data.Services // cerco in redis... string currKey = $"{redisBaseKey}:VSEB:{IdxMacch}"; RedisValue rawData = await redisDb.StringGetAsync(currKey); - //if (!string.IsNullOrEmpty($"{rawData}")) if (rawData.HasValue) { result = JsonConvert.DeserializeObject>($"{rawData}"); @@ -513,6 +513,7 @@ namespace MP.Data.Services } return answ; } + /// /// Recupera il valore in formato DOUBLE /// @@ -841,6 +842,19 @@ namespace MP.Data.Services return answ; } + /// + /// Flush di tutta la cache relativa ad i dati ODL/PODL + /// + /// + public async Task FlushOdlCache() + { + await FlushCache("ODL"); + await FlushCache("PODL"); + await FlushCache("VSODL"); + await FlushCache("StatoMacc"); + await FlushCache("MSFD"); + } + /// /// Recupero info IOB x TAB (da info registrate IOB-WIN--> MP-IO) /// @@ -1225,9 +1239,7 @@ namespace MP.Data.Services { // inserisco evento answ = dbTabController.OdlClearSetup(idxODL, idxMacchina); - await FlushCache("ODL"); - await FlushCache("PODL"); - await FlushCache("VSODL"); + await FlushOdlCache(); } catch (Exception exc) { @@ -1287,9 +1299,7 @@ namespace MP.Data.Services { // inserisco evento answ = dbTabController.OdlDividiDaAltraTavola(idxODL, matrOpr, idxMacchinaTo); - await FlushCache("ODL"); - await FlushCache("PODL"); - await FlushCache("VSODL"); + await FlushOdlCache(); } catch (Exception exc) { @@ -1312,9 +1322,7 @@ namespace MP.Data.Services { // inserisco evento answ = dbTabController.OdlFineProd(idxODL, idxMacchina); - await FlushCache("ODL"); - await FlushCache("PODL"); - await FlushCache("VSODL"); + await FlushOdlCache(); } catch (Exception exc) { @@ -1338,9 +1346,7 @@ namespace MP.Data.Services { // inserisco evento answ = dbTabController.OdlFixMachineSlave(idxMacchina, numDayPrev, doInsert); - await FlushCache("ODL"); - await FlushCache("PODL"); - await FlushCache("VSODL"); + await FlushOdlCache(); } catch (Exception exc) { @@ -1367,9 +1373,7 @@ namespace MP.Data.Services { // inserisco evento answ = dbTabController.OdlInizioSetup(idxODL, matrOpr, idxMacchina, tcRich, pzPallet, note); - await FlushCache("ODL"); - await FlushCache("PODL"); - await FlushCache("VSODL"); + await FlushOdlCache(); } catch (Exception exc) { @@ -1473,9 +1477,7 @@ namespace MP.Data.Services // riordino result = results.FirstOrDefault(); // svuoto cache - await FlushCache("ODL"); - await FlushCache("PODL"); - await FlushCache("VSODL"); + await FlushOdlCache(); if (result == null) { result = new ODLModel(); @@ -1498,9 +1500,7 @@ namespace MP.Data.Services { // inserisco evento answ = await Task.FromResult(dbTabController.OdlSetupPostumo(idxODL, idxMacchina)); - await FlushCache("ODL"); - await FlushCache("PODL"); - await FlushCache("VSODL"); + await FlushOdlCache(); } catch (Exception exc) { @@ -1524,9 +1524,7 @@ namespace MP.Data.Services { // inserisco evento answ = await Task.FromResult(dbTabController.OdlSetupPromPostuma(idxPromOdl, matrOpr, idxMacchina)); - await FlushCache("ODL"); - await FlushCache("PODL"); - await FlushCache("VSODL"); + await FlushOdlCache(); } catch (Exception exc) { @@ -1555,9 +1553,7 @@ namespace MP.Data.Services { // inserisco evento answ = await Task.FromResult(dbTabController.OdlSplit(idxODL, matrOpr, idxMacchina, TCRich, pzPallet, note, startNewOdl, qtyRich)); - await FlushCache("ODL"); - await FlushCache("PODL"); - await FlushCache("VSODL"); + await FlushOdlCache(); } catch (Exception exc) { @@ -1583,9 +1579,7 @@ namespace MP.Data.Services { // inserisco evento answ = dbTabController.OdlUpdate(idxODL, matrOpr, tCRichAttr, pzPallet, note); - await FlushCache("ODL"); - await FlushCache("PODL"); - await FlushCache("VSODL"); + await FlushOdlCache(); } catch (Exception exc) { @@ -1600,14 +1594,14 @@ namespace MP.Data.Services /// /// /// - public async Task OperatoreDeleteRedis(int matrOpr) + public async Task OperatoreDeleteRedis(int matrOpr, Guid DevGuid) { string source = "REDIS"; Stopwatch sw = new Stopwatch(); sw.Start(); bool answ = false; // cerco in redis... - string currKey = $"{redisUserDataKey}:CurrOpr:{matrOpr}"; + string currKey = $"{redisUserDataKey}:CurrOpr:{matrOpr}:CurrDevGuid:{DevGuid}"; RedisValue rawData = await redisDb.StringGetAsync(currKey); if (rawData.HasValue) { @@ -1624,18 +1618,18 @@ namespace MP.Data.Services } /// - /// Scrive l'hash dell'oggetto curr opr + /// Legge l'oggetto operatore loggato /// /// /// - public async Task OperatoreGetRedis(int matrOpr) + public async Task OperatoreGetRedis(int matrOpr, Guid currDevGuid) { string source = "REDIS"; Stopwatch sw = new Stopwatch(); sw.Start(); string answ = ""; // cerco in redis... - string currKey = $"{redisUserDataKey}:CurrOpr:{matrOpr}"; + string currKey = $"{redisUserDataKey}:CurrOpr:{matrOpr}:CurrDevGuid:{currDevGuid}"; RedisValue rawData = await redisDb.StringGetAsync(currKey); if (rawData.HasValue) { @@ -1681,7 +1675,7 @@ namespace MP.Data.Services /// /// /// - public async Task OperatoreSetRedis(int matrOpr, string currOpr) + public async Task OperatoreSetRedis(int matrOpr, string currOpr, Guid currDevGuid) { setExpDays(); string source = "REDIS"; @@ -1689,7 +1683,7 @@ namespace MP.Data.Services sw.Start(); string answ = ""; // cerco in redis... - string currKey = $"{redisUserDataKey}:CurrOpr:{matrOpr}"; + string currKey = $"{redisUserDataKey}:CurrOpr:{matrOpr}:CurrDevGuid:{currDevGuid}"; //RedisValue rawData = await redisDb.StringGetAsync(currKey); // serializzo e salvo... //rawData = JsonConvert.SerializeObject(currOpr); @@ -1759,8 +1753,7 @@ namespace MP.Data.Services { // inserisco evento answ = dbTabController.PODL_startSetup(editRec, matrOpr, tcRich, pzPallet, note, dtEvent); - await FlushCache("ODL"); - await FlushCache("PODL"); + await FlushOdlCache(); } catch (Exception exc) { @@ -1968,6 +1961,42 @@ namespace MP.Data.Services return answ; } + /// + /// Restituisce elenco ULTIMI RC x macchina + /// + /// + /// + public async Task> RegControlliLast(string idxMacchina) + { + // setup parametri costanti + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:RecContr:{idxMacchina}:LAST"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbTabController.RegControlliLast(idxMacchina); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, FastCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"RegControlliLast | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + /// /// Aggiunta record RegistroScarti /// @@ -2105,9 +2134,10 @@ namespace MP.Data.Services try { // inserisco evento - answ = await dbTabController.RegScartiInsert(newRec); + answ = dbTabController.RegScartiInsert(newRec); // reset cache eventi/commenti await FlushCache("RegScarti"); + await FlushCache("RegScartiKit"); } catch (Exception exc) { @@ -2117,88 +2147,183 @@ namespace MP.Data.Services return answ; } + /// + /// Elimina elenco RSK da parent + /// + /// + /// + public async Task RegScartiKitDelete(RegistroScartiModel ParentRec) + { + bool answ = false; + try + { + // inserisco evento + answ = dbTabController.RegScartiKitDelete(ParentRec); + // reset cache eventi/commenti + await FlushCache("RegScarti"); + await FlushCache("RegScartiKit"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in RegScartiKitDelete | macchina: {ParentRec.IdxMacchina} | DataOra: {ParentRec.DataOra} | Causale: {ParentRec.Causale} | MatrOpr: {ParentRec.MatrOpr} | Qta {ParentRec.Qta} | Note: {ParentRec.Note}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + + /// + /// Restituisce elenco RSK filtrato x parent + /// + /// + /// + public async Task> RegScartiKitGetFilt(RegistroScartiModel ParentRec) + { + // setup parametri costanti + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:RegScartiKit:{ParentRec.IdxMacchina}:{ParentRec.DataOra:yyyyyMMdd-HHmm}:{ParentRec.Causale}"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbTabController.RegScartiKitGetFilt(ParentRec); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, FastCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"RegScartiKitGetFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + + /// + /// Split record RegistroScarti --> RegistroScartiKit + /// + /// + /// + public async Task RegScartiKitSplit(RegistroScartiModel newRec) + { + bool answ = false; + try + { + // inserisco evento + answ = await dbTabController.RegScartiKitSplit(newRec); + // reset cache eventi/commenti + await FlushCache("RegScarti"); + await FlushCache("RegScartiKit"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in RegScartiKitSplit | 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; + } + + /// + /// Update qty record singolo articolo di un KIT Scarti + /// + /// + /// + public async Task RegScartiKitUpdateQty(RegistroScartiKitModel editRec) + { + bool answ = false; + try + { + // aggiorno record + answ = dbTabController.RegScartiKitUpdateQty(editRec); + // reset cache eventi/commenti + await FlushCache("RegScarti"); + await FlushCache("RegScartiKit"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in RegScartiKitUpdateQty | macchina: {editRec.IdxMacchina} | DataOra: {editRec.DataOra} | Causale: {editRec.Causale} | MatrOpr: {editRec.MatrOpr} | Qta {editRec.Qta} | Note: {editRec.Note}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + /// /// Resetta (rileggendo) i dati della macchina /// /// /// - public Dictionary resetDatiMacchina(string idxMacchina) + public async Task> resetDatiMacchina(string idxMacchina) { Dictionary answ = new Dictionary(); -#if false - string currHash = dtMaccHash(idxMacchina); // inizio con un bel reset... - memLayer.ML.redFlushKey(currHash); - DS_applicazione.MSFDDataTable tabMSFD = new DS_applicazione.MSFDDataTable(); - // 2018.01.08 SEMPRE senza singleton: instanzio un nuovo oggetto MapoDb - MapoDb connDb = new MapoDb(); - tabMSFD = connDb.taMSFD.getByIdxMacc(idxMacchina); - bool trovato = false; - // se ho righe... - DS_applicazione.MSFDDataTable tab = new DS_applicazione.MSFDDataTable(); - DS_applicazione.MSFDRow rigaMSFD; - if (tabMSFD.Rows.Count > 0) - { - try - { - rigaMSFD = tabMSFD[0]; - trovato = true; - } - catch - { - rigaMSFD = tab.NewMSFDRow(); - } - } - else - { - rigaMSFD = tab.NewMSFDRow(); - } - if (trovato) + string currKey = $"{redisBaseKey}:MSFD"; + await FlushCache(currKey); + var tabMSFD = await VMSFDGetByMacc(idxMacchina); + if (tabMSFD != null && tabMSFD.Count > 0) { + var rigaMSFD = tabMSFD.FirstOrDefault(); // ora provo a compilare... try { // salvo 1:1 i valori... STATO - answ.Add("IdxMicroStato", rigaMSFD.IdxMicroStato.ToString()); - answ.Add("IdxStato", rigaMSFD.IdxStato.ToString()); - answ.Add("CodArticolo", rigaMSFD.CodArticolo); - answ.Add("insEnabled", rigaMSFD.insEnabled.ToString()); - answ.Add("sLogEnabled", rigaMSFD.sLogEnabled.ToString()); - answ.Add("pallet", rigaMSFD.pallet); - answ.Add("CodArticolo_A", rigaMSFD.CodArticolo_A); - answ.Add("CodArticolo_B", rigaMSFD.CodArticolo_B); - answ.Add("TempoCicloBase", rigaMSFD.TempoCicloBase.ToString()); - answ.Add("PzPalletProd", rigaMSFD.PzPalletProd.ToString()); - answ.Add("MatrOpr", rigaMSFD.MatrOpr.ToString()); - answ.Add("lastVal", rigaMSFD.lastVal); - answ.Add("TCBase", rigaMSFD.TempoCicloBase.ToString()); + answ.Add("IdxMicroStato", $"{rigaMSFD.IdxMicroStato}"); + answ.Add("IdxStato", $"{rigaMSFD.IdxStato}"); + answ.Add("CodArticolo", $"{rigaMSFD.CodArticolo}"); + answ.Add("insEnabled", $"{rigaMSFD.InsEnabled}"); + answ.Add("sLogEnabled", $"{rigaMSFD.SLogEnabled}"); + answ.Add("pallet", $"{rigaMSFD.Pallet}"); + answ.Add("CodArticolo_A", $"{rigaMSFD.CodArticoloA}"); + answ.Add("CodArticolo_B", $"{rigaMSFD.CodArticoloB}"); + answ.Add("TempoCicloBase", $"{rigaMSFD.TempoCicloBase}"); + answ.Add("PzPalletProd", $"{rigaMSFD.PzPalletProd}"); + answ.Add("MatrOpr", $"{rigaMSFD.MatrOpr}"); + answ.Add("lastVal", $"{rigaMSFD.LastVal}"); + answ.Add("TCBase", $"{rigaMSFD.TempoCicloBase}"); //...e SETUP - answ.Add("CodMacc", rigaMSFD.codmacchina); - answ.Add("IdxFamIn", rigaMSFD.IdxFamigliaIngresso.ToString()); - answ.Add("Multi", rigaMSFD.Multi.ToString()); - answ.Add("BitFilt", rigaMSFD.BitFilt.ToString()); - answ.Add("MaxVal", rigaMSFD.MaxVal.ToString()); - answ.Add("BSR", rigaMSFD.BSR.ToString()); - answ.Add("ExplodeBit", rigaMSFD.ExplodeBit.ToString()); - answ.Add("NumBit", rigaMSFD.NumBit.ToString()); - answ.Add("IdxFamMacc", rigaMSFD.IdxFamiglia.ToString()); - answ.Add("simplePallet", rigaMSFD.simplePallet.ToString()); - answ.Add("palletChange", rigaMSFD.palletChange.ToString()); + answ.Add("CodMacc", rigaMSFD.Codmacchina); + answ.Add("IdxFamIn", $"{rigaMSFD.IdxFamigliaIngresso}"); + answ.Add("Multi", $"{rigaMSFD.Multi}"); + answ.Add("BitFilt", $"{rigaMSFD.BitFilt}"); + answ.Add("MaxVal", $"{rigaMSFD.MaxVal}"); + answ.Add("BSR", $"{rigaMSFD.Bsr}"); + answ.Add("ExplodeBit", $"{rigaMSFD.ExplodeBit}"); + answ.Add("NumBit", $"{rigaMSFD.NumBit}"); + answ.Add("IdxFamMacc", $"{rigaMSFD.IdxFamiglia}"); + answ.Add("simplePallet", $"{rigaMSFD.SimplePallet}"); + answ.Add("palletChange", $"{rigaMSFD.PalletChange}"); + // cerco dati master/slave... + var macSlave = await Macchine2Slave(); + var mastList = macSlave + .Where(x => x.IdxMacchina.Equals(idxMacchina, StringComparison.InvariantCultureIgnoreCase)) + .ToList(); + var slaveList = macSlave + .Where(x => x.IdxMacchinaSlave.Equals(idxMacchina, StringComparison.InvariantCultureIgnoreCase)) + .ToList(); + + string isMaster = mastList.Count > 0 ? "1" : "0"; + string isSlave = slaveList.Count > 0 ? "1" : "0"; + answ.Add("Master", isMaster); + answ.Add("Slave", isSlave); } catch (Exception exc) { - Log.Info(string.Format("Errore in compilazione dati MSFD:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + Log.Error($"Errore in compilazione dati MSFD:{Environment.NewLine}{exc}"); } - // cerco dati master/slave... - string isMaster = connDb.taM2S.getByMaster(idxMacchina).Count > 0 ? "1" : "0"; - string isSlave = connDb.taM2S.getBySlave(idxMacchina).Count > 0 ? "1" : "0"; - answ.Add("Master", isMaster); - answ.Add("Slave", isSlave); // verifico il timeout che cambia a seconda che sia vero o falso insEnabled... - int tOutShort = memLayer.ML.cdvi("TmOut.MS.S"); - int tOutLong = memLayer.ML.cdvi("TmOut.MS.L"); + int tOutShort = 0; + int tOutLong = 0; + ConfigGetVal("TmOut.MS.S", ref tOutShort); + ConfigGetVal("TmOut.MS.L", ref tOutLong); int redDtMacTOut = tOutLong; try { @@ -2209,13 +2334,8 @@ namespace MP.Data.Services Log.Info($"Eccezione in calcolo timeout dati macchina: idxMacchina{idxMacchina} | TShort: {tOutShort} | TLong {tOutLong}{Environment.NewLine}{exc}"); } // salvo in redis! - memLayer.ML.redSaveHashDict(currHash, answ, redDtMacTOut); + redisHashDictSet(currKey, answ, TimeSpan.FromSeconds(redDtMacTOut)); } - else - { - Log.Info("Errore in chiamata stp_MSFD_getMacc (connDb.taMSFD.getByIdxMacc(idxMacchina))"); - } -#endif return answ; } @@ -2223,7 +2343,7 @@ namespace MP.Data.Services /// Effettua reset microstato macchina /// /// - public void resetMicrostatoMacchina(string idxMacchina) + public async Task resetMicrostatoMacchina(string idxMacchina) { // salvo microstato 0... MicroStatoMacchinaModel newRecMS = new MicroStatoMacchinaModel() @@ -2235,7 +2355,7 @@ namespace MP.Data.Services }; var result = dbTabController.MicroStatoMacchinaUpsert(newRecMS); // reset in redis - resetDatiMacchina(idxMacchina); + await resetDatiMacchina(idxMacchina); } /// @@ -2632,7 +2752,7 @@ namespace MP.Data.Services sw.Start(); StatoProdModel? result = new StatoProdModel(); // cerco in redis... - string currKey = $"{redisBaseKey}:StatoProd:{idxMacchina}:{dtReq:HHmmss}"; + string currKey = $"{redisBaseKey}:StatoProd:{idxMacchina}:{dtReq:HHmm}"; RedisValue rawData = await redisDb.StringGetAsync(currKey); //if (!string.IsNullOrEmpty($"{rawData}")) if (rawData.HasValue) @@ -3190,6 +3310,36 @@ namespace MP.Data.Services return fatto; } + /// + /// Salvataggio Dictionary come HashSet Redis + /// + /// + /// + /// + private bool redisHashDictSet(RedisKey currKey, Dictionary dict, TimeSpan ttl) + { + 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); + redisDb.KeyExpire(currKey, ttl); + 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 ///