diff --git a/MP.Data/Conf/RecipeBlockConfig.cs b/MP.Data/Conf/RecipeBlockConfig.cs index 8c400c81..b960fabc 100644 --- a/MP.Data/Conf/RecipeBlockConfig.cs +++ b/MP.Data/Conf/RecipeBlockConfig.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace MP.Data.Conf { @@ -11,30 +7,21 @@ namespace MP.Data.Conf /// public class RecipeBlockConfig { - /// - /// Dizionario delle chiavi, differenziate dai primi caratteri: - /// C: --> Calcolato - /// E: --> Enum: modificabile ma da dizionario valori seguente - /// F: --> Fixed (NON modificabile) - /// "" --> editabile - /// - public Dictionary ListKeys { get; set; } = new Dictionary(); - + #region Public Properties /// /// Dizionario degli enum permessi /// public Dictionary> EnumVal { get; set; } = new Dictionary>(); - /// - /// Dizionario degli enum permessi - /// - public Dictionary CalcVal { get; set; } = new Dictionary(); - public class CalcDetail - { - public string Description { get; set; } = ""; - public string Type { get; set; } = ""; - public string Format { get; set; } = ""; - } + /// + /// Dizionario delle chiavi, differenziate dai primi caratteri: + /// C: --> Calcolato + /// E: --> Enum: modificabile ma da dizionario valori seguente + /// F: --> Fixed (NON modificabile) "" --> editabile + /// + public Dictionary ListKeys { get; set; } = new Dictionary(); + + #endregion Public Properties } -} +} \ No newline at end of file diff --git a/MP.Data/Controllers/MpMongoController.cs b/MP.Data/Controllers/MpMongoController.cs index d618879b..3dfaaeec 100644 --- a/MP.Data/Controllers/MpMongoController.cs +++ b/MP.Data/Controllers/MpMongoController.cs @@ -92,11 +92,15 @@ namespace MP.Data.Controllers /// /// Init ricetta dato PODL + conf /// - /// + /// + /// + /// /// - public RecipeModel InitRecipe(int idxPODL, string confPath) + public RecipeModel InitRecipe(string confPath, int idxPODL, Dictionary CalcArgs) { RecipeModel answ = new RecipeModel(); + // recupero dati da PODL... + // per prima cosa leggo file di conf x inizializzare ricetta... string fullPath = RecipePath(confPath); bool fileOk = File.Exists(fullPath); @@ -104,36 +108,8 @@ namespace MP.Data.Controllers { string rawData = File.ReadAllText(fullPath); var currRecipe = JsonConvert.DeserializeObject(rawData); - // copio la mia ricetta come conf... - answ = new RecipeModel(idxPODL, currRecipe); - - //answ = new RecipeModel() - //{ - // IdxPODL = idxPODL, - // TemplateFile = currRecipe.TemplateFile, - // HeadConf = currRecipe.HeadConf, - // RowsConf = currRecipe.RowsConf, - // //HeadVal = currRecipe.HeadConf.ListKeys, - // HeadVal = RecipeModel.ConvertToValues(currRecipe.HeadConf.ListKeys), - // // aggiungo 1 riga... - // RowsVal = new Dictionary>() - // { - // { "1", currRecipe.RowsConf.ListKeys} - // } - - // //IdxPODL = idxPODL, - // //TemplateFile = currRecipe.TemplateFile, - // //HeadConf = currRecipe.HeadConf, - // //RowsConf = currRecipe.RowsConf, - // ////HeadVal = currRecipe.HeadConf.ListKeys, - // //HeadVal = RecipeModel.ConvertToObj(currRecipe.HeadConf.ListKeys), - // //// aggiungo 1 riga... - // //RowsVal = new Dictionary>() - // //{ - // // //{ "1", rigaBase } - // // { "1", RecipeModel.ConvertToObj(currRecipe.RowsConf.ListKeys)} - // //} - //}; + // inizializzo dalla conf... + answ = new RecipeModel(idxPODL, currRecipe, CalcArgs); } return answ; diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index aef9d456..94b5d405 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -1034,6 +1034,7 @@ namespace MP.Data.Controllers .DbSetPODL .AsNoTracking() .Where(x => x.IdxPromessa == idxPODL) + .Include(a => a.ArticoloNav) .FirstOrDefault(); } catch (Exception exc) diff --git a/MP.Data/MgModels/RecipeModel.cs b/MP.Data/MgModels/RecipeModel.cs index edb97f91..afe67c56 100644 --- a/MP.Data/MgModels/RecipeModel.cs +++ b/MP.Data/MgModels/RecipeModel.cs @@ -21,19 +21,26 @@ namespace MP.Data.MgModels /// /// Init da configurazione di base /// - /// - public RecipeModel(int IdxPODL, RecipeConfig origConfig) + /// idx PODL + /// + /// Dizionario argomenti x decodifica (es cod articolo, descrizione...) + public RecipeModel(int IdxPODL, RecipeConfig OrigConfig, Dictionary CalcArgs) { this.IdxPODL = IdxPODL; - this.TemplateFile = origConfig.TemplateFile; - this.HeadConf = origConfig.HeadConf; - this.RowsConf = origConfig.RowsConf; + this.TemplateFile = OrigConfig.TemplateFile; + this.HeadConf = OrigConfig.HeadConf; + this.RowsConf = OrigConfig.RowsConf; // init oggetti tipizzati da valori conf ricevuti - this.HeadVal = ElementConverter(origConfig.HeadConf.ListKeys); + this.HeadVal = ElementConverter(OrigConfig.HeadConf.ListKeys, CalcArgs); + // aggiungo args x gestione contatori righe... + CalcArgs.Add("RowNum", $"0"); + CalcArgs.Add("RowTot", $"{OrigConfig.NumRow}"); // aggiungo righe elementi.. - for (int i = 1; i <= origConfig.NumRow; i++) + for (int i = 1; i <= OrigConfig.NumRow; i++) { - this.RowsVal.Add($"{i}", ElementConverter(origConfig.RowsConf.ListKeys)); + // valore calcolato numero riga gestito ad ogni iterazione + CalcArgs["RowNum"] = $"{i}"; + this.RowsVal.Add($"{i}", ElementConverter(OrigConfig.RowsConf.ListKeys, CalcArgs)); } } @@ -92,28 +99,14 @@ namespace MP.Data.MgModels /// /// Converte il dizionario in List Element /// - public static List ElementConverter(Dictionary ListKeys) + public static List ElementConverter(Dictionary ListKeys, Dictionary CalcArgs) { List ListObj = ListKeys - .Select(x => new Element(x.Key, x.Value)) + .Select(x => new Element(x.Key, x.Value, CalcArgs)) .ToList(); return ListObj; } - public static Element getToConfig(string rawKey, string rawVal) - { - return new Element(rawKey, rawVal); - } - - /// - /// Clone dell'oggetto - /// - /// - public RecipeModel Clone() - { - return (RecipeModel)this.MemberwiseClone(); - } - #endregion Public Methods #region Public Classes @@ -128,9 +121,9 @@ namespace MP.Data.MgModels /// /// Init classe da valore kvp /// - /// - /// - public Element(string rawKey, string rawVal) + /// Chiave item + /// Valore grezzo item + public Element(string rawKey, string rawVal, Dictionary CalcArgs) { this.Key = rawKey; this.OrigVal = rawVal; @@ -143,7 +136,16 @@ namespace MP.Data.MgModels { case "C:": this.Type = KeyType.Calc; - this.Value = rawVal.Substring(2); + // recupero item x ricerca in dizionario... + string cKey = rawVal.Substring(2); + if (CalcArgs.ContainsKey(cKey)) + { + this.Value = CalcArgs[cKey]; + } + else + { + this.Value = cKey; + } break; case "E:": diff --git a/MP.SPEC/Components/RecipeMan.razor b/MP.SPEC/Components/RecipeMan.razor index 4523c596..201de174 100644 --- a/MP.SPEC/Components/RecipeMan.razor +++ b/MP.SPEC/Components/RecipeMan.razor @@ -6,40 +6,32 @@ } else { -
+

Testata Ricetta

-
- @if (needSave) + @if (!showHead) + { + @CurrRecipe?.HeadVal.Count par + } + @if (needSave) + { + + + } + -
-
-
-
- -
-
+ } -
- -
-
+ else + { + + } +
@if (showHead && CurrRecipe?.HeadVal != null) @@ -76,7 +68,24 @@ else }
-
Righe Ricetta
+
+
+
Righe Ricetta
+
+
+ + +
+
@if (CurrRecipe?.RowsVal != null) { @foreach (var riga in CurrRecipe.RowsVal) diff --git a/MP.SPEC/Components/RecipeMan.razor.cs b/MP.SPEC/Components/RecipeMan.razor.cs index ee4825bb..e9b40f1f 100644 --- a/MP.SPEC/Components/RecipeMan.razor.cs +++ b/MP.SPEC/Components/RecipeMan.razor.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Components; using MP.Data; using MP.Data.MgModels; using MP.SPEC.Data; +using MP.SPEC.Pages; using Newtonsoft.Json; namespace MP.SPEC.Components @@ -80,6 +81,7 @@ namespace MP.SPEC.Components #region Private Fields private bool showHead = true; + private bool showAllRows = false; private Dictionary showRows = new Dictionary(); #endregion Private Fields @@ -95,12 +97,27 @@ namespace MP.SPEC.Components CurrRecipe = new RecipeModel(); // effettua ricerca ricetta su MongoDb CurrRecipe = await MDService.RecipeGetByPODL(IdxPODL); - OrigRecipe = await MDService.RecipeGetByPODL(IdxPODL); // se non trova crea nuova... if (CurrRecipe == null) { - CurrRecipe = MDService.InitRecipe(IdxPODL, RecipePath); + // preparo dizionario valori calcolati + Dictionary CalcArgs = new Dictionary(); + // aggiungo dati PODL + CalcArgs.Add("IdxPODL", $"{IdxPODL}"); + CalcArgs.Add("CodePODL", $"PODL{IdxPODL:00000000}"); + // recupero altri dati da PODL + var rowPodl = await MDService.PODL_getByKey(IdxPODL); + if (rowPodl != null) + { + CalcArgs.Add("CodArticolo", rowPodl.CodArticolo); + CalcArgs.Add("DescArticolo", rowPodl.ArticoloNav.DescArticolo); + } + CurrRecipe = MDService.InitRecipe(RecipePath, IdxPODL, CalcArgs); + // la salvo... + await MDService.RecipeSetByPODL(CurrRecipe); } + // rileggo la default + OrigRecipe = await MDService.RecipeGetByPODL(IdxPODL); // sistemo lista bool x righe showRows = new Dictionary(); for (int i = 1; i <= CurrRecipe.RowsVal.Count; i++) @@ -136,6 +153,10 @@ namespace MP.SPEC.Components } } + private async Task addRow() + { + await Task.Delay(1); + } private void toggleHead() @@ -143,6 +164,17 @@ namespace MP.SPEC.Components showHead = !showHead; } + private async Task toggleRows() + { + showAllRows = !showAllRows; + foreach (var item in showRows) + { + showRows[item.Key] = showAllRows; + } + await Task.Delay(1); + } + + private async Task toggleRow(string rowNum) { showRows[rowNum] = !showRows[rowNum]; diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index a4b81b96..7554bd33 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -74,12 +74,13 @@ namespace MP.SPEC.Data /// /// Init ricetta /// - /// /// + /// + /// /// - public RecipeModel InitRecipe(int idxPODL, string confPath) + public RecipeModel InitRecipe(string confPath, int idxPODL, Dictionary CalcArgs) { - return mongoController.InitRecipe(idxPODL, confPath); + return mongoController.InitRecipe(confPath, idxPODL, CalcArgs); } /// /// Salva ricetta su MongoDB diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index af7d0f76..807f72ec 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 6.16.2302.911 + 6.16.2302.915 diff --git a/MP.SPEC/Recipe/README.md b/MP.SPEC/Recipe/README.md new file mode 100644 index 00000000..9925615a --- /dev/null +++ b/MP.SPEC/Recipe/README.md @@ -0,0 +1,23 @@ +# Ricette +- [Ricette](#ricette) +- [Gestione formati e tag x ricette](#gestione-formati-e-tag-x-ricette) + - [Campi Calcolati](#campi-calcolati) + + +# Gestione formati e tag x ricette + +Nelle ricette ci possono essere campi liberi, campi da enum (da configurare nel json) e campi calcolati + + +## Campi Calcolati + +I tag noti x decodifica riguardano i campi calcolati; hard coded, e riconosciuti, sono i seguenti: + +| ID | Note | Format | Esempio | +|--------------|-----------------------------------------|------------------|-----------------| +| IdxPODL | IdxODL numerico | - | 123 | +| CodePODL | Codice alfanumerico partendo da IdxPODL | PODL{0:00000000} | PODL00000123 | +| CodArticolo | Campo CodArticolo | - | Art000123 | +| DescArticolo | Campo DescArticolo | - | Articol 123 blu | +| RowNum | Numero riga | - | 1 | +| RowTot | Totale righe | - | 10 | diff --git a/MP.SPEC/Recipe/README.pdf b/MP.SPEC/Recipe/README.pdf new file mode 100644 index 00000000..3f36eaff Binary files /dev/null and b/MP.SPEC/Recipe/README.pdf differ diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index e93ffe87..f0ae4d97 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2302.911

+

Versione: 6.16.2302.915


Note di rilascio:
  • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index 37ed7d71..c653806e 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2302.911 +6.16.2302.915 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index d07e8bc4..69e5e3f5 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2302.911 + 6.16.2302.915 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