Esempio n. 1
0
        private void ProcessRigging(ref ScanObject obj, string barcode)
        {
            if (obj == null)
            {
                obj = new ScanObject(BarcodeProcessType.RIGGING, "N/A");
            }

            if (obj.ScannedObjects == null)
            {
                obj.ScannedObjects = new List <ScanObjectItem>();
            }
            int[] decoded = DecodeAssembyBarcode(barcode);
            obj.ScannedObjects.Add(new ScanObjectItem {
                ObjectBarcode = barcode, ObjectEntityTypeID = decoded[0], UniqueIdentifier = decoded[1]
            });
        }
Esempio n. 2
0
        internal void OnProcessScannedCodes(object sender, BarcodeProcessEventArgs e)
        {
            ScanObject        scannedObject  = null;
            List <ScanObject> scannedObjects = null;

            try
            {
                foreach (var item in BarcodeForm.GetInstance().lbScannedBarcodes.Items)
                {
                    string barcode   = (string)item;
                    string switch_on = barcode.Substring(0, 1);
                    switch (switch_on)
                    {
                    case "A":     // Assembly scanned

                        switch (e.type)
                        {
                        case BarcodeProcessType.DISPATCH:
                            if (!InternalNoteStartScan)
                            {
                                throw new System.InvalidOperationException("Missed scan of delivery/galvanising note!");
                            }

                            if (scannedObject.ScannedObjects == null)
                            {
                                scannedObject.ScannedObjects = new List <ScanObjectItem>();
                            }

                            if (!barcode.Contains("-"))
                            {
                                throw new System.InvalidOperationException(string.Format("Invalid Assembly barcode {0}", barcode));
                            }

                            int[] decoded = DecodeAssembyBarcode(barcode);
                            scannedObject.ScannedObjects.Add(new ScanObjectItem {
                                ObjectBarcode = barcode, ObjectEntityTypeID = decoded[0], UniqueIdentifier = decoded[1]
                            });

                            break;

                        case BarcodeProcessType.RIGGING:

                            if (!barcode.Contains("-"))
                            {
                                throw new System.InvalidOperationException(string.Format("Invalid Assembly barcode {0}", barcode));
                            }

                            ProcessRigging(ref scannedObject, barcode);
                            break;

                        default:
                            break;
                        }
                        break;

                    case "G":     // Galv Note Scanned

                        if (InternalNoteStartScan == false)
                        {
                            InternalNoteStartScan = true;
                            scannedObject         = new ScanObject(BarcodeProcessType.GALVANISING, barcode);
                        }
                        else if (InternalNoteStartScan == true)
                        {
                            if (scannedObject.ScanObjectIdentifier != barcode)
                            {
                                throw new System.InvalidOperationException("Start and End note scans don't match!");
                            }

                            if (scannedObjects == null)
                            {
                                scannedObjects = new List <ScanObject>();
                            }
                            scannedObjects.Add(scannedObject);

                            InternalNoteStartScan = false;
                        }
                        break;

                    case "D":     // Delivery Note Scanned
                        if (InternalNoteStartScan == false)
                        {
                            InternalNoteStartScan = true;
                            scannedObject         = new ScanObject(BarcodeProcessType.DISPATCH, barcode);
                        }
                        else if (InternalNoteStartScan == true)
                        {
                            if (scannedObject.ScanObjectIdentifier != barcode)
                            {
                                throw new System.InvalidOperationException("Start and End note scans don't match!");
                            }
                            // FinaliseScannedObject(scannedObject);


                            if (scannedObjects == null)
                            {
                                scannedObjects = new List <ScanObject>();
                            }
                            scannedObjects.Add(scannedObject);

                            InternalNoteStartScan = false;
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "Barcode Utility", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (e.type == BarcodeProcessType.RIGGING)
                {
                    scannedObjects = new List <ScanObject>();
                    scannedObjects.Add(scannedObject);
                }

                FinaliseScannedObject(scannedObjects);
            }
        }