diff --git a/MP.Core/Utils.cs b/MP.Core/Utils.cs index 544597ff..ca50ee3f 100644 --- a/MP.Core/Utils.cs +++ b/MP.Core/Utils.cs @@ -70,8 +70,9 @@ namespace MP.Core public const string redisXdlData = redisBaseAddr + "Cache:XDL:"; - public const string redisKitTempl = redisBaseAddr + "Cache:Kit:Templ"; public const string redisKitInst = redisBaseAddr + "Cache:Kit:Inst"; + public const string redisKitTempl = redisBaseAddr + "Cache:Kit:Templ"; + public const string redisKitWip = redisBaseAddr + "Cache:Kit:Wip"; #endregion Public Fields diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index 075a368b..ef16c1e0 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -812,6 +812,87 @@ namespace MP.Data.Controllers return fatto; } + /// + /// Elimina record + /// + /// + public bool IstKitDelete(IstanzeKitModel rec2del) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var actRec = dbCtx + .DbSetInstKit + .Where(x => x.KeyKit == rec2del.KeyKit && x.KeyExtOrd == rec2del.KeyExtOrd) + .FirstOrDefault(); + // se ci fosse aggiorno... + if (actRec != null) + { + dbCtx + .DbSetInstKit + .Remove(actRec); + } + var res = dbCtx.SaveChanges(); + fatto = res != 0; + } + return fatto; + } + + /// + /// Elenco istanze KIT da ricerca + /// + /// + /// + /// + public List IstKitFilt(string keyKit, string keyExtOrd) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetInstKit + .Where(x => (string.IsNullOrEmpty(keyKit) && string.IsNullOrEmpty(keyExtOrd)) || (x.KeyKit.Contains(keyKit) && !string.IsNullOrEmpty(keyKit)) || (x.KeyExtOrd.Contains(keyExtOrd) && !string.IsNullOrEmpty(keyExtOrd))) + .AsNoTracking() + .ToList(); + } + return dbResult; + } + + /// + /// Esegue upsert record + /// + /// + public bool IstKitUpsert(IstanzeKitModel editRec) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var actRec = dbCtx + .DbSetInstKit + .Where(x => x.KeyKit == editRec.KeyKit && x.KeyExtOrd == editRec.KeyExtOrd) + .FirstOrDefault(); + + // se ci fosse aggiorno... + if (actRec == null) + { + dbCtx + .DbSetInstKit + .Add(editRec); + } + else + { + actRec.CodArtParent = editRec.CodArtParent; + actRec.CodArtChild = editRec.CodArtChild; + actRec.QtyART = editRec.QtyART; + actRec.QtyKIT = editRec.QtyKIT; + dbCtx.Entry(actRec).State = EntityState.Modified; + } + var res = dbCtx.SaveChanges(); + fatto = res != 0; + } + return fatto; + } + /// /// Elenco giacenze /// @@ -1658,19 +1739,19 @@ namespace MP.Data.Controllers } /// - /// Elenco template da ricerca + /// Elenco template KIT da ricerca /// - /// - /// + /// + /// /// - public List TemplateKitFilt(string codParent, string codChild) + public List TemplateKitFilt(string KitCode, string codChild) { List dbResult = new List(); using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx .DbSetTempKit - .Where(x => (string.IsNullOrEmpty(codParent) && string.IsNullOrEmpty(codChild)) || (x.CodArtParent.Contains(codParent) && !string.IsNullOrEmpty(codParent)) || (x.CodArtChild.Contains(codChild) && !string.IsNullOrEmpty(codChild))) + .Where(x => (string.IsNullOrEmpty(KitCode) && string.IsNullOrEmpty(codChild)) || (x.CodArtParent.Contains(KitCode) && !string.IsNullOrEmpty(KitCode)) || (x.CodArtChild.Contains(codChild) && !string.IsNullOrEmpty(codChild))) .AsNoTracking() .ToList(); } @@ -1700,8 +1781,6 @@ namespace MP.Data.Controllers } else { - actRec.CodArtParent = editRec.CodArtParent; - actRec.CodArtChild = editRec.CodArtChild; actRec.Qty = editRec.Qty; dbCtx.Entry(actRec).State = EntityState.Modified; } @@ -1729,6 +1808,143 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Elimina record + /// + /// + public bool WipKitDelete(WipSetupKitModel rec2del) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var actRec = dbCtx + .DbSetWipKit + .Where(x => x.KeyFilt == rec2del.KeyFilt && x.CodOrd == rec2del.CodOrd) + .FirstOrDefault(); + // se ci fosse aggiorno... + if (actRec != null) + { + dbCtx + .DbSetWipKit + .Remove(actRec); + } + var res = dbCtx.SaveChanges(); + fatto = res != 0; + } + return fatto; + } + + /// + /// Elimina i record associati al KeyFilt indicato + /// + /// + public bool WipKitDeleteGroup(string KeyFilt) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var actRec = dbCtx + .DbSetWipKit + .Where(x => x.KeyFilt == KeyFilt) + .ToList(); + // se ci fosse aggiorno... + if (actRec != null) + { + dbCtx + .DbSetWipKit + .RemoveRange(actRec); + } + var res = dbCtx.SaveChanges(); + fatto = res != 0; + } + return fatto; + } + + /// + /// Elimina record + vecchi della data-ora indicata + /// + /// + /// + public bool WipKitDeleteOlder(DateTime dateLimit) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var actRec = dbCtx + .DbSetWipKit + .Where(x => x.DataIns < dateLimit) + .ToList(); + // se ci fosse aggiorno... + if (actRec != null) + { + dbCtx + .DbSetWipKit + .RemoveRange(actRec); + } + var res = dbCtx.SaveChanges(); + fatto = res != 0; + } + return fatto; + } + + /// + /// Elenco record WipSetupKit da KeyFilt + /// + /// + /// + public List WipKitFilt(string KeyFilt) + { + List dbResult = new List(); + // solo se filtro valido... + if (!string.IsNullOrEmpty(KeyFilt)) + { + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetWipKit + .Where(x => x.KeyFilt.Contains(KeyFilt)) + .AsNoTracking() + .ToList(); + } + } + return dbResult; + } + + /// + /// Esegue upsert record + /// + /// + public bool WipKitUpsert(WipSetupKitModel editRec) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var actRec = dbCtx + .DbSetWipKit + .Where(x => x.KeyFilt == editRec.KeyFilt && x.CodOrd == editRec.CodOrd) + .FirstOrDefault(); + + // se ci fosse aggiorno... + if (actRec == null) + { + dbCtx + .DbSetWipKit + .Add(editRec); + } + else + { + actRec.CodArt = editRec.CodArt; + actRec.DescArt = editRec.DescArt; + actRec.Qta = editRec.Qta; + actRec.DataIns = editRec.DataIns; + dbCtx.Entry(actRec).State = EntityState.Modified; + } + var res = dbCtx.SaveChanges(); + fatto = res != 0; + } + return fatto; + } + #endregion Public Methods #region Private Fields diff --git a/MP.Data/DbModels/WipSetupKitModel.cs b/MP.Data/DbModels/WipSetupKitModel.cs new file mode 100644 index 00000000..739f0940 --- /dev/null +++ b/MP.Data/DbModels/WipSetupKitModel.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace MP.Data.DbModels +{ + /// + /// Classe gestione item temporaneo x setup KIT di lavorazione + /// + [Table("WipSetupKit")] + public class WipSetupKitModel + { + #region Public Properties + + /// + /// Ticket composizione KIT + /// + [MaxLength(50)] + public string KeyFilt { get; set; } = "-"; + + /// + /// Cod esterno ordine (KeyRif ordine ERP) + /// + [MaxLength(50)] + public string CodOrd { get; set; } = ""; + + /// + /// Codice Articolo + /// + [MaxLength(50)] + public string CodArt { get; set; } = ""; + /// + /// Descrizione Articolo + /// + [MaxLength(250)] + public string DescArt { get; set; } = ""; + + /// + /// Quantità articoli dell'ordine + /// + public int Qta { get; set; } + + /// + /// DataOra inserimento record + /// + public DateTime DataIns { get; set; } = DateTime.Now; + + #endregion Public Properties + } +} diff --git a/MP.Data/MoonProContext.cs b/MP.Data/MoonProContext.cs index 76f9d4cf..70966108 100644 --- a/MP.Data/MoonProContext.cs +++ b/MP.Data/MoonProContext.cs @@ -101,6 +101,7 @@ namespace MP.Data public virtual DbSet DbSetAnagCount { get; set; } public virtual DbSet DbSetInstKit { get; set; } public virtual DbSet DbSetTempKit { get; set; } + public virtual DbSet DbSetWipKit { get; set; } #endregion Public Properties @@ -584,6 +585,10 @@ namespace MP.Data { entity.HasKey(e => new { e.CodArtParent, e.CodArtChild }); }); + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.KeyFilt, e.CodOrd}); + }); OnModelCreatingPartial(modelBuilder); } diff --git a/MP.SPEC/Components/GestKitPodl.razor b/MP.SPEC/Components/GestKitPodl.razor new file mode 100644 index 00000000..544292a3 --- /dev/null +++ b/MP.SPEC/Components/GestKitPodl.razor @@ -0,0 +1,28 @@ +
+
+

KIT e Promesse

+
+
+ Elenco KIT associati ad ordini +

...tabella...

