diff --git a/AppData/AppData.csproj b/AppData/AppData.csproj
index 72d6b17..bb88908 100644
--- a/AppData/AppData.csproj
+++ b/AppData/AppData.csproj
@@ -86,6 +86,7 @@
True
DS_App.xsd
+
True
True
diff --git a/AppData/ComLib.cs b/AppData/ComLib.cs
index 97a7076..e7bb5fa 100644
--- a/AppData/ComLib.cs
+++ b/AppData/ComLib.cs
@@ -15,6 +15,14 @@ namespace AppData
public class ComLib
{
+ #region conf posizioni redis
+
+ protected static string redOutPath = "NKC:SERV:BREQ";
+ protected static string redMsgCount = "NKC:SERV:BREQ:MCount";
+ protected static string redMsgList = "NKC:SERV:BREQ:MList";
+
+ #endregion
+
#region definizione classi impiegate con PROD
@@ -384,113 +392,91 @@ namespace AppData
memLayer.ML.setRSV(redKey, redVal);
return answ;
}
+ ///
+ /// Restituisce il prossimo codice di envelope per comunicare con sistemi esterni
+ ///
+ /// Batch contenuto nell'envelope
+ /// note opzionali (motivo envelope)
+ ///
+ public static string getNextEnv(int BatchID, string note)
+ {
+ // incremento counter
+ long nextIndex = memLayer.ML.setRCntI(redMsgCount);
+ // salvo contenuto della busta
+ string answ = $"Z{nextIndex:000000000000}";
+ Dictionary lista = new Dictionary();
+ lista.Add(answ, $"{BatchID}|{note}");
+ memLayer.ML.redSaveHashDict(redMsgList, lista);
+ // ritorno
+ return answ;
+ }
+
///
/// Invia una richiesta di esecuzione di Nesting x un Batch
///
- ///
+ /// Batch di cui si chiede processing
+ /// note opzionali
///
- public static bool sendBatchReq(int BatchID)
+ public static bool sendBatchReq(int BatchID, string note)
{
bool answ = false;
- // in base allo stato del BATCH corrente determino il tempo e le opzioni da inviare...
- var batch = DataLayer.man.taBL.getByKey(BatchID);
- int mTime = 1;
- int pType = 1;
- if (batch[0].STATUS < (int)BatchStatus.EstimationDone)
+ // per prima cosa mi serve una "nuova busta" per inviare i messaggi
+ string nextEnv = getNextEnv(BatchID, note);
+ // preparo il contenuto della busta ed invio i messaggi...
+ try
{
- mTime = memLayer.ML.cdvi("estimMaxTime");
- }
- else
- {
- mTime = memLayer.ML.cdvi("nestMaxTime");
- pType = 2;
- }
- // leggo tab ORDINI da DB
- var tblOrd = DataLayer.man.taOL.getByBatch(BatchID);
- // serializzo
- string redVal = JsonConvert.SerializeObject(tblOrd);
- // salvo
- string redKey = $"NKC:SERV:BREQ:{BatchID}:TAB:ORDERS";
- // scrivo su REDIS
- memLayer.ML.setRSV(redKey, redVal);
-
- var tblItm = DataLayer.man.taIL.getByBatch(BatchID);
- // serializzo
- redVal = JsonConvert.SerializeObject(tblItm);
- // salvo
- redKey = $"NKC:SERV:BREQ:{BatchID}:TAB:ITEMS";
- // scrivo su REDIS
- memLayer.ML.setRSV(redKey, redVal);
- // ora versione gerarchica
- var currBatch = new Batch()
- {
- BatchId = BatchID,
- maxTime = mTime,
- procType = pType
- };
- // serializzo
- redVal = JsonConvert.SerializeObject(currBatch);
- // salvo
- redKey = $"NKC:SERV:BREQ:{BatchID}:TAB:DATA";
- // scrivo su REDIS
- memLayer.ML.setRSV(redKey, redVal);
-
-#if false
-
- Parte currPart;
- Ordine currOrder;
- List ItemList = new List();
- List OrderList = new List();
- foreach (var ordine in tblOrd)
- {
- ItemList = new List();
- // carico items dell'ordine
- var tblHItm = DataLayer.man.taIL.getByOrder(ordine.OrdCod);
- // serializzo
- foreach (var parte in tblHItm)
+ // in base allo stato del BATCH corrente determino il tempo e le opzioni da inviare...
+ var batch = DataLayer.man.taBL.getByKey(BatchID);
+ int mTime = 1;
+ int pType = 1;
+ if (batch[0].STATUS < (int)BatchStatus.EstimationDone)
{
- currPart = new Parte()
- {
- PartId = parte.ItemID,
- CadFilePath = parte.CadFilePath,
- DataMatrix = parte.Item_Dtmx,
- Description = parte.ItemDesc,
- ExtCode = parte.ItemExtCode,
- Qty = parte.ItemQty
- };
- ItemList.Add(currPart);
+ mTime = memLayer.ML.cdvi("estimMaxTime");
}
- // carico ordine
- currOrder = new Ordine()
+ else
{
- OrdCod = ordine.OrdCod,
- DestPlant = ordine.DestPlant,
- DataMatrix = ordine.OrdCod_Dtmx,
- ExtCode = ordine.OrderExtCode,
- Model = ordine.FamilyCode,
- Qty = ordine.OrderQty,
- Items = ItemList
+ mTime = memLayer.ML.cdvi("nestMaxTime");
+ pType = 2;
+ }
+ // leggo tab ORDINI da DB
+ var tblOrd = DataLayer.man.taOL.getByBatch(BatchID);
+ // serializzo
+ string redVal = JsonConvert.SerializeObject(tblOrd);
+ // salvo
+ string redKey = $"{redOutPath}:{nextEnv}:ORDERS";
+ // scrivo su REDIS
+ memLayer.ML.setRSV(redKey, redVal);
+
+ var tblItm = DataLayer.man.taIL.getByBatch(BatchID);
+ // serializzo
+ redVal = JsonConvert.SerializeObject(tblItm);
+ // salvo
+ redKey = $"{redOutPath}:{nextEnv}:ITEMS";
+ // scrivo su REDIS
+ memLayer.ML.setRSV(redKey, redVal);
+ // ora versione gerarchica
+ var currBatch = new Batch()
+ {
+ BatchId = BatchID,
+ maxTime = mTime,
+ procType = pType
};
- // aggiungo a lista
- OrderList.Add(currOrder);
+ // serializzo
+ redVal = JsonConvert.SerializeObject(currBatch);
+ // salvo
+ redKey = $"{redOutPath}:{nextEnv}:DATA";
+ // scrivo su REDIS
+ memLayer.ML.setRSV(redKey, redVal);
+
+ // invio notifica che c'è una busta da processare
+ redKey = $"{redOutPath}:CURR";
+ // scrivo su REDIS
+ memLayer.ML.setRSV(redKey, nextEnv);
+ answ = true;
}
- // ora versione gerarchica
- var currBatch = new Batch()
- {
- BatchId = BatchID,
- maxTime = mTime,
- procType = pType
- Orders = OrderList
- };
-
- // serializzo
- redVal = JsonConvert.SerializeObject(currBatch);
- // salvo
- redKey = $"NKC:SERV:BREQ:{BatchID}:HDATA";
- // scrivo su REDIS
- memLayer.ML.setRSV(redKey, redVal);
-#endif
-
+ catch
+ { }
+ // restituisco ok
return answ;
}
diff --git a/AppData/DS_App.Designer.cs b/AppData/DS_App.Designer.cs
index 822e35f..8cb7a4a 100644
--- a/AppData/DS_App.Designer.cs
+++ b/AppData/DS_App.Designer.cs
@@ -3501,7 +3501,7 @@ namespace AppData.DS_AppTableAdapters {
this._commandCollection = new global::System.Data.SqlClient.SqlCommand[5];
this._commandCollection[0] = new global::System.Data.SqlClient.SqlCommand();
this._commandCollection[0].Connection = this.Connection;
- this._commandCollection[0].CommandText = "SELECT *\r\nFROM dbo.v_BatchList";
+ this._commandCollection[0].CommandText = "SELECT *\r\nFROM v_BatchList";
this._commandCollection[0].CommandType = global::System.Data.CommandType.Text;
this._commandCollection[1] = new global::System.Data.SqlClient.SqlCommand();
this._commandCollection[1].Connection = this.Connection;
diff --git a/AppData/DS_App.xsd b/AppData/DS_App.xsd
index 63eb568..c75cbdd 100644
--- a/AppData/DS_App.xsd
+++ b/AppData/DS_App.xsd
@@ -10,11 +10,11 @@
-
+
SELECT *
-FROM dbo.v_BatchList
+FROM v_BatchList
@@ -452,7 +452,7 @@ SELECT BatchID, OrdCod FROM BatchReqList WHERE (BatchID = @BatchID) AND (OrdCod
-
+
@@ -481,7 +481,7 @@ SELECT BatchID, OrdCod FROM BatchReqList WHERE (BatchID = @BatchID) AND (OrdCod
-
+
@@ -513,7 +513,7 @@ SELECT BatchID, OrdCod FROM BatchReqList WHERE (BatchID = @BatchID) AND (OrdCod
-
+
@@ -580,7 +580,7 @@ SELECT BatchID, OrdCod FROM BatchReqList WHERE (BatchID = @BatchID) AND (OrdCod
-
+
@@ -658,7 +658,7 @@ SELECT BatchID, OrdCod FROM BatchReqList WHERE (BatchID = @BatchID) AND (OrdCod
-
+
@@ -698,9 +698,9 @@ SELECT BatchID, OrdCod FROM BatchReqList WHERE (BatchID = @BatchID) AND (OrdCod
-
-
-
+
+
+
\ No newline at end of file
diff --git a/AppData/List.cs b/AppData/List.cs
new file mode 100644
index 0000000..1e2bd2f
--- /dev/null
+++ b/AppData/List.cs
@@ -0,0 +1,6 @@
+namespace AppData
+{
+ internal class List
+ {
+ }
+}
\ No newline at end of file
diff --git a/NKC_WF/Web.config b/NKC_WF/Web.config
index fd054d3..4e9d608 100644
--- a/NKC_WF/Web.config
+++ b/NKC_WF/Web.config
@@ -36,6 +36,7 @@
+
diff --git a/NKC_WF/WebUserControls/cmp_batchDetail.ascx.cs b/NKC_WF/WebUserControls/cmp_batchDetail.ascx.cs
index ec9e4ae..8b8d88b 100644
--- a/NKC_WF/WebUserControls/cmp_batchDetail.ascx.cs
+++ b/NKC_WF/WebUserControls/cmp_batchDetail.ascx.cs
@@ -75,7 +75,7 @@ namespace NKC_WF.WebUserControls
{
// invia a redis a a richiesta...
ComLib.sendMaterials();
- ComLib.sendBatchReq(BatchId);
+ ComLib.sendBatchReq(BatchId, "Estimation");
// registro su DB nesting iniziato...
DataLayer.man.taBL.updateStatus(BatchId, (int)ComLib.BatchStatus.EstimationRequested);
@@ -94,7 +94,7 @@ namespace NKC_WF.WebUserControls
{
// invia a redis a a richiesta...
ComLib.sendMaterials();
- ComLib.sendBatchReq(BatchId);
+ ComLib.sendBatchReq(BatchId,"Nesting");
// registro su DB nesting iniziato...
DataLayer.man.taBL.updateStatus(BatchId, (int)ComLib.BatchStatus.NestRequested);