From 44fbf8362c4cc1724522028adf46af4e7079db38 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 13 Mar 2020 20:47:04 +0100 Subject: [PATCH] Abbozzata decodifica dati --- MP-MAG/WebUserControls/cmp_barcode.ascx.cs | 1 + MP-MAG/WebUserControls/cmp_prtSemilav.ascx.cs | 280 +++++++++++++++--- MagData/Enum.cs | 14 + MagData/MagData.csproj | 1 + MagData/MagDataLayer.cs | 89 ++++++ MagData/Objects.cs | 36 +++ 6 files changed, 377 insertions(+), 44 deletions(-) create mode 100644 MagData/Objects.cs diff --git a/MP-MAG/WebUserControls/cmp_barcode.ascx.cs b/MP-MAG/WebUserControls/cmp_barcode.ascx.cs index b0e6f93..f4e3865 100644 --- a/MP-MAG/WebUserControls/cmp_barcode.ascx.cs +++ b/MP-MAG/WebUserControls/cmp_barcode.ascx.cs @@ -43,6 +43,7 @@ namespace MP_MAG.WebUserControls set { txtBarcode.Text = ""; + txtBarcode.Focus(); } } /// diff --git a/MP-MAG/WebUserControls/cmp_prtSemilav.ascx.cs b/MP-MAG/WebUserControls/cmp_prtSemilav.ascx.cs index 2e4ad80..f9f3a35 100644 --- a/MP-MAG/WebUserControls/cmp_prtSemilav.ascx.cs +++ b/MP-MAG/WebUserControls/cmp_prtSemilav.ascx.cs @@ -1,4 +1,5 @@ -using System; +using MagData; +using System; using System.Collections.Generic; using System.Linq; using System.Web; @@ -55,8 +56,6 @@ namespace MP_MAG.WebUserControls private void Cmp_barcode_eh_doRefresh(object sender, EventArgs e) { - // verifico barcode - lblDecodedData.Text = cmp_barcode.inputAcquired; bool doRaiseEv = false; @@ -69,6 +68,8 @@ namespace MP_MAG.WebUserControls // aggiorno... doUpdate(); + // verifico barcode + lblDecodedData.Text = lastValidCmd; } private void resetIcons() @@ -87,9 +88,8 @@ namespace MP_MAG.WebUserControls private bool processLastCmd(bool doRaiseEv) { if (lastCmd == "") doRaiseEv = true; -#if false // processiamo barcode letto - decodedData decoData = DataLayer.man.decodeBcode(lastCmd); + decodedData decoData = MagDataLayer.man.decodeBcode(lastCmd); switch (decoData.codeType) { case codeType.UNK: @@ -97,51 +97,243 @@ namespace MP_MAG.WebUserControls resetSelection(false); doRaiseEv = true; break; - case codeType.Item: - cmp_barcode.showOutput("badge badge-success", $"Valid IT Code: {decoData.rawData}"); + case codeType.Lotto: + cmp_barcode.showOutput("badge badge-success", $"Lotto Valido: {decoData.rawData}"); processItemSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); break; - case codeType.ItemGeneric: - cmp_barcode.showOutput("badge badge-success", $"Valid IG Code: {decoData.rawData}"); - processItemSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); - break; - case codeType.OtherItem: - cmp_barcode.showOutput("badge badge-success", $"Valid Generic PART Code: {decoData.rawData}"); - processItemSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); - 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: - cmp_barcode.showOutput("badge badge-warning", $"BUNK - ignored: {decoData.description}"); - doRaiseEv = true; - break; - case codeType.Batch: - cmp_barcode.showOutput("badge badge-warning", $"Batch - ignored: {decoData.description}"); - doRaiseEv = true; - break; - case codeType.Cart: - cmp_barcode.showOutput("badge badge-success", $"Valid CR Code: {decoData.description}"); - processItemSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); - break; - case codeType.Bin: - cmp_barcode.showOutput("badge badge-success", $"Valid BN Code: {decoData.description}"); - processItemSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); - break; - default: - cmp_barcode.showOutput("text-danger", $"Unknown Data: {decoData.rawData} --> no action"); - resetSelection(false); - break; + //case codeType.ItemGeneric: + // cmp_barcode.showOutput("badge badge-success", $"Valid IG Code: {decoData.rawData}"); + // processItemSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); + // break; + //case codeType.OtherItem: + // cmp_barcode.showOutput("badge badge-success", $"Valid Generic PART Code: {decoData.rawData}"); + // processItemSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); + // 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: + // cmp_barcode.showOutput("badge badge-warning", $"BUNK - ignored: {decoData.description}"); + // doRaiseEv = true; + // break; + //case codeType.Batch: + // cmp_barcode.showOutput("badge badge-warning", $"Batch - ignored: {decoData.description}"); + // doRaiseEv = true; + // break; + //case codeType.Cart: + // cmp_barcode.showOutput("badge badge-success", $"Valid CR Code: {decoData.description}"); + // processItemSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); + // break; + //case codeType.Bin: + // cmp_barcode.showOutput("badge badge-success", $"Valid BN Code: {decoData.description}"); + // processItemSuggestion(decoData.codeType, decoData.rawData, decoData.codeInt); + // break; + //default: + // cmp_barcode.showOutput("text-danger", $"Unknown Data: {decoData.rawData} --> no action"); + // resetSelection(false); + // break; } -#endif return doRaiseEv; } + /// + /// Processo il DataMatrix letto + /// + /// + /// + /// + private void processItemSuggestion(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.Lotto: + //var tabOtherItem = DataLayer.man.taOtItem.getByKey(codeInt); + //if (tabOtherItem.Count == 1) + //{ + // showOtherItemDetail(true, tabOtherItem[0], false); + //} + 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; + } + } +#if false + /// + /// Mostra o nasconde dettaglio su ITEM letto + /// + /// + /// + /// + private void showItemDetail(bool showItem, DS_App.ItemListRow itemRow, bool showError) + { + resetShowData(); + divItemDet.Visible = showItem; + divItemError.Visible = showError; + if (showError) + { + displError("Item not found", true); + } + if (showItem) + { + lblItemCode.Text = itemRow.ItemExtCode; + lblItemDesc.Text = itemRow.ItemDesc; + lblItemDtmx.Text = itemRow.ItemDtmx; + itemIdSelected = itemRow.ItemID; + // CONTROLLO SIA in stato 1 --> worked, 2--> selected, 100--> parked... + switch (itemRow.StatusID) + { + case 0: + displError("ERROR: Item not ready", false); + break; + case 1: + case 2: + case 100: + // salvo che è in STATO 2 (picked up) + DataLayer.man.taIL.updateStatus(itemRow.ItemID, 2, PlaceId); + // verifico cosa devo mostrare come PROX passaggio... + showCart = itemRow.ProcessesReq == ""; + showBin = (itemRow.ProcessesReq.Contains("PaintFlag")); + secOp = itemRow.PostProcList; + showSecOp = (secOp != ""); + doUpdate(); + break; + case 3: + displError("Item already on CART!", false); + break; + case 4: + // fino a concorrenza qta richiesta sposto, POI do errori + displError("ALL Item already scanned on BIN!", false); + break; + case 5: + displError("Item already at KIT STATION!", false); + break; + case 990: + displError("Item declared SCRAP!", false); + break; + case 991: + displError("Item declared SCRAP with CNC program created!", false); + break; + default: + displError("ERROR: Item status UNKNOWN!", false); + break; + } + } + lbtResetSel.Visible = (itemIdSelected != 0); + } +#endif + /// + /// 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 + } private void doUpdate() { diff --git a/MagData/Enum.cs b/MagData/Enum.cs index 53a4f13..259830d 100644 --- a/MagData/Enum.cs +++ b/MagData/Enum.cs @@ -16,4 +16,18 @@ namespace MagData CartellinoPedane, CartellinoSemilavorati } + + /// + /// Tipi di barcode gestiti + /// + public enum codeType + { + UNK = 0, + Lotto, + LottoInt, + Date, + PartNumber, + Quantity, + Udc + } } diff --git a/MagData/MagData.csproj b/MagData/MagData.csproj index 317b893..fa87666 100644 --- a/MagData/MagData.csproj +++ b/MagData/MagData.csproj @@ -154,6 +154,7 @@ + True diff --git a/MagData/MagDataLayer.cs b/MagData/MagDataLayer.cs index 90ccde2..a482b1e 100644 --- a/MagData/MagDataLayer.cs +++ b/MagData/MagDataLayer.cs @@ -3,6 +3,7 @@ using SteamWare.IO; using SteamWare.Reports; using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Web; @@ -197,6 +198,94 @@ namespace MagData return answ; } + /// + /// Decodifica barcode + /// + /// + /// + public decodedData decodeBcode(string bcValue) + { + decodedData answ = new decodedData(); + answ.rawData = bcValue; + if (bcValue.StartsWith("M")) + { + answ.codeType = codeType.LottoInt; + answ.code = bcValue.Replace("M", ""); + answ.codeInt = 0; + answ.description = $"Lotto: {answ.code}"; + } + else if (bcValue.StartsWith("P")) + { + answ.codeType = codeType.PartNumber; + answ.code = bcValue.Replace("P", ""); + int codeInt = 0; + int.TryParse(answ.code, NumberStyles.Integer, CultureInfo.InvariantCulture, out codeInt); + answ.codeInt = 0; + answ.description = $"PartNumber Odette: {answ.code}"; + } + else if (bcValue.StartsWith("Q")) + { + answ.codeType = codeType.Quantity; + answ.code = bcValue.Replace("Q", ""); + int codeInt = 0; + int.TryParse(answ.code, NumberStyles.Integer, CultureInfo.InvariantCulture, out codeInt); + answ.codeInt = codeInt; + answ.description = $"Qty Odette: {answ.code}"; + } + else if (bcValue.StartsWith("H")) + { + answ.codeType = codeType.Lotto; + answ.code = bcValue.Replace("H", ""); + answ.codeInt = 0; + answ.description = $"Lotto Odette: {answ.code}"; + } + else if (bcValue.StartsWith("S")) + { + answ.codeType = codeType.Udc; + answ.code = bcValue.Replace("S", ""); + int codeInt = 0; + answ.codeInt = codeInt; + answ.description = $"Item: {answ.code}"; + } + //else if (bcValue.StartsWith("CR")) + //{ + // answ.codeType = codeType.Cart; + // answ.code = bcValue.Replace("CR", ""); + // int codeInt = 0; + // int.TryParse(answ.code, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out codeInt); + // answ.codeInt = codeInt; + // answ.description = $"Cart: {answ.code}"; + //} + //else if (bcValue.StartsWith("BN")) + //{ + // answ.codeType = codeType.Bin; + // answ.code = bcValue.Replace("BN", ""); + // int codeInt = 0; + // int.TryParse(answ.code, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out codeInt); + // answ.codeInt = codeInt; + // answ.description = $"Bin: {answ.code}"; + //} + //else if (bcValue.StartsWith("BP")) + //{ + // answ.codeType = codeType.BinProcessed; + // answ.code = bcValue.Replace("BP", ""); + // int codeInt = 0; + // int.TryParse(answ.code, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out codeInt); + // answ.codeInt = codeInt; + // answ.description = $"Processed Bin: {answ.code}"; + //} + //else if (bcValue.StartsWith("SS")) + //{ + // answ.codeType = codeType.SecScreen; + // answ.code = bcValue.Replace("SS", ""); + // int codeInt = 0; + // int.TryParse(answ.code, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out codeInt); + // answ.codeInt = codeInt; + // answ.description = $"Secondary Screen : {answ.code}"; + //} + return answ; + } + #endregion } } diff --git a/MagData/Objects.cs b/MagData/Objects.cs new file mode 100644 index 0000000..34e82c5 --- /dev/null +++ b/MagData/Objects.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MagData +{ + + /// + /// Valori decodificati + /// + public class decodedData + { + /// + /// Tipo codice decodificato + /// + public codeType codeType { get; set; } = codeType.UNK; + /// + /// Codice decodificato + /// + public string code { get; set; } = ""; + /// + /// Codice decodificato in formato INT + /// + public int codeInt { get; set; } = 0; + /// + /// Descrizione associata + /// + public string description { get; set; } = ""; + /// + /// Dato letto RAW + /// + public string rawData { get; set; } = ""; + } +}