Example #1
0
        public static List <WorkorderLabelInspection> PrepareInspectionResults(int workorderLabelId, ItemData itemData, EnumLabelType labelType)
        {
            List <WorkorderLabelInspection> workorderLabelInspections = new List <WorkorderLabelInspection>();

            workorderLabelInspections.Add(new WorkorderLabelInspection
            {
                TestName          = "Nazwa Modelu",
                ExpectedValueText = itemData.ExpectedName,
                ActualValueText   = itemData.ActualName,
                Result            = itemData.ExpectedName == itemData.ActualName,
                LabelType         = labelType,
                TimeStamp         = DateTime.Now,
                WorkorderLabelId  = workorderLabelId
            });

            workorderLabelInspections.Add(new WorkorderLabelInspection
            {
                TestName          = "Kod Produktu",
                ExpectedValueText = itemData.ExpectedProductCode,
                ActualValueText   = itemData.ActualProductCode,
                Result            = itemData.ExpectedProductCode == itemData.ActualProductCode,
                LabelType         = labelType,
                TimeStamp         = DateTime.Now,
                WorkorderLabelId  = workorderLabelId
            });

            workorderLabelInspections.Add(new WorkorderLabelInspection
            {
                TestName          = "Kod Kreskowy",
                ExpectedValueText = itemData.ExpectedBarcodeSmall,
                ActualValueText   = itemData.ActualBarcode,
                Result            = itemData.ExpectedBarcodeSmall == itemData.ActualBarcode,
                LabelType         = labelType,
                TimeStamp         = DateTime.Now,
                WorkorderLabelId  = workorderLabelId
            });

            workorderLabelInspections.Add(new WorkorderLabelInspection
            {
                TestName          = "Waga",
                ExpectedValueText = itemData.ExpectedWeightKG,
                ActualValueText   = itemData.ActualWeightKG,
                Result            = itemData.ExpectedWeightKG == itemData.ActualWeightKG,
                LabelType         = labelType,
                TimeStamp         = DateTime.Now,
                WorkorderLabelId  = workorderLabelId
            });

            workorderLabelInspections.RemoveAll(x => x.ActualValueText.Length < 1);
            return(workorderLabelInspections);
        }
        private void InspectLabel_AnalizeImage(string fileName, out ItemData itemData, out string serialNumber, out EnumLabelType labelType, bool force = false)
        {
            string[] barcode    = fileName.Split('_'); //FILENAME EXAMPLE: 20201002124748_05292260050040276228_Label_S
            string   labelType_ = barcode[barcode.Length - 1];

            labelType = GetLabelTypeByChar(labelType_);

            imgProcessing.SetImage(string.Format("{0}{1}.{2}", RAW_LABELS_PATH, fileName, "png"));
            imgProcessing.RotateImage(180);
            string bigBarcode = imgProcessing.BarcodeDetectReadAddFrame_Big("");

            ParseBarcode_RatingLabel(barcode.Length >= 2 ? barcode[1] : "", out string serialNumberRating, out string elc);
            ParseBarcode_PackLabel(bigBarcode, out string serialNumberBarcode, out string pncBarcode);

            itemData     = null;
            serialNumber = serialNumberBarcode;

            if (serialNumberRating == serialNumberBarcode || force)
            {
                itemData = uow.ItemDataRepo.GetByItemCodeAndVersion(pncBarcode, elc);

                if (itemData != null)
                {
                    itemData.ActualBarcode     = imgProcessing.BarcodeDetectReadAddFrame_Small(itemData.ExpectedBarcodeSmall);
                    itemData.ActualName        = imgProcessing.ReadModelName(itemData.ExpectedName);
                    itemData.ActualProductCode = imgProcessing.ReadIKEAProductCode(itemData.ExpectedProductCode);
                    itemData.ActualWeightKG    = imgProcessing.ReadWeightBig(itemData.ExpectedWeightKG);
                }
                else
                {
                    itemData = new ItemData()
                    {
                        ItemCode    = pncBarcode,
                        IsDataEmpty = true
                    };
                }
                imgProcessing.SaveFinalPreviewImage(string.Format("{0}{1}_{2}.{3}", INSPECTED_LABELS_PATH, serialNumber, labelType_, "png"));
            }
            else
            {
                Logger2FileSingleton.Instance.SaveLog("LabelInspectionManager.InspectLabel_AnalizeImage(" + fileName + ") UNEXPECTED CONTENT. WRONG SERIAL NUMBER!");
            }
        }
Example #3
0
        public bool SaveInspectionResults(WorkorderLabel workorderLabel, ItemData itemData, EnumLabelType labelType)
        {
            try
            {
                if (workorderLabel.Id > 0 && itemData.IsDataEmpty == false)
                {
                    List <WorkorderLabelInspection> workorderLabelInspections = PrepareInspectionResults(workorderLabel.Id, itemData, labelType);
                    AddOrUpdateRange(workorderLabelInspections);

                    int positiveCount = workorderLabelInspections.Count(x => x.Result == true);
                    return(positiveCount == workorderLabelInspections.Count);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                Logger2FileSingleton.Instance.SaveLog("PrepareInspectionResultToSave Exception. " + ex.Message);
            }

            return(true);
        }