From c9cea2edce31bbf1b5dc55a4ff86e18e34456a71 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 14 Jul 2021 12:14:45 +0200 Subject: [PATCH] OK x unload con 2 macchine --- AppData/ComLib.cs | 16 ++-- AppData/DS_App.Designer.cs | 9 +- AppData/DS_App.xsd | 1 + AppData/DS_App.xss | 86 ++++++++--------- NKC_SDK/NKC.cs | 20 ++-- NKC_WF/BasePage.cs | 2 +- NKC_WF/Controllers/BunkController.cs | 102 +++++++++++---------- NKC_WF/site/MachineLoad.aspx | 3 +- NKC_WF/site/MachineLoad.aspx.cs | 10 +- NKC_WF/site/MachineLoad.aspx.designer.cs | 9 ++ NKC_WF/site/MachineUnload.aspx | 2 +- NKC_WF/site/MachineUnload.aspx.cs | 4 +- NKC_WF/site/MachineUnload.aspx.designer.cs | 18 ++-- 13 files changed, 157 insertions(+), 125 deletions(-) diff --git a/AppData/ComLib.cs b/AppData/ComLib.cs index 0336450..9f717c7 100644 --- a/AppData/ComLib.cs +++ b/AppData/ComLib.cs @@ -1117,7 +1117,7 @@ namespace AppData } else { - tabBunk = DLMan.taSTL.getLoaded(); + tabBunk = DLMan.taSTL.getLoaded(machine); // salvo in redis setCurrBunkTab(machine, tabBunk); } @@ -1790,13 +1790,14 @@ namespace AppData } /// - /// Restituisce il BUNK che è il primo della lista: + /// Restituisce il BUNK che è il primo della lista x la MACCHINA indicata: /// - posizione = 3 (ho letto da webApp il BUNK e preso in carico) /// - NumSheet > NumSheetUnload /// - Ordinato per StackIndex (crescente) x avere il più VECCHIO /// + /// /// - public static ProdBunk prodGetFirstBunk() + public static ProdBunk prodGetFirstBunk(string machine) { DataLayer DLMan = new DataLayer(); // cerco prima su REDIS... @@ -1804,7 +1805,7 @@ namespace AppData if (answ == null) { // vado sul DB e leggo ... - DS_App.StackListDataTable tabBunks = DLMan.taSTL.getLoaded(); + DS_App.StackListDataTable tabBunks = DLMan.taSTL.getLoaded(machine); // controllo di averne almeno 1... if (tabBunks.Count > 0) { @@ -1818,21 +1819,22 @@ namespace AppData } /// - /// Restituisce il PROSSIMO bunk secondo criterio: + /// Restituisce il PROSSIMO bunk x la MACCHINA indicata secondo criterio: /// - posizione = 5 (ho letto da webApp il BUNK e preso in carico) /// - NumSheet > NumSheetUnload /// - Ordinato per StackIndex (crescente) x avere il più VECCHIO /// - SUCCESSIVO al BunkID(=StackID) ricevuto /// + /// /// - public static ProdBunk prodGetNextBunk(int BunkID) + public static ProdBunk prodGetNextBunk(int BunkID, string machine) { DataLayer DLMan = new DataLayer(); ProdBunk answ = getRedisNextBunk(BunkID); if (answ == null) { // vado sul DB e leggo ... - DS_App.StackListDataTable tabBunks = DLMan.taSTL.getLoaded(); + DS_App.StackListDataTable tabBunks = DLMan.taSTL.getLoaded(machine); // controllo di averne almeno 1... if (tabBunks.Count > 0) { diff --git a/AppData/DS_App.Designer.cs b/AppData/DS_App.Designer.cs index 5429784..d683aa1 100644 --- a/AppData/DS_App.Designer.cs +++ b/AppData/DS_App.Designer.cs @@ -28911,6 +28911,7 @@ namespace AppData.DS_AppTableAdapters { this._commandCollection[5].CommandText = "dbo.stp_Stacks_getLoaded"; this._commandCollection[5].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[5].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[5].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@PlaceCod", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[6] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[6].Connection = this.Connection; this._commandCollection[6].CommandText = "dbo.stp_Stacks_getNext"; @@ -29029,8 +29030,14 @@ 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")] [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)] - public virtual DS_App.StackListDataTable getLoaded() { + public virtual DS_App.StackListDataTable getLoaded(string PlaceCod) { this.Adapter.SelectCommand = this.CommandCollection[5]; + if ((PlaceCod == null)) { + this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value; + } + else { + this.Adapter.SelectCommand.Parameters[1].Value = ((string)(PlaceCod)); + } DS_App.StackListDataTable dataTable = new DS_App.StackListDataTable(); this.Adapter.Fill(dataTable); return dataTable; diff --git a/AppData/DS_App.xsd b/AppData/DS_App.xsd index 7b778c2..01ec8c7 100644 --- a/AppData/DS_App.xsd +++ b/AppData/DS_App.xsd @@ -428,6 +428,7 @@ FROM v_StackList dbo.stp_Stacks_getLoaded + diff --git a/AppData/DS_App.xss b/AppData/DS_App.xss index 705abc7..49b8c56 100644 --- a/AppData/DS_App.xss +++ b/AppData/DS_App.xss @@ -4,49 +4,49 @@ Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. --> - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -185,7 +185,7 @@ - + 1034 diff --git a/NKC_SDK/NKC.cs b/NKC_SDK/NKC.cs index 87c5cdd..e15b983 100644 --- a/NKC_SDK/NKC.cs +++ b/NKC_SDK/NKC.cs @@ -29,7 +29,7 @@ namespace NKC_SDK { _baseIp = baseIp; _baseUrl = baseUrl; - _machine = codPost; + _codPost = codPost; } #endregion Public Constructors @@ -52,7 +52,7 @@ namespace NKC_SDK /// /// COD macchina x cui si effettua chiamata /// - protected string _machine { get; set; } = ""; + protected string _codPost { get; set; } = ""; protected string urlAlive { @@ -82,7 +82,7 @@ namespace NKC_SDK { get { - return $"{_baseUrl}api/Sheet/{_machine}"; + return $"{_baseUrl}api/Sheet/{_codPost}"; } } @@ -107,7 +107,7 @@ namespace NKC_SDK { get { - return $"{_baseUrl}api/Sheet/{_machine}"; + return $"{_baseUrl}api/Sheet/{_codPost}"; } } @@ -209,14 +209,14 @@ namespace NKC_SDK #region Protected Methods - protected string urlGetBunk(int currBunkId) + protected string urlGetBunk(int currBunkId, string CodPost) { - return $"{_baseUrl}api/Bunk/{currBunkId}?showNext=false"; + return $"{_baseUrl}api/Bunk/{currBunkId}?showNext=false&machine={CodPost}"; } - protected string urlNextBunk(int currBunkId) + protected string urlNextBunk(int currBunkId, string CodPost) { - return $"{_baseUrl}api/Bunk/{currBunkId}?showNext=true"; + return $"{_baseUrl}api/Bunk/{currBunkId}?showNext=true&machine={CodPost}"; } protected string urlPutBunk(int currBunkId) @@ -347,7 +347,7 @@ namespace NKC_SDK try { // aggiungo macchina nel codice dei fogli... - updatedInfo.Machine = _machine; + updatedInfo.Machine = _codPost; // serializzo oggetto rawdata = JsonConvert.SerializeObject(updatedInfo); // invio con metodo put! @@ -372,7 +372,7 @@ namespace NKC_SDK try { // aggiungo macchina nel codice dei fogli... - updatedSheetList.Machine = _machine; + updatedSheetList.Machine = _codPost; // serializzo oggetto rawdata = JsonConvert.SerializeObject(updatedSheetList); // invio con metodo put! diff --git a/NKC_WF/BasePage.cs b/NKC_WF/BasePage.cs index 62a3af5..f2b6e04 100644 --- a/NKC_WF/BasePage.cs +++ b/NKC_WF/BasePage.cs @@ -16,7 +16,7 @@ namespace NKC_WF protected DataLayer DLMan = new DataLayer(); /// - /// Codice macchina (HARD CODED x ora) + /// Codice macchina (da v2) /// protected string machine = "WRK001"; diff --git a/NKC_WF/Controllers/BunkController.cs b/NKC_WF/Controllers/BunkController.cs index 72a22fd..0864f1a 100644 --- a/NKC_WF/Controllers/BunkController.cs +++ b/NKC_WF/Controllers/BunkController.cs @@ -8,14 +8,22 @@ namespace NKC_WF.Controllers { public class BunkController : ApiController { + #region Protected Fields + + /// + /// COdice macchina (HARD CODED) + /// + protected string CodPost = "WRK001"; + /// /// oggetto static/singleton per fare chiamate sul datalayer /// protected DataLayer DLMan = new DataLayer(); - /// - /// COdice macchina (HARD CODED) - /// - protected string machine = "WRK001"; + + #endregion Protected Fields + + #region Public Methods + /// /// Restituisce il FIRST BUNK da lavorare /// GET: api/Bunk @@ -27,7 +35,7 @@ namespace NKC_WF.Controllers ProdBunk answ = null; try { - answ = ComLib.prodGetFirstBunk(); + answ = ComLib.prodGetFirstBunk(CodPost); } catch { } @@ -42,14 +50,15 @@ namespace NKC_WF.Controllers /// /// [HttpGet] - public ProdBunk Get(int id, bool showNext) + public ProdBunk Get(int id, bool showNext, string machine) { ProdBunk answ = null; + CodPost = machine; try { if (showNext) { - answ = ComLib.prodGetNextBunk(id); + answ = ComLib.prodGetNextBunk(id, CodPost); } else { @@ -63,9 +72,9 @@ namespace NKC_WF.Controllers /************************************ * METODI PUT - * + * * per abilitare è necessario agire sulla conf di IIS: - * + * * - modificare il file applicationHost.config che si trova in C:\Windows\System32\inetsrv\config * - disinstallare webDav oppure commentare le righe * @@ -74,44 +83,9 @@ namespace NKC_WF.Controllers * - aggiungere PUT/DELETE a handler: * * - * + * **************************************/ - - /// - /// Effettua la chiamata di update - /// - /// - /// - // PUT: api/Bunk/5 - [HttpPut] - public void Put(ProdBunk currBunk) - { - // NB. decodifico direttamente come oggetto, vedere qui: - // https://weblog.west-wind.com/posts/2013/dec/13/accepting-raw-request-body-content-with-aspnet-web-api - // https://weblog.west-wind.com/posts/2017/sep/14/accepting-raw-request-body-content-in-aspnet-core-api-controllers - - // se non nullo... - if (currBunk != null) - { - foreach (var item in currBunk.SheetList) - { - DLMan.taSHL.updateDate(item.SheetId, item.Printing.DtStart, item.Printing.DtEnd, item.Machining.DtStart, item.Machining.DtEnd, item.Unloading.DtStart, item.Unloading.DtEnd, (int)item.Status); - // verifico SE SIA AVVENUTO CON SUCCESSO lo step di lavorazione... - if (item.Machining.Success) - { - // SE machining completato --> status a LAVORATO! - if (item.Machining.DtEnd != null) - { - DLMan.taIL.updateSheetStatus(item.SheetId, 1, "PROD"); - } - } - } - } - // INVALIDO eventuale valore BUNK in REDIS... - ComLib.resetRedisBunkData(machine); - } - /// /// Processa una chiamata POST per l'invio in blocco status BUNK /// POST: api/Bunk @@ -142,7 +116,6 @@ namespace NKC_WF.Controllers { // calcolo stsatus dalle date valide... - DLMan.taSHL.updateDate(item.SheetId, item.Printing.DtStart, item.Printing.DtEnd, item.Machining.DtStart, item.Machining.DtEnd, item.Unloading.DtStart, item.Unloading.DtEnd, (int)item.Status); // SE machining completato --> status a LAVORATO! if (item.Machining.DtEnd != null) @@ -162,5 +135,40 @@ namespace NKC_WF.Controllers return answ; } + /// + /// Effettua la chiamata di update + /// + /// + /// + // PUT: api/Bunk/5 + [HttpPut] + public void Put(ProdBunk currBunk) + { + // NB. decodifico direttamente come oggetto, vedere qui: + // https://weblog.west-wind.com/posts/2013/dec/13/accepting-raw-request-body-content-with-aspnet-web-api + // https://weblog.west-wind.com/posts/2017/sep/14/accepting-raw-request-body-content-in-aspnet-core-api-controllers + + // se non nullo... + if (currBunk != null) + { + foreach (var item in currBunk.SheetList) + { + DLMan.taSHL.updateDate(item.SheetId, item.Printing.DtStart, item.Printing.DtEnd, item.Machining.DtStart, item.Machining.DtEnd, item.Unloading.DtStart, item.Unloading.DtEnd, (int)item.Status); + // verifico SE SIA AVVENUTO CON SUCCESSO lo step di lavorazione... + if (item.Machining.Success) + { + // SE machining completato --> status a LAVORATO! + if (item.Machining.DtEnd != null) + { + DLMan.taIL.updateSheetStatus(item.SheetId, 1, "PROD"); + } + } + } + } + // INVALIDO eventuale valore BUNK in REDIS... + ComLib.resetRedisBunkData(CodPost); + } + + #endregion Public Methods } -} +} \ No newline at end of file diff --git a/NKC_WF/site/MachineLoad.aspx b/NKC_WF/site/MachineLoad.aspx index b4a9642..5a6d72b 100644 --- a/NKC_WF/site/MachineLoad.aspx +++ b/NKC_WF/site/MachineLoad.aspx @@ -10,9 +10,10 @@
+
-

 <%: traduci("MachineLoad") %><%--(<%: hfBatchID.Value %>)--%>

+

 <%: traduci("MachineLoad") %>(<%: hfBatchID.Value %>)

diff --git a/NKC_WF/site/MachineLoad.aspx.cs b/NKC_WF/site/MachineLoad.aspx.cs index 6725d80..69230e4 100644 --- a/NKC_WF/site/MachineLoad.aspx.cs +++ b/NKC_WF/site/MachineLoad.aspx.cs @@ -23,10 +23,12 @@ namespace NKC_WF { divMain.Visible = true; cmp_stackLoading.doUpdate(); - cmp_ML_ShDet.BatchId = cmp_stackLoading.BatchIdCurr; - cmp_ML_ShDet1.BatchId = cmp_stackLoading.BatchIdCurr; - cmp_ML_ShDet2.BatchId = cmp_stackLoading.BatchIdCurr; - cmp_ML_ShDet3.BatchId = cmp_stackLoading.BatchIdCurr; + int currBatchId = cmp_stackLoading.BatchIdCurr; + hfBatchID.Value = $"{currBatchId}"; + cmp_ML_ShDet.BatchId = currBatchId; + cmp_ML_ShDet1.BatchId = currBatchId; + cmp_ML_ShDet2.BatchId = currBatchId; + cmp_ML_ShDet3.BatchId = currBatchId; cmp_ML_ShDet.doUpdate(); cmp_ML_ShDet1.doUpdate(); cmp_ML_ShDet2.doUpdate(); diff --git a/NKC_WF/site/MachineLoad.aspx.designer.cs b/NKC_WF/site/MachineLoad.aspx.designer.cs index d5e5d36..77c8ed0 100644 --- a/NKC_WF/site/MachineLoad.aspx.designer.cs +++ b/NKC_WF/site/MachineLoad.aspx.designer.cs @@ -23,6 +23,15 @@ namespace NKC_WF /// protected global::NKC_WF.WebUserControls.cmp_MachSem cmp_MachSem; + /// + /// hfBatchID control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.HiddenField hfBatchID; + /// /// divMain control. /// diff --git a/NKC_WF/site/MachineUnload.aspx b/NKC_WF/site/MachineUnload.aspx index 7624abf..f171c86 100644 --- a/NKC_WF/site/MachineUnload.aspx +++ b/NKC_WF/site/MachineUnload.aspx @@ -14,6 +14,7 @@
+

 <%: traduci("MachineUnload") %>(<%: hfBatchID.Value %>)

@@ -27,7 +28,6 @@
- diff --git a/NKC_WF/site/MachineUnload.aspx.cs b/NKC_WF/site/MachineUnload.aspx.cs index fdbff97..3084a47 100644 --- a/NKC_WF/site/MachineUnload.aspx.cs +++ b/NKC_WF/site/MachineUnload.aspx.cs @@ -127,9 +127,11 @@ namespace NKC_WF if (string.IsNullOrEmpty(cmp_MachSem.currMachine)) { divMain.Visible = false; + machine = "#"; } else { + machine = cmp_MachSem.currMachine; divMain.Visible = true; // imposto dati correnti bool doUpdate = setCurrData(); @@ -158,7 +160,7 @@ namespace NKC_WF { bool needUpdate = false; // recupero bunk corrente... - DS_App.StackListRow currBunk = ComLib.getCurrBunk(); + DS_App.StackListRow currBunk = ComLib.getCurrBunk(machine); if (currBunk != null) { bool chgBtLocal = BatchId != currBunk.BatchID; diff --git a/NKC_WF/site/MachineUnload.aspx.designer.cs b/NKC_WF/site/MachineUnload.aspx.designer.cs index 9e7ca2c..e2a5fd5 100644 --- a/NKC_WF/site/MachineUnload.aspx.designer.cs +++ b/NKC_WF/site/MachineUnload.aspx.designer.cs @@ -32,6 +32,15 @@ namespace NKC_WF /// protected global::NKC_WF.WebUserControls.cmp_MachSem cmp_MachSem; + /// + /// hfBatchID control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.HiddenField hfBatchID; + /// /// hlPartMIA control. /// @@ -59,15 +68,6 @@ namespace NKC_WF /// protected global::System.Web.UI.UpdatePanel upnlStats; - /// - /// hfBatchID control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.HiddenField hfBatchID; - /// /// hfSheetID control. ///