+ @* + + Nessun Record (Ordini associati a KIT) + + + + + + + + + + + + + *@ +
+ +
\ No newline at end of file diff --git a/MP.SPEC/Components/GestKitPodl.razor.cs b/MP.SPEC/Components/GestKitPodl.razor.cs new file mode 100644 index 00000000..e2b99b1b --- /dev/null +++ b/MP.SPEC/Components/GestKitPodl.razor.cs @@ -0,0 +1,7 @@ +namespace MP.SPEC.Components +{ + public partial class GestKitPodl + { + + } +} \ No newline at end of file diff --git a/MP.SPEC/Components/GestKitVerif.razor b/MP.SPEC/Components/GestKitVerif.razor new file mode 100644 index 00000000..a4f81c93 --- /dev/null +++ b/MP.SPEC/Components/GestKitVerif.razor @@ -0,0 +1,78 @@ +
+
+

Verifica KIT

+
+
+ Elenco KIT compatibili +

...tabella...

+ @* + + Nessun KIT trovato + + + + + + + + Prom.ODL + + + + + + + + + + + *@ +
+ Elenco promesse per KIT (100%) +

...tabella...

+ @* + + + + +
+ + +
+
+ +
+
+ +
+
+
+ + + + +
+ +
+
+ +
+ + Nessun Record (P.ODL da eseguire) + +
+ + + + + + + *@ +
+
+ +
+ + diff --git a/MP.SPEC/Components/GestKitVerif.razor.cs b/MP.SPEC/Components/GestKitVerif.razor.cs new file mode 100644 index 00000000..c3394c1d --- /dev/null +++ b/MP.SPEC/Components/GestKitVerif.razor.cs @@ -0,0 +1,7 @@ +namespace MP.SPEC.Components +{ + public partial class GestKitVerif + { + + } +} \ No newline at end of file diff --git a/MP.SPEC/Components/ProdKit/Composer.razor b/MP.SPEC/Components/ProdKit/Composer.razor new file mode 100644 index 00000000..694b7b08 --- /dev/null +++ b/MP.SPEC/Components/ProdKit/Composer.razor @@ -0,0 +1,66 @@ +
+
+
+
+

Composizione KIT

