diff --git a/AppData/ComLib.cs b/AppData/ComLib.cs index e83c92a..ad5be65 100644 --- a/AppData/ComLib.cs +++ b/AppData/ComLib.cs @@ -698,6 +698,40 @@ namespace AppData return answ; } + /// + /// Elenco dei Batch descendant di un batch a sua volta descendant + /// + public static DS_App.BatchListDataTable BatchOtherDescendant(int BatchDescId) + { + DataLayer DLMan = new DataLayer(); + string redKey = $"{redBatchDescend}:{BatchDescId}"; + string rawData = ""; + DS_App.BatchListDataTable answ = new DS_App.BatchListDataTable(); + // 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.taBL.getSplitByKey(BatchDescId); + // salvo in cache + rawData = JsonConvert.SerializeObject(answ); + memLayer.ML.setRSV(redKey, rawData, 5 * 60); + } + return answ; + } + public static string BatchStatusDescr(object value) { string answ = ""; diff --git a/AppData/DS_App.Designer.cs b/AppData/DS_App.Designer.cs index 2e16c85..7a1b6c9 100644 --- a/AppData/DS_App.Designer.cs +++ b/AppData/DS_App.Designer.cs @@ -26449,7 +26449,7 @@ namespace AppData.DS_AppTableAdapters { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] private void InitCommandCollection() { - this._commandCollection = new global::System.Data.SqlClient.SqlCommand[26]; + this._commandCollection = new global::System.Data.SqlClient.SqlCommand[27]; this._commandCollection[0] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[0].Connection = this.Connection; this._commandCollection[0].CommandText = "SELECT *\r\nFROM v_BatchList"; @@ -26560,55 +26560,61 @@ namespace AppData.DS_AppTableAdapters { this._commandCollection[17].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[18] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[18].Connection = this.Connection; - this._commandCollection[18].CommandText = "dbo.stp_Batch_makeDescendantByKey"; + this._commandCollection[18].CommandText = "dbo.stp_Batch_getSplitByKey"; this._commandCollection[18].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[18].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[18].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@BatchID", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[18].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@PlaceCodAnces", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[19] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[19].Connection = this.Connection; - this._commandCollection[19].CommandText = "dbo.stp_Batch_redoPartValid"; + this._commandCollection[19].CommandText = "dbo.stp_Batch_makeDescendantByKey"; this._commandCollection[19].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[19].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[19].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Takt", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[19].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@BatchID", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[19].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@PlaceCodAnces", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[20] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[20].Connection = this.Connection; - this._commandCollection[20].CommandText = "dbo.stp_Batch_resetAllNesting"; + this._commandCollection[20].CommandText = "dbo.stp_Batch_redoPartValid"; this._commandCollection[20].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[20].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[20].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@BatchID", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[20].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Takt", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[21] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[21].Connection = this.Connection; - this._commandCollection[21].CommandText = "dbo.stp_Batch_resetPartUnValid"; + this._commandCollection[21].CommandText = "dbo.stp_Batch_resetAllNesting"; this._commandCollection[21].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[21].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[21].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@BatchID", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[22] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[22].Connection = this.Connection; - this._commandCollection[22].CommandText = "dbo.stp_zzz_resetProdCall"; + this._commandCollection[22].CommandText = "dbo.stp_Batch_resetPartUnValid"; this._commandCollection[22].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[22].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[23] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[23].Connection = this.Connection; - this._commandCollection[23].CommandText = "dbo.stp_Batch_resetTree"; + this._commandCollection[23].CommandText = "dbo.stp_zzz_resetProdCall"; this._commandCollection[23].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[23].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[23].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Original_BatchID", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[24] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[24].Connection = this.Connection; - this._commandCollection[24].CommandText = "dbo.stp_Batch_updateSchedPrior"; + this._commandCollection[24].CommandText = "dbo.stp_Batch_resetTree"; this._commandCollection[24].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[24].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[24].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@BatchID", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[24].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@SchedPrio", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[24].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Original_BatchID", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[25] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[25].Connection = this.Connection; - this._commandCollection[25].CommandText = "dbo.stp_Batch_updateStatus"; + this._commandCollection[25].CommandText = "dbo.stp_Batch_updateSchedPrior"; this._commandCollection[25].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[25].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[25].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@BatchID", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[25].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Status", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[25].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@EnvNum", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[25].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@TotalTime", global::System.Data.SqlDbType.Decimal, 9, global::System.Data.ParameterDirection.Input, 18, 6, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[25].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@SchedPrio", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[26] = new global::System.Data.SqlClient.SqlCommand(); + this._commandCollection[26].Connection = this.Connection; + this._commandCollection[26].CommandText = "dbo.stp_Batch_updateStatus"; + this._commandCollection[26].CommandType = global::System.Data.CommandType.StoredProcedure; + this._commandCollection[26].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[26].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@BatchID", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[26].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Status", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[26].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@EnvNum", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[26].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@TotalTime", global::System.Data.SqlDbType.Decimal, 9, global::System.Data.ParameterDirection.Input, 18, 6, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -26788,6 +26794,23 @@ namespace AppData.DS_AppTableAdapters { return dataTable; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)] + public virtual DS_App.BatchListDataTable getSplitByKey(global::System.Nullable BatchID) { + this.Adapter.SelectCommand = this.CommandCollection[18]; + if ((BatchID.HasValue == true)) { + this.Adapter.SelectCommand.Parameters[1].Value = ((int)(BatchID.Value)); + } + else { + this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value; + } + DS_App.BatchListDataTable dataTable = new DS_App.BatchListDataTable(); + this.Adapter.Fill(dataTable); + return dataTable; + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] @@ -27028,7 +27051,7 @@ namespace AppData.DS_AppTableAdapters { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int makeDescendantByKey(global::System.Nullable BatchID, string PlaceCodAnces) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[18]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[19]; if ((BatchID.HasValue == true)) { command.Parameters[1].Value = ((int)(BatchID.Value)); } @@ -27062,7 +27085,7 @@ namespace AppData.DS_AppTableAdapters { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int redoPartValid(string Takt) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[19]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[20]; if ((Takt == null)) { command.Parameters[1].Value = global::System.DBNull.Value; } @@ -27090,7 +27113,7 @@ namespace AppData.DS_AppTableAdapters { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int resetNesting(global::System.Nullable BatchID) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[20]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[21]; if ((BatchID.HasValue == true)) { command.Parameters[1].Value = ((int)(BatchID.Value)); } @@ -27118,28 +27141,6 @@ namespace AppData.DS_AppTableAdapters { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int resetPartUnValid() { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[21]; - global::System.Data.ConnectionState previousConnectionState = command.Connection.State; - if (((command.Connection.State & global::System.Data.ConnectionState.Open) - != global::System.Data.ConnectionState.Open)) { - command.Connection.Open(); - } - int returnValue; - try { - returnValue = command.ExecuteNonQuery(); - } - finally { - if ((previousConnectionState == global::System.Data.ConnectionState.Closed)) { - command.Connection.Close(); - } - } - return returnValue; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] - [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] - public virtual int resetProdCall() { global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[22]; global::System.Data.ConnectionState previousConnectionState = command.Connection.State; if (((command.Connection.State & global::System.Data.ConnectionState.Open) @@ -27161,8 +27162,30 @@ namespace AppData.DS_AppTableAdapters { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] - public virtual int resetTree(global::System.Nullable Original_BatchID) { + public virtual int resetProdCall() { global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[23]; + global::System.Data.ConnectionState previousConnectionState = command.Connection.State; + if (((command.Connection.State & global::System.Data.ConnectionState.Open) + != global::System.Data.ConnectionState.Open)) { + command.Connection.Open(); + } + int returnValue; + try { + returnValue = command.ExecuteNonQuery(); + } + finally { + if ((previousConnectionState == global::System.Data.ConnectionState.Closed)) { + command.Connection.Close(); + } + } + return returnValue; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + public virtual int resetTree(global::System.Nullable Original_BatchID) { + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[24]; if ((Original_BatchID.HasValue == true)) { command.Parameters[1].Value = ((int)(Original_BatchID.Value)); } @@ -27190,7 +27213,7 @@ namespace AppData.DS_AppTableAdapters { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int updateSchedPrior(global::System.Nullable BatchID, global::System.Nullable SchedPrio) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[24]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[25]; if ((BatchID.HasValue == true)) { command.Parameters[1].Value = ((int)(BatchID.Value)); } @@ -27224,7 +27247,7 @@ namespace AppData.DS_AppTableAdapters { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int updateStatus(global::System.Nullable BatchID, global::System.Nullable Status, string EnvNum, global::System.Nullable TotalTime) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[25]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[26]; if ((BatchID.HasValue == true)) { command.Parameters[1].Value = ((int)(BatchID.Value)); } diff --git a/AppData/DS_App.xsd b/AppData/DS_App.xsd index 1180cfe..cde821f 100644 --- a/AppData/DS_App.xsd +++ b/AppData/DS_App.xsd @@ -233,6 +233,17 @@ FROM v_BatchList + + + + dbo.stp_Batch_getSplitByKey + + + + + + + diff --git a/NKC_WF/Controllers/BatchProcController.cs b/NKC_WF/Controllers/BatchProcController.cs index ff5d172..b471023 100644 --- a/NKC_WF/Controllers/BatchProcController.cs +++ b/NKC_WF/Controllers/BatchProcController.cs @@ -479,10 +479,8 @@ namespace NKC_WF.Controllers // NKC2: se รจ un batch ti dipo descendant if (ComLib.BType(rispNest.BatchID) == BatchType.Descendant) { - // verifico se ce ne siano altri NON validati - - // invio il PRIMO batch descendant - var tabDesc = ComLib.BatchDescendant(rispNest.BatchID); + // verifico se ce ne siano altri NON validati (ma splitted) + var tabDesc = ComLib.BatchOtherDescendant(rispNest.BatchID); if (tabDesc != null && tabDesc.Count > 0) { // ciclo x tutte le righe che NON fossero con nesting effettuato @@ -491,6 +489,7 @@ namespace NKC_WF.Controllers // se NON effettuato if (item.STATUS == 2) { + // invio il PRIMO batch descendant ComLib.sendBatchReq(item.BatchID, "Nesting", 2, false); // registro su DB nesting iniziato... DLMan.taBL.updateStatus(item.BatchID, (int)BatchStatus.NestRequested, "", -1);