From dc4601ff7e893a2a46aae80f6ee36aa7ae2c5a4c Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 9 Jun 2021 19:30:55 +0200 Subject: [PATCH] Continuo redistribuzione dati ordini --- AppData/ComLib.cs | 114 +++++++++++++++--- NKC_WF/NKC_WF.csproj | 8 ++ NKC_WF/WebUserControls/cmp_batchDetail.ascx | 14 +-- .../WebUserControls/cmp_batchDetail.ascx.cs | 47 +++++++- .../cmp_batchDetail.ascx.designer.cs | 27 +++-- NKC_WF/WebUserControls/cmp_orderExtList.ascx | 4 + .../WebUserControls/cmp_orderExtList.ascx.cs | 27 +++++ .../cmp_orderExtList.ascx.designer.cs | 35 ++++++ 8 files changed, 241 insertions(+), 35 deletions(-) create mode 100644 NKC_WF/WebUserControls/cmp_orderExtList.ascx create mode 100644 NKC_WF/WebUserControls/cmp_orderExtList.ascx.cs create mode 100644 NKC_WF/WebUserControls/cmp_orderExtList.ascx.designer.cs diff --git a/AppData/ComLib.cs b/AppData/ComLib.cs index 8a1150f..55ad501 100644 --- a/AppData/ComLib.cs +++ b/AppData/ComLib.cs @@ -53,23 +53,15 @@ namespace AppData public static ComLib man = new ComLib(); public static string redBatchDescend = "NKC:SERV:BATCHDESCEND"; - public static string redMachUnloadCount = "NKC:SERV:MACH_UNLOAD:COUNT"; - public static string redMachUnloadForce = "NKC:SERV:MACH_UNLOAD:FORCERELOAD"; - public static string redMLCurrBunk = "NKC:SERV:TAKT:CurrBunk"; - public static string redMsgCount = "NKC:SERV:BREQ:MCount"; - public static string redMsgList = "NKC:SERV:BREQ:MList"; - public static string redNestAnsw = "NKC:NEST:BANSW"; - + public static string redOrders = "NKC:SERV:ORDERS"; public static string redOutPath = "NKC:SERV:BREQ"; - public static string redProdAnsw = "NKC:PROD:BUNKS"; - public static string redProdReq = "NKC:SERV:BUNKS"; /// @@ -673,17 +665,18 @@ namespace AppData } /// - /// Elenco dei + /// Elenco dei Batch descendant di un batch ancestor /// public static DS_App.BatchListDataTable BatchDescendant(int BatchId) { DataLayer DLMan = new DataLayer(); + string redKey = $"{redBatchDescend}:{BatchId}"; string rawData = ""; DS_App.BatchListDataTable answ = new DS_App.BatchListDataTable(); // cerco in redis - if (memLayer.ML.redKeyPresent(redBatchDescend)) + if (memLayer.ML.redKeyPresent(redKey)) { - rawData = memLayer.ML.getRSV(redBatchDescend); + rawData = memLayer.ML.getRSV(redKey); if (!string.IsNullOrEmpty(rawData)) { try @@ -699,7 +692,7 @@ namespace AppData answ = DLMan.taBL.getDescendByKey(BatchId); // salvo in cache rawData = JsonConvert.SerializeObject(answ); - memLayer.ML.setRSV(redBatchDescend, rawData, 5 * 60); + memLayer.ML.setRSV(redKey, rawData, 5 * 60); } } return answ; @@ -1377,6 +1370,88 @@ namespace AppData return answ; } +#if false + /// + /// Elenco degli orders dato Batch + /// + public static DS_App.OrderListDataTable OrdersByBatch(int BatchId) + { + DataLayer DLMan = new DataLayer(); + string redKey = $"{redOrders}:BYBATCH:{BatchId}"; + string rawData = ""; + DS_App.OrderListDataTable answ = new DS_App.OrderListDataTable(); + // cerco in redis + if (memLayer.ML.redKeyPresent(redKey)) + { + rawData = memLayer.ML.getRSV(redKey); + if (!string.IsNullOrEmpty(rawData)) + { + try + { + answ = JsonConvert.DeserializeObject(rawData); + } + catch + { } + } + // se vuoto rileggo + if (answ.Count == 0) + { + answ = DLMan.taOL.getByBatch(BatchId); + // salvo in cache + rawData = JsonConvert.SerializeObject(answ); + memLayer.ML.setRSV(redKey, rawData, 5 * 60); + } + } + return answ; + } +#endif + + /// + /// Elenco degli orders dato Batch + /// + public static Dictionary OrdersExtByBatch(int BatchId, string PlaceCod) + { + DataLayer DLMan = new DataLayer(); + string redKey = $"{redOrders}:BYBATCH:{BatchId}"; + string rawData = ""; + Dictionary answ = new Dictionary(); + + // cerco in redis + if (memLayer.ML.redKeyPresent(redKey)) + { + rawData = memLayer.ML.getRSV(redKey); + if (!string.IsNullOrEmpty(rawData)) + { + try + { + answ = JsonConvert.DeserializeObject>(rawData); + } + catch + { } + } + // se vuoto rileggo + if (answ.Count == 0) + { + var tabBatchDesc = BatchDescendant(BatchId); + + // recupero ordini MAIN + DS_App.OrderListDataTable currOrders = DLMan.taOL.getByBatch(BatchId); + answ.Add(PlaceCod, currOrders); + + // recupero ordini dei 2 descendant... + foreach (var item in tabBatchDesc) + { + currOrders = DLMan.taOL.getByBatch(item.BatchID); + answ.Add(item.PlaceCod, currOrders); + } + // salvo in cache + rawData = JsonConvert.SerializeObject(answ); + memLayer.ML.setRSV(redKey, rawData, 5 * 60); + } + } + return answ; + } + public static string PositionStatusDescr(object value) { string answ = ""; @@ -1659,7 +1734,8 @@ namespace AppData /// public static void ResetBatchDescendant(int BatchId) { - memLayer.ML.setRSV(redBatchDescend, "", 10); + string redKey = $"{redBatchDescend}:{BatchId}"; + memLayer.ML.setRSV(redKey, "", 10); } /// @@ -1735,6 +1811,16 @@ namespace AppData return answ; } + /// + /// Reset della cache dei BatchDescendant x ID indicato + /// + /// + public static void ResetOrderByBatch(int BatchId) + { + string redKey = $"{redOrders}:BYBATCH:{BatchId}"; + memLayer.ML.setRSV(redKey, "", 10); + } + /// /// Resetto i dati PRIMA di salvare i nuovi dati dal nesting /// diff --git a/NKC_WF/NKC_WF.csproj b/NKC_WF/NKC_WF.csproj index 5cd68cc..b702569 100644 --- a/NKC_WF/NKC_WF.csproj +++ b/NKC_WF/NKC_WF.csproj @@ -530,6 +530,7 @@ + @@ -1489,6 +1490,13 @@ cmp_OOLI_detail.ascx + + cmp_orderExtList.ascx + ASPXCodeBehind + + + cmp_orderExtList.ascx + cmp_orderPrint.ascx ASPXCodeBehind diff --git a/NKC_WF/WebUserControls/cmp_batchDetail.ascx b/NKC_WF/WebUserControls/cmp_batchDetail.ascx index 211e412..cfc9285 100644 --- a/NKC_WF/WebUserControls/cmp_batchDetail.ascx +++ b/NKC_WF/WebUserControls/cmp_batchDetail.ascx @@ -1,4 +1,5 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="cmp_batchDetail.ascx.cs" Inherits="NKC_WF.WebUserControls.cmp_batchDetail" %> +<%@ Register Src="~/WebUserControls/cmp_orderExtList.ascx" TagPrefix="uc1" TagName="cmp_orderExtList" %> @@ -97,14 +98,11 @@
-
+
NE01 %
-
- -
-
+
NE02 %
@@ -113,12 +111,10 @@
ORD LIST NE01 - summary -
- table detail +
ORD LIST NE02- summary -
- table detail +
\ No newline at end of file diff --git a/NKC_WF/WebUserControls/cmp_batchDetail.ascx.cs b/NKC_WF/WebUserControls/cmp_batchDetail.ascx.cs index 3278732..84014b5 100644 --- a/NKC_WF/WebUserControls/cmp_batchDetail.ascx.cs +++ b/NKC_WF/WebUserControls/cmp_batchDetail.ascx.cs @@ -19,7 +19,10 @@ namespace NKC_WF.WebUserControls #region Protected Properties - protected DS_App.BatchListDataTable tabDesc + /// + /// Tabella dei batch Descendant di quello corrente + /// + protected DS_App.BatchListDataTable tabBatchDesc { get { @@ -27,6 +30,15 @@ namespace NKC_WF.WebUserControls } } + protected Dictionary TabOrders + { + get + { + // cerco in redis + return ComLib.OrdersExtByBatch(BatchId, PlaceCod); + } + } + #endregion Protected Properties #region Public Properties @@ -211,6 +223,7 @@ namespace NKC_WF.WebUserControls } } checkCreateDescendant(); + showBatchDescendant(); } get { @@ -242,7 +255,7 @@ namespace NKC_WF.WebUserControls if (BatchId != 0) { // verifico se ho descendant - if (tabDesc.Rows.Count == 0) + if (tabBatchDesc.Rows.Count == 0) { // altrimenti creo... DLMan.taBL.makeDescendantByKey(BatchId, PlaceCod); @@ -250,6 +263,25 @@ namespace NKC_WF.WebUserControls } } + /// + /// Mostro dati dei Batch descendant + /// + private void showBatchDescendant() + { + // se ho qualcosa aggiorno visualizzazione... + if (TabOrders.Count > 0) + { + // se ne ho nel MAIN --> redistribuisco + if (TabOrders["VIRTNE"].Count > 0) + { + // suddivido + } + // ...e poi mostro + cmp_orderExtListNE01.CurrOrders = TabOrders["NE01"]; + cmp_orderExtListNE02.CurrOrders = TabOrders["NE02"]; + } + } + #endregion Private Methods #region Protected Methods @@ -326,13 +358,22 @@ namespace NKC_WF.WebUserControls return num / den; } + /// + /// Elenco ordini dato BatchID + /// + /// + /// + protected DS_App.OrderListDataTable tabOrdersByBatch(int BatchId) + { + return ComLib.OrdersByBatch(BatchId); + } + protected void txtRatio_TextChanged(object sender, EventArgs e) { int valRatio = 0; int.TryParse(txtRatio.Text, out valRatio); lblRatio01.Text = $"{valRatio}"; lblRatio02.Text = $"{100 - valRatio}"; - lblSplitRatio.Text = $"{valRatio}/{100 - valRatio}"; } #endregion Protected Methods diff --git a/NKC_WF/WebUserControls/cmp_batchDetail.ascx.designer.cs b/NKC_WF/WebUserControls/cmp_batchDetail.ascx.designer.cs index c6828d8..89acaa7 100644 --- a/NKC_WF/WebUserControls/cmp_batchDetail.ascx.designer.cs +++ b/NKC_WF/WebUserControls/cmp_batchDetail.ascx.designer.cs @@ -77,15 +77,6 @@ namespace NKC_WF.WebUserControls /// protected global::System.Web.UI.WebControls.Label lblRatio01; - /// - /// lblSplitRatio control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Label lblSplitRatio; - /// /// lblRatio02 control. /// @@ -103,5 +94,23 @@ namespace NKC_WF.WebUserControls /// To modify move field declaration from designer file to code-behind file. /// protected global::System.Web.UI.WebControls.TextBox txtRatio; + + /// + /// cmp_orderExtListNE01 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::NKC_WF.WebUserControls.cmp_orderExtList cmp_orderExtListNE01; + + /// + /// cmp_orderExtListNE02 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::NKC_WF.WebUserControls.cmp_orderExtList cmp_orderExtListNE02; } } diff --git a/NKC_WF/WebUserControls/cmp_orderExtList.ascx b/NKC_WF/WebUserControls/cmp_orderExtList.ascx new file mode 100644 index 0000000..3e39959 --- /dev/null +++ b/NKC_WF/WebUserControls/cmp_orderExtList.ascx @@ -0,0 +1,4 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="cmp_orderExtList.ascx.cs" Inherits="NKC_WF.WebUserControls.cmp_orderExtList" %> + + + \ No newline at end of file diff --git a/NKC_WF/WebUserControls/cmp_orderExtList.ascx.cs b/NKC_WF/WebUserControls/cmp_orderExtList.ascx.cs new file mode 100644 index 0000000..5870a4c --- /dev/null +++ b/NKC_WF/WebUserControls/cmp_orderExtList.ascx.cs @@ -0,0 +1,27 @@ +using AppData; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace NKC_WF.WebUserControls +{ + public partial class cmp_orderExtList : System.Web.UI.UserControl + { + #region Public Properties + + public DS_App.OrderListDataTable CurrOrders { get; set; } + + #endregion Public Properties + + #region Protected Methods + + protected void Page_Load(object sender, EventArgs e) + { + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/NKC_WF/WebUserControls/cmp_orderExtList.ascx.designer.cs b/NKC_WF/WebUserControls/cmp_orderExtList.ascx.designer.cs new file mode 100644 index 0000000..9316e98 --- /dev/null +++ b/NKC_WF/WebUserControls/cmp_orderExtList.ascx.designer.cs @@ -0,0 +1,35 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace NKC_WF.WebUserControls +{ + + + public partial class cmp_orderExtList + { + + /// + /// grView control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.GridView grView; + + /// + /// ods control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.ObjectDataSource ods; + } +}