+
+
+ +
+
+
+
+ @* + + Nessun Ordine caricato + + + + + + + + + + + + + *@ +
+
+ + + + + + + + + + + + + @foreach (var record in ListRecords) + { + + + + + + + + + } + +
Cod OrdineCod ArticoloDescr. Art.QtyData
@record.CodOrd@record.CodArt@record.DescArt@record.Qta@($"{record.DataIns:yyyy.MM.dd HH:mm:ss}") + +
+
+
+
+ +
+ + diff --git a/MP.SPEC/Components/ProdKit/Composer.razor.cs b/MP.SPEC/Components/ProdKit/Composer.razor.cs new file mode 100644 index 00000000..ff96b4ce --- /dev/null +++ b/MP.SPEC/Components/ProdKit/Composer.razor.cs @@ -0,0 +1,112 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MP.Data.DbModels; +using MP.SPEC.Data; + +namespace MP.SPEC.Components.ProdKit +{ + public partial class Composer + { + #region Public Properties + + [Parameter] + public PODLExpModel? Rec2Add + { + get => currRec; + set + { + if (currRec != value) + { + currRec = value; + if (value != null) + { + // chiamo tentativo update! + WipSetupKitModel newRec = new WipSetupKitModel() + { + KeyFilt = KeyFilt, + CodArt = value.CodArticolo, + CodOrd = value.KeyRichiesta, + DescArt = value.DescArticolo, + Qta = value.NumPezzi, + DataIns = DateTime.Now + }; + bool fatto = MDService.WipKitUpsert(newRec); + } + // rileggoi + ReloadData(); + } + } + } + + #endregion Public Properties + + #region Protected Properties + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + [Inject] + protected MpDataService MDService { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected async Task CleanupOld() + { + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare tutti i record temporanei della procedura di composizione KIT?")) + return; + + // elimino TUTTO... + DateTime dtLimit = DateTime.Now;//.AddHours(-1); + var done = MDService.WipKitDeleteOlder(dtLimit); + ReloadData(); + } + + protected async Task DoDelete(WipSetupKitModel rec2del) + { + if (!await JSRuntime.InvokeAsync("confirm", "Eliminazione riga KIT: sei sicuro di voler procedere?")) + return; + + var done = MDService.WipKitDelete(rec2del); + ReloadData(); + } + + protected override void OnInitialized() + { + // calcolo codice temporaneo utente...da apertura KIT + if (string.IsNullOrEmpty(KeyFilt)) + { + DateTime adesso = DateTime.Now; + KeyFilt = $"KIT_{adesso:yyMMdd}_{adesso:HHmmss}"; + // elimino dati + vecchi di 2h... + DateTime dtLimit = DateTime.Now.AddHours(-2); + var done = MDService.WipKitDeleteOlder(dtLimit); + } + + ReloadData(); + } + + #endregion Protected Methods + + #region Private Fields + + private PODLExpModel? currRec = null; + private string KeyFilt = ""; + private List ListRecords = new List(); + + private List SearchRecord = new List(); + + #endregion Private Fields + + #region Private Methods + + private void ReloadData() + { + SearchRecord = MDService.WipKitFilt(KeyFilt); + ListRecords = SearchRecord.ToList(); + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP.SPEC/Components/ProdKit/Manager.razor b/MP.SPEC/Components/ProdKit/Manager.razor new file mode 100644 index 00000000..901fa89f --- /dev/null +++ b/MP.SPEC/Components/ProdKit/Manager.razor @@ -0,0 +1,16 @@ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + diff --git a/MP.SPEC/Components/ProdKit/Manager.razor.cs b/MP.SPEC/Components/ProdKit/Manager.razor.cs new file mode 100644 index 00000000..dda2ba14 --- /dev/null +++ b/MP.SPEC/Components/ProdKit/Manager.razor.cs @@ -0,0 +1,49 @@ +using Microsoft.AspNetCore.Components; +using MP.Data.DbModels; +using MP.SPEC.Data; + +namespace MP.SPEC.Components.ProdKit +{ + public partial class Manager + { + #region Protected Properties + + [Inject] + protected MpDataService MDService { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected override void OnInitialized() + { + if (string.IsNullOrEmpty(padCodXdl)) + { + padCodXdl = MDService.ConfigTryGet("padCodXdl"); + } + currPodlRec = null; + } + + #endregion Protected Methods + + #region Private Fields + + private string padCodXdl = "00000"; + + /// + /// Salvataggio su Tab WIP dei dati del PODL ricevuto... + /// + /// + protected void SavePodl(PODLExpModel selRec) + { + currPodlRec = selRec; + } + + /// + /// Record PODL corrente da inserire + /// + private PODLExpModel? currPodlRec = null; + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/MP.SPEC/Components/ProdKit/PodlMan.razor b/MP.SPEC/Components/ProdKit/PodlMan.razor new file mode 100644 index 00000000..392629c4 --- /dev/null +++ b/MP.SPEC/Components/ProdKit/PodlMan.razor @@ -0,0 +1,125 @@ +
+
+
+
+ PODL disponibili +
+
+
+ + + @* *@ +
+
+
+
+
+ @if (ListRecords == null || isLoading) + { + + } + else if (totalCount == 0) + { +
Nessun record trovato
+ } + else + { +
+
+ + + + + + + + + + + @foreach (var record in ListRecords) + { + + + + + + + } + +
+ @if (currRecord != null) + { + + } + Info ciclo Articolo Att
+ + +
+
+
+ PODL +
+
+ @($"{record.IdxPromessa.ToString(PadCodXdl)}") +
+
+
+
+
N° pezzi:
+
@record.NumPezzi
+
+
+
T. Ciclo:
+
@record.Tcassegnato.ToString("N2")
+
+
+
+ @record.KeyRichiesta +
+
+
+ @record.CodArticolo +
+
+
@record.DescArticolo
+
+
+ @if (record.Note != "") + { +
+ Note: @record.Note +
+ } +
+
+ @if (@record.Attivabile) + { + + } + else + { + + } +
+ @if (!string.IsNullOrEmpty(record.Recipe)) + { +
+ +
+ } +
+
+
+ } +
+ +
+ + + + diff --git a/MP.SPEC/Components/ProdKit/PodlMan.razor.cs b/MP.SPEC/Components/ProdKit/PodlMan.razor.cs new file mode 100644 index 00000000..43e025e8 --- /dev/null +++ b/MP.SPEC/Components/ProdKit/PodlMan.razor.cs @@ -0,0 +1,331 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MP.Data; +using MP.Data.DbModels; +using MP.SPEC.Data; +using MP.SPEC.Services; +using NLog; + +namespace MP.SPEC.Components.ProdKit +{ + public partial class PodlMan : IDisposable + { + #region Public Properties + + [Parameter] + public string PadCodXdl { get; set; } = "0000"; + + [Parameter] + public EventCallback PagerResetReq { get; set; } + + [Parameter] + public EventCallback EC_RecordSel { get; set; } + + [Parameter] + public EventCallback UpdateRecordCount { get; set; } + + #endregion Public Properties + + #region Public Methods + + public string checkSelect(PODLExpModel record) + { + string answ = ""; + if (currRecord != null) + { + try + { + answ = (currRecord.IdxPromessa == record.IdxPromessa) ? "table-info" : ""; + //answ = ((EditRecord.IdxMacchina == record.IdxMacchina) && (EditRecord.CodArticolo == record.CodArticolo) && (EditRecord.CodFase == record.CodFase)) ? "table-info" : ""; + } + catch + { } + } + return answ; + } + + public void Dispose() + { + currRecord = null; + SearchRecords = null; + ListRecords = null; + ListStati = null; + GC.Collect(); + } + + #endregion Public Methods + + + protected void ResetParent() + { + SearchVal = ""; + UpdateTable(); + } + + protected string sParentCss + { + get => string.IsNullOrEmpty(SearchVal) ? "btn-secondary" : "btn-primary"; + } + + #region Protected Properties + + protected SelectXdlParams ActFilter { get; set; } = new SelectXdlParams(); + + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + [Inject] + protected MpDataService MDService { get; set; } = null!; + + [Inject] + protected IOApiService MpIoApiCall { get; set; } = null!; + + [Inject] + protected NavigationManager NavManager { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected override async Task OnInitializedAsync() + { + ListStati = await MDService.AnagStatiComm(); + string SPEC_PODL_gest = await MDService.ConfigTryGetAsync("SPEC_PODL_gest"); + DateTime oggi = DateTime.Today; + ActFilter = new SelectXdlParams() + { + DtEnd = oggi.AddDays(1), + DtStart = oggi.AddYears(-1), + HasOdl = false, + MaxRecord = 1000, + NumRec = 5 + }; + } + + protected override async Task OnParametersSetAsync() + { + if (!lastFilter.Equals(ActFilter)) + { + lastFilter = ActFilter.clone(); + await ReloadData(); + } + } + + protected async void OnSeachUpdated() + { + await InvokeAsync(() => + { + PagerResetReq.InvokeAsync(true); + Task task = UpdateData(); + StateHasChanged(); + }); + } + + protected async Task ReloadData() + { + ListRecords = null; + isLoading = true; + SearchRecords = await MDService.POdlListGetFilt(hasOdl, StatoSel, macchina, reparto, selDtStart, selDtEnd); + // filtro tenendo SOLO se hanno keyRichiesta CodExt... Hard Coded... + SearchRecords = SearchRecords + .Where(x => !string.IsNullOrEmpty(x.KeyRichiesta)) + .ToList(); + + UpdateTable(); + isLoading = false; + } + + protected async Task resetSel(bool forceUpdate) + { + currRecord = null; + if (forceUpdate) + { + await ReloadData(); + } + } + + protected async Task selRecord(PODLExpModel? selRec) + { + currRecord = selRec; + await EC_RecordSel.InvokeAsync(selRec); +#if false + // rimuovo selezione + currRecord = null; +#endif + } + + protected void SetNumPage(int newNum) + { + currPage = newNum; + UpdateTable(); + } + + protected void SetNumRec(int newNum) + { + currPage = 1; + numRecord = newNum; + UpdateTable(); + } + + protected async Task UpdateData() + { + currRecord = null; + await ReloadData(); + } + + #endregion Protected Methods + + #region Private Fields + + private static Logger Log = LogManager.GetCurrentClassLogger(); + + + private PODLExpModel? currRecord = null; + + private List? ListRecords; + + private List? ListStati; + + /// + /// Elenco ODL correnti... + /// + private List odlCurrList = new List(); + + private List? SearchRecords; + + #endregion Private Fields + + #region Private Properties + + private int _totalCount { get; set; } = -1; + + private int currPage + { + get => ActFilter.CurrPage; + set => ActFilter.CurrPage = value; + } + + private bool hasOdl + { + get => ActFilter.HasOdl; + set => ActFilter.HasOdl = value; + } + + private bool isLoading { get; set; } = false; + + private SelectXdlParams lastFilter { get; set; } = new SelectXdlParams() { CurrPage = -1 }; + + private string macchina + { + get => ActFilter.IdxMacchina; + set => ActFilter.IdxMacchina = value; + } + + private int numRecord + { + get => ActFilter.NumRec; + set => ActFilter.NumRec = value; + } + + private string reparto + { + get => ActFilter.CodReparto; + set => ActFilter.CodReparto = value; + } + + protected string SearchVal + { + get => searchVal; + set + { + if (searchVal != value) + { + searchVal = value; + UpdateTable(); + } + } + } + + private string searchVal = ""; + + private DateTime selDtEnd + { + get => ActFilter.DtEnd; + set + { + if (!ActFilter.DtEnd.Equals(value)) + { + ActFilter.DtEnd = value; + currPage = 1; + } + } + } + + private DateTime selDtStart + { + get => ActFilter.DtStart; + set + { + if (!ActFilter.DtStart.Equals(value)) + { + ActFilter.DtStart = value; + currPage = 1; + } + } + } + + private string StatoSel + { + get => ActFilter.CodFase; + set => ActFilter.CodFase = value; + } + + private int totalCount + { + get => _totalCount; + set + { + if (_totalCount != value) + { + _totalCount = value; + UpdateRecordCount.InvokeAsync(value); + } + } + } + + #endregion Private Properties + + #region Private Methods + + private void UpdateTable() + { + totalCount = 0; + if (SearchRecords != null) + { + var filtRec = new List(SearchRecords); + // se ho ricerca filtro! + if (!string.IsNullOrEmpty(searchVal)) + { + int idxPodl = 0; + // SE la ricerca contiene PODL filtro e cerco... + if (searchVal.Contains("PODL")) + { + } + int.TryParse(searchVal.Replace("PODL", ""), out idxPodl); + filtRec = SearchRecords + .Where(x => (x.KeyRichiesta.Contains(searchVal) || x.KeyBCode.Contains(searchVal) || (x.IdxPromessa == idxPodl && idxPodl > 0))) + .ToList(); + } + // fix conteggi + totalCount = filtRec.Count; + ListRecords = filtRec + .Skip(numRecord * (currPage - 1)) + .Take(numRecord) + .ToList(); + } + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP.SPEC/Components/ScratchPodlKit.razor b/MP.SPEC/Components/ScratchPodlKit.razor new file mode 100644 index 00000000..97b46602 --- /dev/null +++ b/MP.SPEC/Components/ScratchPodlKit.razor @@ -0,0 +1,195 @@ +
+
+
+
+
+
+ Elenco istanze KIT di produzione +
+
+
+
+ +
+ + + +
+
+
+ + @if (EditRecord != null) + { + + @* @if (doSearchArt) + { + + + + } +
+
+
+
Modifica
+
+ +
+
+
+ @if (string.IsNullOrEmpty(EditRecord.CodArtParent)) + { + + } + else + { + + } + +
+
+
+ @if (string.IsNullOrEmpty(EditRecord.CodArtChild)) + { +
+ +
+ + +
+
+ } + else + { +
+ + +
+ } +
+
+
+ + +
+
+
+ +
+
+ @if (EditRecord.Qty > 0 && !string.IsNullOrEmpty(EditRecord.CodArtParent) && !string.IsNullOrEmpty(EditRecord.CodArtChild)) + { + + } + else + { + + } +
+
+
+
+
+
*@ + } +
+
+ + @if (ListRecords == null) + { + + } + else if (totalCount == 0) + { +
+ Nessun record trovato +
+ } + else + { +
+
+ + + + + + + + + + + + + + + @foreach (var record in ListRecords) + { + + + + + + + + + + + } + +
+ @if (EditRecord != null) + { + + } + Kit Istanza Cod Ext Cod Kit (Parent) Articolo (Child) Qty Kit Qty Art
+ + +
@record.KeyKit
+
+
@record.KeyExtOrd
+
+
@record.CodArtParent
+
+
@record.CodArtChild
+
+
@record.QtyKIT
+
+
@record.QtyART
+
+ @if (DelEnabled(record)) + { + + } + else + { + + } +
+
+
+ } +
+ +
+ + + diff --git a/MP.SPEC/Components/ScratchPodlKit.razor.cs b/MP.SPEC/Components/ScratchPodlKit.razor.cs new file mode 100644 index 00000000..27f3f0ab --- /dev/null +++ b/MP.SPEC/Components/ScratchPodlKit.razor.cs @@ -0,0 +1,534 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MP.Data.DbModels; +using MP.SPEC.Data; + +namespace MP.SPEC.Components +{ + public partial class ScratchPodlKit : ComponentBase, IDisposable + { + #region Public Methods + + public void Dispose() + { + EditRecord = null; + SearchRecords = null; + ListRecords = null; + GC.Collect(); + } + + #endregion Public Methods + + #region Protected Fields + + protected int kitCount = 0; + + protected int totalCount = 0; + + #endregion Protected Fields + + #region Protected Properties + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + [Inject] + protected MpDataService MDService { get; set; } = null!; + + [Inject] + protected NavigationManager NavManager { get; set; } = null!; + + protected string SearchComm + { + get => sCodComm; + set + { + if (sCodComm != value) + { + sCodComm = value; + currPage = 1; + ListRecords = null; + ReloadData(); + } + } + } + + protected string sParentCss + { + get => string.IsNullOrEmpty(sCodComm) ? "btn-secondary" : "btn-primary"; + } + + #endregion Protected Properties + + #region Protected Methods + + protected string checkSelect(IstanzeKitModel currRec) + { + string answ = ""; + if (EditRecord != null) + { + try + { + answ = (EditRecord.KeyKit == currRec.KeyKit && EditRecord.KeyExtOrd == currRec.KeyExtOrd) ? "table-info" : ""; + } + catch + { } + } + return answ; + } + + protected bool DelEnabled(IstanzeKitModel reqRec) + { + bool answ = false; + + return answ; + } + + + /// + /// Verifica eliminabilità del record: se è avviato il PODL non è liminabile... + /// + /// + /// + protected async Task DoCancel() + { + EditRecord = null; + ReloadData(); + await Task.Delay(1); + } + + /// + /// Eliminazione record selezionato (previa conferma) + /// + /// + /// + protected async Task DoDelete(IstanzeKitModel selRec) + { + if (!await JSRuntime.InvokeAsync("confirm", "Eliminazione riga Istanza KIT: sei sicuro di voler procedere?")) + return; + + await Task.Delay(1); + var done = await MDService.IstKitDelete(selRec); + EditRecord = null; + ReloadData(); + await Task.Delay(1); + } + + protected async Task DoUpdate(IstanzeKitModel selRec) + { + if (!await JSRuntime.InvokeAsync("confirm", "Confermi di voler salvare le modifiche?")) + return; + + await Task.Delay(1); + var done = await MDService.IstKitUpsert(selRec); + EditRecord = null; + ReloadData(); + await Task.Delay(1); + } + + private bool OptAdmKitEnabled = false; + + protected override void OnInitialized() + { + numRecord = 10; + // gestione di base dei KIT + string rawVal = MDService.ConfigTryGet("OptAdmKitEnabled"); + if (!string.IsNullOrEmpty(rawVal)) + { + bool.TryParse(rawVal, out OptAdmKitEnabled); + } + // conf variabili decodifica + regExp_KO = MDService.ConfigTryGet("regExp_KO"); + regExp_OK = MDService.ConfigTryGet("regExp_OK"); + regExp_KitStart = MDService.ConfigTryGet("regExp_KitStart"); + regExp_KitSave = MDService.ConfigTryGet("regExp_KitSave"); + // altre variabili + rawVal = MDService.ConfigTryGet("SPEC_nArtSearch"); + if (!string.IsNullOrEmpty(rawVal)) + { + int.TryParse(rawVal, out minChar); + } + } + +#if false + protected override void OnAfterRender(bool firstRender) + { + if (firstRender) + { + if (OptAdmKitEnabled) + { + doReset(); + } + } + //base.OnAfterRender(firstRender); + } +#endif + + + + protected override void OnParametersSet() + { + ReloadData(); + } + + protected void ResetData() + { + EditRecord = null; + } + + protected void ResetParent() + { + SearchComm = ""; + ReloadData(); + } + + protected void ResetSel() + { + EditRecord = null; + } + + protected void SelRecord(IstanzeKitModel selRec) + { + EditRecord = selRec; + } + + protected void SetNumPage(int newNum) + { + currPage = newNum; + } + + protected void SetNumRec(int newNum) + { + currPage = 1; + numRecord = newNum; + } + + protected void UpdateData() + { + EditRecord = null; + ReloadData(); + } + + #endregion Protected Methods + + #region Private Fields + + /// + /// Boolear controllo visualizzazione ricerca articoli + /// + private bool doSearchArt = false; + + private IstanzeKitModel? EditRecord = null; + + private List? ListRecords; + + private int minChar = 2; + + /// + /// RegExp x SAVE KIT + /// + private string regExp_KitSave = "#RKE"; + + /// + /// RegExp x START KIT + /// + private string regExp_KitStart = "#RKS"; + + /// + /// RegExp x RESET / CANCEL + /// + private string regExp_KO = "#RKO"; + + /// + /// RegExp x CONFERMA + /// + private string regExp_OK = "#ROK"; + + private List? SearchRecords; + + #endregion Private Fields + + #region Private Properties + + private int _currPage { get; set; } = 1; + + private int _numRecord { get; set; } = 10; + + private int currPage + { + get => _currPage; + set + { + if (_currPage != value) + { + _currPage = value; + ReloadData(); + } + } + } + + private bool isLoading { get; set; } = false; + + private int numRecord + { + get => _numRecord; + set + { + if (_numRecord != value) + { + _numRecord = value; + ReloadData(); + } + } + } + + private string sCodComm { get; set; } = ""; + + private bool ShowCharts { get; set; } = false; + + #endregion Private Properties + + #region Private Methods + + private void ReloadData() + { + isLoading = true; + SearchRecords = MDService.IstKitFilt("", ""); + totalCount = SearchRecords.Count; + // conto i kit = distinct... + kitCount = SearchRecords.GroupBy(x => x.CodArtParent).Count(); + ListRecords = SearchRecords + .Skip(numRecord * (currPage - 1)) + .Take(numRecord) + .ToList(); + isLoading = false; + } + + /// + /// Toggle modale ricerca articoli + /// + private void SearchArtToggle() + { + doSearchArt = !doSearchArt; + } + + /// + /// Salva selezione articolo + /// + /// + private void SetCodArtChild(string codArt) + { + if (EditRecord != null) + { + EditRecord.CodArtChild = codArt; + doSearchArt = false; + } + } + + #endregion Private Methods + + +#if false + + + public string codKitTemp + { + get + { + return memLayer.ML.StringSessionObj(string.Format("codKitTemp_{0}", uid)); + } + set + { + memLayer.ML.setSessionVal(string.Format("codKitTemp_{0}", uid), value); + hlCodKitTemp.Value = value; + grViewWSK.DataBind(); + } + } + + /// + /// Ultimo Codice KIT creato + /// + public string lastKitMade + { + get + { + return memLayer.ML.StringSessionObj("lastKitMade"); + } + set + { + memLayer.ML.setSessionVal("lastKitMade", value); + } + } + + /// + /// Aggiunge (in obj OrdineKit) l'ordine coi parametri indicati + /// + /// + /// + /// + /// + /// + public bool addOrdArt(string codOrd, string codArt, string descArt, int qta) + { + bool answ = false; + // verifico di avere un codiceKIT + checkCodKit(); + // salvo info x il cod temporaneo... + DataLayerObj.taWKS.insertQuery(codKitTemp, codOrd, codArt, descArt, qta); + // verifico SE HO un KIT riconosciuto e quindi un CodArt di KIT valido... + string currCodArtKit = "###"; + var TksTab = DataLayerObj.taTKS.GetData(codKitTemp, 1); + bool showPODL = false; + if (TksTab.Rows.Count > 0) + { + // verifico se ho aderenza 100%... + if (TksTab[0].TotalScore == 1) + { + currCodArtKit = TksTab[0].CodArtParent; + showPODL = true; + } + } + hfCodArtKit.Value = currCodArtKit; + divPODL.Visible = showPODL; + answ = true; + grViewWSK.DataBind(); + grViewKitSel.DataBind(); + grViewPODL.DataBind(); + grViewIstanzeKIT.DataBind(); + return answ; + } + + + private void doReset() + { + // elimino eventuali record ODL + DataLayerObj.taWKS.deleteQuery(codKitTemp); + codKitTemp = ""; + divPODL.Visible = false; + checkCodKit(); + } + + /// + /// Ultimo input registrato + /// + public string lastInput + { + get + { + return hlLastInput.Value; + } + set + { + hlLastInput.Value = value; + } + } + + /// + /// Aggiorno controllo secondo ULTIMO input + /// + public void doUpdate() + { + // aggiorno label... + messOut = ""; + // controllo input (reset/inizio o salva...) + if (lastInput == regExp_KO) + { + // resetto dati + doReset(); + messOut = "Effettuato reset!"; + } + else if (lastInput == regExp_KitStart) + { + // resetto dati + doReset(); + messOut = "Inizio configurazione KIT"; + } + else if (lastInput == regExp_KitSave) + { + // controllo SE HO un kit selezionato... + string currCodArtKit = "###"; + var TksTab = DataLayerObj.taTKS.GetData(codKitTemp, 1); + bool showPODL = false; + if (TksTab.Rows.Count > 0) + { + // verifico se ho aderenza 100%... + if (TksTab[0].TotalScore == 1) + { + currCodArtKit = TksTab[0].CodArtParent; + showPODL = true; + } + } + if (showPODL) + { + // in questo caso creo istanza! + creazioneIstanzaKit(currCodArtKit); + } + } + else if (lastInput == regExp_OK) + { + } + // ennesimo check cod TEMP + checkCodKit(); + } + + /// + /// Verifico SE HO un codKit Temporaneo sennò lo creo... + /// + private void checkCodKit() + { + if (codKitTemp == "") + { + // genero un NUOVO cod temp kit... + codKitTemp = string.Format("KIT_{0:yyMMdd_HHmmss}", DateTime.Now); + } + } + + public string messOut + { + set + { + lblOut.Text = value; + } + get + { + return lblOut.Text; + } + } + + protected void grViewKitSel_SelectedIndexChanged(object sender, EventArgs e) + { + // se ho selezionato recupero CHIAVE = CodArticolo del KIT + string CodArtParent = grViewKitSel.SelectedValue.ToString(); + // crea KIT x quel CodArtParent... + creazioneIstanzaKit(CodArtParent); + } + /// + /// Crea una NUOVA istanza KIT + /// + /// CodArt dell'Assieme/KIT + private void creazioneIstanzaKit(string CodArtParent) + { + // calcolo NUOVO codice kit... + var tabKey = DataLayerObj.taIstK.getNewKey(); + if (tabKey.Rows.Count == 1) + { + // stacco un NUOVO codice KIT + lastKitMade = tabKey[0].KeyKit; + // inserisco ISTANZA KIT! + DataLayerObj.taIstK.insertByWKS(lastKitMade, CodArtParent, codKitTemp); + // faccio reset valori WKS... + doReset(); + // ora resetto ordine caricato... + messOut = string.Format("Creato NUOVA P.ODL cod {0} per il KIT {1}", lastKitMade, CodArtParent); + // sollevo evento x impostare lettura KIT a BARCODE (x conferma successiva...) + // sollevo evento nuovo valore... + if (eh_selKit != null) + { + eh_selKit(this, new EventArgs()); + } + } + } +#endif + + } +} \ No newline at end of file diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index 9dd0f611..d235ac17 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -1,4 +1,5 @@ -using EgwCoreLib.Utils; +using DnsClient.Protocol; +using EgwCoreLib.Utils; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; using MP.Core.Conf; @@ -138,6 +139,22 @@ namespace MP.SPEC.Data return fatto; } + /// + /// Stacca un nuovo counter x il tipo richiesto + /// + /// + public AnagCountersModel AnagCountersGetNext(string cntType) + { + AnagCountersModel result = new AnagCountersModel(); + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + result = dbController.AnagCountersGetNext(cntType); + sw.Stop(); + Log.Debug($"AnagCountersGetNext | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + /// /// Elenco Gruppi /// @@ -402,6 +419,39 @@ namespace MP.SPEC.Data return mongoController.CalcRecipe(currRecipe); } + /// + /// Recupero tab config in modalità Sincrona + /// + /// + public List ConfigGetAll() + { + string currMode = "REDIS"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + List? result = new List(); + // cerco in redis... + RedisValue rawData = redisDb.StringGet(Utils.redisConfKey); + if (!string.IsNullOrEmpty($"{rawData}")) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + } + else + { + currMode = "DB"; + result = dbController.ConfigGetAll(); + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSet(Utils.redisConfKey, rawData, getRandTOut(redisLongTimeCache)); + } + if (result == null) + { + result = new List(); + } + stopWatch.Stop(); + Log.Debug($"ConfigGetAll Read from {currMode}: {stopWatch.Elapsed.TotalMilliseconds}ms"); + return result; + } + /// /// Recupero tab config in modalità Asincrona /// @@ -437,39 +487,6 @@ namespace MP.SPEC.Data return result; } - /// - /// Recupero tab config in modalità Sincrona - /// - /// - public List ConfigGetAll() - { - string currMode = "REDIS"; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - List? result = new List(); - // cerco in redis... - RedisValue rawData = redisDb.StringGet(Utils.redisConfKey); - if (!string.IsNullOrEmpty($"{rawData}")) - { - result = JsonConvert.DeserializeObject>($"{rawData}"); - } - else - { - currMode = "DB"; - result = dbController.ConfigGetAll(); - // serializzo e salvo... - rawData = JsonConvert.SerializeObject(result); - redisDb.StringSet(Utils.redisConfKey, rawData, getRandTOut(redisLongTimeCache)); - } - if (result == null) - { - result = new List(); - } - stopWatch.Stop(); - Log.Debug($"ConfigGetAll Read from {currMode}: {stopWatch.Elapsed.TotalMilliseconds}ms"); - return result; - } - /// /// Reset dati cache config /// @@ -488,7 +505,7 @@ namespace MP.SPEC.Data { string answ = ""; // preselezione valori - if(configData==null || configData.Count==0) + if (configData == null || configData.Count == 0) { configData = ConfigGetAll(); } @@ -537,11 +554,6 @@ namespace MP.SPEC.Data return answ; } - /// - /// Cache dati config - /// - private List configData { get; set; } = new List(); - /// /// Update chiave config /// @@ -752,6 +764,58 @@ namespace MP.SPEC.Data return await dbController.EvListInsert(newRec); } + /// + /// Esegue flush memoria redis dato keyVal + /// + /// + /// + public bool ExecFlushRedisPattern(string pattern) + { + bool answ = false; + var listEndpoints = redisConnAdmin.GetEndPoints(); + foreach (var endPoint in listEndpoints) + { + //var server = redisConnAdmin.GetServer(listEndpoints[0]); + var server = redisConnAdmin.GetServer(endPoint); + if (server != null) + { + var keyList = server.Keys(redisDb.Database, pattern); + foreach (var item in keyList) + { + redisDb.KeyDelete(item); + } + answ = true; + } + } + return answ; + } + + /// + /// Esegue flush memoria redis dato keyVal, async + /// + /// + /// + public async Task ExecFlushRedisPatternAsync(RedisValue pattern) + { + bool answ = false; + var listEndpoints = redisConnAdmin.GetEndPoints(); + foreach (var endPoint in listEndpoints) + { + var server = redisConnAdmin.GetServer(endPoint); + if (server != null) + { + var keyList = server.Keys(redisDb.Database, pattern); + foreach (var item in keyList) + { + await redisDb.KeyDeleteAsync(item); + } + answ = true; + } + } + + return answ; + } + /// /// Imposta in redis la scadenza della pagina x il reload /// @@ -792,6 +856,20 @@ namespace MP.SPEC.Data return answ; } + /// + /// Flush cache relativa a MP-IO x dati ODL + /// + /// + public async Task FlushMpIoOdlCache() + { + // svuoto dalla cache REDIS del server IO... + bool ok01 = await ResetIoCache("CurrODL"); + bool ok02 = await ResetIoCache("CurrOdlRow"); + bool ok03 = await ResetIoCache("CurrStatoMacc"); + bool ok04 = await ResetIoCache("DtMac"); + return ok01 && ok02 && ok03 && ok04; + } + public async Task FlushRedisCache() { await Task.Delay(1); @@ -1002,6 +1080,72 @@ namespace MP.SPEC.Data return result; } + /// + /// Elimina record + svuotamento cache + /// + /// + public async Task IstKitDelete(IstanzeKitModel currRecord) + { + bool fatto = false; + // salvo + fatto = dbController.IstKitDelete(currRecord); + // svuoto cache + RedisValue pattern = $"{Utils.redisKitInst}:*"; + await ExecFlushRedisPatternAsync(pattern); + return fatto; + } + + /// + /// Elenco Istanze KIT da ricerca + /// + /// + /// + /// + public List IstKitFilt(string keyKit, string keyExtOrd) + { + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{Utils.redisKitInst}:{keyKit}:{keyExtOrd}"; + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbController.IstKitFilt(keyKit, keyExtOrd); + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSet(currKey, rawData, TimeSpan.FromMinutes(redisLongTimeCache)); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"IstKitFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + + /// + /// Esegue salvataggio record + svuotamento cache + /// + /// + public async Task IstKitUpsert(IstanzeKitModel currRecord) + { + bool fatto = false; + // salvo + fatto = dbController.IstKitUpsert(currRecord); + // svuoto cache + RedisValue pattern = $"{Utils.redisKitInst}:*"; + await ExecFlushRedisPatternAsync(pattern); + return fatto; + } + /// /// /// id odl da cercare @@ -1214,6 +1358,7 @@ namespace MP.SPEC.Data Log.Debug($"MachIobConf per {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms"); return result; } + /// /// Recupero singolo recordo info Machine-IOB x TAB (da info registrate IOB-WIN --> MP-IO) /// @@ -1779,58 +1924,6 @@ namespace MP.SPEC.Data return answ; } - /// - /// Esegue flush memoria redis dato keyVal - /// - /// - /// - public bool ExecFlushRedisPattern(string pattern) - { - bool answ = false; - var listEndpoints = redisConnAdmin.GetEndPoints(); - foreach (var endPoint in listEndpoints) - { - //var server = redisConnAdmin.GetServer(listEndpoints[0]); - var server = redisConnAdmin.GetServer(endPoint); - if (server != null) - { - var keyList = server.Keys(redisDb.Database, pattern); - foreach (var item in keyList) - { - redisDb.KeyDelete(item); - } - answ = true; - } - } - return answ; - } - - /// - /// Esegue flush memoria redis dato keyVal, async - /// - /// - /// - public async Task ExecFlushRedisPatternAsync(RedisValue pattern) - { - bool answ = false; - var listEndpoints = redisConnAdmin.GetEndPoints(); - foreach (var endPoint in listEndpoints) - { - var server = redisConnAdmin.GetServer(endPoint); - if (server != null) - { - var keyList = server.Keys(redisDb.Database, pattern); - foreach (var item in keyList) - { - await redisDb.KeyDeleteAsync(item); - } - answ = true; - } - } - - return answ; - } - /// /// Reset della cache IO post operazioni come setup ODL... /// @@ -1844,25 +1937,10 @@ namespace MP.SPEC.Data { pattern = new RedisValue($"{MpIoNS}:{baseMem}:*"); } - bool answ = await ExecFlushRedisPattern(pattern); + bool answ = await ExecFlushRedisPatternAsync(pattern); return answ; } - /// - /// Flush cache relativa a MP-IO x dati ODL - /// - /// - public async Task FlushMpIoOdlCache() - { - // svuoto dalla cache REDIS del server IO... - bool ok01 = await ResetIoCache("CurrODL"); - bool ok02 = await ResetIoCache("CurrOdlRow"); - bool ok03 = await ResetIoCache("CurrStatoMacc"); - bool ok04 = await ResetIoCache("DtMac"); - return ok01 && ok02 && ok03 && ok04; - } - - /// /// Statistiche ODL calcolate (da stored stp_STAT_ODL) /// @@ -1898,6 +1976,72 @@ namespace MP.SPEC.Data return Task.FromResult(currTagConf); } + /// + /// Elimina record + svuotamento cache + /// + /// + public async Task TemplateKitDelete(TemplateKitModel currRecord) + { + bool fatto = false; + // salvo + fatto = dbController.TemplateKitDelete(currRecord); + // svuoto cache + RedisValue pattern = $"{Utils.redisKitTempl}:*"; + await ExecFlushRedisPatternAsync(pattern); + return fatto; + } + + /// + /// Elenco Template KIT da ricerca + /// + /// + /// + /// + public List TemplateKitFilt(string codParent, string codChild) + { + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{Utils.redisKitTempl}:{codParent}:{codChild}"; + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbController.TemplateKitFilt(codParent, codChild); + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSet(currKey, rawData, TimeSpan.FromMinutes(redisLongTimeCache)); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"TemplateKitFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + + /// + /// Esegue salvataggio record + svuotamento cache + /// + /// + public async Task TemplateKitUpsert(TemplateKitModel currRecord) + { + bool fatto = false; + // salvo + fatto = dbController.TemplateKitUpsert(currRecord); + // svuoto cache + RedisValue pattern = $"{Utils.redisKitTempl}:*"; + await ExecFlushRedisPatternAsync(pattern); + return fatto; + } + /// /// Esegue traduzione dato vocabolario da Lingua + Lemma /// @@ -1961,91 +2105,6 @@ namespace MP.SPEC.Data return answ; } - - - /// - /// Elimina record + svuotamento cache - /// - /// - public async Task TemplateKitDelete(TemplateKitModel currRecord) - { - bool fatto = false; - // salvo - fatto = dbController.TemplateKitDelete(currRecord); - // svuoto cache - RedisValue pattern = $"{Utils.redisKitTempl}:*"; - await ExecFlushRedisPatternAsync(pattern); - return fatto; - } - - - /// - /// Stacca un nuovo counter x il tipo richiesto - /// - /// - public AnagCountersModel AnagCountersGetNext(string cntType) - { - AnagCountersModel result = new AnagCountersModel(); - string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); - result = dbController.AnagCountersGetNext(cntType); - sw.Stop(); - Log.Debug($"AnagCountersGetNext | {source} | {sw.Elapsed.TotalMilliseconds}ms"); - return result; - } - - /// - /// Elenco template da ricerca - /// - /// - /// - /// - public List TemplateKitFilt(string codParent, string codChild) - { - string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); - List? result = new List(); - // cerco in redis... - string currKey = $"{Utils.redisKitTempl}:{codParent}:{codChild}"; - RedisValue rawData = redisDb.StringGet(currKey); - if (rawData.HasValue) - { - result = JsonConvert.DeserializeObject>($"{rawData}"); - source = "REDIS"; - } - else - { - result = dbController.TemplateKitFilt(codParent, codChild); - // serializzo e salvo... - rawData = JsonConvert.SerializeObject(result); - redisDb.StringSet(currKey, rawData, TimeSpan.FromMinutes(redisLongTimeCache)); - } - if (result == null) - { - result = new List(); - } - sw.Stop(); - Log.Debug($"TemplateKitFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms"); - return result; - } - - /// - /// Esegue salvataggio record + svuotamento cache - /// - /// - public async Task TemplateKitUpsert(TemplateKitModel currRecord) - { - bool fatto = false; - // salvo - fatto = dbController.TemplateKitUpsert(currRecord); - // svuoto cache - RedisValue pattern = $"{Utils.redisKitTempl}:*"; - await ExecFlushRedisPatternAsync(pattern); - return fatto; - } - /// /// Elenco completo tabella Vocabolario /// @@ -2080,6 +2139,101 @@ namespace MP.SPEC.Data return result; } + /// + /// Elimina record + svuotamento cache + /// + /// + public bool WipKitDelete(WipSetupKitModel currRecord) + { + bool fatto = false; + // salvo + fatto = dbController.WipKitDelete(currRecord); + // svuoto cache + RedisValue pattern = $"{Utils.redisKitWip}:*"; + ExecFlushRedisPattern(pattern); + return fatto; + } + + /// + /// Elimina i record associati al KeyFilt indicato + /// + /// + public bool WipKitDeleteGroup(string KeyFilt) + { + bool fatto = false; + // salvo + fatto = dbController.WipKitDeleteGroup(KeyFilt); + // svuoto cache + RedisValue pattern = $"{Utils.redisKitWip}:*"; + ExecFlushRedisPattern(pattern); + return fatto; + } + + /// + /// Elimina i record più vecchi della data-ora indicata + /// + /// + public bool WipKitDeleteOlder(DateTime DateLimit) + { + bool fatto = false; + // salvo + fatto = dbController.WipKitDeleteOlder(DateLimit); + // svuoto cache + RedisValue pattern = $"{Utils.redisKitWip}:*"; + ExecFlushRedisPattern(pattern); + return fatto; + } + + /// + /// Elenco Template KIT da ricerca + /// + /// + /// + public List WipKitFilt(string KeyFilt) + { + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{Utils.redisKitWip}:{KeyFilt}"; + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbController.WipKitFilt(KeyFilt); + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSet(currKey, rawData, TimeSpan.FromMinutes(redisLongTimeCache)); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"WipKitFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + + /// + /// Esegue salvataggio record + svuotamento cache + /// + /// + public bool WipKitUpsert(WipSetupKitModel currRecord) + { + bool fatto = false; + // salvo + fatto = dbController.WipKitUpsert(currRecord); + // svuoto cache + RedisValue pattern = $"{Utils.redisKitWip}:*"; + ExecFlushRedisPattern(pattern); + return fatto; + } + #endregion Public Methods #region Protected Fields @@ -2174,8 +2328,11 @@ namespace MP.SPEC.Data #region Private Fields private static IConfiguration _configuration = null!; + private static ILogger _logger = null!; + private static Logger Log = LogManager.GetCurrentClassLogger(); + private string MpIoNS = ""; /// @@ -2204,6 +2361,15 @@ namespace MP.SPEC.Data #endregion Private Fields + #region Private Properties + + /// + /// Cache dati config + /// + private List configData { get; set; } = new List(); + + #endregion Private Properties + #region Private Methods /// @@ -2211,7 +2377,7 @@ namespace MP.SPEC.Data /// /// /// - private async Task ExecFlushRedisPattern(RedisValue pattern) + private bool ExecFlushRedisPattern(RedisValue pattern) { bool answ = false; var listEndpoints = redisConn.GetEndPoints(); @@ -2224,7 +2390,7 @@ namespace MP.SPEC.Data var keyList = server.Keys(redisDb.Database, pattern); foreach (var item in keyList) { - await redisDb.KeyDeleteAsync(item); + redisDb.KeyDelete(item); } answ = true; } diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index f140349a..09de6fb9 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 6.16.2504.1007 + 6.16.2504.1019 1800a78a-6ff1-40f9-b490-87fb8bfc1394 en diff --git a/MP.SPEC/Pages/Articoli.razor b/MP.SPEC/Pages/Articoli.razor index a2027d50..1949a154 100644 --- a/MP.SPEC/Pages/Articoli.razor +++ b/MP.SPEC/Pages/Articoli.razor @@ -167,6 +167,10 @@ { } + else + { + + } } @@ -177,6 +181,9 @@ } \ No newline at end of file diff --git a/MP.SPEC/Pages/ForceReset.razor b/MP.SPEC/Pages/ForceReset.razor new file mode 100644 index 00000000..2b51deed --- /dev/null +++ b/MP.SPEC/Pages/ForceReset.razor @@ -0,0 +1,84 @@ +@page "/force-reset" +@using MP.SPEC.Data + +
+
+ +
+
+ +
+
+ + +
+
+
+
+ + +@code { + + [Inject] + protected NavigationManager NavMan { get; set; } = null!; + [Inject] + protected MsgServiceSpec MsgServ { get; set; } = null!; + [Inject] + protected MpDataService MDService { get; set; } = null!; + + private int currVal = 0; + private int nextVal = 0; + private int expTimeMsec = 10; + private int bDelay = 150; + private string title = "..."; + /// + /// Esecuzione task di reset... + /// + /// + protected override async Task OnInitializedAsync() + { + title = "Reset and Reload Data"; + currVal = 0; + nextVal = 10; + await InvokeAsync(StateHasChanged); + await Task.Delay(bDelay); + // title = "Clearing Local Browser Data"; + // currVal = 10; + // nextVal = 30;loca + // await InvokeAsync(StateHasChanged); + // await MsgServ.ClearLocalStor(); + // await Task.Delay(bDelay); + // title = "Clearing Session Browser Data"; + // currVal = 30; + // nextVal = 50; + // await InvokeAsync(StateHasChanged); + // await MsgServ.ClearSessionStor(); + // await Task.Delay(bDelay); + // title = "Final Cache cleanup..."; + // currVal = 50; + // nextVal = 80; + // MsgServ.RigaOper = null; + // MsgServ.LastIdxMacchina = ""; + // await InvokeAsync(StateHasChanged); + // await Task.Delay(2 * bDelay); + // // attendo + // title = "Reload!"; + // currVal = 80; + // nextVal = 100; + // await InvokeAsync(StateHasChanged); + // // rimando alla home... + // await Task.Delay(bDelay); + // NavMan.NavigateTo("Index", true); + + + await Task.Delay(bDelay); + await MDService.FlushRedisCache(); + title = "Reload!"; + currVal = 80; + nextVal = 100; + await InvokeAsync(StateHasChanged); + await Task.Delay(bDelay); + // rimando a pagina corrente + NavMan.NavigateTo("Index", true); + } +} diff --git a/MP.SPEC/Pages/Giacenze.razor.cs b/MP.SPEC/Pages/Giacenze.razor.cs index 21783e55..e79e5ff8 100644 --- a/MP.SPEC/Pages/Giacenze.razor.cs +++ b/MP.SPEC/Pages/Giacenze.razor.cs @@ -29,7 +29,7 @@ namespace MP.SPEC.Pages await MDService.ConfigResetCache(); giacenzeConf = await MDService.ConfigTryGetAsync("SPEC_ShowGiacenze"); await Task.Delay(1); - padCodXdl = await MDService.ConfigTryGetAsync("padCodXdl"); + padCodXdl = await MDService.ConfigTryGetAsync("PadCodXdl"); var uri = NavManager.ToAbsoluteUri(NavManager.Uri); if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("IdxOdl", out var _idxOdl)) { diff --git a/MP.SPEC/Pages/Index.razor b/MP.SPEC/Pages/Index.razor index 6e4daf2d..363048ba 100644 --- a/MP.SPEC/Pages/Index.razor +++ b/MP.SPEC/Pages/Index.razor @@ -1,4 +1,5 @@ @page "/" +@page "/Index" Index diff --git a/MP.SPEC/Pages/KIT.razor b/MP.SPEC/Pages/KIT.razor index af93f106..22887a4a 100644 --- a/MP.SPEC/Pages/KIT.razor +++ b/MP.SPEC/Pages/KIT.razor @@ -7,9 +7,7 @@
KIT - Definizione KIT multiprodotto per singolo ciclo -
-
+ Definizione KIT multiprodotto per singolo ciclo | @kitCount Kit disp.
@@ -27,7 +25,7 @@
- +
diff --git a/MP.SPEC/Pages/KIT.razor.cs b/MP.SPEC/Pages/KIT.razor.cs index a7d55d73..59b4c8e9 100644 --- a/MP.SPEC/Pages/KIT.razor.cs +++ b/MP.SPEC/Pages/KIT.razor.cs @@ -10,28 +10,9 @@ namespace MP.SPEC.Pages { #region Public Methods - public string checkSelect(TemplateKitModel currRec) - { - string answ = ""; -#if false - if (currRecord != null) - { - try - { - answ = (currRecord.CodArticolo == CodArticolo) ? "table-info" : ""; - } - catch - { } - } -#endif - return answ; - } - public void Dispose() { EditRecord = null; - ListTipoArt = null; - ListAziende = null; SearchRecords = null; ListRecords = null; GC.Collect(); @@ -39,6 +20,14 @@ namespace MP.SPEC.Pages #endregion Public Methods + #region Protected Fields + + protected int kitCount = 0; + + protected int totalCount = 0; + + #endregion Protected Fields + #region Protected Properties [Inject] @@ -67,15 +56,6 @@ namespace MP.SPEC.Pages { sCodChild = value; currPage = 1; -#if false - var pUpd = Task.Run(async () => - { - ListRecords = null; - await Task.Delay(1); - await ReloadData(); - }); - pUpd.Wait(); -#endif ListRecords = null; ReloadData(); } @@ -107,23 +87,25 @@ namespace MP.SPEC.Pages get => string.IsNullOrEmpty(sCodParent) ? "btn-secondary" : "btn-primary"; } - protected int totalCount - { - get - { - int answ = 0; - if (SearchRecords != null) - { - answ = SearchRecords.Count; - } - return answ; - } - } - #endregion Protected Properties #region Protected Methods + protected string checkSelect(TemplateKitModel currRec) + { + string answ = ""; + if (EditRecord != null) + { + try + { + answ = (EditRecord.CodArtParent == currRec.CodArtParent && EditRecord.CodArtChild == currRec.CodArtChild) ? "table-info" : ""; + } + catch + { } + } + return answ; + } + /// /// Crea nuovo record e va in editing... /// @@ -204,7 +186,7 @@ namespace MP.SPEC.Pages await Task.Delay(1); } - protected override async Task OnInitializedAsync() + protected override void OnInitialized() { numRecord = 10; string rawVal = MDService.ConfigTryGet("SPEC_nArtSearch"); @@ -222,8 +204,6 @@ namespace MP.SPEC.Pages { bool.TryParse(rawVal, out enabKitSearch); } - ListAziende = await MDService.ElencoAziende(); - ListTipoArt = await MDService.AnagTipoArtLV(); } protected override void OnParametersSet() @@ -290,12 +270,8 @@ namespace MP.SPEC.Pages private bool enabKitSearch = false; - private List? ListAziende; - private List? ListRecords; - private List? ListTipoArt; - private int minChar = 2; private string sCodChild = ""; @@ -350,6 +326,9 @@ namespace MP.SPEC.Pages { isLoading = true; SearchRecords = MDService.TemplateKitFilt(SearchParent, SearchChild); + totalCount = SearchRecords.Count; + // conto i kit = distinct... + kitCount = SearchRecords.GroupBy(x => x.CodArtParent).Count(); ListRecords = SearchRecords .Skip(numRecord * (currPage - 1)) .Take(numRecord) diff --git a/MP.SPEC/Pages/ODL.razor.cs b/MP.SPEC/Pages/ODL.razor.cs index 26f13aeb..c6f4f787 100644 --- a/MP.SPEC/Pages/ODL.razor.cs +++ b/MP.SPEC/Pages/ODL.razor.cs @@ -112,7 +112,7 @@ namespace MP.SPEC.Pages } ListStati = await MDService.AnagStatiComm(); ListMacchine = await MDService.MacchineGetFilt(selReparto); - padCodXdl = await MDService.ConfigTryGetAsync("padCodXdl"); + padCodXdl = await MDService.ConfigTryGetAsync("PadCodXdl"); } protected async Task pgResetReq(bool doReset) diff --git a/MP.SPEC/Pages/PODL.razor b/MP.SPEC/Pages/PODL.razor index aedbc78a..baea886f 100644 --- a/MP.SPEC/Pages/PODL.razor +++ b/MP.SPEC/Pages/PODL.razor @@ -294,6 +294,9 @@ } \ No newline at end of file diff --git a/MP.SPEC/Pages/PODL.razor.cs b/MP.SPEC/Pages/PODL.razor.cs index 02b2e1bd..f21b9b8c 100644 --- a/MP.SPEC/Pages/PODL.razor.cs +++ b/MP.SPEC/Pages/PODL.razor.cs @@ -240,6 +240,7 @@ namespace MP.SPEC.Pages protected void SetNumRec(int newNum) { + currPage = 1; numRecord = newNum; } diff --git a/MP.SPEC/Pages/Podl2Kit.razor b/MP.SPEC/Pages/Podl2Kit.razor new file mode 100644 index 00000000..15c7adf3 --- /dev/null +++ b/MP.SPEC/Pages/Podl2Kit.razor @@ -0,0 +1,43 @@ +@page "/PoKit" +@page "/podl-kit" +@page "/podl2kit" + +
+
+
+
+
+
+ PODL - KIT + Raggruppamento PODL in KIT di produzione +
+
+
+
+
+ +
+ @*
+ + + +
*@ +
+
+
+
+ + @if (doAddNew) + { + + } + else + { + + } +
+ @* *@ +
+ + diff --git a/MP.SPEC/Pages/Podl2Kit.razor.cs b/MP.SPEC/Pages/Podl2Kit.razor.cs new file mode 100644 index 00000000..337599c6 --- /dev/null +++ b/MP.SPEC/Pages/Podl2Kit.razor.cs @@ -0,0 +1,581 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.JSInterop; +using MP.Data.DbModels; +using MP.SPEC.Data; +using NLog.Layouts; + +namespace MP.SPEC.Pages +{ + public partial class Podl2Kit : ComponentBase, IDisposable + { + #region Public Methods + + public void Dispose() + { + EditRecord = null; + SearchRecords = null; + ListRecords = null; + GC.Collect(); + } + + #endregion Public Methods + + #region Protected Fields + + protected int kitCount = 0; + + protected int totalCount = 0; + + #endregion Protected Fields + + #region Protected Properties + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + [Inject] + protected MpDataService MDService { get; set; } = null!; + + [Inject] + protected NavigationManager NavManager { get; set; } = null!; + + protected string SearchComm + { + get => sCodComm; + set + { + if (sCodComm != value) + { + sCodComm = value; + currPage = 1; + ListRecords = null; + ReloadData(); + } + } + } + + protected string sParentCss + { + get => string.IsNullOrEmpty(sCodComm) ? "btn-secondary" : "btn-primary"; + } + + #endregion Protected Properties + + #region Protected Methods + + protected string checkSelect(IstanzeKitModel currRec) + { + string answ = ""; + if (EditRecord != null) + { + try + { + answ = (EditRecord.KeyKit == currRec.KeyKit && EditRecord.KeyExtOrd == currRec.KeyExtOrd) ? "table-info" : ""; + } + catch + { } + } + return answ; + } + + protected bool DelEnabled(IstanzeKitModel reqRec) + { + bool answ = false; + + return answ; + } + + /// + /// Apre procedura creazione nuova istanza KIT + /// + /// + protected async Task DoAddNew() + { + doAddNew = !doAddNew; +#if false + // imposto a ricerca x iniziare + string codParent = SearchParent; + // se deve essere autogenerato da counter... + if (AutoGen) + { + var cntRec = MDService.AnagCountersGetNext("NumKitArt"); + if (cntRec != null) + { + codParent = $"{cntRec.CntCode}{cntRec.LastNum:000000}"; + } + else + { + codParent = ""; + } + } + EditRecord = new IstanzeKitModel() + { + CodArtParent = codParent, + CodArtChild = "", + QtyKIT = 1, + QtyART = 1 + }; +#endif + await Task.Delay(1); + } + + /// + /// Verifica eliminabilità del record: se è avviato il PODL non è liminabile... + /// + /// + /// + protected async Task DoCancel() + { + EditRecord = null; + ReloadData(); + await Task.Delay(1); + } + + /// + /// Eliminazione record selezionato (previa conferma) + /// + /// + /// + protected async Task DoDelete(IstanzeKitModel selRec) + { + if (!await JSRuntime.InvokeAsync("confirm", "Eliminazione riga Istanza KIT: sei sicuro di voler procedere?")) + return; + + await Task.Delay(1); + var done = await MDService.IstKitDelete(selRec); + EditRecord = null; + ReloadData(); + await Task.Delay(1); + } + + protected async Task DoUpdate(IstanzeKitModel selRec) + { + if (!await JSRuntime.InvokeAsync("confirm", "Confermi di voler salvare le modifiche?")) + return; + + await Task.Delay(1); + var done = await MDService.IstKitUpsert(selRec); + EditRecord = null; + ReloadData(); + await Task.Delay(1); + } + + private bool OptAdmKitEnabled = false; + + protected override void OnInitialized() + { + numRecord = 10; + // gestione di base dei KIT + string rawVal = MDService.ConfigTryGet("OptAdmKitEnabled"); + if (!string.IsNullOrEmpty(rawVal)) + { + bool.TryParse(rawVal, out OptAdmKitEnabled); + } + // conf variabili decodifica + regExp_KO = MDService.ConfigTryGet("regExp_KO"); + regExp_OK = MDService.ConfigTryGet("regExp_OK"); + regExp_KitStart = MDService.ConfigTryGet("regExp_KitStart"); + regExp_KitSave = MDService.ConfigTryGet("regExp_KitSave"); + // altre variabili + rawVal = MDService.ConfigTryGet("SPEC_nArtSearch"); + if (!string.IsNullOrEmpty(rawVal)) + { + int.TryParse(rawVal, out minChar); + } + } + +#if false + protected override void OnAfterRender(bool firstRender) + { + if (firstRender) + { + if (OptAdmKitEnabled) + { + doReset(); + } + } + //base.OnAfterRender(firstRender); + } +#endif + + + + protected override void OnParametersSet() + { + ReloadData(); + } + + protected void ResetData() + { + EditRecord = null; + } + + protected void ResetParent() + { + SearchComm = ""; + ReloadData(); + } + + protected void ResetSel() + { + EditRecord = null; + } + + protected void SelRecord(IstanzeKitModel selRec) + { + EditRecord = selRec; + } + + protected void SetNumPage(int newNum) + { + currPage = newNum; + } + + protected void SetNumRec(int newNum) + { + currPage = 1; + numRecord = newNum; + } + + protected void UpdateData() + { + EditRecord = null; + ReloadData(); + } + + #endregion Protected Methods + + #region Private Fields + + private bool doAddNew = false; + + /// + /// Boolear controllo visualizzazione ricerca articoli + /// + private bool doSearchArt = false; + + private IstanzeKitModel? EditRecord = null; + + private List? ListRecords; + + private int minChar = 2; + + /// + /// RegExp x SAVE KIT + /// + private string regExp_KitSave = "#RKE"; + + /// + /// RegExp x START KIT + /// + private string regExp_KitStart = "#RKS"; + + /// + /// RegExp x RESET / CANCEL + /// + private string regExp_KO = "#RKO"; + + /// + /// RegExp x CONFERMA + /// + private string regExp_OK = "#ROK"; + + private List? SearchRecords; + + #endregion Private Fields + + #region Private Properties + + private int _currPage { get; set; } = 1; + + private int _numRecord { get; set; } = 10; + + private int currPage + { + get => _currPage; + set + { + if (_currPage != value) + { + _currPage = value; + ReloadData(); + } + } + } + + private bool isLoading { get; set; } = false; + + private int numRecord + { + get => _numRecord; + set + { + if (_numRecord != value) + { + _numRecord = value; + ReloadData(); + } + } + } + + private string sCodComm { get; set; } = ""; + + private bool ShowCharts { get; set; } = false; + + #endregion Private Properties + + #region Private Methods + + private void ReloadData() + { + isLoading = true; + SearchRecords = MDService.IstKitFilt("", ""); + totalCount = SearchRecords.Count; + // conto i kit = distinct... + kitCount = SearchRecords.GroupBy(x => x.CodArtParent).Count(); + ListRecords = SearchRecords + .Skip(numRecord * (currPage - 1)) + .Take(numRecord) + .ToList(); + isLoading = false; + } + + /// + /// Toggle modale ricerca articoli + /// + private void SearchArtToggle() + { + doSearchArt = !doSearchArt; + } + + /// + /// Salva selezione articolo + /// + /// + private void SetCodArtChild(string codArt) + { + if (EditRecord != null) + { + EditRecord.CodArtChild = codArt; + doSearchArt = false; + } + } + + #endregion Private Methods + + + private string addNewBtnText + { + get => doAddNew ? "Annulla creazione Istanza KIT" : "Composizione Nuovo KIT"; + } + private string addNewBtnCss + { + get => doAddNew ? "btn-secondary" : "btn-primary"; + } + + +#if false + + + public string codKitTemp + { + get + { + return memLayer.ML.StringSessionObj(string.Format("codKitTemp_{0}", uid)); + } + set + { + memLayer.ML.setSessionVal(string.Format("codKitTemp_{0}", uid), value); + hlCodKitTemp.Value = value; + grViewWSK.DataBind(); + } + } + + /// + /// Ultimo Codice KIT creato + /// + public string lastKitMade + { + get + { + return memLayer.ML.StringSessionObj("lastKitMade"); + } + set + { + memLayer.ML.setSessionVal("lastKitMade", value); + } + } + + /// + /// Aggiunge (in obj OrdineKit) l'ordine coi parametri indicati + /// + /// + /// + /// + /// + /// + public bool addOrdArt(string codOrd, string codArt, string descArt, int qta) + { + bool answ = false; + // verifico di avere un codiceKIT + checkCodKit(); + // salvo info x il cod temporaneo... + DataLayerObj.taWKS.insertQuery(codKitTemp, codOrd, codArt, descArt, qta); + // verifico SE HO un KIT riconosciuto e quindi un CodArt di KIT valido... + string currCodArtKit = "###"; + var TksTab = DataLayerObj.taTKS.GetData(codKitTemp, 1); + bool showPODL = false; + if (TksTab.Rows.Count > 0) + { + // verifico se ho aderenza 100%... + if (TksTab[0].TotalScore == 1) + { + currCodArtKit = TksTab[0].CodArtParent; + showPODL = true; + } + } + hfCodArtKit.Value = currCodArtKit; + divPODL.Visible = showPODL; + answ = true; + grViewWSK.DataBind(); + grViewKitSel.DataBind(); + grViewPODL.DataBind(); + grViewIstanzeKIT.DataBind(); + return answ; + } + + + private void doReset() + { + // elimino eventuali record ODL + DataLayerObj.taWKS.deleteQuery(codKitTemp); + codKitTemp = ""; + divPODL.Visible = false; + checkCodKit(); + } + + /// + /// Ultimo input registrato + /// + public string lastInput + { + get + { + return hlLastInput.Value; + } + set + { + hlLastInput.Value = value; + } + } + + /// + /// Aggiorno controllo secondo ULTIMO input + /// + public void doUpdate() + { + // aggiorno label... + messOut = ""; + // controllo input (reset/inizio o salva...) + if (lastInput == regExp_KO) + { + // resetto dati + doReset(); + messOut = "Effettuato reset!"; + } + else if (lastInput == regExp_KitStart) + { + // resetto dati + doReset(); + messOut = "Inizio configurazione KIT"; + } + else if (lastInput == regExp_KitSave) + { + // controllo SE HO un kit selezionato... + string currCodArtKit = "###"; + var TksTab = DataLayerObj.taTKS.GetData(codKitTemp, 1); + bool showPODL = false; + if (TksTab.Rows.Count > 0) + { + // verifico se ho aderenza 100%... + if (TksTab[0].TotalScore == 1) + { + currCodArtKit = TksTab[0].CodArtParent; + showPODL = true; + } + } + if (showPODL) + { + // in questo caso creo istanza! + creazioneIstanzaKit(currCodArtKit); + } + } + else if (lastInput == regExp_OK) + { + } + // ennesimo check cod TEMP + checkCodKit(); + } + + /// + /// Verifico SE HO un codKit Temporaneo sennò lo creo... + /// + private void checkCodKit() + { + if (codKitTemp == "") + { + // genero un NUOVO cod temp kit... + codKitTemp = string.Format("KIT_{0:yyMMdd_HHmmss}", DateTime.Now); + } + } + + public string messOut + { + set + { + lblOut.Text = value; + } + get + { + return lblOut.Text; + } + } + + protected void grViewKitSel_SelectedIndexChanged(object sender, EventArgs e) + { + // se ho selezionato recupero CHIAVE = CodArticolo del KIT + string CodArtParent = grViewKitSel.SelectedValue.ToString(); + // crea KIT x quel CodArtParent... + creazioneIstanzaKit(CodArtParent); + } + /// + /// Crea una NUOVA istanza KIT + /// + /// CodArt dell'Assieme/KIT + private void creazioneIstanzaKit(string CodArtParent) + { + // calcolo NUOVO codice kit... + var tabKey = DataLayerObj.taIstK.getNewKey(); + if (tabKey.Rows.Count == 1) + { + // stacco un NUOVO codice KIT + lastKitMade = tabKey[0].KeyKit; + // inserisco ISTANZA KIT! + DataLayerObj.taIstK.insertByWKS(lastKitMade, CodArtParent, codKitTemp); + // faccio reset valori WKS... + doReset(); + // ora resetto ordine caricato... + messOut = string.Format("Creato NUOVA P.ODL cod {0} per il KIT {1}", lastKitMade, CodArtParent); + // sollevo evento x impostare lettura KIT a BARCODE (x conferma successiva...) + // sollevo evento nuovo valore... + if (eh_selKit != null) + { + eh_selKit(this, new EventArgs()); + } + } + } +#endif + + } +} \ No newline at end of file diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index 8070d5e2..461853d2 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2504.1007

+

Versione: 6.16.2504.1019


Note di rilascio:
  • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index 0269c5cd..5feba2ef 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2504.1007 +6.16.2504.1019 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index 7fbd1950..184db0c0 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2504.1007 + 6.16.2504.1019 https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html false