using MagData; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace MP_MAG.WebUserControls { public partial class cmp_PLScanner : BaseUserControl { #region Protected Properties /// /// Comando ULTIMO barcode letto /// protected string lastCmd { get { return hfLastBCode.Value; } set { hfLastBCode.Value = value; lastValidCmd = value; } } /// /// ULTIMO Comando barcode VALIDO (!="") letto /// protected string lastValidCmd { get { return hfLastValidBCode.Value; } set { // solo se è non nullo/vuoto if (!string.IsNullOrEmpty(value)) { hfLastValidBCode.Value = value; } } } #endregion Protected Properties #region Private Methods private void Cmp_barcode_eh_doRefresh(object sender, EventArgs e) { bool doRaiseEv = false; // processo evento.. lastCmd = cmp_barcode.inputAcquired.ToUpper(); doRaiseEv = processLastCmd(doRaiseEv); // reset comando cmp_barcode.inputAcquired = ""; // aggiorno... doUpdate(); } private void Cmp_barcode_eh_doReset(object sender, EventArgs e) { } private void doUpdate() { #if false // reset grafico icnCart.Attributes.Remove("class"); icnCart.Attributes.Add("class", "btn btn-sm btn-block btn-outline-secondary"); icnBin.Attributes.Remove("class"); icnBin.Attributes.Add("class", "btn btn-sm btn-block btn-outline-secondary"); icnSecOp.Attributes.Remove("class"); icnSecOp.Attributes.Add("class", "btn btn-sm btn-block btn-outline-secondary"); // in base al secondo mostro uno o altro... if (showCart) { icnCart.Attributes.Remove("class"); icnCart.Attributes.Add("class", "btn btn-sm btn-block btn-success"); lblMessage.Text = "Item recognized"; // controllo SE HO cart if (currCartTab.Count == 1) { var cartRow = currCartTab[0]; // imposto OUT lblDestination.Text = $"SEND TO CART C{cartRow.CartIndex} ({cartRow.CartDtmx})"; } else { lblDestination.Text = $"ERROR SEARCHING CART: {currCartTab.Count} found!"; } lblDestination.CssClass = "text-success"; } else if (showBin) { icnBin.Attributes.Remove("class"); icnBin.Attributes.Add("class", "btn btn-sm btn-block btn-primary"); lblMessage.Text = "Item recognized"; if (currBinTab.Count == 1) { var binRow = currBinTab[0]; lblDestination.Text = $"SEND TO BIN B{binRow.BinIndex} ({binRow.BinDtmx})"; } else { lblDestination.Text = $"ERROR SEARCHING BIN: {currBinTab.Count} found!"; } lblDestination.CssClass = "text-primary"; } if (showSecOp) { icnSecOp.Attributes.Remove("class"); icnSecOp.Attributes.Add("class", "btn btn-sm btn-block btn-info"); lblMessage.Text = "Item recognized"; lblLastBCode.Text = $"DO SEC OP: {secOp}"; lblLastBCode.CssClass = "text-info"; } // fix btn reset! lbtResetSel.Visible = (itemIdSelected != 0); #endif } private bool processLastCmd(bool doRaiseEv) { if (lastCmd == "") doRaiseEv = true; // processiamo barcode letto decodedData decoData = MagDataLayer.man.decodeBcode(lastValidCmd); switch (decoData.codeType) { case codeType.Command: case codeType.PackList: case codeType.Pedana: case codeType.Udc: cmp_barcode.showOutput("badge badge-success", $"{decoData.description}"); processSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); doRaiseEv = true; break; default: cmp_barcode.showOutput("text-danger", $"Codice sconosciuto: {decoData.rawData} --> ignoro"); resetSelection(false); doRaiseEv = true; break; } return doRaiseEv; } /// /// Processo il codice letto /// /// /// /// private void processSuggestion(codeType tipoCod, string rawData, int codeInt) { //DS_App.ItemListDataTable tabItem = null; // processo suggerimenti x ITEM / cart / bin dato suo RawData (Dtmx) e Cod univoco (intero) switch (tipoCod) { case codeType.Command: // verifico tipo comando switch (rawData) { case "CMDRESET": cmp_SelPackList.PackListID = 0; cmp_SelPedana.Pedana = "ND"; cmp_SelUdc.UDC = "NA"; resetSelection(true); break; default: break; } break; case codeType.PackList: // FARE!!! verificare packlist valida... if (true) { // seleziono PackList cmp_SelPackList.PackListID = codeInt; } tryLinkAlUdc(); #if false // IN PRIMIS cerco lotto valido DS_Mag.ElencoLottiDataTable tabLotti; tabLotti = MagDataLayer.man.taEL.getByKey(rawData, "*", codStatoIN); if (tabLotti.Count == 1) { // se trovato cerco in elenco --> aggiungo in lista se non c'è var currLotti = lottiSel; if (!currLotti.Contains(rawData)) { currLotti.Add(rawData); lottiSel = currLotti; } } #endif break; case codeType.Pedana: // verifico e seleziono pedana if (true) { cmp_SelPedana.Pedana = rawData; } //tabItem = DataLayer.man.taIL.getBySearch(codeInt, rawData, 0, 999); //if (tabItem.Count == 1) //{ // showItemDetail(true, tabItem[0], false); //} //else if (tabItem.Count == 0) //{ // showItemDetail(false, null, true); //} break; case codeType.Udc: // verifico e seleziono udc if (true) { cmp_SelUdc.UDC = rawData; } tryLinkAlUdc(); break; //case codeType.Item: // tabItem = DataLayer.man.taIL.getBySearch(codeInt, rawData, 0, 999); // if (tabItem.Count == 1) // { // showItemDetail(true, tabItem[0], false); // } // else if (tabItem.Count == 0) // { // showItemDetail(false, null, true); // } // break; //case codeType.ItemGeneric: // // PRIMA CERCSE ne ho in stato 1..3 // tabItem = DataLayer.man.taIL.getBySearch(0, rawData, 1, 3); // if (tabItem.Count == 0) // { // // se NON ne trovo cerci FINO a stato 5... // tabItem = DataLayer.man.taIL.getBySearch(0, rawData, 1, 5); // } // if (tabItem.Count == 1) // { // showItemDetail(true, tabItem[0], false); // } // else if (tabItem.Count == 0) // { // showItemDetail(false, null, true); // } // break; //case codeType.Cart: // // verifico NON SIA richiesto PAINT // if (showBin) // { // displError("PAINT: BIN REQUESTED: please retry", true); // } // else // { // if (currCartTab.Count == 1) // { // // controllo se sia quello corretto // if (rawData != currCartTab[0].CartDtmx) // { // displError("INCORRECT CART: please retry", true); // } // else // { // // dichiaro che è depositato // DataLayer.man.taIL.updateStatus(itemIdSelected, 3, PlaceId); // lblDestination.Text = $"Item {itemIdSelected} PUT IN CART {rawData}"; // resetSelection(false); // } // } // } // break; //case codeType.Bin: // // verifico NON SIA richiesto PAINT // if (showCart) // { // displError("NOT PAINTED: CART REQUESTED: please retry", true); // } // else // { // if (currBinTab.Count == 1) // { // // controllo se sia quello corretto // if (rawData != currBinTab[0].BinDtmx) // { // displError("INCORRECT BIN: please retry", true); // } // else // { // // dichiaro che è depositato // DataLayer.man.taIL.updateStatus(itemIdSelected, 4, PlaceId); // lblDestination.Text = $"Item {itemIdSelected} PUT IN BIN {rawData}"; // resetSelection(false); // } // } // } // break; default: break; } } private void tryLinkAlUdc() { // verifica UDC ed al, se entrambi validi e LIBERI // se c'è già un associazione UDC con altro AL --> chiede rilettura // se non c'era effettua associazione } #endregion Private Methods #region Protected Methods protected void Page_Load(object sender, EventArgs e) { // eventi barcode cmp_barcode.eh_doRefresh += Cmp_barcode_eh_doRefresh; // eventi reset lotti IN cmp_barcode.eh_doReset += Cmp_barcode_eh_doReset; ; } /// /// Reset selezione item + blocchi suggerimento + sel REDIS x pagina unload /// /// protected void resetSelection(bool resetStatus) { #if false if (resetStatus) { try { // SE item esiste... var tabItem = DataLayer.man.taIL.getBySearch(itemIdSelected, itemIdSelected.ToString(), 0, 999); if (tabItem.Count == 1) { // riposto item a status 1... DataLayer.man.taIL.updateStatus(itemIdSelected, 1, PlaceId); } } catch { } } // elimino item sel... itemIdSelected = 0; resetShowData(); ComLib.resetItemPickup(SheetID, DeviceId); #endif } #endregion Protected Methods } }