diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..32a8a48
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,4 @@
+[*.cs]
+
+# IDE0058: Il valore dell'espressione non viene mai usato
+csharp_style_unused_value_expression_statement_preference = discard_variable:none
diff --git a/AppData/AppData.csproj b/AppData/AppData.csproj
index c041ece..911a3fc 100644
--- a/AppData/AppData.csproj
+++ b/AppData/AppData.csproj
@@ -188,6 +188,9 @@
+
+ .editorconfig
+
diff --git a/AppData/ComLib.cs b/AppData/ComLib.cs
index 0fa39e4..6dd90fa 100644
--- a/AppData/ComLib.cs
+++ b/AppData/ComLib.cs
@@ -10,574 +10,601 @@ using System.Web;
namespace AppData
{
- ///
- /// Classe con metodi di supporto per COMUNICAZIONE
- ///
- public class ComLib
- {
- #region Gestione persistenza risposte via REST da NESTING
-
///
- /// Database corrente MongoDB
+ /// Classe con metodi di supporto per COMUNICAZIONE
///
- IMongoDatabase database;
- ///
- /// Init classe ComLib
- ///
- public ComLib()
+ public class ComLib
{
- database = memLayer.ML.getMongoDatabase("NKC");
- }
- ///
- /// Classe impiego sstatico ComLib...
- ///
- public static ComLib man = new ComLib();
+ #region Gestione persistenza risposte via REST da NESTING
- ///
- /// Salva una risposta ricevuta x STIMA
- ///
- /// Stringa della risposta JSON ricevuta dal nesting
- ///
- public bool saveEstAnsw(nestReplyBatchInitial nestAnsw)
- {
- bool answ = false;
- try
- {
- // definisco filtro
- var filtBuilder = Builders.Filter;
- var filter = filtBuilder.Eq("BatchID", nestAnsw.BatchID);
- var collRawData = database.GetCollection("EstimationArchive");
- // elimino old
- collRawData.DeleteMany(filter);
- // aggiungo
- collRawData.InsertOne(nestAnsw);
-
- answ = true;
- }
- catch
- { }
- return answ;
- }
- ///
- /// Salva una risposta ricevuta x NESTING
- ///
- /// Stringa della risposta JSON ricevuta dal nesting
- ///
- public bool saveNestAnsw(nestReplyBatchFinal nestAnsw)
- {
- bool answ = false;
- try
- {
- // definisco filtro
- var filtBuilder = Builders.Filter;
- var filter = filtBuilder.Eq("BatchID", nestAnsw.BatchID);
- var collRawData = database.GetCollection("NestingArchive");
- // elimino old
- collRawData.DeleteMany(filter);
- // aggiungo
- collRawData.InsertOne(nestAnsw);
- answ = true;
- }
- catch
- { }
- return answ;
- }
- ///
- /// Recupero risposta stima salvata
- ///
- ///
- ///
- public nestReplyBatchInitial getEstAnsw(int BatchID)
- {
- nestReplyBatchInitial answ = null;
- try
- {
- // definisco filtro
- var filtBuilder = Builders.Filter;
- var filter = filtBuilder.Eq("BatchID", BatchID);
- var collRawData = database.GetCollection("EstimationArchive");
- // recupero
- answ = collRawData.Find(filter).Project("{_id: 0}").FirstOrDefault();
- }
- catch
- { }
- return answ;
- }
- ///
- /// Recupero risposta nesting salvata
- ///
- ///
- ///
- public nestReplyBatchFinal getNestAnsw(int BatchID)
- {
- nestReplyBatchFinal answ = null;
- try
- {
- // definisco filtro
- var filtBuilder = Builders.Filter;
- var filter = filtBuilder.Eq("BatchID", BatchID);
- FindOptions opz = new FindOptions { ShowRecordId = false };
- var collRawData = database.GetCollection("NestingArchive");
- // recupero
- answ = collRawData.Find(filter).Project("{_id: 0}").FirstOrDefault();
- }
- catch
- { }
- return answ;
- }
-
- ///
- /// restitusice ultima chiamata REST registrata su REDIS
- ///
- ///
- public static string lastRestAnsw()
- {
- string answ = "";
- // recupero ultima call
- string redKey = $"{redNestAnsw}:LAST_CALL";
- answ = memLayer.ML.getRSV(redKey);
- return answ;
- }
-
-
- #endregion
-
- ///
- /// Wrapper traduzione termini
- ///
- ///
- ///
- public static string traduci(string lemma)
- {
- return user_std.UtSn.Traduci(lemma);
- }
- #region conf posizioni redis
-
- public static string redOutPath = "NKC:SERV:BREQ";
- public static string redMsgCount = "NKC:SERV:BREQ:MCount";
- public static string redMsgList = "NKC:SERV:BREQ:MList";
- public static string redMLCurrStack = "NKC:SERV:TAKT:CurrStack";
-
- public static string redNestAnsw = "NKC:NEST:BANSW";
-
- public static string redProdReq = "NKC:SERV:BUNKS";
- public static string redProdAnsw = "NKC:PROD:BUNKS";
-
-
-
- #endregion
-
- #region definizione classi impiegate con PROD
-
- public static string PositionStatusDescr(object value)
- {
- string answ = "";
- try
- {
- BatchPosition pStatus = (BatchPosition)Enum.Parse(typeof(BatchPosition), value.ToString());
- switch (pStatus)
+ ///
+ /// Database corrente MongoDB
+ ///
+ IMongoDatabase database;
+ ///
+ /// Init classe ComLib
+ ///
+ public ComLib()
{
- case BatchPosition.NotStarted:
- answ = traduci("NotStarted");
- break;
- case BatchPosition.StackStarted:
- answ = traduci("Stacking");
- break;
- case BatchPosition.StackDone:
- answ = traduci("StackDone");
- break;
- case BatchPosition.Current:
- answ = traduci("StackCurrent");
- break;
- case BatchPosition.Completed:
- answ = traduci("StackCompleted");
- break;
- default:
- break;
+ database = memLayer.ML.getMongoDatabase("NKC");
}
- }
- catch
- { }
- return answ;
- }
- public static string BatchStatusDescr(object value)
- {
- string answ = "";
- try
- {
- BatchStatus bStatus = (BatchStatus)Enum.Parse(typeof(BatchStatus), value.ToString());
- switch (bStatus)
+ ///
+ /// Classe impiego sstatico ComLib...
+ ///
+ public static ComLib man = new ComLib();
+
+ ///
+ /// Salva una risposta ricevuta x STIMA
+ ///
+ /// Stringa della risposta JSON ricevuta dal nesting
+ ///
+ public bool saveEstAnsw(nestReplyBatchInitial nestAnsw)
{
- case BatchStatus.Imported:
- answ = "Imported";
- break;
- case BatchStatus.EstimationRequested:
- answ = "Estimation Requested";
- break;
- case BatchStatus.EstimationDone:
- answ = "Estimation Completed";
- break;
- case BatchStatus.NestRequested:
- answ = "Nesting Requested";
- break;
- case BatchStatus.NestDone:
- answ = "Nesting Completed";
- break;
- case BatchStatus.Approved:
- answ = "Nesting Approved";
- break;
- case BatchStatus.Discarded:
- answ = "Nesting Discarded";
- break;
- case BatchStatus.Errors:
- answ = "Nesting Impossibile (data errors)";
- break;
- case BatchStatus.PartEval:
- answ = "Part/Item under evaluation";
- break;
- case BatchStatus.PartOk:
- answ = "Part/Item Validated";
- break;
- case BatchStatus.PartKo:
- answ = "Part/Item NOT Validated";
- break;
- default:
- answ = $"Status unknown: {bStatus}";
- break;
- }
- }
- catch
- { }
- return answ;
- }
-
- ///
- /// Oggetto globale TAKT
- ///
- public class Takt
- {
- ///
- /// Codice univoco oggetto TAKT (data.num)
- ///
- public string TaktId { get; set; }
- ///
- /// Stato del TAKT
- ///
- public CStatus Status { get; set; }
- ///
- /// Elenco degli Stack da lavorare
- ///
- public List StackList { get; set; }
- ///
- /// Numero di Stack da lavorare
- ///
- public int NumStack
- {
- get
- {
- int answ = 0;
- try
- {
- answ = StackList.Count;
- }
- catch
- { }
- return answ;
- }
- }
- }
-
- #endregion
-
- #region definizione classi impiegate con NEST
-
-
- public class Parte
- {
- public int PartId { get; set; }
- public string DataMatrix { get; set; }
- public string ExtCode { get; set; }
- public string Description { get; set; }
- public int MatId { get; set; }
- public string PostProc { get; set; }
- public string ProcessReq { get; set; }
- public string CadFilePath { get; set; }
- public int Qty { get; set; }
- }
-
- public class BatchData
- {
- ///
- /// ID del batch in esecuzione
- ///
- public int BatchId { get; set; }
- ///
- /// tempo amssimo eprmesso x nesting (minuti)
- ///
- public int maxTime { get; set; }
- ///
- /// Tipo di processing richiesto
- /// 1 = stima
- /// 2 = nesting
- ///
- [JsonConverter(typeof(StringEnumConverter))]
- public int procType { get; set; }
- ///
- /// Codice della amcchina x cui si effettua richeista
- ///
- [JsonConverter(typeof(StringEnumConverter))]
- public mType machineType { get; set; }
- ///
- /// Tipo di ordine richeisto
- ///
- [JsonConverter(typeof(StringEnumConverter))]
- public oType orderType { get; set; }
- }
- ///
- /// Salva su redis l'oggetto dei materiali serializzato
- ///
- ///
- public static bool sendMaterials()
- {
- bool answ = false;
- // leggo tab MNATERIALS da DB
- var table = DataLayer.man.taMat.GetData();
- // serializzo
- string redVal = JsonConvert.SerializeObject(table);
- // salvo
- string redKey = $"NKC:SERV:CONF:MATERIALS";
- // scrivo per ora solo su REDIS
- 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;
- }
- ///
- /// Restituisce elenco KVP delle buste ancora "pending" (quando processate le elimina da elenco...)
- ///
- ///
- public static KeyValuePair[] getEnvList()
- {
- KeyValuePair[] answ = memLayer.ML.redGetHash(redMsgList);
- return answ;
- }
- ///
- /// resetta la richeista corrente in modo che non ce ne siano altre in coda
- ///
- ///
- public static bool resetBatchReq()
- {
- bool answ = false;
- try
- {
- currBatchReq = "";
- answ = true;
- }
- catch
- { }
- return answ;
- }
- public static string currBatchReqKey
- {
- get
- {
- return $"{redOutPath}:CURR";
- }
- }
- ///
- /// Valore della richiesta corrente di elaborazione batch
- ///
- public static string currBatchReq
- {
- get
- {
- return memLayer.ML.getRSV(currBatchReqKey);
- }
- set
- {
- // scrivo su REDIS
- memLayer.ML.setRSV(currBatchReqKey, value);
- }
- }
- ///
- /// Manda il primo batch di VALIDAZIONE al NESTING...
- ///
- ///
- public static bool sendFirstValidationBatch()
- {
- bool answ = false;
- // verifico se NON CI SIANO GIA' validazioni in corso...
- var tabBatchRunning = DataLayer.man.taBL.getByStatus(1, "", 0);
- if (tabBatchRunning.Count == 0)
- {
- // ora verifico, se ci sono batch in stato 8 (da validare) --> metto in coda!
- var tabBatch = DataLayer.man.taBL.getByStatus(8, "", 1);
- bool hasValReq = tabBatch.Count > 0;
- if (hasValReq)
- {
- // invia a redis una richiesta...
- sendMaterials();
- // recupero PRIMO batchID da validare
- int nextBatchId = 0;
- try
- {
- nextBatchId = tabBatch[0].BatchID;
- }
- catch
- { }
- if (nextBatchId > 0)
- {
- // richiedo!
- sendBatchReq(nextBatchId, "Estimation", 1);
- // registro su DB nesting iniziato... QUANDO MI RISPONDE dovrò verificare che era un batch x VALIDAZIONE
- DataLayer.man.taBL.updateStatus(nextBatchId, (int)BatchStatus.EstimationRequested, "", 0);
- answ = true;
- }
- }
- }
- // resituisco
- return answ;
- }
- ///
- /// Invia una richiesta di esecuzione di Nesting x un Batch
- ///
- /// Batch di cui si chiede processing
- /// note opzionali
- /// Tipo processo: 1 = stima, 2 = nesting
- ///
- public static bool sendBatchReq(int BatchID, string note, int pType)
- {
- bool answ = false;
- // 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
- {
- // 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;
- if (batch[0].STATUS < (int)BatchStatus.EstimationDone)
- {
- mTime = memLayer.ML.cdvi("estimMaxTime");
- }
- else
- {
- mTime = memLayer.ML.cdvi("nestMaxTime");
- }
-
- // init oggetti x fare cicli...
- Order currOrder = null;
- Kit currentKit = null;
- Part currPart = null;
- List listOrder = new List();
- List listKit = new List();
- List listPart = new List();
-
- // leggo tab ORDINI da DB
- var tblOrd = DataLayer.man.taOL.getByBatch(BatchID);
- // leggo tab KIT da DB
- var tblKit = DataLayer.man.taKL.getByBatch(BatchID);
- // leggo tab ITEMS da DB
- var tblItm = DataLayer.man.taIL.getByBatch(BatchID);
-
- // ciclo per comporre oggetto con cicli annidiati ext --> int
- foreach (var rigaOrd in tblOrd)
- {
- listKit = new List();
- // compongo kit
- var righeKit = (DS_App.KitListRow[])tblKit.Select($"OrdID = {rigaOrd.OrdID}");
- foreach (var rigaKit in righeKit)
- {
- listPart = new List();
- // elenco ITEMS
- var righeItems = (DS_App.ItemListRow[])tblItm.Select($"KitID = {rigaKit.KitID}");
- foreach (var rigaItem in righeItems)
+ bool answ = false;
+ try
{
- currPart = new Part()
- {
- PartId = rigaItem.ItemID,
- PartExtCode = rigaItem.ItemExtCode,
- PartDtmx = rigaItem.ItemDtmx,
- PartQty = rigaItem.ItemQty,
- MatId = rigaItem.MatID,
- CadFilePath = rigaItem.CadFilePath
- };
- listPart.Add(currPart);
+ // definisco filtro
+ var filtBuilder = Builders.Filter;
+ var filter = filtBuilder.Eq("BatchID", nestAnsw.BatchID);
+ var collRawData = database.GetCollection("EstimationArchive");
+ // elimino old
+ collRawData.DeleteMany(filter);
+ // aggiungo
+ collRawData.InsertOne(nestAnsw);
+
+ answ = true;
}
- // compongo KIT
- currentKit = new Kit()
- {
- KitId = rigaKit.KitID,
- KitExtCode = rigaKit.KitExtCode,
- PartList = listPart
- };
- listKit.Add(currentKit);
- }
- // compongo ordine
- currOrder = new Order()
- {
- OrderId = rigaOrd.OrdID,
- OrderCod = rigaOrd.FamilyCode,
- OrderExtCode = rigaOrd.OrderExtCode,
- DestPlant = rigaOrd.DestPlant,
- KitList = listKit
- };
- listOrder.Add(currOrder);
+ catch
+ { }
+ return answ;
}
- // oggetto complessivo
- batchRequest newBatchreq = new batchRequest()
+ ///
+ /// Salva una risposta ricevuta x NESTING
+ ///
+ /// Stringa della risposta JSON ricevuta dal nesting
+ ///
+ public bool saveNestAnsw(nestReplyBatchFinal nestAnsw)
{
- BatchId = BatchID,
- EnvNum = nextEnv,
- MaxTime = mTime,
- ProcType = pType,
- MachineType = mType.Multiax,
- OrderType = oType.BatchRequest,
- OrderList = listOrder
- };
+ bool answ = false;
+ try
+ {
+ // definisco filtro
+ var filtBuilder = Builders.Filter;
+ var filter = filtBuilder.Eq("BatchID", nestAnsw.BatchID);
+ var collRawData = database.GetCollection("NestingArchive");
+ // elimino old
+ collRawData.DeleteMany(filter);
+ // aggiungo
+ collRawData.InsertOne(nestAnsw);
+ answ = true;
+ }
+ catch
+ { }
+ return answ;
+ }
+ ///
+ /// Recupero risposta stima salvata
+ ///
+ ///
+ ///
+ public nestReplyBatchInitial getEstAnsw(int BatchID)
+ {
+ nestReplyBatchInitial answ = null;
+ try
+ {
+ // definisco filtro
+ var filtBuilder = Builders.Filter;
+ var filter = filtBuilder.Eq("BatchID", BatchID);
+ var collRawData = database.GetCollection("EstimationArchive");
+ // recupero
+ answ = collRawData.Find(filter).Project("{_id: 0}").FirstOrDefault();
+ }
+ catch
+ { }
+ return answ;
+ }
+ ///
+ /// Recupero risposta nesting salvata
+ ///
+ ///
+ ///
+ public nestReplyBatchFinal getNestAnsw(int BatchID)
+ {
+ nestReplyBatchFinal answ = null;
+ try
+ {
+ // definisco filtro
+ var filtBuilder = Builders.Filter;
+ var filter = filtBuilder.Eq("BatchID", BatchID);
+ FindOptions opz = new FindOptions { ShowRecordId = false };
+ var collRawData = database.GetCollection("NestingArchive");
+ // recupero
+ answ = collRawData.Find(filter).Project("{_id: 0}").FirstOrDefault();
+ }
+ catch
+ { }
+ return answ;
+ }
- // serializzo
- string redVal = JsonConvert.SerializeObject(newBatchreq);
- // salvo
- string redKey = $"{redOutPath}:{nextEnv}";
- // scrivo su REDIS
- memLayer.ML.setRSV(redKey, redVal);
+ ///
+ /// restitusice ultima chiamata REST registrata su REDIS
+ ///
+ ///
+ public static string lastRestAnsw()
+ {
+ string answ = "";
+ // recupero ultima call
+ string redKey = $"{redNestAnsw}:LAST_CALL";
+ answ = memLayer.ML.getRSV(redKey);
+ return answ;
+ }
- // invio notifica che c'è una busta da processare
- memLayer.ML.setRSV(currBatchReqKey, nextEnv);
- answ = true;
- }
- catch (Exception exc)
- { }
- // restituisco ok
- return answ;
- }
- ///
- /// Verifica lo stato di una richiesta di esecuzione BATCH x stima/nesting
- ///
- /// OfflineOrder di cui si chiede processing
- /// note opzionali
- ///
- public static bool checkBatchReq(int OffOrderID)
- {
- bool answ = false;
+ ///
+ /// Salva una risposta ricevuta dal PROD
+ ///
+ /// Stringa della risposta JSON ricevuta dal PROD
+ ///
+ public bool saveProdAnsw(SheetWorkList prodAnsw)
+ {
+ bool answ = false;
+ try
+ {
+ // definisco filtro
+ var filtBuilder = Builders.Filter;
+ // filtro vuoto x svuotare sempre
+ var filter = filtBuilder.Empty;
+ var collRawData = database.GetCollection("ProdArchive");
+ // elimino old (TUTTI!!!)
+ collRawData.DeleteMany(filter);
+ // aggiungo
+ collRawData.InsertOne(prodAnsw);
+ // fatto!
+ answ = true;
+ }
+ catch(Exception exc)
+ { }
+ return answ;
+ }
+
+ #endregion
+
+ ///
+ /// Wrapper traduzione termini
+ ///
+ ///
+ ///
+ public static string traduci(string lemma)
+ {
+ return user_std.UtSn.Traduci(lemma);
+ }
+ #region conf posizioni redis
+
+ public static string redOutPath = "NKC:SERV:BREQ";
+ public static string redMsgCount = "NKC:SERV:BREQ:MCount";
+ public static string redMsgList = "NKC:SERV:BREQ:MList";
+ public static string redMLCurrStack = "NKC:SERV:TAKT:CurrStack";
+
+ public static string redNestAnsw = "NKC:NEST:BANSW";
+
+ public static string redProdReq = "NKC:SERV:BUNKS";
+ public static string redProdAnsw = "NKC:PROD:BUNKS";
+
+
+
+ #endregion
+
+ #region definizione classi impiegate con PROD
+
+ public static string PositionStatusDescr(object value)
+ {
+ string answ = "";
+ try
+ {
+ BatchPosition pStatus = (BatchPosition)Enum.Parse(typeof(BatchPosition), value.ToString());
+ switch (pStatus)
+ {
+ case BatchPosition.NotStarted:
+ answ = traduci("NotStarted");
+ break;
+ case BatchPosition.StackStarted:
+ answ = traduci("Stacking");
+ break;
+ case BatchPosition.StackDone:
+ answ = traduci("StackDone");
+ break;
+ case BatchPosition.Current:
+ answ = traduci("StackCurrent");
+ break;
+ case BatchPosition.Completed:
+ answ = traduci("StackCompleted");
+ break;
+ default:
+ break;
+ }
+ }
+ catch
+ { }
+ return answ;
+ }
+ public static string BatchStatusDescr(object value)
+ {
+ string answ = "";
+ try
+ {
+ BatchStatus bStatus = (BatchStatus)Enum.Parse(typeof(BatchStatus), value.ToString());
+ switch (bStatus)
+ {
+ case BatchStatus.Imported:
+ answ = "Imported";
+ break;
+ case BatchStatus.EstimationRequested:
+ answ = "Estimation Requested";
+ break;
+ case BatchStatus.EstimationDone:
+ answ = "Estimation Completed";
+ break;
+ case BatchStatus.NestRequested:
+ answ = "Nesting Requested";
+ break;
+ case BatchStatus.NestDone:
+ answ = "Nesting Completed";
+ break;
+ case BatchStatus.Approved:
+ answ = "Nesting Approved";
+ break;
+ case BatchStatus.Discarded:
+ answ = "Nesting Discarded";
+ break;
+ case BatchStatus.Errors:
+ answ = "Nesting Impossibile (data errors)";
+ break;
+ case BatchStatus.PartEval:
+ answ = "Part/Item under evaluation";
+ break;
+ case BatchStatus.PartOk:
+ answ = "Part/Item Validated";
+ break;
+ case BatchStatus.PartKo:
+ answ = "Part/Item NOT Validated";
+ break;
+ default:
+ answ = $"Status unknown: {bStatus}";
+ break;
+ }
+ }
+ catch
+ { }
+ return answ;
+ }
+
+ ///
+ /// Oggetto globale TAKT
+ ///
+ public class Takt
+ {
+ ///
+ /// Codice univoco oggetto TAKT (data.num)
+ ///
+ public string TaktId { get; set; }
+ ///
+ /// Stato del TAKT
+ ///
+ public CStatus Status { get; set; }
+ ///
+ /// Elenco degli Stack da lavorare
+ ///
+ public List StackList { get; set; }
+ ///
+ /// Numero di Stack da lavorare
+ ///
+ public int NumStack
+ {
+ get
+ {
+ int answ = 0;
+ try
+ {
+ answ = StackList.Count;
+ }
+ catch
+ { }
+ return answ;
+ }
+ }
+ }
+
+ #endregion
+
+ #region definizione classi impiegate con NEST
+
+
+ public class Parte
+ {
+ public int PartId { get; set; }
+ public string DataMatrix { get; set; }
+ public string ExtCode { get; set; }
+ public string Description { get; set; }
+ public int MatId { get; set; }
+ public string PostProc { get; set; }
+ public string ProcessReq { get; set; }
+ public string CadFilePath { get; set; }
+ public int Qty { get; set; }
+ }
+
+ public class BatchData
+ {
+ ///
+ /// ID del batch in esecuzione
+ ///
+ public int BatchId { get; set; }
+ ///
+ /// tempo amssimo eprmesso x nesting (minuti)
+ ///
+ public int maxTime { get; set; }
+ ///
+ /// Tipo di processing richiesto
+ /// 1 = stima
+ /// 2 = nesting
+ ///
+ [JsonConverter(typeof(StringEnumConverter))]
+ public int procType { get; set; }
+ ///
+ /// Codice della amcchina x cui si effettua richeista
+ ///
+ [JsonConverter(typeof(StringEnumConverter))]
+ public mType machineType { get; set; }
+ ///
+ /// Tipo di ordine richeisto
+ ///
+ [JsonConverter(typeof(StringEnumConverter))]
+ public oType orderType { get; set; }
+ }
+ ///
+ /// Salva su redis l'oggetto dei materiali serializzato
+ ///
+ ///
+ public static bool sendMaterials()
+ {
+ bool answ = false;
+ // leggo tab MNATERIALS da DB
+ var table = DataLayer.man.taMat.GetData();
+ // serializzo
+ string redVal = JsonConvert.SerializeObject(table);
+ // salvo
+ string redKey = $"NKC:SERV:CONF:MATERIALS";
+ // scrivo per ora solo su REDIS
+ 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;
+ }
+ ///
+ /// Restituisce elenco KVP delle buste ancora "pending" (quando processate le elimina da elenco...)
+ ///
+ ///
+ public static KeyValuePair[] getEnvList()
+ {
+ KeyValuePair[] answ = memLayer.ML.redGetHash(redMsgList);
+ return answ;
+ }
+ ///
+ /// resetta la richeista corrente in modo che non ce ne siano altre in coda
+ ///
+ ///
+ public static bool resetBatchReq()
+ {
+ bool answ = false;
+ try
+ {
+ currBatchReq = "";
+ answ = true;
+ }
+ catch
+ { }
+ return answ;
+ }
+ public static string currBatchReqKey
+ {
+ get
+ {
+ return $"{redOutPath}:CURR";
+ }
+ }
+ ///
+ /// Valore della richiesta corrente di elaborazione batch
+ ///
+ public static string currBatchReq
+ {
+ get
+ {
+ return memLayer.ML.getRSV(currBatchReqKey);
+ }
+ set
+ {
+ // scrivo su REDIS
+ memLayer.ML.setRSV(currBatchReqKey, value);
+ }
+ }
+ ///
+ /// Manda il primo batch di VALIDAZIONE al NESTING...
+ ///
+ ///
+ public static bool sendFirstValidationBatch()
+ {
+ bool answ = false;
+ // verifico se NON CI SIANO GIA' validazioni in corso...
+ var tabBatchRunning = DataLayer.man.taBL.getByStatus(1, "", 0);
+ if (tabBatchRunning.Count == 0)
+ {
+ // ora verifico, se ci sono batch in stato 8 (da validare) --> metto in coda!
+ var tabBatch = DataLayer.man.taBL.getByStatus(8, "", 1);
+ bool hasValReq = tabBatch.Count > 0;
+ if (hasValReq)
+ {
+ // invia a redis una richiesta...
+ sendMaterials();
+ // recupero PRIMO batchID da validare
+ int nextBatchId = 0;
+ try
+ {
+ nextBatchId = tabBatch[0].BatchID;
+ }
+ catch
+ { }
+ if (nextBatchId > 0)
+ {
+ // richiedo!
+ sendBatchReq(nextBatchId, "Estimation", 1);
+ // registro su DB nesting iniziato... QUANDO MI RISPONDE dovrò verificare che era un batch x VALIDAZIONE
+ DataLayer.man.taBL.updateStatus(nextBatchId, (int)BatchStatus.EstimationRequested, "", 0);
+ answ = true;
+ }
+ }
+ }
+ // resituisco
+ return answ;
+ }
+ ///
+ /// Invia una richiesta di esecuzione di Nesting x un Batch
+ ///
+ /// Batch di cui si chiede processing
+ /// note opzionali
+ /// Tipo processo: 1 = stima, 2 = nesting
+ ///
+ public static bool sendBatchReq(int BatchID, string note, int pType)
+ {
+ bool answ = false;
+ // 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
+ {
+ // 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;
+ if (batch[0].STATUS < (int)BatchStatus.EstimationDone)
+ {
+ mTime = memLayer.ML.cdvi("estimMaxTime");
+ }
+ else
+ {
+ mTime = memLayer.ML.cdvi("nestMaxTime");
+ }
+
+ // init oggetti x fare cicli...
+ Order currOrder = null;
+ Kit currentKit = null;
+ Part currPart = null;
+ List listOrder = new List();
+ List listKit = new List();
+ List listPart = new List();
+
+ // leggo tab ORDINI da DB
+ var tblOrd = DataLayer.man.taOL.getByBatch(BatchID);
+ // leggo tab KIT da DB
+ var tblKit = DataLayer.man.taKL.getByBatch(BatchID);
+ // leggo tab ITEMS da DB
+ var tblItm = DataLayer.man.taIL.getByBatch(BatchID);
+
+ // ciclo per comporre oggetto con cicli annidiati ext --> int
+ foreach (var rigaOrd in tblOrd)
+ {
+ listKit = new List();
+ // compongo kit
+ var righeKit = (DS_App.KitListRow[])tblKit.Select($"OrdID = {rigaOrd.OrdID}");
+ foreach (var rigaKit in righeKit)
+ {
+ listPart = new List();
+ // elenco ITEMS
+ var righeItems = (DS_App.ItemListRow[])tblItm.Select($"KitID = {rigaKit.KitID}");
+ foreach (var rigaItem in righeItems)
+ {
+ currPart = new Part()
+ {
+ PartId = rigaItem.ItemID,
+ PartExtCode = rigaItem.ItemExtCode,
+ PartDtmx = rigaItem.ItemDtmx,
+ PartQty = rigaItem.ItemQty,
+ MatId = rigaItem.MatID,
+ CadFilePath = rigaItem.CadFilePath
+ };
+ listPart.Add(currPart);
+ }
+ // compongo KIT
+ currentKit = new Kit()
+ {
+ KitId = rigaKit.KitID,
+ KitExtCode = rigaKit.KitExtCode,
+ PartList = listPart
+ };
+ listKit.Add(currentKit);
+ }
+ // compongo ordine
+ currOrder = new Order()
+ {
+ OrderId = rigaOrd.OrdID,
+ OrderCod = rigaOrd.FamilyCode,
+ OrderExtCode = rigaOrd.OrderExtCode,
+ DestPlant = rigaOrd.DestPlant,
+ KitList = listKit
+ };
+ listOrder.Add(currOrder);
+ }
+ // oggetto complessivo
+ batchRequest newBatchreq = new batchRequest()
+ {
+ BatchId = BatchID,
+ EnvNum = nextEnv,
+ MaxTime = mTime,
+ ProcType = pType,
+ MachineType = mType.Multiax,
+ OrderType = oType.BatchRequest,
+ OrderList = listOrder
+ };
+
+ // serializzo
+ string redVal = JsonConvert.SerializeObject(newBatchreq);
+ // salvo
+ string redKey = $"{redOutPath}:{nextEnv}";
+ // scrivo su REDIS
+ memLayer.ML.setRSV(redKey, redVal);
+
+ // invio notifica che c'è una busta da processare
+ memLayer.ML.setRSV(currBatchReqKey, nextEnv);
+ answ = true;
+ }
+ catch (Exception exc)
+ { }
+ // restituisco ok
+ return answ;
+ }
+
+ ///
+ /// Verifica lo stato di una richiesta di esecuzione BATCH x stima/nesting
+ ///
+ /// OfflineOrder di cui si chiede processing
+ /// note opzionali
+ ///
+ public static bool checkBatchReq(int OffOrderID)
+ {
+ bool answ = false;
#if false
string typeSearch = "OffOrdCalculation";
string keyEnv = "";
@@ -623,1489 +650,1489 @@ namespace AppData
}
}
#endif
- // restituisco ok
- return answ;
- }
-
- ///
- /// Invia una richiesta di esecuzione di CAM x un ordine offline
- ///
- /// OfflineOrder di cui si chiede processing
- /// note opzionali
- ///
- public static bool sendOfflineOrderReq(int OffOrderID, string note)
- {
- bool answ = false;
- // per prima cosa mi serve una "nuova busta" per inviare i messaggi
- string nextEnv = getNextEnv(OffOrderID, note);
- // preparo il contenuto della busta ed invio i messaggi...
- try
- {
- int mTime = 5;
- int pType = 1;
- // serializzo ordini come ARRAY VUOTO
- string redVal = "[]";
- // salvo
- string redKey = $"{redOutPath}:{nextEnv}:ORDERS";
- // scrivo su REDIS
- memLayer.ML.setRSV(redKey, redVal);
- // ora ITEMS
- var tblItm = DataLayer.man.taIL.getByOfflineOrder(OffOrderID);
- // serializzo
- redVal = JsonConvert.SerializeObject(tblItm);
- // salvo
- redKey = $"{redOutPath}:{nextEnv}:ITEMS";
- // scrivo su REDIS
- memLayer.ML.setRSV(redKey, redVal);
- // ora versione gerarchica
- var currBatch = new BatchData()
- {
- BatchId = OffOrderID,
- maxTime = mTime,
- procType = pType,
- machineType = mType.Offline,
- orderType = oType.OfflineOrder
- };
- // 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
- memLayer.ML.setRSV(currBatchReqKey, nextEnv);
- answ = true;
- }
- catch (Exception exc)
- {
- logger.lg.scriviLog($"Eccezione in sendOfflineOrderReq:{Environment.NewLine}{exc}");
- }
- // restituisco ok
- return answ;
- }
-
- ///
- /// Verifica lo stato di una richiesta di esecuzione
- ///
- /// OfflineOrder di cui si chiede processing
- /// note opzionali
- ///
- public static bool checkOfflineOrderReq(int OffOrderID)
- {
- bool answ = false;
- string typeSearch = "OffOrdCalculation";
- string keyEnv = "";
- // recupero lista dei vari task APERTI...
- KeyValuePair[] comAperte = getEnvList();
- // processo x cercare ordine...
- foreach (var item in comAperte)
- {
- // cerco dove sia quello richiesto
- if (item.Value.Contains(typeSearch))
- {
- // controllo SE sia quello richiesto
- if (item.Value == $"{OffOrderID}|{typeSearch}")
- {
- keyEnv = item.Key;
- break;
- }
+ // restituisco ok
+ return answ;
}
- }
- // controllo e se c'è risposta --> update DB
- string redKey = $"{redNestAnsw}:FULL:{keyEnv}";
- string rawAnsw = memLayer.ML.getRSV(redKey);
- if (rawAnsw != "")
- {
- // cerco risposta come stack --> disegno...
- var offOrder = deserializeOfflineOrder(rawAnsw);
- // se ho in risposta 1+ sheets...
- if (offOrder.SheetList.Count > 0)
+
+ ///
+ /// Invia una richiesta di esecuzione di CAM x un ordine offline
+ ///
+ /// OfflineOrder di cui si chiede processing
+ /// note opzionali
+ ///
+ public static bool sendOfflineOrderReq(int OffOrderID, string note)
{
- // se ho 1 solo sheet
- var sheets = offOrder.SheetList;
- // controllo se ho CNC prog
- answ = sheets[0].MachiningProgram != "";
- if (answ)
- {
- // aggiorno su DB il disegno...
- string disegno = sheets[0].Drawing;
- DataLayer.man.taOffOL.updateDrawing(OffOrderID, disegno);
- }
- }
- }
- // restituisco ok
- return answ;
- }
- ///
- /// Resetto i dati PRIMA di salvare i nuovi dati dal nesting
- ///
- ///
- ///
- public static void resetPrevDataFromNesting(int BatchID)
- {
- //elimino dati child MA NON il batch...
- DataLayer.man.taBL.deleteTree(BatchID, 0);
- }
- ///
- /// Salvo dati Bunks/Sheets/Parts ricevuti da Nesting (COMPETATO)
- ///
- ///
- ///
- public static void updateBunksFromNesting(int BatchID, List BunkList)
- {
- // inizio a processare... bunks!
- if (BunkList != null)
- {
- foreach (var bunk in BunkList)
- {
- // creo il BUNK!
- var newBunk = DataLayer.man.taSTL.insertAndReturn(bunk.BunkIndex, BatchID);
- // se ho un bunk in risposta...
- if (newBunk.Count == 1)
- {
- var currBunk = newBunk[0];
- // processo sheets
- if (bunk.SheetList != null)
+ bool answ = false;
+ // per prima cosa mi serve una "nuova busta" per inviare i messaggi
+ string nextEnv = getNextEnv(OffOrderID, note);
+ // preparo il contenuto della busta ed invio i messaggi...
+ try
{
- foreach (var sheet in bunk.SheetList)
- {
- // creo lo sheet...
- var newSheet = DataLayer.man.taSHL.insertAndReturn(sheet.SheetIndex, sheet.MatId, (decimal)sheet.EstimatedWorktime, currBunk.StackID, sheet.PrintProgram, sheet.MachiningProgram, sheet.Drawing);
- // se ho 1 sheet in risposta
- if (newSheet.Count == 1)
+ int mTime = 5;
+ int pType = 1;
+ // serializzo ordini come ARRAY VUOTO
+ string redVal = "[]";
+ // salvo
+ string redKey = $"{redOutPath}:{nextEnv}:ORDERS";
+ // scrivo su REDIS
+ memLayer.ML.setRSV(redKey, redVal);
+ // ora ITEMS
+ var tblItm = DataLayer.man.taIL.getByOfflineOrder(OffOrderID);
+ // serializzo
+ redVal = JsonConvert.SerializeObject(tblItm);
+ // salvo
+ redKey = $"{redOutPath}:{nextEnv}:ITEMS";
+ // scrivo su REDIS
+ memLayer.ML.setRSV(redKey, redVal);
+ // ora versione gerarchica
+ var currBatch = new BatchData()
{
- var currSheet = newSheet[0];
- // processo items!
- if (sheet.PartList != null)
- {
- foreach (var part in sheet.PartList)
+ BatchId = OffOrderID,
+ maxTime = mTime,
+ procType = pType,
+ machineType = mType.Offline,
+ orderType = oType.OfflineOrder
+ };
+ // 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
+ memLayer.ML.setRSV(currBatchReqKey, nextEnv);
+ answ = true;
+ }
+ catch (Exception exc)
+ {
+ logger.lg.scriviLog($"Eccezione in sendOfflineOrderReq:{Environment.NewLine}{exc}");
+ }
+ // restituisco ok
+ return answ;
+ }
+
+ ///
+ /// Verifica lo stato di una richiesta di esecuzione
+ ///
+ /// OfflineOrder di cui si chiede processing
+ /// note opzionali
+ ///
+ public static bool checkOfflineOrderReq(int OffOrderID)
+ {
+ bool answ = false;
+ string typeSearch = "OffOrdCalculation";
+ string keyEnv = "";
+ // recupero lista dei vari task APERTI...
+ KeyValuePair[] comAperte = getEnvList();
+ // processo x cercare ordine...
+ foreach (var item in comAperte)
+ {
+ // cerco dove sia quello richiesto
+ if (item.Value.Contains(typeSearch))
+ {
+ // controllo SE sia quello richiesto
+ if (item.Value == $"{OffOrderID}|{typeSearch}")
{
- // aggiungo part a sheet (in tab nesting)
- DataLayer.man.taNest.insertAndReturn(currSheet.SheetID, part.PartId);
+ keyEnv = item.Key;
+ break;
}
- }
- // ora salvo ANCHE i remnants dello sheet... SE ci sono
- if (sheet.Remnant != null)
- {
- DataLayer.man.taRem.insertAndReturn(BatchID, sheet.MatId, currSheet.SheetID, sheet.Remnant.L_mm, sheet.Remnant.W_mm, false);
- }
}
- }
}
- }
- }
- }
- }
- ///
- /// Salvo dati su PartList ricevuti da Nesting (COMPETATO)
- ///
- ///
- ///
- public static void updateBinsFromNesting(int BatchID, List BinList)
- {
- // inizio a processare... bunks!
- if (BinList != null)
- {
- foreach (var item in BinList)
- {
- // creo il BIN!
- var newBin = DataLayer.man.taBN.insertAndReturn(item.BinIndex);
- // se ho un BIN in risposta...
- if (newBin.Count == 1)
- {
- var currBin = newBin[0];
- // processo sheets
- if (item.PartList != null)
+ // controllo e se c'è risposta --> update DB
+ string redKey = $"{redNestAnsw}:FULL:{keyEnv}";
+ string rawAnsw = memLayer.ML.getRSV(redKey);
+ if (rawAnsw != "")
{
- foreach (var part in item.PartList)
- {
- // creo lo sheet...
- var newB2I = DataLayer.man.taBNLS.insertAndReturn(currBin.BinID, part.PartId);
- }
+ // cerco risposta come stack --> disegno...
+ var offOrder = deserializeOfflineOrder(rawAnsw);
+ // se ho in risposta 1+ sheets...
+ if (offOrder.SheetList.Count > 0)
+ {
+ // se ho 1 solo sheet
+ var sheets = offOrder.SheetList;
+ // controllo se ho CNC prog
+ answ = sheets[0].MachiningProgram != "";
+ if (answ)
+ {
+ // aggiorno su DB il disegno...
+ string disegno = sheets[0].Drawing;
+ DataLayer.man.taOffOL.updateDrawing(OffOrderID, disegno);
+ }
+ }
}
- }
+ // restituisco ok
+ return answ;
}
- }
- }
- ///
- /// Salvo dati su PartList ricevuti da Nesting (COMPETATO)
- ///
- ///
- ///
- public static void updateCartsFromNesting(int BatchID, List CartList)
- {
- // inizio a processare... bunks!
- if (CartList != null)
- {
- foreach (var item in CartList)
+ ///
+ /// Resetto i dati PRIMA di salvare i nuovi dati dal nesting
+ ///
+ ///
+ ///
+ public static void resetPrevDataFromNesting(int BatchID)
{
- // creo il CART!
- var newCart = DataLayer.man.taCR.insertAndReturn(item.CartIndex);
- // se ho un CART in risposta...
- if (newCart.Count == 1)
- {
- var currCart = newCart[0];
- // processo sheets
- if (item.KitList != null)
+ //elimino dati child MA NON il batch...
+ DataLayer.man.taBL.deleteTree(BatchID, 0);
+ }
+ ///
+ /// Salvo dati Bunks/Sheets/Parts ricevuti da Nesting (COMPETATO)
+ ///
+ ///
+ ///
+ public static void updateBunksFromNesting(int BatchID, List BunkList)
+ {
+ // inizio a processare... bunks!
+ if (BunkList != null)
{
- foreach (var kit in item.KitList)
- {
- // creo lo sheet...
- var updKit = DataLayer.man.taKL.updateCart(kit.KitId, currCart.CartID);
- }
+ foreach (var bunk in BunkList)
+ {
+ // creo il BUNK!
+ var newBunk = DataLayer.man.taSTL.insertAndReturn(bunk.BunkIndex, BatchID);
+ // se ho un bunk in risposta...
+ if (newBunk.Count == 1)
+ {
+ var currBunk = newBunk[0];
+ // processo sheets
+ if (bunk.SheetList != null)
+ {
+ foreach (var sheet in bunk.SheetList)
+ {
+ // creo lo sheet...
+ var newSheet = DataLayer.man.taSHL.insertAndReturn(sheet.SheetIndex, sheet.MatId, (decimal)sheet.EstimatedWorktime, currBunk.StackID, sheet.PrintProgram, sheet.MachiningProgram, sheet.Drawing);
+ // se ho 1 sheet in risposta
+ if (newSheet.Count == 1)
+ {
+ var currSheet = newSheet[0];
+ // processo items!
+ if (sheet.PartList != null)
+ {
+ foreach (var part in sheet.PartList)
+ {
+ // aggiungo part a sheet (in tab nesting)
+ DataLayer.man.taNest.insertAndReturn(currSheet.SheetID, part.PartId);
+ }
+ }
+ // ora salvo ANCHE i remnants dello sheet... SE ci sono
+ if (sheet.Remnant != null)
+ {
+ DataLayer.man.taRem.insertAndReturn(BatchID, sheet.MatId, currSheet.SheetID, sheet.Remnant.L_mm, sheet.Remnant.W_mm, false);
+ }
+ }
+ }
+ }
+ }
+ }
}
- }
}
- }
- }
- ///
- /// Salvo dati su PartList ricevuti da Nesting (stima)
- ///
- ///
- public static void updatePartsFromNesting(List PartList)
- {
- string PostProcList = "";
- string ProcessesReq = "";
- string pdfFilePath = "";
- // salvo elenco materiali x ogni item...
- foreach (Part currItem in PartList)
- {
- // calcolo parametri...
- PostProcList = getPostProcList(currItem.OptParameters);
- ProcessesReq = getProcessesReq(currItem.OptParameters);
- pdfFilePath = getPdfFilePath(currItem.OptParameters);
- DataLayer.man.taIL.updateFromNesting(currItem.PartId, currItem.MatId, PostProcList, ProcessesReq, pdfFilePath);
- }
- }
-
- ///
- /// Recupera le operazioni di PostProcessing, esempio:
- /// - T-Nut
- /// - Round
- /// - Chop
- ///
- ///
- ///
- public static string getPostProcList(Dictionary optParameters)
- {
- string answ = "";
- foreach (var currOpt in optParameters)
- {
- switch (currOpt.Key)
+ ///
+ /// Salvo dati su PartList ricevuti da Nesting (COMPETATO)
+ ///
+ ///
+ ///
+ public static void updateBinsFromNesting(int BatchID, List BinList)
{
- case "ChopAtTab":
- case "RoundEdge":
- case "TNutFlag":
- // se contiene YES aggiungo...
- if (currOpt.Value.ToLower() == "yes")
+ // inizio a processare... bunks!
+ if (BinList != null)
{
- answ += $"{currOpt.Key}#";
+ foreach (var item in BinList)
+ {
+ // creo il BIN!
+ var newBin = DataLayer.man.taBN.insertAndReturn(item.BinIndex);
+ // se ho un BIN in risposta...
+ if (newBin.Count == 1)
+ {
+ var currBin = newBin[0];
+ // processo sheets
+ if (item.PartList != null)
+ {
+ foreach (var part in item.PartList)
+ {
+ // creo lo sheet...
+ var newB2I = DataLayer.man.taBNLS.insertAndReturn(currBin.BinID, part.PartId);
+ }
+ }
+ }
+ }
}
- break;
}
- }
- // se finisce per "#" trimmo...
- if (answ.EndsWith("#"))
- {
- answ = answ.Substring(0, answ.Length - 1);
- }
- return answ;
- }
- ///
- /// Recupera le operazioni RICHIESTE a valle
- /// - Paint
- /// - Assembly
- /// - SecOp
- ///
- ///
- ///
- public static string getProcessesReq(Dictionary optParameters)
- {
- string answ = "";
- foreach (var currOpt in optParameters)
- {
- switch (currOpt.Key)
+ ///
+ /// Salvo dati su PartList ricevuti da Nesting (COMPETATO)
+ ///
+ ///
+ ///
+ public static void updateCartsFromNesting(int BatchID, List CartList)
{
- case "AssemblyCell":
- case "PaintFlag":
- // se contiene YES aggiungo...
- if (currOpt.Value.ToLower() == "yes")
+ // inizio a processare... bunks!
+ if (CartList != null)
{
- answ += $"{currOpt.Key}#";
+ foreach (var item in CartList)
+ {
+ // creo il CART!
+ var newCart = DataLayer.man.taCR.insertAndReturn(item.CartIndex);
+ // se ho un CART in risposta...
+ if (newCart.Count == 1)
+ {
+ var currCart = newCart[0];
+ // processo sheets
+ if (item.KitList != null)
+ {
+ foreach (var kit in item.KitList)
+ {
+ // creo lo sheet...
+ var updKit = DataLayer.man.taKL.updateCart(kit.KitId, currCart.CartID);
+ }
+ }
+ }
+ }
}
- break;
}
- }
- // se finisce per "#" trimmo...
- if (answ.EndsWith("#"))
- {
- answ = answ.Substring(0, answ.Length - 1);
- }
- return answ;
- }
- ///
- /// Recupera file pdf
- ///
- ///
- ///
- public static string getPdfFilePath(Dictionary optParameters)
- {
- string answ = "";
- if (optParameters.ContainsKey("PdfLink"))
- {
- answ = optParameters["PdfLink"];
- }
- return answ;
- }
-
- #endregion
-
- #region metodi helper di conversione
-
- ///
- /// Helper x serializzare l'oggetto
- ///
- ///
- ///
- public static string serializeTakt(Takt currData)
- {
- string answ = JsonConvert.SerializeObject(currData);
- return answ;
- }
- ///
- /// Helper x deserializzare l'oggetto
- ///
- ///
- ///
- public static Takt deserializeTakt(string rawData)
- {
- Takt answ = JsonConvert.DeserializeObject(rawData);
- return answ;
- }
- ///
- /// Deserializza un ordine offline
- ///
- ///
- ///
- public static nestReplyOffOrd deserializeOfflineOrder(string rawData)
- {
- nestReplyOffOrd answ = null;
- try
- {
- answ = JsonConvert.DeserializeObject(rawData);
- }
- catch
- { }
- return answ;
- }
-
- #endregion
-
- #region metodi x data persistence
-
- ///
- /// Salvo il Takt inviato
- ///
- /// Origine del dato: SERV / PROD / NEST
- ///
- ///
- public static bool saveTakt(string origin, Takt currData)
- {
- bool answ = false;
- try
- {
- // calcolo valori redis
- string redKey = $"NKC:{origin.ToUpper()}:TAKT:{currData.TaktId}";
- string redVal = serializeTakt(currData);
- // scrivo per ora solo su REDIS
- memLayer.ML.setRSV(redKey, redVal);
- answ = true;
- }
- catch
- { }
- return answ;
- }
-
- ///
- /// Leggo il Takt inviato
- ///
- /// Origine del dato: SERV / PROD / NEST
- ///
- ///
- public static Takt readTakt(string origin, string TaktId)
- {
- Takt answ = null;
- try
- {
- string redKey = $"NKC:{origin.ToUpper()}:TAKT:{TaktId}";
- string redVal = memLayer.ML.getRSV(redKey);
- answ = deserializeTakt(redVal);
- }
- catch
- { }
- return answ;
- }
-
-
-
- #endregion
-
- #region metodi per PROD
-
- ///
- /// Esegue richieste lettura da PROD
- ///
- public static void procProdReadReq()
- {
- // !!!FIXME!!!
- }
- ///
- /// Esegue richieste scrittura da PROD
- ///
- public static void procProdWriteReq()
- {
- // !!!FIXME!!!
- }
-
- ///
- /// Fornisce il prossimo TAKT da elaborare oppure null se non ce ne fossero altri da elaborare per la data CORRENTE
- ///
- ///
- public Takt prodGetNextTakt()
- {
- return null;
- }
- ///
- /// Chiave primo bunk su redis
- ///
- protected static string redFirstBunkKey = $"{redProdReq}:FirstBunk";
- ///
- /// Chiave primo bunk su redis
- ///
- protected static string redAllNextBunkKey = $"{redProdReq}:NextBunk";
- ///
- /// TTL standard x dati da scambiare con PROD (30 gg)
- ///
- protected static int ttlProdData = 3600 * 24 * 30;
- ///
- /// Chiave primo bunk su redis
- ///
- protected static string redNextBunkKey(int BunkID)
- {
- return $"{redProdReq}:NextBunk:{BunkID}";
- }
- ///
- /// Resetto in REDIS i dati di bunk (corrente e successivi)
- ///
- public static void resetRedisBunkData()
- {
- redisFirstBunk = null;
- }
- ///
- /// Cache redis del PRIMO bunk da lavorare
- ///
- private static ProdBunk redisFirstBunk
- {
- get
- {
- ProdBunk answ = null;
- string rawData = memLayer.ML.getRSV(redFirstBunkKey);
- if (!string.IsNullOrEmpty(rawData))
+ ///
+ /// Salvo dati su PartList ricevuti da Nesting (stima)
+ ///
+ ///
+ public static void updatePartsFromNesting(List PartList)
{
- // provo a deserializzare
- try
- {
- answ = JsonConvert.DeserializeObject(rawData);
- }
- catch
- { }
- }
- return answ;
- }
- set
- {
- if (value != null)
- {
- string redVal = JsonConvert.SerializeObject(value);
- // default lascio x 5 minuti...
- memLayer.ML.setRSV(redFirstBunkKey, redVal, ttlProdData);
- }
- else
- // se null elimino da redis
- {
- memLayer.ML.setRSV(redFirstBunkKey, "");
- // elimino TUTTI i next...
- memLayer.ML.redFlushKey(redAllNextBunkKey);
- }
- }
- }
- ///
- /// Aggiorna la POSITION del BATCH a aprtire dallo stato DI TUTTI i bunk
- /// 0 = not started, 1 = STACKS started, 2 = STACKS done, 3 = Current, 4 = Completed
- ///
- ///
- ///
- public static void updateBatchPosition(int BatchID)
- {
- // chiamo stored x checkPosition
- DataLayer.man.taBL.checkPosition(BatchID);
- }
- ///
- /// Aggiorna la POSITION del BATCH a partire dallo stato dei bunk/stack selezionato
- /// 0 = not started, 1 = STACKS started, 2 = STACKS done, 3 = Current, 4 = Completed
- ///
- ///
- ///
- public static void updateBatchPositionByBunk(int BunkID)
- {
- // recupero il BatchID
- DS_App.StackListDataTable tabBunk = DataLayer.man.taSTL.getByKey(BunkID);
- if (tabBunk.Count > 0)
- {
- try
- {
- int BatchID = tabBunk[0].BatchID;
- // chiamo procedura di check sull'intero bunk
- updateBatchPosition(BatchID);
- }
- catch
- { }
- }
- }
- ///
- /// Recupero da Redis del SUCCESSIVO bunk da lavorare
- ///
- ///
- ///
- private static ProdBunk getRedisNextBunk(int currBunkId)
- {
- ProdBunk answ = null;
- string rawData = memLayer.ML.getRSV(redNextBunkKey(currBunkId));
- if (rawData != "")
- {
- // provo a deserializzare
- try
- {
- answ = JsonConvert.DeserializeObject(rawData);
- }
- catch
- { }
- }
- return answ;
- }
- ///
- /// Salvo in Redis il SUCCESSIVO bunk da lavorare
- ///
- ///
- ///
- private static void setRedisNextBunk(int currBunkId, ProdBunk value)
- {
- if (value != null)
- {
- string redVal = JsonConvert.SerializeObject(value);
- // default lascio x 5 minuti...
- memLayer.ML.setRSV(redNextBunkKey(currBunkId), redVal, ttlProdData);
- }
- else
- // se null elimino da redis
- {
- memLayer.ML.setRSV(redNextBunkKey(currBunkId), "");
- }
- }
- ///
- /// Elenco di sheet in lavorazione su una data macchina:
- /// - da macchina recupera il BATCH
- /// - dal batch prende i BUNK attivi sulla macchina (posizione 3)
- /// - filtra i fogli già lavorati
- ///
- ///
- ///
- public static SheetWorkList prodGetSheetWorkList(string codPost)
- {
- // init out
- SheetWorkList answ = null;
- // recupero batch corrente
- DS_App.BatchListDataTable currBatch = DataLayer.man.taBL.getCurrentByMachine(codPost);
- try
- {
- if (currBatch != null)
- {
- // come batch DOVREI averne solo 1 in corso...
- DS_App.BatchListRow batchRow = currBatch[0];
- // recupero i vari SHEETS del batch...
- DS_App.SheetListDataTable sheetTable = DataLayer.man.taSHL.getByBatch(batchRow.BatchID);
- List sheetList = new List();
- // controllo che SIA NULL la data di unload --> NON ancora scaricato
- foreach (var item in sheetTable)
- {
- // metto in elenco SOLO se NON nulla data fine unload
- if (item.IsUnlEndNull())
+ string PostProcList = "";
+ string ProcessesReq = "";
+ string pdfFilePath = "";
+ // salvo elenco materiali x ogni item...
+ foreach (Part currItem in PartList)
{
- sheetList.Add(item);
+ // calcolo parametri...
+ PostProcList = getPostProcList(currItem.OptParameters);
+ ProcessesReq = getProcessesReq(currItem.OptParameters);
+ pdfFilePath = getPdfFilePath(currItem.OptParameters);
+ DataLayer.man.taIL.updateFromNesting(currItem.PartId, currItem.MatId, PostProcList, ProcessesReq, pdfFilePath);
}
- }
- answ = convertSheetWorkList(sheetList);
}
- }
- catch (Exception exc)
- { }
- return answ;
- }
-
- ///
- /// Rranscodifica dati da format DB a formato PROD
- ///
- /// Elenco fogli da DB
- ///
- private static SheetWorkList convertSheetWorkList(List sheetList)
- {
- SheetWorkList answ;
- List elSheet = new List();
- string nestBasePath = memLayer.ML.CRS("nestBasePath").ToLower();
- string servBasePath = memLayer.ML.CRS("servBasePath").ToLower();
- string prodBasePath = memLayer.ML.CRS("prodBasePath").ToLower();
- DateTime dataStart = DateTime.Now;
- ProdSheetExt currPanel;
- // ciclo elenco fogli x escludere lavorati...
- foreach (var item in sheetList)
- {
- // converto i workData con check null sul campo data
- WorkData wdPrint = new WorkData()
+ ///
+ /// Recupera le operazioni di PostProcessing, esempio:
+ /// - T-Nut
+ /// - Round
+ /// - Chop
+ ///
+ ///
+ ///
+ public static string getPostProcList(Dictionary optParameters)
{
- DtStart = item.IsPrntStartNull() ? null : (DateTime?)item.PrntStart,
- DtEnd = item.IsPrntEndNull() ? null : (DateTime?)item.PrntEnd,
- ProgramPath = item.PrintFilePath.ToLower().Replace(nestBasePath, prodBasePath).Replace(servBasePath, prodBasePath)
- };
- WorkData wdMachining = new WorkData()
- {
- DtStart = item.IsWrkStartNull() ? null : (DateTime?)item.WrkStart,
- DtEnd = item.IsWrkEndNull() ? null : (DateTime?)item.WrkEnd,
- ProgramPath = item.CncFilePath.ToLower().Replace(nestBasePath, prodBasePath).Replace(servBasePath, prodBasePath)
- };
- WorkData wdUnload = new WorkData()
- {
- DtStart = item.IsUnlStartNull() ? null : (DateTime?)item.UnlStart,
- DtEnd = item.IsUnlEndNull() ? null : (DateTime?)item.UnlEnd
- };
- MaterialData material = new MaterialData()
- {
- MaterialId = item.MatID,
- MaterialDescription = item.MatDesc,
- MaterialPN = item.MatExtCode.ToString()
- };
- PStatus currPnlStatus = PStatus.Programmed;
- Enum.TryParse(item.ShStatus.ToString(), out currPnlStatus);
- currPanel = new ProdSheetExt()
- {
- BunkId = item.StackID,
- Printing = wdPrint,
- Machining = wdMachining,
- Material = material,
- SheetId = item.SheetID,
- SheetIndex = item.SheetIndex,
- Status = currPnlStatus,
- Unloading = wdUnload
- };
- elSheet.Add(currPanel);
- if (!item.IsPrntStartNull())
- {
- dataStart = item.PrntStart < dataStart ? item.PrntStart : dataStart;
- }
- }
- // compongo il bunk...
- answ = new SheetWorkList()
- {
- SheetList = elSheet
- };
- return answ;
- }
-
-
- ///
- /// Restituisce il BUNK che è il primo della lista:
- /// - 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()
- {
- // cerco prima su REDIS...
- ProdBunk answ = redisFirstBunk;
- if (answ == null)
- {
- // vado sul DB e leggo ...
- DS_App.StackListDataTable tabBunks = DataLayer.man.taSTL.getLoaded();
- // controllo di averne almeno 1...
- if (tabBunks.Count > 0)
- {
- DS_App.StackListRow currBunk = tabBunks[0];
- answ = getBunkFromDb(currBunk);
- // se ho qualcosa salvo su REDIS
- redisFirstBunk = answ;
- }
- }
- return answ;
- }
- ///
- /// BUNK corrente (x ora copia di first, poi sarà quello SELEZIONATO tra quelli SELEZIONABILI)
- ///
- ///
- public static DS_App.StackListRow getCurrBunk()
- {
- DS_App.StackListRow answ = null;
- var tabStl = DataLayer.man.taSTL.getLoaded();
- if (tabStl.Count > 0)
- {
- answ = tabStl[0];
- }
- return answ;
- }
- ///
- /// Recupera lo sheet corrente da un BUNK come quello in status 5...
- ///
- ///
- ///
- public static DS_App.SheetListRow getCurrSheet(int BatchID)
- {
- DS_App.SheetListRow answ = null;
- if (BatchID > 0)
- {
- // recupero sheet corrente da Bunk...
- DS_App.SheetListDataTable tabSheets = DataLayer.man.taSHL.getByMLStatus(BatchID, 5, 5);
- if (tabSheets.Count > 0)
- {
- answ = tabSheets[0];
- }
- }
- return answ;
- }
- ///
- /// Restituisce il PROSSIMO bunk 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)
- {
- ProdBunk answ = getRedisNextBunk(BunkID);
- if (answ == null)
- {
- // vado sul DB e leggo ...
- DS_App.StackListDataTable tabBunks = DataLayer.man.taSTL.getLoaded();
- // controllo di averne almeno 1...
- if (tabBunks.Count > 0)
- {
- DS_App.StackListRow currBunk = null;
- bool trovato = false;
- // ciclo
- foreach (var item in tabBunks)
- {
- if (trovato)
+ string answ = "";
+ foreach (var currOpt in optParameters)
{
- currBunk = item;
- break;
+ switch (currOpt.Key)
+ {
+ case "ChopAtTab":
+ case "RoundEdge":
+ case "TNutFlag":
+ // se contiene YES aggiungo...
+ if (currOpt.Value.ToLower() == "yes")
+ {
+ answ += $"{currOpt.Key}#";
+ }
+ break;
+ }
}
- // controllo se sia quello richiesto
- if (item.StackID == BunkID)
+ // se finisce per "#" trimmo...
+ if (answ.EndsWith("#"))
{
- trovato = true;
+ answ = answ.Substring(0, answ.Length - 1);
}
- }
- // se c'è un bunk trovato --> carico
- if (currBunk != null)
- {
- answ = getBunkFromDb(currBunk);
- // salvo su redis
- setRedisNextBunk(BunkID, answ);
- }
+ return answ;
}
- }
- return answ;
- }
- ///
- /// Recupera e transcodifica DA DB i dati di UN SINGOLO bunk
- ///
- ///
- ///
- private static ProdBunk getBunkFromDb(DS_App.StackListRow currBunk)
- {
- ProdBunk answ;
- // calcolo attributi oggetti
- CStatus currSt = CStatus.Programmed;
- if (currBunk.Position == 5)
- {
- currSt = CStatus.Running;
- }
- else
- {
- currSt = CStatus.Done;
- }
- List elSheet = new List();
- // recupero gli sheets di questo stack...
- DS_App.SheetListDataTable tabSheets = DataLayer.man.taSHL.getByStack(currBunk.StackID);
- DateTime dataStart = DateTime.Now;
- ProdSheet currPanel;
- string nestBasePath = memLayer.ML.CRS("nestBasePath").ToLower();
- string servBasePath = memLayer.ML.CRS("servBasePath").ToLower();
- string prodBasePath = memLayer.ML.CRS("prodBasePath").ToLower();
- foreach (var item in tabSheets)
- {
- // converto i workData con check null sul campo data
- WorkData wdPrint = new WorkData()
+ ///
+ /// Recupera le operazioni RICHIESTE a valle
+ /// - Paint
+ /// - Assembly
+ /// - SecOp
+ ///
+ ///
+ ///
+ public static string getProcessesReq(Dictionary optParameters)
{
- DtStart = item.IsPrntStartNull() ? null : (DateTime?)item.PrntStart,
- DtEnd = item.IsPrntEndNull() ? null : (DateTime?)item.PrntEnd,
- ProgramPath = item.PrintFilePath.ToLower().Replace(nestBasePath, prodBasePath).Replace(servBasePath, prodBasePath)
- };
- WorkData wdMachining = new WorkData()
- {
- DtStart = item.IsWrkStartNull() ? null : (DateTime?)item.WrkStart,
- DtEnd = item.IsWrkEndNull() ? null : (DateTime?)item.WrkEnd,
- ProgramPath = item.CncFilePath.ToLower().Replace(nestBasePath, prodBasePath).Replace(servBasePath, prodBasePath)
- };
- WorkData wdUnload = new WorkData()
- {
- DtStart = item.IsUnlStartNull() ? null : (DateTime?)item.UnlStart,
- DtEnd = item.IsUnlEndNull() ? null : (DateTime?)item.UnlEnd
- };
- MaterialData material = new MaterialData()
- {
- MaterialId = item.MatID,
- MaterialDescription = item.MatDesc,
- MaterialPN = item.MatExtCode.ToString()
- };
- PStatus currPnlStatus = PStatus.Programmed;
- Enum.TryParse(item.ShStatus.ToString(), out currPnlStatus);
- currPanel = new ProdSheet()
- {
- Printing = wdPrint,
- Machining = wdMachining,
- Unloading = wdUnload,
- Material = material,
- SheetId = item.SheetID,
- Status = currPnlStatus
- };
- elSheet.Add(currPanel);
- if (!item.IsPrntStartNull())
- {
- dataStart = item.PrntStart < dataStart ? item.PrntStart : dataStart;
- }
- }
- // compongo il bunk...
- answ = new ProdBunk()
- {
- BunkId = currBunk.StackID,
- Status = currSt,
- DataMatrix = currBunk.StackDtmx,
- SheetList = elSheet,
- DtStart = dataStart
- };
- return answ;
- }
- ///
- /// Recupera e transcodifica DA DB i dati di UN SINGOLO bunk
- ///
- ///
- ///
- public static ProdBunk prodGetBunk(int StackID)
- {
- ProdBunk answ = null;
- List elSheet = new List();
- var tabBunks = DataLayer.man.taSTL.getByKey(StackID);
- if (tabBunks.Count == 1)
- {
- DS_App.StackListRow currBunk = tabBunks[0];
- // calcolo attributi oggetti
- CStatus currSt = CStatus.Programmed;
- if (currBunk.Position == 5)
- {
- currSt = CStatus.Running;
- }
- else
- {
- currSt = CStatus.Done;
- }
- // recupero gli sheets di questo stack...
- DS_App.SheetListDataTable tabSheets = DataLayer.man.taSHL.getByStack(StackID);
- DateTime dataStart = DateTime.Now;
- ProdSheet currPanel;
- string nestBasePath = memLayer.ML.CRS("nestBasePath").ToLower();
- string servBasePath = memLayer.ML.CRS("servBasePath").ToLower();
- string prodBasePath = memLayer.ML.CRS("prodBasePath").ToLower();
- foreach (var item in tabSheets)
- {
- // converto i workData
- WorkData wdPrint = new WorkData()
- {
- DtStart = item.IsPrntStartNull() ? null : (DateTime?)item.PrntStart,
- DtEnd = item.IsPrntEndNull() ? null : (DateTime?)item.PrntEnd,
- ProgramPath = item.PrintFilePath.ToLower().Replace(nestBasePath, prodBasePath).Replace(servBasePath, prodBasePath)
- };
- WorkData wdMachining = new WorkData()
- {
- DtStart = item.IsWrkStartNull() ? null : (DateTime?)item.WrkStart,
- DtEnd = item.IsWrkEndNull() ? null : (DateTime?)item.WrkEnd,
- ProgramPath = item.CncFilePath.ToLower().Replace(nestBasePath, prodBasePath).Replace(servBasePath, prodBasePath)
- };
- WorkData wdUnload = new WorkData()
- {
- DtStart = item.IsUnlStartNull() ? null : (DateTime?)item.UnlStart,
- DtEnd = item.IsUnlEndNull() ? null : (DateTime?)item.UnlEnd
- };
- MaterialData material = new MaterialData()
- {
- MaterialId = item.MatID,
- MaterialDescription = item.MatDesc,
- MaterialPN = item.MatExtCode.ToString()
- };
- PStatus currPnlStatus = PStatus.Programmed;
- Enum.TryParse(item.ShStatus.ToString(), out currPnlStatus);
- currPanel = new ProdSheet()
- {
- Printing = wdPrint,
- Machining = wdMachining,
- Unloading = wdUnload,
- Material = material,
- SheetId = item.StackID,
- Status = currPnlStatus
- };
- elSheet.Add(currPanel);
- if (!item.IsPrntStartNull())
- {
- dataStart = item.PrntStart < dataStart ? item.PrntStart : dataStart;
- }
- }
- // compongo il bunk...
- answ = new ProdBunk()
- {
- BunkId = currBunk.StackID,
- Status = currSt,
- DataMatrix = currBunk.StackDtmx,
- SheetList = elSheet,
- DtStart = dataStart
- };
- }
- return answ;
- }
- ///
- /// Valore dello Stack correntemente in processing per ML (MachineLoad)
- ///
- public static string taktMLCurrStack
- {
- get
- {
- return memLayer.ML.getRSV(redMLCurrStack);
- }
- set
- {
- memLayer.ML.setRSV(redMLCurrStack, value);
- }
- }
-
- #endregion
-
- #region metodi x UNLOAD
-
- ///
- /// Calcola area REDIS per FOGLIO in fase di scarico
- ///
- ///
- ///
- public static string machineUnloadArea(int SheetID)
- {
- // se 0 --> tutto l'albero, sennò solo area corrente...
- string answ = "";
- if (SheetID > 0)
- {
- answ = memLayer.ML.redHash($"MachineUnload:{SheetID}");
- }
- else
- {
- answ = memLayer.ML.redHash($"MachineUnload");
- }
- return answ;
- }
- ///
- /// Calcola area REDIS per BUNK in fase di scarico
- ///
- ///
- ///
- public static string machineUnloadBunkArea(int BunkID)
- {
- // se 0 --> tutto l'albero, sennò solo area corrente...
- string answ = "";
- if (BunkID > 0)
- {
- answ = memLayer.ML.redHash($"MachineUnload:Bunk:{BunkID}");
- }
- else
- {
- answ = memLayer.ML.redHash($"MachineUnload:Bunk");
- }
- return answ;
- }
-
-
- ///
- /// Recupera da REDIS info indice revisione x BUNK (cambio foglio)
- ///
- ///
- ///
- public static int getSheetRevByBunk(int BunkID)
- {
- int answ = 0;
- if (BunkID > 0)
- {
- // recupero da REDIS!
- string redKeyExp = memLayer.ML.redHash($"DataExp");
- string redKeyRev = $"{ComLib.machineUnloadBunkArea(BunkID)}:Rev";
- // controllo expiry globale... se manca SVUOTO area
- string rawData = memLayer.ML.getRSV(redKeyExp);
- if (string.IsNullOrEmpty(rawData))
- {
- // svuoto e scrivo...
- memLayer.ML.redFlushKey(memLayer.ML.redHash($"MachineUnload"));
- memLayer.ML.redFlushKey(memLayer.ML.redHash($"TabSheets"));
- memLayer.ML.setRSV(redKeyExp, $"Reload Data {DateTime.Now}", 3600);
- }
- answ = memLayer.ML.getRCnt(redKeyRev);
- }
- return answ;
- }
-
-
- ///
- /// Aggiorna revisione indice sheet x BUNK (cambio foglio)
- ///
- ///
- ///
- public static long advaceSheetRevByBunk(int BunkID)
- {
- long answ = 0;
- if (BunkID > 0)
- {
- // recupero da REDIS!
- string redKeyExp = memLayer.ML.redHash($"DataExp");
- string redKeyRev = $"{ComLib.machineUnloadBunkArea(BunkID)}:Rev";
- // incremento...
- answ = memLayer.ML.setRCntI(redKeyRev);
- // se > 999 --> resetto
- if (answ > 999)
- {
- memLayer.ML.resetRCnt(redKeyRev);
- }
- }
- return answ;
- }
-
-
- ///
- /// Svuota elenco pezzi nella postazione di unload
- ///
- ///
- ///
- public bool resetSheetUnload(int SheetID = 0)
- {
- bool answ = false;
- try
- {
- memLayer.ML.redFlushKey(machineUnloadArea(SheetID));
- answ = true;
- }
- catch
- { }
- return answ;
- }
- ///
- ///
- ///
- ///
- ///
- public static string getCurrentCss(int sheetID)
- {
- // area REDIS!
- string redKeyBase = $"{machineUnloadArea(sheetID)}";
- // TTL standard
- int dataCacheTTL = memLayer.ML.cdvi("cssCacheTTL");
- dataCacheTTL = dataCacheTTL <= 0 ? 60 : dataCacheTTL;
- // files
- string filename = HttpContext.Current.Server.MapPath("~/Content/SheetColor.css");
- string answ = File.ReadAllText(filename);
- // solo se sheet > 0...
- if (sheetID > 0)
- {
- // elenco items da foglio!!!
- var tabItems = DataLayer.man.taIL.getBySheet(sheetID);
- List itemsAll = new List();
- List itemsDepo = new List();
- List itemsCart = new List();
- List itemsBin = new List();
- List itemsSecOp = new List();
-
- //se ho items...
- if (tabItems.Count > 0)
- {
- // ciclo!
- foreach (var item in tabItems)
- {
- // aggiungoncomunque a lista generale...
- itemsAll.Add(item.ItemDtmx);
- // controllo SE sia stato depositato... check status 3/4
- if (item.StatusID == 3 || item.StatusID == 4)
+ string answ = "";
+ foreach (var currOpt in optParameters)
{
- itemsDepo.Add(item.ItemDtmx);
+ switch (currOpt.Key)
+ {
+ case "AssemblyCell":
+ case "PaintFlag":
+ // se contiene YES aggiungo...
+ if (currOpt.Value.ToLower() == "yes")
+ {
+ answ += $"{currOpt.Key}#";
+ }
+ break;
+ }
}
- else if (item.ProcessesReq.Contains("PaintFlag"))
+ // se finisce per "#" trimmo...
+ if (answ.EndsWith("#"))
{
- itemsBin.Add(item.ItemDtmx);
+ answ = answ.Substring(0, answ.Length - 1);
+ }
+ return answ;
+ }
+ ///
+ /// Recupera file pdf
+ ///
+ ///
+ ///
+ public static string getPdfFilePath(Dictionary optParameters)
+ {
+ string answ = "";
+ if (optParameters.ContainsKey("PdfLink"))
+ {
+ answ = optParameters["PdfLink"];
+ }
+ return answ;
+ }
+
+ #endregion
+
+ #region metodi helper di conversione
+
+ ///
+ /// Helper x serializzare l'oggetto
+ ///
+ ///
+ ///
+ public static string serializeTakt(Takt currData)
+ {
+ string answ = JsonConvert.SerializeObject(currData);
+ return answ;
+ }
+ ///
+ /// Helper x deserializzare l'oggetto
+ ///
+ ///
+ ///
+ public static Takt deserializeTakt(string rawData)
+ {
+ Takt answ = JsonConvert.DeserializeObject(rawData);
+ return answ;
+ }
+ ///
+ /// Deserializza un ordine offline
+ ///
+ ///
+ ///
+ public static nestReplyOffOrd deserializeOfflineOrder(string rawData)
+ {
+ nestReplyOffOrd answ = null;
+ try
+ {
+ answ = JsonConvert.DeserializeObject(rawData);
+ }
+ catch
+ { }
+ return answ;
+ }
+
+ #endregion
+
+ #region metodi x data persistence
+
+ ///
+ /// Salvo il Takt inviato
+ ///
+ /// Origine del dato: SERV / PROD / NEST
+ ///
+ ///
+ public static bool saveTakt(string origin, Takt currData)
+ {
+ bool answ = false;
+ try
+ {
+ // calcolo valori redis
+ string redKey = $"NKC:{origin.ToUpper()}:TAKT:{currData.TaktId}";
+ string redVal = serializeTakt(currData);
+ // scrivo per ora solo su REDIS
+ memLayer.ML.setRSV(redKey, redVal);
+ answ = true;
+ }
+ catch
+ { }
+ return answ;
+ }
+
+ ///
+ /// Leggo il Takt inviato
+ ///
+ /// Origine del dato: SERV / PROD / NEST
+ ///
+ ///
+ public static Takt readTakt(string origin, string TaktId)
+ {
+ Takt answ = null;
+ try
+ {
+ string redKey = $"NKC:{origin.ToUpper()}:TAKT:{TaktId}";
+ string redVal = memLayer.ML.getRSV(redKey);
+ answ = deserializeTakt(redVal);
+ }
+ catch
+ { }
+ return answ;
+ }
+
+
+
+ #endregion
+
+ #region metodi per PROD
+
+ ///
+ /// Esegue richieste lettura da PROD
+ ///
+ public static void procProdReadReq()
+ {
+ // !!!FIXME!!!
+ }
+ ///
+ /// Esegue richieste scrittura da PROD
+ ///
+ public static void procProdWriteReq()
+ {
+ // !!!FIXME!!!
+ }
+
+ ///
+ /// Fornisce il prossimo TAKT da elaborare oppure null se non ce ne fossero altri da elaborare per la data CORRENTE
+ ///
+ ///
+ public Takt prodGetNextTakt()
+ {
+ return null;
+ }
+ ///
+ /// Chiave primo bunk su redis
+ ///
+ protected static string redFirstBunkKey = $"{redProdReq}:FirstBunk";
+ ///
+ /// Chiave primo bunk su redis
+ ///
+ protected static string redAllNextBunkKey = $"{redProdReq}:NextBunk";
+ ///
+ /// TTL standard x dati da scambiare con PROD (30 gg)
+ ///
+ protected static int ttlProdData = 3600 * 24 * 30;
+ ///
+ /// Chiave primo bunk su redis
+ ///
+ protected static string redNextBunkKey(int BunkID)
+ {
+ return $"{redProdReq}:NextBunk:{BunkID}";
+ }
+ ///
+ /// Resetto in REDIS i dati di bunk (corrente e successivi)
+ ///
+ public static void resetRedisBunkData()
+ {
+ redisFirstBunk = null;
+ }
+ ///
+ /// Cache redis del PRIMO bunk da lavorare
+ ///
+ private static ProdBunk redisFirstBunk
+ {
+ get
+ {
+ ProdBunk answ = null;
+ string rawData = memLayer.ML.getRSV(redFirstBunkKey);
+ if (!string.IsNullOrEmpty(rawData))
+ {
+ // provo a deserializzare
+ try
+ {
+ answ = JsonConvert.DeserializeObject(rawData);
+ }
+ catch
+ { }
+ }
+ return answ;
+ }
+ set
+ {
+ if (value != null)
+ {
+ string redVal = JsonConvert.SerializeObject(value);
+ // default lascio x 5 minuti...
+ memLayer.ML.setRSV(redFirstBunkKey, redVal, ttlProdData);
+ }
+ else
+ // se null elimino da redis
+ {
+ memLayer.ML.setRSV(redFirstBunkKey, "");
+ // elimino TUTTI i next...
+ memLayer.ML.redFlushKey(redAllNextBunkKey);
+ }
+ }
+ }
+ ///
+ /// Aggiorna la POSITION del BATCH a aprtire dallo stato DI TUTTI i bunk
+ /// 0 = not started, 1 = STACKS started, 2 = STACKS done, 3 = Current, 4 = Completed
+ ///
+ ///
+ ///
+ public static void updateBatchPosition(int BatchID)
+ {
+ // chiamo stored x checkPosition
+ DataLayer.man.taBL.checkPosition(BatchID);
+ }
+ ///
+ /// Aggiorna la POSITION del BATCH a partire dallo stato dei bunk/stack selezionato
+ /// 0 = not started, 1 = STACKS started, 2 = STACKS done, 3 = Current, 4 = Completed
+ ///
+ ///
+ ///
+ public static void updateBatchPositionByBunk(int BunkID)
+ {
+ // recupero il BatchID
+ DS_App.StackListDataTable tabBunk = DataLayer.man.taSTL.getByKey(BunkID);
+ if (tabBunk.Count > 0)
+ {
+ try
+ {
+ int BatchID = tabBunk[0].BatchID;
+ // chiamo procedura di check sull'intero bunk
+ updateBatchPosition(BatchID);
+ }
+ catch
+ { }
+ }
+ }
+ ///
+ /// Recupero da Redis del SUCCESSIVO bunk da lavorare
+ ///
+ ///
+ ///
+ private static ProdBunk getRedisNextBunk(int currBunkId)
+ {
+ ProdBunk answ = null;
+ string rawData = memLayer.ML.getRSV(redNextBunkKey(currBunkId));
+ if (rawData != "")
+ {
+ // provo a deserializzare
+ try
+ {
+ answ = JsonConvert.DeserializeObject(rawData);
+ }
+ catch
+ { }
+ }
+ return answ;
+ }
+ ///
+ /// Salvo in Redis il SUCCESSIVO bunk da lavorare
+ ///
+ ///
+ ///
+ private static void setRedisNextBunk(int currBunkId, ProdBunk value)
+ {
+ if (value != null)
+ {
+ string redVal = JsonConvert.SerializeObject(value);
+ // default lascio x 5 minuti...
+ memLayer.ML.setRSV(redNextBunkKey(currBunkId), redVal, ttlProdData);
+ }
+ else
+ // se null elimino da redis
+ {
+ memLayer.ML.setRSV(redNextBunkKey(currBunkId), "");
+ }
+ }
+ ///
+ /// Elenco di sheet in lavorazione su una data macchina:
+ /// - da macchina recupera il BATCH
+ /// - dal batch prende i BUNK attivi sulla macchina (posizione 3)
+ /// - filtra i fogli già lavorati
+ ///
+ ///
+ ///
+ public static SheetWorkList prodGetSheetWorkList(string codPost)
+ {
+ // init out
+ SheetWorkList answ = null;
+ // recupero batch corrente
+ DS_App.BatchListDataTable currBatch = DataLayer.man.taBL.getCurrentByMachine(codPost);
+ try
+ {
+ if (currBatch != null)
+ {
+ // come batch DOVREI averne solo 1 in corso...
+ DS_App.BatchListRow batchRow = currBatch[0];
+ // recupero i vari SHEETS del batch...
+ DS_App.SheetListDataTable sheetTable = DataLayer.man.taSHL.getByBatch(batchRow.BatchID);
+ List sheetList = new List();
+ // controllo che SIA NULL la data di unload --> NON ancora scaricato
+ foreach (var item in sheetTable)
+ {
+ // metto in elenco SOLO se NON nulla data fine unload
+ if (item.IsUnlEndNull())
+ {
+ sheetList.Add(item);
+ }
+ }
+ answ = convertSheetWorkList(sheetList);
+ }
+ }
+ catch (Exception exc)
+ { }
+ return answ;
+ }
+
+
+ ///
+ /// Rranscodifica dati da format DB a formato PROD
+ ///
+ /// Elenco fogli da DB
+ ///
+ private static SheetWorkList convertSheetWorkList(List sheetList)
+ {
+ SheetWorkList answ;
+ List elSheet = new List();
+ string nestBasePath = memLayer.ML.CRS("nestBasePath").ToLower();
+ string servBasePath = memLayer.ML.CRS("servBasePath").ToLower();
+ string prodBasePath = memLayer.ML.CRS("prodBasePath").ToLower();
+ DateTime dataStart = DateTime.Now;
+ ProdSheetExt currPanel;
+ // ciclo elenco fogli x escludere lavorati...
+ foreach (var item in sheetList)
+ {
+ // converto i workData con check null sul campo data
+ WorkData wdPrint = new WorkData()
+ {
+ DtStart = item.IsPrntStartNull() ? null : (DateTime?)item.PrntStart,
+ DtEnd = item.IsPrntEndNull() ? null : (DateTime?)item.PrntEnd,
+ ProgramPath = item.PrintFilePath.ToLower().Replace(nestBasePath, prodBasePath).Replace(servBasePath, prodBasePath)
+ };
+ WorkData wdMachining = new WorkData()
+ {
+ DtStart = item.IsWrkStartNull() ? null : (DateTime?)item.WrkStart,
+ DtEnd = item.IsWrkEndNull() ? null : (DateTime?)item.WrkEnd,
+ ProgramPath = item.CncFilePath.ToLower().Replace(nestBasePath, prodBasePath).Replace(servBasePath, prodBasePath)
+ };
+ WorkData wdUnload = new WorkData()
+ {
+ DtStart = item.IsUnlStartNull() ? null : (DateTime?)item.UnlStart,
+ DtEnd = item.IsUnlEndNull() ? null : (DateTime?)item.UnlEnd
+ };
+ MaterialData material = new MaterialData()
+ {
+ MaterialId = item.MatID,
+ MaterialDescription = item.MatDesc,
+ MaterialPN = item.MatExtCode.ToString()
+ };
+ PStatus currPnlStatus = PStatus.Programmed;
+ Enum.TryParse(item.ShStatus.ToString(), out currPnlStatus);
+ currPanel = new ProdSheetExt()
+ {
+ BunkId = item.StackID,
+ Printing = wdPrint,
+ Machining = wdMachining,
+ Material = material,
+ SheetId = item.SheetID,
+ SheetIndex = item.SheetIndex,
+ Status = currPnlStatus,
+ Unloading = wdUnload
+ };
+ elSheet.Add(currPanel);
+ if (!item.IsPrntStartNull())
+ {
+ dataStart = item.PrntStart < dataStart ? item.PrntStart : dataStart;
+ }
+ }
+ // compongo il bunk...
+ answ = new SheetWorkList()
+ {
+ SheetList = elSheet
+ };
+ return answ;
+ }
+
+
+ ///
+ /// Restituisce il BUNK che è il primo della lista:
+ /// - 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()
+ {
+ // cerco prima su REDIS...
+ ProdBunk answ = redisFirstBunk;
+ if (answ == null)
+ {
+ // vado sul DB e leggo ...
+ DS_App.StackListDataTable tabBunks = DataLayer.man.taSTL.getLoaded();
+ // controllo di averne almeno 1...
+ if (tabBunks.Count > 0)
+ {
+ DS_App.StackListRow currBunk = tabBunks[0];
+ answ = getBunkFromDb(currBunk);
+ // se ho qualcosa salvo su REDIS
+ redisFirstBunk = answ;
+ }
+ }
+ return answ;
+ }
+ ///
+ /// BUNK corrente (x ora copia di first, poi sarà quello SELEZIONATO tra quelli SELEZIONABILI)
+ ///
+ ///
+ public static DS_App.StackListRow getCurrBunk()
+ {
+ DS_App.StackListRow answ = null;
+ var tabStl = DataLayer.man.taSTL.getLoaded();
+ if (tabStl.Count > 0)
+ {
+ answ = tabStl[0];
+ }
+ return answ;
+ }
+ ///
+ /// Recupera lo sheet corrente da un BUNK come quello in status 5...
+ ///
+ ///
+ ///
+ public static DS_App.SheetListRow getCurrSheet(int BatchID)
+ {
+ DS_App.SheetListRow answ = null;
+ if (BatchID > 0)
+ {
+ // recupero sheet corrente da Bunk...
+ DS_App.SheetListDataTable tabSheets = DataLayer.man.taSHL.getByMLStatus(BatchID, 5, 5);
+ if (tabSheets.Count > 0)
+ {
+ answ = tabSheets[0];
+ }
+ }
+ return answ;
+ }
+ ///
+ /// Restituisce il PROSSIMO bunk 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)
+ {
+ ProdBunk answ = getRedisNextBunk(BunkID);
+ if (answ == null)
+ {
+ // vado sul DB e leggo ...
+ DS_App.StackListDataTable tabBunks = DataLayer.man.taSTL.getLoaded();
+ // controllo di averne almeno 1...
+ if (tabBunks.Count > 0)
+ {
+ DS_App.StackListRow currBunk = null;
+ bool trovato = false;
+ // ciclo
+ foreach (var item in tabBunks)
+ {
+ if (trovato)
+ {
+ currBunk = item;
+ break;
+ }
+ // controllo se sia quello richiesto
+ if (item.StackID == BunkID)
+ {
+ trovato = true;
+ }
+ }
+ // se c'è un bunk trovato --> carico
+ if (currBunk != null)
+ {
+ answ = getBunkFromDb(currBunk);
+ // salvo su redis
+ setRedisNextBunk(BunkID, answ);
+ }
+ }
+ }
+ return answ;
+ }
+ ///
+ /// Recupera e transcodifica DA DB i dati di UN SINGOLO bunk
+ ///
+ ///
+ ///
+ private static ProdBunk getBunkFromDb(DS_App.StackListRow currBunk)
+ {
+ ProdBunk answ;
+ // calcolo attributi oggetti
+ CStatus currSt = CStatus.Programmed;
+ if (currBunk.Position == 5)
+ {
+ currSt = CStatus.Running;
}
else
{
- itemsCart.Add(item.ItemDtmx);
+ currSt = CStatus.Done;
}
- // controllo ANCHE postprocessing
- if (item.PostProcList != "")
+ List elSheet = new List();
+ // recupero gli sheets di questo stack...
+ DS_App.SheetListDataTable tabSheets = DataLayer.man.taSHL.getByStack(currBunk.StackID);
+ DateTime dataStart = DateTime.Now;
+ ProdSheet currPanel;
+ string nestBasePath = memLayer.ML.CRS("nestBasePath").ToLower();
+ string servBasePath = memLayer.ML.CRS("servBasePath").ToLower();
+ string prodBasePath = memLayer.ML.CRS("prodBasePath").ToLower();
+ foreach (var item in tabSheets)
{
- itemsSecOp.Add(item.ItemDtmx);
+ // converto i workData con check null sul campo data
+ WorkData wdPrint = new WorkData()
+ {
+ DtStart = item.IsPrntStartNull() ? null : (DateTime?)item.PrntStart,
+ DtEnd = item.IsPrntEndNull() ? null : (DateTime?)item.PrntEnd,
+ ProgramPath = item.PrintFilePath.ToLower().Replace(nestBasePath, prodBasePath).Replace(servBasePath, prodBasePath)
+ };
+ WorkData wdMachining = new WorkData()
+ {
+ DtStart = item.IsWrkStartNull() ? null : (DateTime?)item.WrkStart,
+ DtEnd = item.IsWrkEndNull() ? null : (DateTime?)item.WrkEnd,
+ ProgramPath = item.CncFilePath.ToLower().Replace(nestBasePath, prodBasePath).Replace(servBasePath, prodBasePath)
+ };
+ WorkData wdUnload = new WorkData()
+ {
+ DtStart = item.IsUnlStartNull() ? null : (DateTime?)item.UnlStart,
+ DtEnd = item.IsUnlEndNull() ? null : (DateTime?)item.UnlEnd
+ };
+ MaterialData material = new MaterialData()
+ {
+ MaterialId = item.MatID,
+ MaterialDescription = item.MatDesc,
+ MaterialPN = item.MatExtCode.ToString()
+ };
+ PStatus currPnlStatus = PStatus.Programmed;
+ Enum.TryParse(item.ShStatus.ToString(), out currPnlStatus);
+ currPanel = new ProdSheet()
+ {
+ Printing = wdPrint,
+ Machining = wdMachining,
+ Unloading = wdUnload,
+ Material = material,
+ SheetId = item.SheetID,
+ Status = currPnlStatus
+ };
+ elSheet.Add(currPanel);
+ if (!item.IsPrntStartNull())
+ {
+ dataStart = item.PrntStart < dataStart ? item.PrntStart : dataStart;
+ }
}
- }
+ // compongo il bunk...
+ answ = new ProdBunk()
+ {
+ BunkId = currBunk.StackID,
+ Status = currSt,
+ DataMatrix = currBunk.StackDtmx,
+ SheetList = elSheet,
+ DtStart = dataStart
+ };
+ return answ;
}
-
-
- // FIX BIN
- answ = updateCssByItemList(answ, redKeyBase, "ItemsBin", itemsBin, dataCacheTTL);
-
- // FIX CART
- answ = updateCssByItemList(answ, redKeyBase, "ItemsCart", itemsCart, dataCacheTTL);
-
- // FIX Scaricati
- answ = updateCssByItemList(answ, redKeyBase, "ItemsDepo", itemsDepo, dataCacheTTL);
-
- // FIX SEC-OP
- answ = updateCssByItemList(answ, redKeyBase, "ItemsSecOp", itemsSecOp, dataCacheTTL);
-
- // FIXED SEL da array oggetti selezionati...
- answ = updateCssByPickedItems(answ, redKeyBase, "ItemsSel", dataCacheTTL);
-
-
- // INFINE serializzo e salvo tutti gli items trovati...
- string serVal = JsonConvert.SerializeObject(itemsAll);
- memLayer.ML.setRSV($"{redKeyBase}:ItemsAll", serVal, dataCacheTTL);
-
- // salvo redis css!
- memLayer.ML.setRSV($"{redKeyBase}:Css", answ, dataCacheTTL);
- }
-
- return answ;
- }
- ///
- /// Registra che un dato ITEM è stato prelevato in fase di scarico da ID foglio + datamatrix
- ///
- /// ID foglio
- /// Cod del device di scarico
- /// Cod datamatrix ITEM
- ///
- public static bool saveItemPickup(int sheetID, string deviceId, string itemDtmx)
- {
- // area REDIS!
- string redKeyBase = $"{machineUnloadArea(sheetID)}";
- bool answ = false;
- string rawData = memLayer.ML.getRSV($"{redKeyBase}:ItemsSel");
- Dictionary dictData = new Dictionary();
- if (!string.IsNullOrEmpty(rawData))
- {
- dictData = JsonConvert.DeserializeObject>(rawData);
- }
- try
- {
- // cerco chiave device...
- if (dictData.ContainsKey(deviceId))
+ ///
+ /// Recupera e transcodifica DA DB i dati di UN SINGOLO bunk
+ ///
+ ///
+ ///
+ public static ProdBunk prodGetBunk(int StackID)
{
- // sostituisco
- dictData[deviceId] = itemDtmx;
+ ProdBunk answ = null;
+ List elSheet = new List();
+ var tabBunks = DataLayer.man.taSTL.getByKey(StackID);
+ if (tabBunks.Count == 1)
+ {
+ DS_App.StackListRow currBunk = tabBunks[0];
+ // calcolo attributi oggetti
+ CStatus currSt = CStatus.Programmed;
+ if (currBunk.Position == 5)
+ {
+ currSt = CStatus.Running;
+ }
+ else
+ {
+ currSt = CStatus.Done;
+ }
+ // recupero gli sheets di questo stack...
+ DS_App.SheetListDataTable tabSheets = DataLayer.man.taSHL.getByStack(StackID);
+ DateTime dataStart = DateTime.Now;
+ ProdSheet currPanel;
+ string nestBasePath = memLayer.ML.CRS("nestBasePath").ToLower();
+ string servBasePath = memLayer.ML.CRS("servBasePath").ToLower();
+ string prodBasePath = memLayer.ML.CRS("prodBasePath").ToLower();
+ foreach (var item in tabSheets)
+ {
+ // converto i workData
+ WorkData wdPrint = new WorkData()
+ {
+ DtStart = item.IsPrntStartNull() ? null : (DateTime?)item.PrntStart,
+ DtEnd = item.IsPrntEndNull() ? null : (DateTime?)item.PrntEnd,
+ ProgramPath = item.PrintFilePath.ToLower().Replace(nestBasePath, prodBasePath).Replace(servBasePath, prodBasePath)
+ };
+ WorkData wdMachining = new WorkData()
+ {
+ DtStart = item.IsWrkStartNull() ? null : (DateTime?)item.WrkStart,
+ DtEnd = item.IsWrkEndNull() ? null : (DateTime?)item.WrkEnd,
+ ProgramPath = item.CncFilePath.ToLower().Replace(nestBasePath, prodBasePath).Replace(servBasePath, prodBasePath)
+ };
+ WorkData wdUnload = new WorkData()
+ {
+ DtStart = item.IsUnlStartNull() ? null : (DateTime?)item.UnlStart,
+ DtEnd = item.IsUnlEndNull() ? null : (DateTime?)item.UnlEnd
+ };
+ MaterialData material = new MaterialData()
+ {
+ MaterialId = item.MatID,
+ MaterialDescription = item.MatDesc,
+ MaterialPN = item.MatExtCode.ToString()
+ };
+ PStatus currPnlStatus = PStatus.Programmed;
+ Enum.TryParse(item.ShStatus.ToString(), out currPnlStatus);
+ currPanel = new ProdSheet()
+ {
+ Printing = wdPrint,
+ Machining = wdMachining,
+ Unloading = wdUnload,
+ Material = material,
+ SheetId = item.StackID,
+ Status = currPnlStatus
+ };
+ elSheet.Add(currPanel);
+ if (!item.IsPrntStartNull())
+ {
+ dataStart = item.PrntStart < dataStart ? item.PrntStart : dataStart;
+ }
+ }
+ // compongo il bunk...
+ answ = new ProdBunk()
+ {
+ BunkId = currBunk.StackID,
+ Status = currSt,
+ DataMatrix = currBunk.StackDtmx,
+ SheetList = elSheet,
+ DtStart = dataStart
+ };
+ }
+ return answ;
}
- else
+ ///
+ /// Valore dello Stack correntemente in processing per ML (MachineLoad)
+ ///
+ public static string taktMLCurrStack
{
- dictData.Add(deviceId, itemDtmx);
+ get
+ {
+ return memLayer.ML.getRSV(redMLCurrStack);
+ }
+ set
+ {
+ memLayer.ML.setRSV(redMLCurrStack, value);
+ }
}
- // salvo!
- rawData = JsonConvert.SerializeObject(dictData);
- memLayer.ML.setRSV($"{redKeyBase}:ItemsSel", rawData);
- answ = true;
- // reset memoria redis del CSS x obbligare refresh...
- memLayer.ML.setRSV($"{redKeyBase}:Css", "");
- }
- catch
- { }
- return answ;
- }
- ///
- /// Registra che un dato ITEM è stato prelevato in fase di scarico da ID foglio + datamatrix
- ///
- /// ID foglio
- /// Cod del device di scarico
- ///
- public static bool resetItemPickup(int sheetID, string deviceId)
- {
- // area REDIS!
- string redKeyBase = $"{machineUnloadArea(sheetID)}";
- bool answ = false;
- string rawData = memLayer.ML.getRSV($"{redKeyBase}:ItemsSel");
- if (!string.IsNullOrEmpty(rawData))
- {
- try
- {
- Dictionary dictData = JsonConvert.DeserializeObject>(rawData);
- // cerco chiave device...
- if (dictData.ContainsKey(deviceId))
- {
- // sostituisco
- dictData.Remove(deviceId);
- }
- // salvo!
- rawData = JsonConvert.SerializeObject(dictData);
- memLayer.ML.setRSV($"{redKeyBase}:ItemsSel", rawData);
- answ = true;
- // reset memoria redis del CSS x obbligare refresh...
- memLayer.ML.setRSV($"{redKeyBase}:Css", "");
- }
- catch
- { }
- }
- return answ;
- }
- ///
- /// Processa elenco items e salva in redis valori x css, elenchi, ...
- ///
- /// CSS corrente
- /// HASH abse x area REDIS
- /// nome variabile x elenco items
- /// Elenco items specifici
- /// TTL della cache x salvataggio valori
- ///
- public static string updateCssByItemList(string currCss, string redKeyBase, string varName, List itemList, int dataCacheTTL)
- {
- string replaceVal = "";
- if (itemList.Count > 0)
- {
- foreach (var item in itemList)
- {
- replaceVal += $"#{item},";
- }
- if (replaceVal.Length > 1)
- {
- replaceVal = replaceVal.Remove(replaceVal.Length - 1);
- }
- // FIX CSS!
- currCss = currCss.Replace($"#{varName}", replaceVal);
- //serializzo e salvo
- string serVal = JsonConvert.SerializeObject(itemList);
- memLayer.ML.setRSV($"{redKeyBase}:{varName}", serVal, dataCacheTTL);
- }
- return currCss;
- }
+ #endregion
- ///
- /// Processa elenco items e salva in redis valori x css, elenchi, ...
- ///
- /// CSS corrente
- /// HASH abse x area REDIS
- /// nome variabile x elenco items
- /// TTL della cache x salvataggio valori
- ///
- public static string updateCssByPickedItems(string currCss, string redKeyBase, string varName, int dataCacheTTL)
- {
- string replaceVal = "";
- string rawData = memLayer.ML.getRSV($"{redKeyBase}:ItemsSel");
- if (!string.IsNullOrEmpty(rawData))
- {
- try
+ #region metodi x UNLOAD
+
+ ///
+ /// Calcola area REDIS per FOGLIO in fase di scarico
+ ///
+ ///
+ ///
+ public static string machineUnloadArea(int SheetID)
{
- Dictionary dictData = JsonConvert.DeserializeObject>(rawData);
- // ciclo x cercare x ogni chiave (sessione utente)
- foreach (var item in dictData)
- {
- replaceVal += $"#{item.Value},";
- }
- if (replaceVal.Length > 1)
- {
- replaceVal = replaceVal.Remove(replaceVal.Length - 1);
- }
- // FIX CSS!
- currCss = currCss.Replace("#ItemsSel", replaceVal);
+ // se 0 --> tutto l'albero, sennò solo area corrente...
+ string answ = "";
+ if (SheetID > 0)
+ {
+ answ = memLayer.ML.redHash($"MachineUnload:{SheetID}");
+ }
+ else
+ {
+ answ = memLayer.ML.redHash($"MachineUnload");
+ }
+ return answ;
}
- catch
- { }
-
- }
- return currCss;
- }
-
- ///
- /// IP del device
- ///
- ///
- public static string GetIPAddress()
- {
- HttpContext context = HttpContext.Current;
- string ipAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
-
- if (!string.IsNullOrEmpty(ipAddress))
- {
- string[] addresses = ipAddress.Split(',');
- if (addresses.Length != 0)
+ ///
+ /// Calcola area REDIS per BUNK in fase di scarico
+ ///
+ ///
+ ///
+ public static string machineUnloadBunkArea(int BunkID)
{
- return addresses[0];
+ // se 0 --> tutto l'albero, sennò solo area corrente...
+ string answ = "";
+ if (BunkID > 0)
+ {
+ answ = memLayer.ML.redHash($"MachineUnload:Bunk:{BunkID}");
+ }
+ else
+ {
+ answ = memLayer.ML.redHash($"MachineUnload:Bunk");
+ }
+ return answ;
}
- }
- return context.Request.ServerVariables["REMOTE_ADDR"];
- }
- ///
- /// Calcola area REDIS per MACCHINA
- ///
- ///
- ///
- public static string machineArea(string machineCod)
- {
- string answ = memLayer.ML.redHash($"currMachineData:{machineCod}");
- return answ;
- }
- ///
- /// Recupera prossimo batch da DB (NEXT... da db x status... ok SOLO x singola macchina)
- ///
- protected int getNextBatch
- {
- get
- {
- int answ = 0;
- try
+ ///
+ /// Recupera da REDIS info indice revisione x BUNK (cambio foglio)
+ ///
+ ///
+ ///
+ public static int getSheetRevByBunk(int BunkID)
{
- var currData = DataLayer.man.taBL.getNextAvailable();
- if (currData.Count > 0)
- {
- answ = currData[0].BatchID;
- }
+ int answ = 0;
+ if (BunkID > 0)
+ {
+ // recupero da REDIS!
+ string redKeyExp = memLayer.ML.redHash($"DataExp");
+ string redKeyRev = $"{ComLib.machineUnloadBunkArea(BunkID)}:Rev";
+ // controllo expiry globale... se manca SVUOTO area
+ string rawData = memLayer.ML.getRSV(redKeyExp);
+ if (string.IsNullOrEmpty(rawData))
+ {
+ // svuoto e scrivo...
+ memLayer.ML.redFlushKey(memLayer.ML.redHash($"MachineUnload"));
+ memLayer.ML.redFlushKey(memLayer.ML.redHash($"TabSheets"));
+ memLayer.ML.setRSV(redKeyExp, $"Reload Data {DateTime.Now}", 3600);
+ }
+ answ = memLayer.ML.getRCnt(redKeyRev);
+ }
+ return answ;
}
- catch
- { }
- return answ;
- }
- }
- ///
- /// Recupera SHEET da batch e sstati permessi...
- ///
- ///
- ///
- ///
- ///
- protected int getSheetIdByBatch(int BatchID, int minVal, int maxVal)
- {
- int answ = 0;
- try
- {
- var tabSheet = DataLayer.man.taSHL.getByMLStatus(BatchID, minVal, maxVal);
- if (tabSheet.Count > 0)
- {
- answ = tabSheet[0].SheetID;
- }
- }
- catch
- { }
- return answ;
- }
- ///
- /// Fornisce un dictionary di valori ATTUALI per una specifica macchina
- ///
- ///
- ///
- public Dictionary getCurrMachineData(string machineCod)
- {
- Dictionary answ = new Dictionary();
- // cerco in REDIS
- string rawData = memLayer.ML.getRSV(machineArea(machineCod));
- if (!string.IsNullOrEmpty(rawData))
- {
- answ = JsonConvert.DeserializeObject>(rawData);
- }
- else
- {
- // recupero batch e sheet...
- int batchId = getNextBatch;
- // se non trovo creo un oggetto NUOVO e vuoto x ogni oggetto... e salvo...
- answ.Add("BatchID", batchId.ToString());
- answ.Add("SheetID_load", getSheetIdByBatch(batchId, 0, 1).ToString());
- answ.Add("SheetID_print", getSheetIdByBatch(batchId, 1, 2).ToString());
- answ.Add("SheetID_work", getSheetIdByBatch(batchId, 2, 3).ToString());
- answ.Add("SheetID_unload", getSheetIdByBatch(batchId, 3, 5).ToString());
- // serializzo e salvo!
- saveMachineData(machineCod, answ);
- }
- // restituisco!
- return answ;
- }
- ///
- /// Salvataggio array dati di una macchina
- ///
- ///
- ///
- ///
- public bool saveMachineData(string machineCod, Dictionary paramsArray)
- {
- bool answ = false;
- try
- {
- // serializzo e salvo!
- string rawData = JsonConvert.SerializeObject(paramsArray);
- memLayer.ML.setRSV(machineArea(machineCod), rawData);
- answ = true;
- }
- catch
- { }
- // restituisco!
- return answ;
- }
- ///
- /// Fornisce un dictionary di valori ATTUALI per una specifica macchina
- ///
- ///
- ///
- ///
- ///
- public bool saveMachineParam(string machineCod, string Key, string Val)
- {
- bool answ = false;
- // recupero i dati
- try
- {
- var currData = getCurrMachineData(machineCod);
- // aggiorno il record
- if (currData.ContainsKey(Key))
- {
- currData[Key] = Val;
- }
- // oppure aggiungo...
- else
- {
- currData.Add(Key, Val);
- }
- // salvo...
- saveMachineData(machineCod, currData);
- answ = true;
- }
- catch
- { }
- return answ;
- }
- #endregion
- }
+ ///
+ /// Aggiorna revisione indice sheet x BUNK (cambio foglio)
+ ///
+ ///
+ ///
+ public static long advaceSheetRevByBunk(int BunkID)
+ {
+ long answ = 0;
+ if (BunkID > 0)
+ {
+ // recupero da REDIS!
+ string redKeyExp = memLayer.ML.redHash($"DataExp");
+ string redKeyRev = $"{ComLib.machineUnloadBunkArea(BunkID)}:Rev";
+ // incremento...
+ answ = memLayer.ML.setRCntI(redKeyRev);
+ // se > 999 --> resetto
+ if (answ > 999)
+ {
+ memLayer.ML.resetRCnt(redKeyRev);
+ }
+ }
+ return answ;
+ }
+
+
+ ///
+ /// Svuota elenco pezzi nella postazione di unload
+ ///
+ ///
+ ///
+ public bool resetSheetUnload(int SheetID = 0)
+ {
+ bool answ = false;
+ try
+ {
+ memLayer.ML.redFlushKey(machineUnloadArea(SheetID));
+ answ = true;
+ }
+ catch
+ { }
+ return answ;
+ }
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static string getCurrentCss(int sheetID)
+ {
+ // area REDIS!
+ string redKeyBase = $"{machineUnloadArea(sheetID)}";
+ // TTL standard
+ int dataCacheTTL = memLayer.ML.cdvi("cssCacheTTL");
+ dataCacheTTL = dataCacheTTL <= 0 ? 60 : dataCacheTTL;
+ // files
+ string filename = HttpContext.Current.Server.MapPath("~/Content/SheetColor.css");
+ string answ = File.ReadAllText(filename);
+ // solo se sheet > 0...
+ if (sheetID > 0)
+ {
+ // elenco items da foglio!!!
+ var tabItems = DataLayer.man.taIL.getBySheet(sheetID);
+ List itemsAll = new List();
+ List itemsDepo = new List();
+ List itemsCart = new List();
+ List itemsBin = new List();
+ List itemsSecOp = new List();
+
+ //se ho items...
+ if (tabItems.Count > 0)
+ {
+ // ciclo!
+ foreach (var item in tabItems)
+ {
+ // aggiungoncomunque a lista generale...
+ itemsAll.Add(item.ItemDtmx);
+ // controllo SE sia stato depositato... check status 3/4
+ if (item.StatusID == 3 || item.StatusID == 4)
+ {
+ itemsDepo.Add(item.ItemDtmx);
+ }
+ else if (item.ProcessesReq.Contains("PaintFlag"))
+ {
+ itemsBin.Add(item.ItemDtmx);
+ }
+ else
+ {
+ itemsCart.Add(item.ItemDtmx);
+ }
+ // controllo ANCHE postprocessing
+ if (item.PostProcList != "")
+ {
+ itemsSecOp.Add(item.ItemDtmx);
+ }
+ }
+ }
+
+
+ // FIX BIN
+ answ = updateCssByItemList(answ, redKeyBase, "ItemsBin", itemsBin, dataCacheTTL);
+
+ // FIX CART
+ answ = updateCssByItemList(answ, redKeyBase, "ItemsCart", itemsCart, dataCacheTTL);
+
+ // FIX Scaricati
+ answ = updateCssByItemList(answ, redKeyBase, "ItemsDepo", itemsDepo, dataCacheTTL);
+
+ // FIX SEC-OP
+ answ = updateCssByItemList(answ, redKeyBase, "ItemsSecOp", itemsSecOp, dataCacheTTL);
+
+ // FIXED SEL da array oggetti selezionati...
+ answ = updateCssByPickedItems(answ, redKeyBase, "ItemsSel", dataCacheTTL);
+
+
+ // INFINE serializzo e salvo tutti gli items trovati...
+ string serVal = JsonConvert.SerializeObject(itemsAll);
+ memLayer.ML.setRSV($"{redKeyBase}:ItemsAll", serVal, dataCacheTTL);
+
+ // salvo redis css!
+ memLayer.ML.setRSV($"{redKeyBase}:Css", answ, dataCacheTTL);
+ }
+
+ return answ;
+ }
+ ///
+ /// Registra che un dato ITEM è stato prelevato in fase di scarico da ID foglio + datamatrix
+ ///
+ /// ID foglio
+ /// Cod del device di scarico
+ /// Cod datamatrix ITEM
+ ///
+ public static bool saveItemPickup(int sheetID, string deviceId, string itemDtmx)
+ {
+ // area REDIS!
+ string redKeyBase = $"{machineUnloadArea(sheetID)}";
+ bool answ = false;
+ string rawData = memLayer.ML.getRSV($"{redKeyBase}:ItemsSel");
+ Dictionary dictData = new Dictionary();
+ if (!string.IsNullOrEmpty(rawData))
+ {
+ dictData = JsonConvert.DeserializeObject>(rawData);
+ }
+ try
+ {
+ // cerco chiave device...
+ if (dictData.ContainsKey(deviceId))
+ {
+ // sostituisco
+ dictData[deviceId] = itemDtmx;
+ }
+ else
+ {
+ dictData.Add(deviceId, itemDtmx);
+ }
+ // salvo!
+ rawData = JsonConvert.SerializeObject(dictData);
+ memLayer.ML.setRSV($"{redKeyBase}:ItemsSel", rawData);
+ answ = true;
+ // reset memoria redis del CSS x obbligare refresh...
+ memLayer.ML.setRSV($"{redKeyBase}:Css", "");
+ }
+ catch
+ { }
+ return answ;
+ }
+ ///
+ /// Registra che un dato ITEM è stato prelevato in fase di scarico da ID foglio + datamatrix
+ ///
+ /// ID foglio
+ /// Cod del device di scarico
+ ///
+ public static bool resetItemPickup(int sheetID, string deviceId)
+ {
+ // area REDIS!
+ string redKeyBase = $"{machineUnloadArea(sheetID)}";
+ bool answ = false;
+ string rawData = memLayer.ML.getRSV($"{redKeyBase}:ItemsSel");
+ if (!string.IsNullOrEmpty(rawData))
+ {
+ try
+ {
+ Dictionary dictData = JsonConvert.DeserializeObject>(rawData);
+ // cerco chiave device...
+ if (dictData.ContainsKey(deviceId))
+ {
+ // sostituisco
+ dictData.Remove(deviceId);
+ }
+ // salvo!
+ rawData = JsonConvert.SerializeObject(dictData);
+ memLayer.ML.setRSV($"{redKeyBase}:ItemsSel", rawData);
+ answ = true;
+ // reset memoria redis del CSS x obbligare refresh...
+ memLayer.ML.setRSV($"{redKeyBase}:Css", "");
+ }
+ catch
+ { }
+ }
+ return answ;
+ }
+
+ ///
+ /// Processa elenco items e salva in redis valori x css, elenchi, ...
+ ///
+ /// CSS corrente
+ /// HASH abse x area REDIS
+ /// nome variabile x elenco items
+ /// Elenco items specifici
+ /// TTL della cache x salvataggio valori
+ ///
+ public static string updateCssByItemList(string currCss, string redKeyBase, string varName, List itemList, int dataCacheTTL)
+ {
+ string replaceVal = "";
+ if (itemList.Count > 0)
+ {
+ foreach (var item in itemList)
+ {
+ replaceVal += $"#{item},";
+ }
+ if (replaceVal.Length > 1)
+ {
+ replaceVal = replaceVal.Remove(replaceVal.Length - 1);
+ }
+ // FIX CSS!
+ currCss = currCss.Replace($"#{varName}", replaceVal);
+ //serializzo e salvo
+ string serVal = JsonConvert.SerializeObject(itemList);
+ memLayer.ML.setRSV($"{redKeyBase}:{varName}", serVal, dataCacheTTL);
+ }
+ return currCss;
+ }
+
+ ///
+ /// Processa elenco items e salva in redis valori x css, elenchi, ...
+ ///
+ /// CSS corrente
+ /// HASH abse x area REDIS
+ /// nome variabile x elenco items
+ /// TTL della cache x salvataggio valori
+ ///
+ public static string updateCssByPickedItems(string currCss, string redKeyBase, string varName, int dataCacheTTL)
+ {
+ string replaceVal = "";
+ string rawData = memLayer.ML.getRSV($"{redKeyBase}:ItemsSel");
+ if (!string.IsNullOrEmpty(rawData))
+ {
+ try
+ {
+ Dictionary dictData = JsonConvert.DeserializeObject>(rawData);
+ // ciclo x cercare x ogni chiave (sessione utente)
+ foreach (var item in dictData)
+ {
+ replaceVal += $"#{item.Value},";
+ }
+ if (replaceVal.Length > 1)
+ {
+ replaceVal = replaceVal.Remove(replaceVal.Length - 1);
+ }
+ // FIX CSS!
+ currCss = currCss.Replace("#ItemsSel", replaceVal);
+ }
+ catch
+ { }
+
+ }
+ return currCss;
+ }
+
+ ///
+ /// IP del device
+ ///
+ ///
+ public static string GetIPAddress()
+ {
+ HttpContext context = HttpContext.Current;
+ string ipAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
+
+ if (!string.IsNullOrEmpty(ipAddress))
+ {
+ string[] addresses = ipAddress.Split(',');
+ if (addresses.Length != 0)
+ {
+ return addresses[0];
+ }
+ }
+
+ return context.Request.ServerVariables["REMOTE_ADDR"];
+ }
+
+ ///
+ /// Calcola area REDIS per MACCHINA
+ ///
+ ///
+ ///
+ public static string machineArea(string machineCod)
+ {
+ string answ = memLayer.ML.redHash($"currMachineData:{machineCod}");
+ return answ;
+ }
+ ///
+ /// Recupera prossimo batch da DB (NEXT... da db x status... ok SOLO x singola macchina)
+ ///
+ protected int getNextBatch
+ {
+ get
+ {
+ int answ = 0;
+ try
+ {
+ var currData = DataLayer.man.taBL.getNextAvailable();
+ if (currData.Count > 0)
+ {
+ answ = currData[0].BatchID;
+ }
+ }
+ catch
+ { }
+ return answ;
+ }
+ }
+ ///
+ /// Recupera SHEET da batch e sstati permessi...
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected int getSheetIdByBatch(int BatchID, int minVal, int maxVal)
+ {
+ int answ = 0;
+ try
+ {
+ var tabSheet = DataLayer.man.taSHL.getByMLStatus(BatchID, minVal, maxVal);
+ if (tabSheet.Count > 0)
+ {
+ answ = tabSheet[0].SheetID;
+ }
+ }
+ catch
+ { }
+ return answ;
+ }
+ ///
+ /// Fornisce un dictionary di valori ATTUALI per una specifica macchina
+ ///
+ ///
+ ///
+ public Dictionary getCurrMachineData(string machineCod)
+ {
+ Dictionary answ = new Dictionary();
+ // cerco in REDIS
+ string rawData = memLayer.ML.getRSV(machineArea(machineCod));
+ if (!string.IsNullOrEmpty(rawData))
+ {
+ answ = JsonConvert.DeserializeObject>(rawData);
+ }
+ else
+ {
+ // recupero batch e sheet...
+ int batchId = getNextBatch;
+ // se non trovo creo un oggetto NUOVO e vuoto x ogni oggetto... e salvo...
+ answ.Add("BatchID", batchId.ToString());
+ answ.Add("SheetID_load", getSheetIdByBatch(batchId, 0, 1).ToString());
+ answ.Add("SheetID_print", getSheetIdByBatch(batchId, 1, 2).ToString());
+ answ.Add("SheetID_work", getSheetIdByBatch(batchId, 2, 3).ToString());
+ answ.Add("SheetID_unload", getSheetIdByBatch(batchId, 3, 5).ToString());
+ // serializzo e salvo!
+ saveMachineData(machineCod, answ);
+ }
+ // restituisco!
+ return answ;
+ }
+ ///
+ /// Salvataggio array dati di una macchina
+ ///
+ ///
+ ///
+ ///
+ public bool saveMachineData(string machineCod, Dictionary paramsArray)
+ {
+ bool answ = false;
+ try
+ {
+ // serializzo e salvo!
+ string rawData = JsonConvert.SerializeObject(paramsArray);
+ memLayer.ML.setRSV(machineArea(machineCod), rawData);
+ answ = true;
+ }
+ catch
+ { }
+ // restituisco!
+ return answ;
+ }
+ ///
+ /// Fornisce un dictionary di valori ATTUALI per una specifica macchina
+ ///
+ ///
+ ///
+ ///
+ ///
+ public bool saveMachineParam(string machineCod, string Key, string Val)
+ {
+ bool answ = false;
+ // recupero i dati
+ try
+ {
+ var currData = getCurrMachineData(machineCod);
+ // aggiorno il record
+ if (currData.ContainsKey(Key))
+ {
+ currData[Key] = Val;
+ }
+ // oppure aggiungo...
+ else
+ {
+ currData.Add(Key, Val);
+ }
+ // salvo...
+ saveMachineData(machineCod, currData);
+ answ = true;
+ }
+ catch
+ { }
+ return answ;
+ }
+
+ #endregion
+
+ }
}
diff --git a/Jenkinsfile b/Jenkinsfile
index 9a7ebf4..c23909b 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -11,7 +11,7 @@ pipeline {
steps {
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
script {
- withEnv(['NEXT_BUILD_NUMBER=268']) {
+ withEnv(['NEXT_BUILD_NUMBER=269']) {
// env.versionNumber = VersionNumber(versionNumberString : '0.9.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2019-07-01', skipFailedBuilds: true)
env.versionNumber = VersionNumber(versionNumberString : '0.9.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2019-07-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
env.versionNumberBeta = VersionNumber(versionNumberString : '0.9.${BUILD_DATE_FORMATTED, "yyMM"}-beta.${BUILDS_ALL_TIME}', projectStartDate : '2019-07-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
diff --git a/NKC_WF.sln b/NKC_WF.sln
index 2af74d1..fec5a68 100644
--- a/NKC_WF.sln
+++ b/NKC_WF.sln
@@ -11,6 +11,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VersGen", "VersGen\VersGen.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NKC_SDK", "NKC_SDK\NKC_SDK.csproj", "{5A0B6E45-169B-44D4-9E24-13718B8EB7CC}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AF976E24-B296-403D-BCDA-6574E7B2F1DC}"
+ ProjectSection(SolutionItems) = preProject
+ .editorconfig = .editorconfig
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
diff --git a/NKC_WF/Controllers/SheetController.cs b/NKC_WF/Controllers/SheetController.cs
index 18f5674..7415038 100644
--- a/NKC_WF/Controllers/SheetController.cs
+++ b/NKC_WF/Controllers/SheetController.cs
@@ -11,154 +11,160 @@ using System.Web.Http;
namespace NKC_WF.Controllers
{
- public class SheetController : ApiController
- {
- ///
- /// Restituisce un array di sheet da lavorare (quindi NON ancora scaricati, anche di + BUNK)
- /// GET: api/Sheet
- ///
- ///
- [HttpGet]
- public SheetWorkList Get()
+ public class SheetController : ApiController
{
- // fisso su machcina 1
- string machineName = "WRK001";
- SheetWorkList answ = null;
- try
- {
- answ = ComLib.prodGetSheetWorkList(machineName);
- }
- catch
- { }
- return answ;
- }
- ///
- /// Ottengo elenco specifico dato cod MACCHINA
- /// GET: api/Sheet/WRK001
- ///
- ///
- ///
- [HttpGet]
- public SheetWorkList Get(string id)
- {
- SheetWorkList answ = null;
- try
- {
- answ = ComLib.prodGetSheetWorkList(id);
- }
- catch
- { }
- return answ;
- }
-
- /************************************
- * 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
- *
- *
- *
- * - aggiungere PUT/DELETE a handler:
- *
- *
- *
- **************************************/
-
- ///
- /// Effettua la chiamata di update x SINGOLO foglio
- ///
- /// Oggetto con Elenco fogli da aggiornare
- // PUT: api/Bunk/5
- [HttpPut]
- public void Put(SheetWorkList sheetUpdated)
- {
- // 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
-
- if (sheetUpdated != null)
- {
- if (sheetUpdated.SheetList != null)
+ ///
+ /// Restituisce un array di sheet da lavorare (quindi NON ancora scaricati, anche di + BUNK)
+ /// GET: api/Sheet
+ ///
+ ///
+ [HttpGet]
+ public SheetWorkList Get()
{
- foreach (var currSheet in sheetUpdated.SheetList)
- {
- // se non nullo...
- if (currSheet != null)
+ // fisso su machcina 1
+ string machineName = "WRK001";
+ SheetWorkList answ = null;
+ try
{
- DataLayer.man.taSHL.updateDate(currSheet.SheetId, currSheet.Printing.DtStart, currSheet.Printing.DtEnd, currSheet.Machining.DtStart, currSheet.Machining.DtEnd, currSheet.Unloading.DtStart, currSheet.Unloading.DtEnd, (int)currSheet.Status);
- // verifico SE SIA AVVENUTO CON SUCCESSO lo step di lavorazione...
- if (currSheet.Machining.Success)
- {
- // SE machining completato --> status a LAVORATO!
- if (currSheet.Machining.DtEnd != null)
- {
- DataLayer.man.taIL.updateSheetStatus(currSheet.SheetId, 1, "PROD");
- }
- }
- // segnalo avanzamento su redis x pagina unload
- ComLib.advaceSheetRevByBunk(currSheet.BunkId);
+ answ = ComLib.prodGetSheetWorkList(machineName);
}
- }
+ catch
+ { }
+ return answ;
}
- // INVALIDO eventuale valore BUNK in REDIS...
- ComLib.resetRedisBunkData();
- }
- }
-
- ///
- /// Processa una chiamata POST per l'invio in blocco status BUNK
- /// POST: api/Bunk
- ///
- ///
- [HttpPost]
- public string Post()
- {
- string answ = "";
- // questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
- string content = "";
- System.Web.HttpContext.Current.Request.InputStream.Position = 0;
- using (var reader = new StreamReader(System.Web.HttpContext.Current.Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
- {
- content = reader.ReadToEnd();
- }
- //Rest
- System.Web.HttpContext.Current.Request.InputStream.Position = 0;
- // procedo a deserializzare in blocco l'oggetto...
- try
- {
- // deserializzo.
- SheetWorkList sheetUpdated = JsonConvert.DeserializeObject(content);
- if (sheetUpdated != null)
+ ///
+ /// Ottengo elenco specifico dato cod MACCHINA
+ /// GET: api/Sheet/WRK001
+ ///
+ ///
+ ///
+ [HttpGet]
+ public SheetWorkList Get(string id)
{
- if (sheetUpdated.SheetList != null)
- {
- foreach (var currSheet in sheetUpdated.SheetList)
+ SheetWorkList answ = null;
+ try
{
- // se non nullo...
- if (currSheet != null)
- {
- DataLayer.man.taSHL.updateDate(currSheet.SheetId, currSheet.Printing.DtStart, currSheet.Printing.DtEnd, currSheet.Machining.DtStart, currSheet.Machining.DtEnd, currSheet.Unloading.DtStart, currSheet.Unloading.DtEnd, (int)currSheet.Status);
- // SE machining completato --> status a LAVORATO!
- if (currSheet.Machining.DtEnd != null)
- {
- DataLayer.man.taIL.updateSheetStatus(currSheet.SheetId, 1, "PROD");
- }
- // segnalo avanzamento su redis x pagina unload
- ComLib.advaceSheetRevByBunk(currSheet.BunkId);
- answ = "OK";
- }
+ answ = ComLib.prodGetSheetWorkList(id);
}
- }
+ catch
+ { }
+ return answ;
+ }
+
+ /************************************
+ * 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
+ *
+ *
+ *
+ * - aggiungere PUT/DELETE a handler:
+ *
+ *
+ *
+ **************************************/
+
+ ///
+ /// Effettua la chiamata di update x SINGOLO foglio
+ ///
+ /// Oggetto con Elenco fogli da aggiornare
+ // PUT: api/Bunk/5
+ [HttpPut]
+ public void Put(SheetWorkList sheetUpdated)
+ {
+ // 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
+
+ if (sheetUpdated != null)
+ {
+ // 2020.01.16 salvo su mongoDb la risposta...
+ ComLib.man.saveProdAnsw(sheetUpdated);
+
+ if (sheetUpdated.SheetList != null)
+ {
+ foreach (var currSheet in sheetUpdated.SheetList)
+ {
+ // se non nullo...
+ if (currSheet != null)
+ {
+ DataLayer.man.taSHL.updateDate(currSheet.SheetId, currSheet.Printing.DtStart, currSheet.Printing.DtEnd, currSheet.Machining.DtStart, currSheet.Machining.DtEnd, currSheet.Unloading.DtStart, currSheet.Unloading.DtEnd, (int)currSheet.Status);
+ // verifico SE SIA AVVENUTO CON SUCCESSO lo step di lavorazione...
+ if (currSheet.Machining.Success)
+ {
+ // SE machining completato --> status a LAVORATO!
+ if (currSheet.Machining.DtEnd != null)
+ {
+ DataLayer.man.taIL.updateSheetStatus(currSheet.SheetId, 1, "PROD");
+ }
+ }
+ // segnalo avanzamento su redis x pagina unload
+ ComLib.advaceSheetRevByBunk(currSheet.BunkId);
+ }
+ }
+ }
+ // INVALIDO eventuale valore BUNK in REDIS...
+ ComLib.resetRedisBunkData();
+ }
+ }
+
+ ///
+ /// Processa una chiamata POST per l'invio in blocco status BUNK
+ /// POST: api/Bunk
+ ///
+ ///
+ [HttpPost]
+ public string Post()
+ {
+ string answ = "";
+ // questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
+ string content = "";
+ System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ using (var reader = new StreamReader(System.Web.HttpContext.Current.Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
+ {
+ content = reader.ReadToEnd();
+ }
+ //Rest
+ System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // procedo a deserializzare in blocco l'oggetto...
+ try
+ {
+ // deserializzo.
+ SheetWorkList sheetUpdated = JsonConvert.DeserializeObject(content);
+ if (sheetUpdated != null)
+ {
+ // 2020.01.16 salvo su mongoDb la risposta...
+ ComLib.man.saveProdAnsw(sheetUpdated);
+
+ if (sheetUpdated.SheetList != null)
+ {
+ foreach (var currSheet in sheetUpdated.SheetList)
+ {
+ // se non nullo...
+ if (currSheet != null)
+ {
+ DataLayer.man.taSHL.updateDate(currSheet.SheetId, currSheet.Printing.DtStart, currSheet.Printing.DtEnd, currSheet.Machining.DtStart, currSheet.Machining.DtEnd, currSheet.Unloading.DtStart, currSheet.Unloading.DtEnd, (int)currSheet.Status);
+ // SE machining completato --> status a LAVORATO!
+ if (currSheet.Machining.DtEnd != null)
+ {
+ DataLayer.man.taIL.updateSheetStatus(currSheet.SheetId, 1, "PROD");
+ }
+ // segnalo avanzamento su redis x pagina unload
+ ComLib.advaceSheetRevByBunk(currSheet.BunkId);
+ answ = "OK";
+ }
+ }
+ }
+ }
+ }
+ catch (Exception exc)
+ {
+ answ = "NO";
+ }
+ return answ;
}
- }
- catch (Exception exc)
- {
- answ = "NO";
- }
- return answ;
}
- }
}
diff --git a/NKC_WF/WebUserControls/cmp_stackLoading.ascx.cs b/NKC_WF/WebUserControls/cmp_stackLoading.ascx.cs
index 245275f..8d6076a 100644
--- a/NKC_WF/WebUserControls/cmp_stackLoading.ascx.cs
+++ b/NKC_WF/WebUserControls/cmp_stackLoading.ascx.cs
@@ -5,219 +5,226 @@ using System;
namespace NKC_WF.WebUserControls
{
- public partial class cmp_stackLoading : BaseUserControl
- {
- protected void Page_Load(object sender, EventArgs e)
+ public partial class cmp_stackLoading : BaseUserControl
{
- if (!Page.IsPostBack)
- {
- // svuoto input barcode...
- cmp_barcode.inputAcquired = "";
- lastCmd = "";
- cmp_stackNextloading.BatchId = BatchIdCurr;
- raiseEvent();
- doUpdate();
- }
- cmp_barcode.eh_doRefresh += Cmp_barcode_eh_doRefresh;
- }
- ///
- /// Comando barcode letto
- ///
- protected string lastCmd
- {
- get
- {
- return hfBarcode.Value;
- }
- set
- {
- hfBarcode.Value = value;
- }
- }
- public int BatchIdCurr
- {
- get
- {
- int answ = 0;
- try
+ protected void Page_Load(object sender, EventArgs e)
{
- int.TryParse(frmView.SelectedValue.ToString(), out answ);
- }
- catch
- { }
- return answ;
- }
- }
- public int StackId
- {
- set
- {
- hfStackId.Value = value.ToString();
- lastCmd = "";
- cmp_barcode.resetMessage();
- doUpdate();
- }
- get
- {
- int answ = 0;
- int.TryParse(hfStackId.Value, out answ);
- return answ;
- }
- }
- private void Cmp_barcode_eh_doRefresh(object sender, EventArgs e)
- {
- bool doRaiseEv = false;
- // processo evento..
- lastCmd = cmp_barcode.inputAcquired.ToUpper();
- if (lastCmd == "") doRaiseEv = true;
- // processiamo barcode letto
- decodedData decoData = DataLayer.man.decodeBcode(lastCmd);
- switch (decoData.codeType)
- {
- case codeType.UNK:
- cmp_barcode.showOutput("text-danger", $"Unknown Data: {decoData.rawData} --> no action");
- doRaiseEv = true;
- break;
- case codeType.Item:
- case codeType.ItemGeneric:
- cmp_barcode.showOutput("text-warning", $"Item - ignored: {decoData.description}");
- doRaiseEv = true;
- break;
- case codeType.Material:
- cmp_barcode.showOutput("badge badge-warning", $"Material - ignored: {decoData.description}");
- doRaiseEv = true;
- break;
- case codeType.Sheet:
- cmp_barcode.showOutput("badge badge-warning", $"Sheet - ignored: {decoData.description}");
- doRaiseEv = true;
- break;
- case codeType.Stack:
- // verifico SE lo stack esista...
- DS_App.StackListDataTable tabStack = DataLayer.man.taSTL.getByKey(decoData.codeInt);
- if (tabStack.Count == 0)
- {
- cmp_barcode.showOutput("badge badge-danger", $"BUNK NOT FOUND: {decoData.description}");
- }
- else
- {
- // controllo sia quello RICHIESTO, eventualmente permetteremo TUTTI quelli del giorno in ogni ordine...
- if (decoData.codeInt == cmp_stackNextloading.StackIdReq)
+ if (!Page.IsPostBack)
{
- cmp_barcode.showOutput("badge badge-success", $"BUNK OK, {decoData.rawData}");
- ComLib.taktMLCurrStack = decoData.code;
- // processo DB e salvo che lo stack è stato caricato in MACHINE LOAD
- int stackId = 0;
- try
- {
- var tabStacks = DataLayer.man.taSTL.getByDtmx(decoData.rawData);
- if (tabStack.Count == 1)
+ // svuoto input barcode...
+ cmp_barcode.inputAcquired = "";
+ lastCmd = "";
+ cmp_stackNextloading.BatchId = BatchIdCurr;
+ raiseEvent();
+ doUpdate();
+ }
+ cmp_barcode.eh_doRefresh += Cmp_barcode_eh_doRefresh;
+ }
+ ///
+ /// Comando barcode letto
+ ///
+ protected string lastCmd
+ {
+ get
+ {
+ return hfBarcode.Value;
+ }
+ set
+ {
+ hfBarcode.Value = value;
+ }
+ }
+ public int BatchIdCurr
+ {
+ get
+ {
+ int answ = 0;
+ try
{
- stackId = tabStack[0].StackID;
+ if (frmView.SelectedValue != null)
+ {
+ string selBatch = $"{frmView.SelectedValue}";
+ if (!string.IsNullOrEmpty(selBatch))
+ {
+ int.TryParse(selBatch, out answ);
+ }
+ }
}
- }
- catch
- { }
- // SE HO uno stackId valido (>0)...
- if (stackId > 0)
- {
- DataLayer.man.taSTL.updatePos(stackId, 5);
- // controllo status del bunk nel suo insieme...
- ComLib.updateBatchPositionByBunk(stackId);
- doRaiseEv = true;
- }
+ catch
+ { }
+ return answ;
}
- else
- {
- cmp_barcode.showOutput("badge badge-danger", $"WRONG BUNK, {decoData.rawData}");
- }
- }
- //DS_App.SheetListDataTable nextTbl = DataLayer.man.taSHL.getNextByStack(StackId);
- //// se tab vuota --> HO FINITO!!!!
- //if (nextTbl.Count == 0)
- //{
- // cmp_barcode.showOutput("badge badge-warning", $"STACK IS COMPLETED, {decoData.description}");
- //}
- //// se ho valori --> controllo se corretto...
- //else
- //{
- // string codReq = nextTbl[0].MatExtCode.ToString();
- // if (codReq == decoData.codeInt.ToString())
- // {
- // cmp_barcode.showOutput("badge badge-success", $"SHEET RECORDED: {decoData.description}");
- // // chiamo stored x indicare preparato
- // DataLayer.man.taSHL.setPrepared(nextTbl[0].SheetID);
- // }
- // else
- // {
- // cmp_barcode.showOutput("badge badge-danger", $"WRONG SHEET: {decoData.description}");
- // }
- //}
-
- //cmp_barcode.showOutput("badge badge-warning", "Stack - ignored");
- break;
- case codeType.Batch:
- cmp_barcode.showOutput("badge badge-warning", $"Batch - ignored: {decoData.description}");
- doRaiseEv = true;
- break;
- default:
- doRaiseEv = true;
- break;
- }
- // reset comando
- cmp_barcode.inputAcquired = "";
- // aggiorno...
- doUpdate();
- // se richiesto faccio raiseEvent
- if (doRaiseEv)
- {
- cmp_stackNextloading.doUpdate();
- raiseEvent();
- }
- }
-
- protected void checkVisibility()
- {
- lblLoaded.Visible = StackId != 0;
- frmView.Visible = !lblLoaded.Visible;
- // fix div di simulazione
- divSim.Visible = (memLayer.ML.CRS("environment") == "DEV");
- }
-
- public void doUpdate()
- {
- checkVisibility();
- }
-
-
-
- protected void frmView_DataBound(object sender, EventArgs e)
- {
- cmp_stackNextloading.BatchId = BatchIdCurr;
- raiseEvent();
- }
-
- protected void lbtAdvanceProd_Click(object sender, EventArgs e)
- {
- // chiama stored x cambiare dt dei vari processi governati dal prod...
- var currStack = DataLayer.man.taSTL.getCurrByBatch(BatchIdCurr);
- if (currStack != null)
- {
- if (currStack.Count > 0)
- {
- int stackIdCurr = currStack[0].StackID;
- DataLayer.man.taSHL.advanceInStack(stackIdCurr);
}
- doUpdate();
- cmp_stackNextloading.doUpdate();
- // segnalo avanzamento su redis x pagina unload
- ComLib.advaceSheetRevByBunk(BatchIdCurr);
- raiseEvent();
- }
- }
+ public int StackId
+ {
+ set
+ {
+ hfStackId.Value = value.ToString();
+ lastCmd = "";
+ cmp_barcode.resetMessage();
+ doUpdate();
+ }
+ get
+ {
+ int answ = 0;
+ int.TryParse(hfStackId.Value, out answ);
+ return answ;
+ }
+ }
+ private void Cmp_barcode_eh_doRefresh(object sender, EventArgs e)
+ {
+ bool doRaiseEv = false;
+ // processo evento..
+ lastCmd = cmp_barcode.inputAcquired.ToUpper();
+ if (lastCmd == "") doRaiseEv = true;
+ // processiamo barcode letto
+ decodedData decoData = DataLayer.man.decodeBcode(lastCmd);
+ switch (decoData.codeType)
+ {
+ case codeType.UNK:
+ cmp_barcode.showOutput("text-danger", $"Unknown Data: {decoData.rawData} --> no action");
+ doRaiseEv = true;
+ break;
+ case codeType.Item:
+ case codeType.ItemGeneric:
+ cmp_barcode.showOutput("text-warning", $"Item - ignored: {decoData.description}");
+ doRaiseEv = true;
+ break;
+ case codeType.Material:
+ cmp_barcode.showOutput("badge badge-warning", $"Material - ignored: {decoData.description}");
+ doRaiseEv = true;
+ break;
+ case codeType.Sheet:
+ cmp_barcode.showOutput("badge badge-warning", $"Sheet - ignored: {decoData.description}");
+ doRaiseEv = true;
+ break;
+ case codeType.Stack:
+ // verifico SE lo stack esista...
+ DS_App.StackListDataTable tabStack = DataLayer.man.taSTL.getByKey(decoData.codeInt);
+ if (tabStack.Count == 0)
+ {
+ cmp_barcode.showOutput("badge badge-danger", $"BUNK NOT FOUND: {decoData.description}");
+ }
+ else
+ {
+ // controllo sia quello RICHIESTO, eventualmente permetteremo TUTTI quelli del giorno in ogni ordine...
+ if (decoData.codeInt == cmp_stackNextloading.StackIdReq)
+ {
+ cmp_barcode.showOutput("badge badge-success", $"BUNK OK, {decoData.rawData}");
+ ComLib.taktMLCurrStack = decoData.code;
+ // processo DB e salvo che lo stack è stato caricato in MACHINE LOAD
+ int stackId = 0;
+ try
+ {
+ var tabStacks = DataLayer.man.taSTL.getByDtmx(decoData.rawData);
+ if (tabStack.Count == 1)
+ {
+ stackId = tabStack[0].StackID;
+ }
+ }
+ catch
+ { }
+ // SE HO uno stackId valido (>0)...
+ if (stackId > 0)
+ {
+ DataLayer.man.taSTL.updatePos(stackId, 5);
+ // controllo status del bunk nel suo insieme...
+ ComLib.updateBatchPositionByBunk(stackId);
+ doRaiseEv = true;
+ }
+ }
+ else
+ {
+ cmp_barcode.showOutput("badge badge-danger", $"WRONG BUNK, {decoData.rawData}");
+ }
+ }
+ //DS_App.SheetListDataTable nextTbl = DataLayer.man.taSHL.getNextByStack(StackId);
+ //// se tab vuota --> HO FINITO!!!!
+ //if (nextTbl.Count == 0)
+ //{
+ // cmp_barcode.showOutput("badge badge-warning", $"STACK IS COMPLETED, {decoData.description}");
+ //}
+ //// se ho valori --> controllo se corretto...
+ //else
+ //{
+ // string codReq = nextTbl[0].MatExtCode.ToString();
+ // if (codReq == decoData.codeInt.ToString())
+ // {
+ // cmp_barcode.showOutput("badge badge-success", $"SHEET RECORDED: {decoData.description}");
+ // // chiamo stored x indicare preparato
+ // DataLayer.man.taSHL.setPrepared(nextTbl[0].SheetID);
+ // }
+ // else
+ // {
+ // cmp_barcode.showOutput("badge badge-danger", $"WRONG SHEET: {decoData.description}");
+ // }
+ //}
- protected void lbtAdvanceBunk_Click(object sender, EventArgs e)
- {
- // simula invio barcode del PROSSIMO BUNK (SE necessario)
+ //cmp_barcode.showOutput("badge badge-warning", "Stack - ignored");
+ break;
+ case codeType.Batch:
+ cmp_barcode.showOutput("badge badge-warning", $"Batch - ignored: {decoData.description}");
+ doRaiseEv = true;
+ break;
+ default:
+ doRaiseEv = true;
+ break;
+ }
+ // reset comando
+ cmp_barcode.inputAcquired = "";
+ // aggiorno...
+ doUpdate();
+ // se richiesto faccio raiseEvent
+ if (doRaiseEv)
+ {
+ cmp_stackNextloading.doUpdate();
+ raiseEvent();
+ }
+ }
+
+ protected void checkVisibility()
+ {
+ lblLoaded.Visible = StackId != 0;
+ frmView.Visible = !lblLoaded.Visible;
+ // fix div di simulazione
+ divSim.Visible = (memLayer.ML.CRS("environment") == "DEV");
+ }
+
+ public void doUpdate()
+ {
+ checkVisibility();
+ }
+
+
+
+ protected void frmView_DataBound(object sender, EventArgs e)
+ {
+ cmp_stackNextloading.BatchId = BatchIdCurr;
+ raiseEvent();
+ }
+
+ protected void lbtAdvanceProd_Click(object sender, EventArgs e)
+ {
+ // chiama stored x cambiare dt dei vari processi governati dal prod...
+ var currStack = DataLayer.man.taSTL.getCurrByBatch(BatchIdCurr);
+ if (currStack != null)
+ {
+ if (currStack.Count > 0)
+ {
+ int stackIdCurr = currStack[0].StackID;
+ DataLayer.man.taSHL.advanceInStack(stackIdCurr);
+ }
+ doUpdate();
+ cmp_stackNextloading.doUpdate();
+ // segnalo avanzamento su redis x pagina unload
+ ComLib.advaceSheetRevByBunk(BatchIdCurr);
+ raiseEvent();
+ }
+ }
+
+ protected void lbtAdvanceBunk_Click(object sender, EventArgs e)
+ {
+ // simula invio barcode del PROSSIMO BUNK (SE necessario)
+ }
}
- }
}
\ No newline at end of file