From 69a2c01fffa5955280cdf376e581ab8e0b91ab9d Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 22 May 2020 12:58:40 +0200 Subject: [PATCH] Fix gestione reset operatore in post multi --- AppData/mUtils.cs | 352 +++-- C-TRACK/WebUserControls/mod_task2post.ascx.cs | 258 ++-- C-TRACK/barcode.aspx.cs | 1347 +++++++++-------- 3 files changed, 983 insertions(+), 974 deletions(-) diff --git a/AppData/mUtils.cs b/AppData/mUtils.cs index 49ed61a..729c0ca 100644 --- a/AppData/mUtils.cs +++ b/AppData/mUtils.cs @@ -2,188 +2,186 @@ namespace AppData { - public class mUtils - { - - #region definizione Regexp - /// - /// RegExp x Cod ARTICOLO - /// - public static string reCodArt = memLayer.ML.cdv("regExp_CodArt"); - /// - /// RegExp x Cod OPERATORE - /// - public static string reCodOper = memLayer.ML.cdv("regExp_CodOper"); - /// - /// RegExp x Cod POSTAZIONE - /// - public static string reCodPost = memLayer.ML.cdv("regExp_CodPost"); - /// - /// RegExp x Cod COMMESSA (NumTask) - /// - public static string reNumTask = memLayer.ML.cdv("regExp_NumTask"); - /// - /// RegExp x QTA - /// - public static string reQta = memLayer.ML.cdv("regExp_QtaRic"); - /// - /// RegExp x RESET / CANCEL - /// - public static string reReset = memLayer.ML.cdv("regExp_KO"); - /// - /// RegExp x CONFERMA ADD - /// - public static string reAddNew = memLayer.ML.cdv("regExp_AddNew"); - /// - /// RegExp x CONFERMA DELETE - /// - public static string reDelete = memLayer.ML.cdv("regExp_DEL"); - /// - /// Comando x RESET OPERATORE - /// - public static string reCmdResetOper = memLayer.ML.cdv("regExp_CmdResetOper"); - /// - /// Comando x RESET COMMESSA (NumTask) - /// - public static string reCmdResetNumTask = memLayer.ML.cdv("regExp_CmdResetNumTask"); - /// - /// Comando x PAUSA (es COMMESSA/NumTask) - /// - public static string reCmdPause = memLayer.ML.cdv("regExp_CmdPause"); - /// - /// Comando x CHIUSURA COMMESSA (NumTask) - /// - public static string reCmdClose = memLayer.ML.cdv("regExp_CmdClose"); - - - - /// - /// OPZIONE: indica che è abilitato BCode - /// - public static bool OptUseBCode = memLayer.ML.CRB("OptUseBCode"); - /// - /// OPZIONE: indica che è abilitata selezione TASK/COMMESSA - /// - public static bool OptUseSelTask = memLayer.ML.CRB("OptUseSelTask"); - /// - /// OPZIONE: indica che è abilitata selezione TAG - /// - public static bool OptUseSelTag = memLayer.ML.CRB("OptUseSelTag"); - - /// - /// OPZIONE: indica che è da eseguire il preprocessing - /// - public static bool OptBCodePrepDo = memLayer.ML.CRB("OptBCodePrepDo"); - /// - /// RegExp x Cod dati raw x preprocessare - /// - public static string rePreproc = memLayer.ML.cdv("regExp_Preproc"); - /// - /// RegExp x Cod dati da TENERE post preprocessing - /// - public static string rePreprocKeep = memLayer.ML.cdv("regExp_PreprocKeep"); - - #endregion - - /// - /// Codice Operatore - /// - public static string CodOpr + public class mUtils { - get - { - string answ = ""; - answ = memLayer.ML.StringSessionObj("CodOpr"); - // se vuoto cerco anche nei cookies... - if (answ == "") - { - answ = memLayer.ML.getCookieVal("CTrack_CodOpr"); - // se non vuoto salvo... - memLayer.ML.setSessionVal("CodOpr", answ); - } - return answ; - } - set - { - memLayer.ML.setSessionVal("CodOpr", value); - memLayer.ML.setCookieVal("CTrack_CodOpr", value); - memLayer.ML.emptySessionVal("NomeOpr"); - } - } - /// - /// Codice postazione di lavoro - /// - public static string CodPost - { - get - { - string answ = ""; - answ = memLayer.ML.StringSessionObj("CodPost"); - if (string.IsNullOrEmpty(answ)) - { - answ = memLayer.ML.getCookieVal("CTrack_CodPost"); - // se non vuoto salvo... - memLayer.ML.setSessionVal("CodPost", answ); - } - return answ; - } - set - { - memLayer.ML.setSessionVal("CodPost", value); - memLayer.ML.setCookieVal("CTrack_CodPost", value); - memLayer.ML.emptySessionVal("DescPost"); - } - } - /// - /// Restituisce boolean se post corrente sia multi operatore - /// - public static bool postIsMulti - { - get - { - bool answ = false; - if (memLayer.ML.isInSessionObject("postIsMulti")) - { - answ = memLayer.ML.BoolSessionObj("postIsMulti"); - } - else - { - string rawAnsw = memLayer.ML.getCookieVal("CTrack_postIsMulti"); - bool.TryParse(rawAnsw, out answ); - // se non vuoto salvo... - memLayer.ML.setSessionVal("postIsMulti", answ); - } - return answ; - } - set - { - memLayer.ML.setSessionVal("postIsMulti", value); - memLayer.ML.setCookieVal("CTrack_postIsMulti", value.ToString()); - } - } - /// - /// oggetto valore opzionale letto 8e scorporato da barcode), es TAG in commessa + tag - /// - public static string optValueBC - { - get - { - string answ; - if (memLayer.ML.isInSessionObject("optValueBC")) + #region definizione Regexp + /// + /// RegExp x Cod ARTICOLO + /// + public static string reCodArt = memLayer.ML.cdv("regExp_CodArt"); + /// + /// RegExp x Cod OPERATORE + /// + public static string reCodOper = memLayer.ML.cdv("regExp_CodOper"); + /// + /// RegExp x Cod POSTAZIONE + /// + public static string reCodPost = memLayer.ML.cdv("regExp_CodPost"); + /// + /// RegExp x Cod COMMESSA (NumTask) + /// + public static string reNumTask = memLayer.ML.cdv("regExp_NumTask"); + /// + /// RegExp x QTA + /// + public static string reQta = memLayer.ML.cdv("regExp_QtaRic"); + /// + /// RegExp x RESET / CANCEL + /// + public static string reReset = memLayer.ML.cdv("regExp_KO"); + /// + /// RegExp x CONFERMA ADD + /// + public static string reAddNew = memLayer.ML.cdv("regExp_AddNew"); + /// + /// RegExp x CONFERMA DELETE + /// + public static string reDelete = memLayer.ML.cdv("regExp_DEL"); + /// + /// Comando x RESET OPERATORE + /// + public static string reCmdResetOper = memLayer.ML.cdv("regExp_CmdResetOper"); + /// + /// Comando x RESET COMMESSA (NumTask) + /// + public static string reCmdResetNumTask = memLayer.ML.cdv("regExp_CmdResetNumTask"); + /// + /// Comando x PAUSA (es COMMESSA/NumTask) + /// + public static string reCmdPause = memLayer.ML.cdv("regExp_CmdPause"); + /// + /// Comando x CHIUSURA COMMESSA (NumTask) + /// + public static string reCmdClose = memLayer.ML.cdv("regExp_CmdClose"); + + /// + /// OPZIONE: indica che è abilitato BCode + /// + public static bool OptUseBCode = memLayer.ML.CRB("OptUseBCode"); + /// + /// OPZIONE: indica che è abilitata selezione TASK/COMMESSA + /// + public static bool OptUseSelTask = memLayer.ML.CRB("OptUseSelTask"); + /// + /// OPZIONE: indica che è abilitata selezione TAG + /// + public static bool OptUseSelTag = memLayer.ML.CRB("OptUseSelTag"); + + /// + /// OPZIONE: indica che è da eseguire il preprocessing + /// + public static bool OptBCodePrepDo = memLayer.ML.CRB("OptBCodePrepDo"); + /// + /// RegExp x Cod dati raw x preprocessare + /// + public static string rePreproc = memLayer.ML.cdv("regExp_Preproc"); + /// + /// RegExp x Cod dati da TENERE post preprocessing + /// + public static string rePreprocKeep = memLayer.ML.cdv("regExp_PreprocKeep"); + + #endregion + + /// + /// Codice Operatore + /// + public static string CodOpr { - answ = memLayer.ML.StringSessionObj("optValueBC"); + get + { + string answ = ""; + answ = memLayer.ML.StringSessionObj("CodOpr"); + // se vuoto cerco anche nei cookies... + if (answ == "") + { + answ = memLayer.ML.getCookieVal("CTrack_CodOpr"); + // se non vuoto salvo... + memLayer.ML.setSessionVal("CodOpr", answ); + } + return answ; + } + set + { + memLayer.ML.setSessionVal("CodOpr", value); + memLayer.ML.setCookieVal("CTrack_CodOpr", value); + memLayer.ML.emptySessionVal("NomeOpr"); + } } - else + /// + /// Codice postazione di lavoro + /// + public static string CodPost { - answ = ""; + get + { + string answ = ""; + answ = memLayer.ML.StringSessionObj("CodPost"); + if (string.IsNullOrEmpty(answ)) + { + answ = memLayer.ML.getCookieVal("CTrack_CodPost"); + // se non vuoto salvo... + memLayer.ML.setSessionVal("CodPost", answ); + } + return answ; + } + set + { + memLayer.ML.setSessionVal("CodPost", value); + memLayer.ML.setCookieVal("CTrack_CodPost", value); + memLayer.ML.emptySessionVal("DescPost"); + } + } + /// + /// Restituisce boolean se post corrente sia multi operatore + /// + public static bool postIsMulti + { + get + { + bool answ = false; + if (memLayer.ML.isInSessionObject("postIsMulti")) + { + answ = memLayer.ML.BoolSessionObj("postIsMulti"); + } + else + { + string rawAnsw = memLayer.ML.getCookieVal("CTrack_postIsMulti"); + bool.TryParse(rawAnsw, out answ); + // se non vuoto salvo... + memLayer.ML.setSessionVal("postIsMulti", answ); + } + return answ; + } + set + { + memLayer.ML.setSessionVal("postIsMulti", value); + memLayer.ML.setCookieVal("CTrack_postIsMulti", value.ToString()); + } + } + + /// + /// oggetto valore opzionale letto 8e scorporato da barcode), es TAG in commessa + tag + /// + public static string optValueBC + { + get + { + string answ; + if (memLayer.ML.isInSessionObject("optValueBC")) + { + answ = memLayer.ML.StringSessionObj("optValueBC"); + } + else + { + answ = ""; + } + return answ; + } + set + { + memLayer.ML.setSessionVal("optValueBC", value, false); + } } - return answ; - } - set - { - memLayer.ML.setSessionVal("optValueBC", value, false); - } } - } } diff --git a/C-TRACK/WebUserControls/mod_task2post.ascx.cs b/C-TRACK/WebUserControls/mod_task2post.ascx.cs index f038cee..7e46f71 100644 --- a/C-TRACK/WebUserControls/mod_task2post.ascx.cs +++ b/C-TRACK/WebUserControls/mod_task2post.ascx.cs @@ -7,142 +7,148 @@ using System.Web.UI.WebControls; namespace C_TRACK.WebUserControls { - public partial class mod_task2post : System.Web.UI.UserControl - { - /// - /// evento aggiunta record - /// - public event EventHandler eh_reqUpdate; - protected void Page_Load(object sender, EventArgs e) + public partial class mod_task2post : System.Web.UI.UserControl { - if (!Page.IsPostBack) - { - if (mUtils.postIsMulti) + /// + /// evento aggiunta record + /// + public event EventHandler eh_reqUpdate; + protected void Page_Load(object sender, EventArgs e) { - doUpdate(); + if (!Page.IsPostBack) + { + if (mUtils.postIsMulti) + { + doUpdate(); + } + } + } + public void doUpdate() + { + try + { + grView.DataBind(); + } + catch + { + logger.lg.scriviLog($"Eccezione in render gridView: CodPost = {memLayer.ML.StringSessionObj("CodPost")}"); + } + } + /// + /// Stato TASK da mostrare + /// + public bool taskIsActive + { + get + { + bool answ = false; + bool.TryParse(hfIsActive.Value, out answ); + return answ; + } + set + { + hfIsActive.Value = value.ToString(); + } + } + /// + /// Verifica se lo stato sia ATTIVO + /// + /// + /// + public bool checkActive(object _IsActive) + { + bool answ = false; + bool.TryParse(_IsActive.ToString(), out answ); + return answ; + } + /// + /// CodPost selezionato in sessione + /// + protected string codPost + { + get + { + return memLayer.ML.StringSessionObj("CodPost"); + } } - } - } - public void doUpdate() - { - grView.DataBind(); - } - /// - /// Stato TASK da mostrare - /// - public bool taskIsActive - { - get - { - bool answ = false; - bool.TryParse(hfIsActive.Value, out answ); - return answ; - } - set - { - hfIsActive.Value = value.ToString(); - } - } - /// - /// Verifica se lo stato sia ATTIVO - /// - /// - /// - public bool checkActive(object _IsActive) - { - bool answ = false; - bool.TryParse(_IsActive.ToString(), out answ); - return answ; - } - /// - /// CodPost selezionato in sessione - /// - protected string codPost - { - get - { - return memLayer.ML.StringSessionObj("CodPost"); - } - } + protected void grView_SelectedIndexChanged(object sender, EventArgs e) + { + string numTask = grView.SelectedValue.ToString(); + // chiamo toggle status, segnalo update! + dataLayer.man.taTL2Post.ToggleActive(codPost, numTask); + reportUpdate(); + } - protected void grView_SelectedIndexChanged(object sender, EventArgs e) - { - string numTask = grView.SelectedValue.ToString(); - // chiamo toggle status, segnalo update! - dataLayer.man.taTL2Post.ToggleActive(codPost, numTask); - reportUpdate(); - } + protected void grView_RowDeleted(object sender, GridViewDeletedEventArgs e) + { + reportUpdate(); + } - protected void grView_RowDeleted(object sender, GridViewDeletedEventArgs e) - { - reportUpdate(); - } + private void reportUpdate() + { + // invoco update... + if (eh_reqUpdate != null) + { + eh_reqUpdate(this, new EventArgs()); + } + } - private void reportUpdate() - { - // invoco update... - if (eh_reqUpdate != null) - { - eh_reqUpdate(this, new EventArgs()); - } - } + /// + /// Input da processare (tipo codOperatore...)... + /// + public string newInput + { + set + { + processInput(value); + } + } - /// - /// Input da processare (tipo codOperatore...)... - /// - public string newInput - { - set - { - processInput(value); - } - } + /// + /// Cod OPERATORE corrente + /// + public string NumTask + { + get + { + return memLayer.ML.StringSessionObj("currNumTaskMulti"); + } + set + { + memLayer.ML.setSessionVal("currNumTaskMulti", value); + } + } + /// + /// Effettua riconoscimento input e determina valori commessa / articolo / qta + /// + /// + private void processInput(string value) + { + // verifico se sia un operatore... + Match testNumTask = Regex.Match(value, mUtils.reNumTask); - /// - /// Cod OPERATORE corrente - /// - public string NumTask - { - get - { - return memLayer.ML.StringSessionObj("currNumTaskMulti"); - } - set - { - memLayer.ML.setSessionVal("currNumTaskMulti", value); - } - } - /// - /// Effettua riconoscimento input e determina valori commessa / articolo / qta - /// - /// - private void processInput(string value) - { - // verifico se sia un operatore... - Match testNumTask = Regex.Match(value, mUtils.reNumTask); + if (testNumTask.Success) + { + NumTask = value; + string codTag = mUtils.optValueBC != "" ? mUtils.optValueBC : ""; + dataLayer.man.taTL2Post.InsertQuery(codPost, NumTask, codTag); + reportUpdate(); + } + doUpdate(); + } - if (testNumTask.Success) - { - NumTask = value; - string codTag = mUtils.optValueBC != "" ? mUtils.optValueBC : ""; - dataLayer.man.taTL2Post.InsertQuery(codPost, NumTask, codTag); - reportUpdate(); - } - doUpdate(); - } + protected void grView_RowUpdated(object sender, GridViewUpdatedEventArgs e) + { + reportUpdate(); + } - protected void grView_RowUpdated(object sender, GridViewUpdatedEventArgs e) - { - reportUpdate(); + public bool showTag + { + get + { + return memLayer.ML.CRB("OptUseSelTag"); + } + } } - - public bool showTag - { - get - { - return memLayer.ML.CRB("OptUseSelTag"); - } - } - } } \ No newline at end of file diff --git a/C-TRACK/barcode.aspx.cs b/C-TRACK/barcode.aspx.cs index e5a2584..bd0a679 100644 --- a/C-TRACK/barcode.aspx.cs +++ b/C-TRACK/barcode.aspx.cs @@ -9,702 +9,707 @@ using System.Web.UI; namespace C_TRACK { - public partial class barcode : System.Web.UI.Page - { - /// - /// idxRec della fase attiva - /// - public int idxRecCurr + public partial class barcode : System.Web.UI.Page { - get - { - return memLayer.ML.IntSessionObj("idxRecCurr"); - } - } - /// - /// Qta della fase attiva - /// - public int QtaFaseCurr - { - get - { - return memLayer.ML.IntSessionObj("QtaFaseCurr"); - } - } - /// - /// Codice TASK corrente - /// - public string CurrNumTask - { - get - { - return memLayer.ML.StringSessionObj("CurrNumTask"); - } - set - { - memLayer.ML.setSessionVal("CurrNumTask", value); - // cerco articolo e lo salvo... - string CurrCodArt = ""; - try + /// + /// idxRec della fase attiva + /// + public int idxRecCurr { - CurrCodArt = dataLayer.man.taTL.getByKey(value)[0].CodArt; - } - catch - { } - memLayer.ML.setSessionVal("CurrCodArt", CurrCodArt); - - } - } - /// - /// Codice TAG corrente - /// - public string CurrCodTag - { - get - { - // se è visibile il modulo restituisco val selezionato altrimenti vuoto... - return mod_selTag.Visible ? mod_selTag.CodTag : ""; - } - set - { - mod_selTag.CodTag = value; - } - } - protected void Page_Load(object sender, EventArgs e) - { - // Crea stopwatch. - Stopwatch stopwatch = new Stopwatch(); - // Avvio... - stopwatch.Start(); - checkVisib(); - if (!Page.IsPostBack) - { - traduciObj(); - numDD = memLayer.ML.CRI("numDD"); - cacheValSec = memLayer.ML.CRI("cacheValSec"); - divReload.Visible = devicesAuthProxy.stObj.userHasRight("CT_userStart"); - setTipoTaskSel(); - } - checkRequisiti(); - // effettuo load valori... - setupComandiBarcode(); - setupValoriBarcode(); - // a seconda di pagina singola o multi determino come procedere con comani / dati grezzi... - if (mUtils.postIsMulti) - { - // gestiosco segnali "grezzi" - mod_barcode1.eh_dataRead += Mod_barcode_eh_dataRead; - mod_postMulti.eh_reqUpdate += Mod_postMulti_eh_reqUpdate; - } - else - { - // registro eventi - mod_barcode1.eh_comandoRegistrato += new EventHandler(Mod_barcode_eh_comandoRegistrato); - mod_btnComandi1.eh_clickComando += new EventHandler(mod_btnComandi1_eh_clickComando); - } - mod_selTask.eh_dataSel += Mod_selTask_eh_dataSel; - // registro - stopwatch.Stop(); - lastUpdDuration = stopwatch.Elapsed; - } - - private void Mod_postMulti_eh_reqUpdate(object sender, EventArgs e) - { - setTipoTaskSel(); - // aggiorna eleco task... - mod_taskRec.doUpdate(); - } - - private void setTipoTaskSel() - { - // in base al tipo di postazione è per user o per post multi - if (mUtils.postIsMulti) - { - mod_taskRec.tipoSelezione = WebUserControls.selType.byPostMulti; - } - else - { - mod_taskRec.tipoSelezione = WebUserControls.selType.byUser; - } - } - - private void Mod_selTask_eh_dataSel(object sender, EventArgs e) - { - // selezione commessa --> chiamo metodo caricamento comandi in modulo barcode... - mod_barcode1.loadBtnClickComando(); - // refresh master... - ((WebMasterPages.Bootstrap)this.Master).doUpdate(); - } - - /// - /// Verifica visibilità componenti bcode e selettore... - /// - private void checkVisib() - { - mod_barcode1.Visible = mUtils.OptUseBCode; - mod_selTask.Visible = mUtils.OptUseSelTask; - // per i tags NON DEVE essere una post multi e DEVE esserci una comemssa... - mod_selTag.Visible = mUtils.OptUseSelTag && !mUtils.postIsMulti && CurrNumTask != ""; - // se ho in pancia la selezione di un opzione ed è visibile tag --> seleziono! - if (mUtils.OptBCodePrepDo && mod_selTag.Visible) - { - // SE HO in memoria... - if (mUtils.optValueBC != "") - { - try - { - // seleziono - mod_selTag.PrevCodTag = mUtils.optValueBC; - } - catch - { } - //...e tolgo valore preselezione - mUtils.optValueBC = ""; - } - } - } - - /// - /// Verifica i requisiti (operatore e postazione) per operare - /// - private void checkRequisiti() - { - mod_btnComandi1.Visible = (mUtils.CodOpr != "" && mUtils.CodPost != ""); - // ora controllo SE SIA una postazione multi e di conseguenza imposto div relativi... - showMulti = mUtils.postIsMulti; - } - - protected bool showMulti - { - set - { - divMulti.Visible = value; - mod_postMulti.Visible = value; - divMain.Attributes.Remove("class"); - divMain.Attributes.Add("class", value ? "col-12 col-xl-9" : "col-12"); - } - } - - /// - /// Numero comandi ammessi caricati - /// - public int nComandi - { - get - { - return comandiAmmessiBCode.Count; - } - } - /// - /// Numero record BCode caricati - /// - public int nBCodeRec - { - get - { - return valoriAmmessiBCode.Count; - } - } - /// - /// Memorizzo durata ultimo update (lettura record...) come timespan - /// - public TimeSpan lastUpdDuration - { - get - { - return (TimeSpan)memLayer.ML.objSessionObj("lastUpdDuration"); - } - set - { - memLayer.ML.setSessionVal("lastUpdDuration", value); - } - } - /// - /// inviato un comando dai link buttons - /// - /// - /// - void mod_btnComandi1_eh_clickComando(object sender, EventArgs e) - { - // chiamo metodo caricamento comandi in modulo barcode... - mod_barcode1.loadBtnClickComando(); - } - - private void traduciObj() - { - } - /// - /// imposta/recupera valore num gg da rileggere... - /// - public int numDD - { - get - { - int answ = 85; - try - { - answ = Convert.ToInt32(txtNumDD.Text.Trim()); - } - catch - { } - return answ; - } - set - { - txtNumDD.Text = value.ToString(); - } - } - /// - /// logLevel impostato... - /// - public int logLevel - { - get - { - int answ = 1; - try - { - answ = memLayer.ML.CRI("_logLevel"); - } - catch - { } - return answ; - } - } - /// - /// imposta/recupera valore num sec validità cache... - /// - public int cacheValSec - { - get - { - int answ = 55; - try - { - answ = Convert.ToInt32(txtCacheSec.Text.Trim()); - } - catch - { } - - return answ; - } - set - { - txtCacheSec.Text = value.ToString(); - } - } - /// - /// Variabile x controllo scadenza valori in cache - /// - protected DateTime lastDataRefresh - { - get - { - DateTime answ = DateTime.Now.AddDays(-1); - try - { - answ = Convert.ToDateTime(memLayer.ML.objCacheObj("lastBCodeDataRead")); - } - catch - { } - return answ; - } - set - { - // registro che i valori in cache sono scaduti... - memLayer.ML.setCacheVal("lastBCodeDataRead", value); - if (logLevel > 5) - { - logger.lg.scriviLog("impostata validita cache"); - } - } - } - protected bool cacheValida - { - get - { - bool answ = false; - try - { - if (DateTime.Now.Subtract(lastDataRefresh).TotalSeconds < cacheValSec) - { - answ = true; - } - } - catch - { } - return answ; - } - } - /// - /// Elenco (da cache) dei valori ammessi x BCode - /// - protected Dictionary valoriAmmessiBCode - { - get - { - Dictionary answ = new Dictionary(); - bool valIncache = memLayer.ML.isInCacheObject("valoriAmmessiBCode"); - if (valIncache && cacheValida) - { - answ = JsonConvert.DeserializeObject>(memLayer.ML.objCacheObj("valoriAmmessiBCode").ToString()); - } - return answ; - } - set - { - string serVal = JsonConvert.SerializeObject(value); - memLayer.ML.setCacheVal("valoriAmmessiBCode", serVal); - lastDataRefresh = DateTime.Now; - } - } - /// - /// Elenco (da cache) dei comandi ammessi x BCode - /// - protected Dictionary comandiAmmessiBCode - { - get - { - Dictionary answ = new Dictionary(); - if (memLayer.ML.isInCacheObject("comandiAmmessiBCode")) - { - try - { - answ = JsonConvert.DeserializeObject>(memLayer.ML.objCacheObj("comandiAmmessiBCode").ToString()); - } - catch - { - answ = new Dictionary(); - } - } - return answ; - } - set - { - string serVal = JsonConvert.SerializeObject(value); - memLayer.ML.setCacheVal("comandiAmmessiBCode", serVal); - lastDataRefresh = DateTime.Now; - } - } - /// - /// effettuo il setup dei valori ammessi x il barcode... - /// - private void setupValoriBarcode() - { - if (valoriAmmessiBCode.Count > 0) - { - // assegno valori al barcode... - mod_barcode1.tabValori = valoriAmmessiBCode; - if (logLevel > 5) - { - logger.lg.scriviLog("Letti da cache VALORI Barcode", tipoLog.INFO); - } - } - else - { - // Crea stopwatch. - Stopwatch stopwatch = new Stopwatch(); - // Avvio... - stopwatch.Start(); - // carico dati! - if (logLevel > 5) - { - logger.lg.scriviLog("Inizio setup valori Barcode", tipoLog.INFO); - } - - Dictionary valori = new Dictionary(); - - // aggiungo i COD OPERATORE - var tabOpr = dataLayer.man.taAO.GetData(); - foreach (var rigaOpr in tabOpr) - { - valori.Add(rigaOpr.CodOpr, string.Format("{0} {1}", rigaOpr.Cognome, rigaOpr.Nome)); - } - if (logLevel > 5) - { - logger.lg.scriviLog("Caricato OPERATORI per Barcode", tipoLog.INFO); - } - - // aggiungo le POSTAZIONI - var tabPost = dataLayer.man.taAP.GetData(); - foreach (var rigaPost in tabPost) - { - valori.Add(rigaPost.CodPost, rigaPost.Descrizione); - } - if (logLevel > 5) - { - logger.lg.scriviLog("Caricato POSTAZIONI per Barcode", tipoLog.INFO); - } - // aggiungo le commesse... - var tabTask = dataLayer.man.taTL.getLastNumDD(numDD); - foreach (var rigaTask in tabTask) - { - valori.Add(rigaTask.NumTask, string.Format("Comm. {0} | Art. {1} | Qta {2}", rigaTask.NumTask, rigaTask.CodArt, rigaTask.QtaRic)); - } - if (logLevel > 5) - { - logger.lg.scriviLog("Caricato TaskList per Barcode", tipoLog.INFO); - } - // assegno valori al barcode... - mod_barcode1.tabValori = valori; - valoriAmmessiBCode = valori; - lastDataRefresh = DateTime.Now; - logger.lg.scriviLog("Letti da DB VALORI Barcode", tipoLog.INFO); - stopwatch.Start(); - lastUpdDuration = stopwatch.Elapsed; - } - } - /// - /// carico da tab i comandi ammessi per il barcode... - /// - private void setupComandiBarcode() - { - if (comandiAmmessiBCode.Count > 0) - { - // assegno valori al barcode... - mod_barcode1.comandiAmmessi = comandiAmmessiBCode; - if (logLevel > 5) - { - logger.lg.scriviLog("Letti da cache COMANDI Barcode", tipoLog.INFO); - } - } - else - { - Dictionary comandi = new Dictionary(); - - // !!!FARE!!! togliere... - var tabCmd = dataLayer.man.taTE2S.getByMappa("E_BC"); - foreach (var rigaCmd in tabCmd) - { - comandi.Add(rigaCmd.CodEvento.ToUpper(), devicesAuthProxy.stObj.traduci(rigaCmd.text2show)); - } - - - var tabFasi = dataLayer.man.taAF.GetData(); - foreach (var rigaFase in tabFasi) - { - comandi.Add(rigaFase.CodFase, rigaFase.DescrFase); - } - - // impongo i comandi al barcode... - mod_barcode1.comandiAmmessi = comandi; - comandiAmmessiBCode = comandi; - logger.lg.scriviLog("Letti da DB COMANDI Barcode", tipoLog.INFO); - } - } - /// - /// il barcode ha registrato un evento... - /// - /// - /// - void Mod_barcode_eh_dataRead(object sender, EventArgs e) - { - // passo il processing al modulo postMulti... - mod_postMulti.processInput(mod_barcode1.rawInput); - } - /// - /// il barcode ha registrato un evento... - /// - /// - /// - void Mod_barcode_eh_comandoRegistrato(object sender, EventArgs e) - { - switch (stateMachine.st.azioneComando(mod_barcode1.comandoRegistrato)) - { - case tipoAzione.annulla: - mod_barcode1.resetMe(); - break; - case tipoAzione.conferma: - // se input completo eseguo... - if (mod_barcode1.comandoRegistrato.currCmdIn != "" && mod_barcode1.comandoRegistrato.valore != "") - { - eseguiComando(); - } - else // altrimenti warning... e rimetto valori precedenti - { - mod_barcode1.txtRich2show = user_std.UtSn.Traduci("codObjUnknown"); - mod_barcode1.comandoRegistrato.currCmdIn = mod_barcode1.comandoRegistrato.prevCmdIn; - mod_barcode1.comandoRegistrato.descrComando = mod_barcode1.comandoRegistrato.descrComandoPrev; - mod_barcode1.txtInput2show = mod_barcode1.comandoRegistrato.descrComandoPrev; - } - break; - case tipoAzione.esegui: - // se ho auto conferma eseguo! - if (memLayer.ML.CRB("autoConfCmd")) - { - mod_barcode1.comandoRegistrato.prevCmdIn = mod_barcode1.comandoRegistrato.currCmdIn; - mod_barcode1.comandoRegistrato.currCmdIn = "ok"; - eseguiComando(); - } - else - { - if (mod_barcode1.comandoRegistrato.valore != "") + get { - mod_barcode1.txtRich2show = user_std.UtSn.Traduci("pleaseConfirm"); + return memLayer.ML.IntSessionObj("idxRecCurr"); + } + } + /// + /// Qta della fase attiva + /// + public int QtaFaseCurr + { + get + { + return memLayer.ML.IntSessionObj("QtaFaseCurr"); + } + } + /// + /// Codice TASK corrente + /// + public string CurrNumTask + { + get + { + return memLayer.ML.StringSessionObj("CurrNumTask"); + } + set + { + memLayer.ML.setSessionVal("CurrNumTask", value); + // cerco articolo e lo salvo... + string CurrCodArt = ""; + try + { + CurrCodArt = dataLayer.man.taTL.getByKey(value)[0].CodArt; + } + catch + { } + memLayer.ML.setSessionVal("CurrCodArt", CurrCodArt); + + } + } + /// + /// Codice TAG corrente + /// + public string CurrCodTag + { + get + { + // se è visibile il modulo restituisco val selezionato altrimenti vuoto... + return mod_selTag.Visible ? mod_selTag.CodTag : ""; + } + set + { + mod_selTag.CodTag = value; + } + } + protected void Page_Load(object sender, EventArgs e) + { + // Crea stopwatch. + Stopwatch stopwatch = new Stopwatch(); + // Avvio... + stopwatch.Start(); + checkVisib(); + if (!Page.IsPostBack) + { + traduciObj(); + numDD = memLayer.ML.CRI("numDD"); + cacheValSec = memLayer.ML.CRI("cacheValSec"); + divReload.Visible = devicesAuthProxy.stObj.userHasRight("CT_userStart"); + setTipoTaskSel(); + } + checkRequisiti(); + // effettuo load valori... + setupComandiBarcode(); + setupValoriBarcode(); + // a seconda di pagina singola o multi determino come procedere con comani / dati grezzi... + if (mUtils.postIsMulti) + { + // gestiosco segnali "grezzi" + mod_barcode1.eh_dataRead += Mod_barcode_eh_dataRead; + mod_postMulti.eh_reqUpdate += Mod_postMulti_eh_reqUpdate; + // SE fosse un reset ESEGUO comando!!! + if (mod_barcode1.comandoRegistrato.prevCmdIn == mUtils.reCmdResetOper) + { + eseguiComando(); + } } else { - mod_barcode1.txtRich2show = user_std.UtSn.Traduci("codObjUnknown"); + // registro eventi + mod_barcode1.eh_comandoRegistrato += new EventHandler(Mod_barcode_eh_comandoRegistrato); + mod_btnComandi1.eh_clickComando += new EventHandler(mod_btnComandi1_eh_clickComando); } - } - break; - case tipoAzione.noAct: - break; - default: - break; - } - mod_btnComandi1.updateBtn(); - } - /// - /// eseguo il comando - /// - private void eseguiComando() - { - // in primis: sono in esecuzione, x cui il comando è valido... - string msg2show = ""; - Match testNumTask = Regex.Match(mod_barcode1.comandoRegistrato.valore, mUtils.reNumTask); - Match testOper = Regex.Match(mod_barcode1.comandoRegistrato.valore, mUtils.reCodOper); - Match testPost = Regex.Match(mod_barcode1.comandoRegistrato.valore, mUtils.reCodPost); + mod_selTask.eh_dataSel += Mod_selTask_eh_dataSel; + // registro + stopwatch.Stop(); + lastUpdDuration = stopwatch.Elapsed; + } - // verifico se cmd setup utente... - if (mod_barcode1.comandoRegistrato.prevCmdIn == mUtils.reCmdResetOper) - { - // rimuovo OPR da POST occupate - dataLayer.man.taAP.resetOpr(mUtils.CodOpr); - // rimuovo OPR da sessione - mUtils.CodOpr = ""; - // rimuovo post corrente... - mUtils.CodPost = ""; - // rimuovo MULTI - mUtils.postIsMulti = false; - // rimuovo COMMESSA - CurrNumTask = ""; - // rimuovo eventuale val opzionale - mUtils.optValueBC = ""; - // torno a pagina base... - Response.Redirect("~/barcode"); - } - else if (mod_barcode1.comandoRegistrato.prevCmdIn == mUtils.reCmdResetNumTask) - { - // rimuovo COMMESSA - CurrNumTask = ""; - // rimuovo eventuale val opzionale - mUtils.optValueBC = ""; - // torno a pagina base... - Response.Redirect("~/barcode"); - } - //else if (mod_barcode1.comandoRegistrato.valore.Contains("OPR.")) - else if (testOper.Success) - { - // imposto operatore - mUtils.CodOpr = mod_barcode1.comandoRegistrato.valore; - // SE HO postazione... - if (mUtils.CodPost != "") + private void Mod_postMulti_eh_reqUpdate(object sender, EventArgs e) { - // ...e SE la postazione è libera associo e registro - var tabPost = dataLayer.man.taAP.getByKey(mUtils.CodPost); - if (tabPost.Rows.Count == 1) - { - var rigaPost = tabPost[0]; - if (rigaPost.CodOpr == mUtils.CodOpr || rigaPost.CodOpr == "") + setTipoTaskSel(); + // aggiorna eleco task... + mod_taskRec.doUpdate(); + } + + private void setTipoTaskSel() + { + // in base al tipo di postazione è per user o per post multi + if (mUtils.postIsMulti) { - dataLayer.man.taAP.setOpr(mUtils.CodPost, mUtils.CodOpr); + mod_taskRec.tipoSelezione = WebUserControls.selType.byPostMulti; } else { - // tolgo postazione (è occupata...) - mUtils.CodPost = ""; + mod_taskRec.tipoSelezione = WebUserControls.selType.byUser; } - } } - Response.Redirect("~/barcode"); - } - else if (testPost.Success) - { - // SE HO operatore ... - if (mUtils.CodOpr != "") + + private void Mod_selTask_eh_dataSel(object sender, EventArgs e) { - // ...e SE la postazione è libera o c'è lui associo e registro - var tabPost = dataLayer.man.taAP.getByKey(mod_barcode1.comandoRegistrato.valore); - if (tabPost.Rows.Count == 1) - { - var rigaPost = tabPost[0]; - if (rigaPost.CodOpr == mUtils.CodOpr || rigaPost.CodOpr == "") + // selezione commessa --> chiamo metodo caricamento comandi in modulo barcode... + mod_barcode1.loadBtnClickComando(); + // refresh master... + ((WebMasterPages.Bootstrap)this.Master).doUpdate(); + } + + /// + /// Verifica visibilità componenti bcode e selettore... + /// + private void checkVisib() + { + mod_barcode1.Visible = mUtils.OptUseBCode; + mod_selTask.Visible = mUtils.OptUseSelTask; + // per i tags NON DEVE essere una post multi e DEVE esserci una comemssa... + mod_selTag.Visible = mUtils.OptUseSelTag && !mUtils.postIsMulti && CurrNumTask != ""; + // se ho in pancia la selezione di un opzione ed è visibile tag --> seleziono! + if (mUtils.OptBCodePrepDo && mod_selTag.Visible) { - mUtils.CodPost = mod_barcode1.comandoRegistrato.valore; - dataLayer.man.taAP.setOpr(mUtils.CodPost, mUtils.CodOpr); - // svuoto vallori + // SE HO in memoria... + if (mUtils.optValueBC != "") + { + try + { + // seleziono + mod_selTag.PrevCodTag = mUtils.optValueBC; + } + catch + { } + //...e tolgo valore preselezione + mUtils.optValueBC = ""; + } } - } } - Response.Redirect("~/barcode"); - } - else if (testNumTask.Success) - { - CurrNumTask = mod_barcode1.comandoRegistrato.valore; - Response.Redirect("~/barcode"); - } - else if (mod_barcode1.comandoRegistrato.prevCmdIn == mUtils.reCmdPause) - { - // registro chiusura con qta 0 (pausa) - dataLayer.man.taTR.updateQuery(idxRecCurr, DateTime.Now, 0); - Response.Redirect("~/barcode"); - } - else if (mod_barcode1.comandoRegistrato.prevCmdIn == mUtils.reCmdClose) - { - // registro chiusura con la qta indicata - dataLayer.man.taTR.updateQuery(idxRecCurr, DateTime.Now, QtaFaseCurr); - Response.Redirect("~/barcode"); - } - else if (dataLayer.man.taAF.getByKey(mod_barcode1.comandoRegistrato.prevCmdIn).Rows.Count > 0) - { - // se è un comando di fase --> registro INIZIO! - dataLayer.man.taTR.insertQuery(mUtils.CodOpr, mUtils.CodPost, CurrNumTask, CurrCodTag, mod_barcode1.comandoRegistrato.prevCmdIn, DateTime.Now); - // controllo se sia fase di CHIUSURA DEFINITIVA registro con INIZIO e FINE insieme e CHIUDO commessa... - var rigaFase = dataLayer.man.taAF.getByKey(mod_barcode1.comandoRegistrato.prevCmdIn)[0]; - if (rigaFase.CloseTask) + + /// + /// Verifica i requisiti (operatore e postazione) per operare + /// + private void checkRequisiti() { - // chiudo direttamente SIA fase che il TASK principale... - dataLayer.man.taTL.updateClose(CurrNumTask, true); - // se è abilitato PODL indico chiuso anche li... IdxOdl = -10 - - // tolgo comm corrente... - CurrNumTask = ""; - // rimuovo eventuale val opzionale - mUtils.optValueBC = ""; + mod_btnComandi1.Visible = (mUtils.CodOpr != "" && mUtils.CodPost != ""); + // ora controllo SE SIA una postazione multi e di conseguenza imposto div relativi... + showMulti = mUtils.postIsMulti; } - Response.Redirect("~/barcode"); - } - // reset e mostro output... - mod_barcode1.resetMe(); - if (msg2show != "") - { - mod_barcode1.txtInput2show = msg2show; - } - } - protected void btnReload_Click(object sender, EventArgs e) - { - resetCache(); - } + protected bool showMulti + { + set + { + divMulti.Visible = value; + mod_postMulti.Visible = value; + divMain.Attributes.Remove("class"); + divMain.Attributes.Add("class", value ? "col-12 col-xl-9" : "col-12"); + } + } - private void resetCache() - { - // resetto tutto! - comandiAmmessiBCode = new Dictionary(); - valoriAmmessiBCode = new Dictionary(); - lastDataRefresh = DateTime.Now.AddDays(-1); - } + /// + /// Numero comandi ammessi caricati + /// + public int nComandi + { + get + { + return comandiAmmessiBCode.Count; + } + } + /// + /// Numero record BCode caricati + /// + public int nBCodeRec + { + get + { + return valoriAmmessiBCode.Count; + } + } + /// + /// Memorizzo durata ultimo update (lettura record...) come timespan + /// + public TimeSpan lastUpdDuration + { + get + { + return (TimeSpan)memLayer.ML.objSessionObj("lastUpdDuration"); + } + set + { + memLayer.ML.setSessionVal("lastUpdDuration", value); + } + } + /// + /// inviato un comando dai link buttons + /// + /// + /// + void mod_btnComandi1_eh_clickComando(object sender, EventArgs e) + { + // chiamo metodo caricamento comandi in modulo barcode... + mod_barcode1.loadBtnClickComando(); + } - protected void txtCacheSec_TextChanged(object sender, EventArgs e) - { - resetCache(); - } + private void traduciObj() + { + } + /// + /// imposta/recupera valore num gg da rileggere... + /// + public int numDD + { + get + { + int answ = 85; + try + { + answ = Convert.ToInt32(txtNumDD.Text.Trim()); + } + catch + { } + return answ; + } + set + { + txtNumDD.Text = value.ToString(); + } + } + /// + /// logLevel impostato... + /// + public int logLevel + { + get + { + int answ = 1; + try + { + answ = memLayer.ML.CRI("_logLevel"); + } + catch + { } + return answ; + } + } + /// + /// imposta/recupera valore num sec validità cache... + /// + public int cacheValSec + { + get + { + int answ = 55; + try + { + answ = Convert.ToInt32(txtCacheSec.Text.Trim()); + } + catch + { } - protected void txtNumDD_TextChanged(object sender, EventArgs e) - { - resetCache(); + return answ; + } + set + { + txtCacheSec.Text = value.ToString(); + } + } + /// + /// Variabile x controllo scadenza valori in cache + /// + protected DateTime lastDataRefresh + { + get + { + DateTime answ = DateTime.Now.AddDays(-1); + try + { + answ = Convert.ToDateTime(memLayer.ML.objCacheObj("lastBCodeDataRead")); + } + catch + { } + return answ; + } + set + { + // registro che i valori in cache sono scaduti... + memLayer.ML.setCacheVal("lastBCodeDataRead", value); + if (logLevel > 5) + { + logger.lg.scriviLog("impostata validita cache"); + } + } + } + protected bool cacheValida + { + get + { + bool answ = false; + try + { + if (DateTime.Now.Subtract(lastDataRefresh).TotalSeconds < cacheValSec) + { + answ = true; + } + } + catch + { } + return answ; + } + } + /// + /// Elenco (da cache) dei valori ammessi x BCode + /// + protected Dictionary valoriAmmessiBCode + { + get + { + Dictionary answ = new Dictionary(); + bool valIncache = memLayer.ML.isInCacheObject("valoriAmmessiBCode"); + if (valIncache && cacheValida) + { + answ = JsonConvert.DeserializeObject>(memLayer.ML.objCacheObj("valoriAmmessiBCode").ToString()); + } + return answ; + } + set + { + string serVal = JsonConvert.SerializeObject(value); + memLayer.ML.setCacheVal("valoriAmmessiBCode", serVal); + lastDataRefresh = DateTime.Now; + } + } + /// + /// Elenco (da cache) dei comandi ammessi x BCode + /// + protected Dictionary comandiAmmessiBCode + { + get + { + Dictionary answ = new Dictionary(); + if (memLayer.ML.isInCacheObject("comandiAmmessiBCode")) + { + try + { + answ = JsonConvert.DeserializeObject>(memLayer.ML.objCacheObj("comandiAmmessiBCode").ToString()); + } + catch + { + answ = new Dictionary(); + } + } + return answ; + } + set + { + string serVal = JsonConvert.SerializeObject(value); + memLayer.ML.setCacheVal("comandiAmmessiBCode", serVal); + lastDataRefresh = DateTime.Now; + } + } + /// + /// effettuo il setup dei valori ammessi x il barcode... + /// + private void setupValoriBarcode() + { + if (valoriAmmessiBCode.Count > 0) + { + // assegno valori al barcode... + mod_barcode1.tabValori = valoriAmmessiBCode; + if (logLevel > 5) + { + logger.lg.scriviLog("Letti da cache VALORI Barcode", tipoLog.INFO); + } + } + else + { + // Crea stopwatch. + Stopwatch stopwatch = new Stopwatch(); + // Avvio... + stopwatch.Start(); + // carico dati! + if (logLevel > 5) + { + logger.lg.scriviLog("Inizio setup valori Barcode", tipoLog.INFO); + } + + Dictionary valori = new Dictionary(); + + // aggiungo i COD OPERATORE + var tabOpr = dataLayer.man.taAO.GetData(); + foreach (var rigaOpr in tabOpr) + { + valori.Add(rigaOpr.CodOpr, string.Format("{0} {1}", rigaOpr.Cognome, rigaOpr.Nome)); + } + if (logLevel > 5) + { + logger.lg.scriviLog("Caricato OPERATORI per Barcode", tipoLog.INFO); + } + + // aggiungo le POSTAZIONI + var tabPost = dataLayer.man.taAP.GetData(); + foreach (var rigaPost in tabPost) + { + valori.Add(rigaPost.CodPost, rigaPost.Descrizione); + } + if (logLevel > 5) + { + logger.lg.scriviLog("Caricato POSTAZIONI per Barcode", tipoLog.INFO); + } + // aggiungo le commesse... + var tabTask = dataLayer.man.taTL.getLastNumDD(numDD); + foreach (var rigaTask in tabTask) + { + valori.Add(rigaTask.NumTask, string.Format("Comm. {0} | Art. {1} | Qta {2}", rigaTask.NumTask, rigaTask.CodArt, rigaTask.QtaRic)); + } + if (logLevel > 5) + { + logger.lg.scriviLog("Caricato TaskList per Barcode", tipoLog.INFO); + } + // assegno valori al barcode... + mod_barcode1.tabValori = valori; + valoriAmmessiBCode = valori; + lastDataRefresh = DateTime.Now; + logger.lg.scriviLog("Letti da DB VALORI Barcode", tipoLog.INFO); + stopwatch.Start(); + lastUpdDuration = stopwatch.Elapsed; + } + } + /// + /// carico da tab i comandi ammessi per il barcode... + /// + private void setupComandiBarcode() + { + if (comandiAmmessiBCode.Count > 0) + { + // assegno valori al barcode... + mod_barcode1.comandiAmmessi = comandiAmmessiBCode; + if (logLevel > 5) + { + logger.lg.scriviLog("Letti da cache COMANDI Barcode", tipoLog.INFO); + } + } + else + { + Dictionary comandi = new Dictionary(); + + // !!!FARE!!! togliere... + var tabCmd = dataLayer.man.taTE2S.getByMappa("E_BC"); + foreach (var rigaCmd in tabCmd) + { + comandi.Add(rigaCmd.CodEvento.ToUpper(), devicesAuthProxy.stObj.traduci(rigaCmd.text2show)); + } + + + var tabFasi = dataLayer.man.taAF.GetData(); + foreach (var rigaFase in tabFasi) + { + comandi.Add(rigaFase.CodFase, rigaFase.DescrFase); + } + + // impongo i comandi al barcode... + mod_barcode1.comandiAmmessi = comandi; + comandiAmmessiBCode = comandi; + logger.lg.scriviLog("Letti da DB COMANDI Barcode", tipoLog.INFO); + } + } + /// + /// il barcode ha registrato un evento... + /// + /// + /// + void Mod_barcode_eh_dataRead(object sender, EventArgs e) + { + // passo il processing al modulo postMulti... + mod_postMulti.processInput(mod_barcode1.rawInput); + } + /// + /// il barcode ha registrato un evento... + /// + /// + /// + void Mod_barcode_eh_comandoRegistrato(object sender, EventArgs e) + { + switch (stateMachine.st.azioneComando(mod_barcode1.comandoRegistrato)) + { + case tipoAzione.annulla: + mod_barcode1.resetMe(); + break; + case tipoAzione.conferma: + // se input completo eseguo... + if (mod_barcode1.comandoRegistrato.currCmdIn != "" && mod_barcode1.comandoRegistrato.valore != "") + { + eseguiComando(); + } + else // altrimenti warning... e rimetto valori precedenti + { + mod_barcode1.txtRich2show = user_std.UtSn.Traduci("codObjUnknown"); + mod_barcode1.comandoRegistrato.currCmdIn = mod_barcode1.comandoRegistrato.prevCmdIn; + mod_barcode1.comandoRegistrato.descrComando = mod_barcode1.comandoRegistrato.descrComandoPrev; + mod_barcode1.txtInput2show = mod_barcode1.comandoRegistrato.descrComandoPrev; + } + break; + case tipoAzione.esegui: + // se ho auto conferma eseguo! + if (memLayer.ML.CRB("autoConfCmd")) + { + mod_barcode1.comandoRegistrato.prevCmdIn = mod_barcode1.comandoRegistrato.currCmdIn; + mod_barcode1.comandoRegistrato.currCmdIn = "ok"; + eseguiComando(); + } + else + { + if (mod_barcode1.comandoRegistrato.valore != "") + { + mod_barcode1.txtRich2show = user_std.UtSn.Traduci("pleaseConfirm"); + } + else + { + mod_barcode1.txtRich2show = user_std.UtSn.Traduci("codObjUnknown"); + } + } + break; + case tipoAzione.noAct: + break; + default: + break; + } + mod_btnComandi1.updateBtn(); + } + /// + /// eseguo il comando + /// + private void eseguiComando() + { + // in primis: sono in esecuzione, x cui il comando è valido... + string msg2show = ""; + Match testNumTask = Regex.Match(mod_barcode1.comandoRegistrato.valore, mUtils.reNumTask); + Match testOper = Regex.Match(mod_barcode1.comandoRegistrato.valore, mUtils.reCodOper); + Match testPost = Regex.Match(mod_barcode1.comandoRegistrato.valore, mUtils.reCodPost); + + // verifico se cmd setup utente... + if (mod_barcode1.comandoRegistrato.prevCmdIn == mUtils.reCmdResetOper) + { + // rimuovo OPR da POST occupate + dataLayer.man.taAP.resetOpr(mUtils.CodOpr); + // rimuovo OPR da sessione + mUtils.CodOpr = ""; + // rimuovo post corrente... + mUtils.CodPost = ""; + // rimuovo MULTI + mUtils.postIsMulti = false; + // rimuovo COMMESSA + CurrNumTask = ""; + // rimuovo eventuale val opzionale + mUtils.optValueBC = ""; + // torno a pagina base... + Response.Redirect("~/barcode"); + } + else if (mod_barcode1.comandoRegistrato.prevCmdIn == mUtils.reCmdResetNumTask) + { + // rimuovo COMMESSA + CurrNumTask = ""; + // rimuovo eventuale val opzionale + mUtils.optValueBC = ""; + // torno a pagina base... + Response.Redirect("~/barcode"); + } + //else if (mod_barcode1.comandoRegistrato.valore.Contains("OPR.")) + else if (testOper.Success) + { + // imposto operatore + mUtils.CodOpr = mod_barcode1.comandoRegistrato.valore; + // SE HO postazione... + if (mUtils.CodPost != "") + { + // ...e SE la postazione è libera associo e registro + var tabPost = dataLayer.man.taAP.getByKey(mUtils.CodPost); + if (tabPost.Rows.Count == 1) + { + var rigaPost = tabPost[0]; + if (rigaPost.CodOpr == mUtils.CodOpr || rigaPost.CodOpr == "") + { + dataLayer.man.taAP.setOpr(mUtils.CodPost, mUtils.CodOpr); + } + else + { + // tolgo postazione (è occupata...) + mUtils.CodPost = ""; + } + } + } + Response.Redirect("~/barcode"); + } + else if (testPost.Success) + { + // SE HO operatore ... + if (mUtils.CodOpr != "") + { + // ...e SE la postazione è libera o c'è lui associo e registro + var tabPost = dataLayer.man.taAP.getByKey(mod_barcode1.comandoRegistrato.valore); + if (tabPost.Rows.Count == 1) + { + var rigaPost = tabPost[0]; + if (rigaPost.CodOpr == mUtils.CodOpr || rigaPost.CodOpr == "") + { + mUtils.CodPost = mod_barcode1.comandoRegistrato.valore; + dataLayer.man.taAP.setOpr(mUtils.CodPost, mUtils.CodOpr); + // svuoto vallori + } + } + } + Response.Redirect("~/barcode"); + } + else if (testNumTask.Success) + { + CurrNumTask = mod_barcode1.comandoRegistrato.valore; + Response.Redirect("~/barcode"); + } + else if (mod_barcode1.comandoRegistrato.prevCmdIn == mUtils.reCmdPause) + { + // registro chiusura con qta 0 (pausa) + dataLayer.man.taTR.updateQuery(idxRecCurr, DateTime.Now, 0); + Response.Redirect("~/barcode"); + } + else if (mod_barcode1.comandoRegistrato.prevCmdIn == mUtils.reCmdClose) + { + // registro chiusura con la qta indicata + dataLayer.man.taTR.updateQuery(idxRecCurr, DateTime.Now, QtaFaseCurr); + Response.Redirect("~/barcode"); + } + else if (dataLayer.man.taAF.getByKey(mod_barcode1.comandoRegistrato.prevCmdIn).Rows.Count > 0) + { + // se è un comando di fase --> registro INIZIO! + dataLayer.man.taTR.insertQuery(mUtils.CodOpr, mUtils.CodPost, CurrNumTask, CurrCodTag, mod_barcode1.comandoRegistrato.prevCmdIn, DateTime.Now); + // controllo se sia fase di CHIUSURA DEFINITIVA registro con INIZIO e FINE insieme e CHIUDO commessa... + var rigaFase = dataLayer.man.taAF.getByKey(mod_barcode1.comandoRegistrato.prevCmdIn)[0]; + if (rigaFase.CloseTask) + { + // chiudo direttamente SIA fase che il TASK principale... + dataLayer.man.taTL.updateClose(CurrNumTask, true); + // se è abilitato PODL indico chiuso anche li... IdxOdl = -10 + + // tolgo comm corrente... + CurrNumTask = ""; + // rimuovo eventuale val opzionale + mUtils.optValueBC = ""; + } + Response.Redirect("~/barcode"); + } + // reset e mostro output... + mod_barcode1.resetMe(); + if (msg2show != "") + { + mod_barcode1.txtInput2show = msg2show; + } + } + + protected void btnReload_Click(object sender, EventArgs e) + { + resetCache(); + } + + private void resetCache() + { + // resetto tutto! + comandiAmmessiBCode = new Dictionary(); + valoriAmmessiBCode = new Dictionary(); + lastDataRefresh = DateTime.Now.AddDays(-1); + } + + protected void txtCacheSec_TextChanged(object sender, EventArgs e) + { + resetCache(); + } + + protected void txtNumDD_TextChanged(object sender, EventArgs e) + { + resetCache(); + } } - } }