using AppData; using NKC_SDK; using SteamWare; using System; using System.Text; namespace NKC_WF.WebUserControls { public partial class cmp_batchDetail : System.Web.UI.UserControl { public event EventHandler eh_doRefresh; protected void Page_Load(object sender, EventArgs e) { } public int BatchId { set { hfBatchId.Value = value.ToString(); frmView.DataBind(); if (memLayer.ML.CRB("enableMongo")) { // cerco da lista salvataggi Estim/Nest... var estimAnsw = ComLib.man.getEstAnsw(value); var nestAnsw = ComLib.man.getNestAnsw(value); StringBuilder sb = new StringBuilder(); if (estimAnsw != null) { try { sb.AppendLine($"ESTIM: EnvNum: {estimAnsw.EnvNum} | Worktime: {estimAnsw.EstimatedWorktime / 60:N2} min | Processing Runtime {estimAnsw.ProcessingRuntime / 60:N2} min | Parts #: {estimAnsw.PartList.Count}"); } catch { } } if (nestAnsw != null) { try { sb.AppendLine($"NEST: EnvNum: {nestAnsw.EnvNum} | Worktime: {nestAnsw.EstimatedWorktime / 60:N2} min | Processing Runtime {nestAnsw.ProcessingRuntime / 60:N2} min | Bunks #: {nestAnsw.BunkList.Count} | Carts #: {nestAnsw.CartList.Count}"); } catch { } } lblTestJson.Text = sb.Replace("\r\n", "
").ToString(); } } get { int answ = 0; int.TryParse(hfBatchId.Value, out answ); return answ; } } /// /// Controlla se lo stato sia uguale a quello richiesto /// /// /// /// public bool checkStatus(object _status, BatchStatus statusReq) { bool answ = false; int status = -1; int.TryParse(_status.ToString(), out status); answ = (status == (int)statusReq); return answ; } public bool canStartNew(object _status) { bool answ = false; // in primis controllo SE ci siano task running, nel qual caso è false e basta... int numEst = DataLayer.man.taBL.getByStatus((int)BatchStatus.EstimationRequested, "", 0).Count; int numNest = DataLayer.man.taBL.getByStatus((int)BatchStatus.NestRequested, "", 0).Count; answ = ((numEst + numNest) == 0); return answ; } /// /// Converte il codice stato in effettivo campo /// /// /// public string BStatus(object _status) { string answ = ComLib.BatchStatusDescr(_status); return answ; } protected void lbtAccept_Click(object sender, EventArgs e) { // registro accettazione Nesting DataLayer.man.taBL.acceptBatch(BatchId, DataLayer.man.CodSoggCurrUser); raiseEvent(); } protected void lbtStopEstim_Click(object sender, EventArgs e) { // !!!FIXME!!! inviare a redis... // registro su DB nesting iniziato... DataLayer.man.taBL.updateStatus(BatchId, (int)BatchStatus.Imported, "", -1); raiseEvent(); } protected void lbtSendEstim_Click(object sender, EventArgs e) { // invia a redis una richiesta... ComLib.sendMaterials(); ComLib.sendBatchReq(BatchId, "Estimation", 1); // registro su DB nesting iniziato... DataLayer.man.taBL.updateStatus(BatchId, (int)BatchStatus.EstimationRequested, "", 0); raiseEvent(); } protected void lbtStopNesting_Click(object sender, EventArgs e) { // !!!FIXME!!! inviare a redis... // registro su DB nesting iniziato... DataLayer.man.taBL.updateStatus(BatchId, (int)BatchStatus.EstimationDone, "", -1); raiseEvent(); } protected void lbtSendNesting_Click(object sender, EventArgs e) { // invia a redis a a richiesta... ComLib.sendMaterials(); ComLib.sendBatchReq(BatchId, "Nesting", 2); // registro su DB nesting iniziato... DataLayer.man.taBL.updateStatus(BatchId, (int)BatchStatus.NestRequested, "", -1); raiseEvent(); } private void raiseEvent() { // se qualcuno ascolta sollevo evento nuovo valore... if (eh_doRefresh != null) { eh_doRefresh(this, new EventArgs()); } } } }