Example #1
0
        public async void DeleteLabel(TLabel inLabel, List <Customer> customersList)
        {
            try
            {
                int index      = customersList.FindIndex(c => c.Name == inLabel.Name);
                int indexLabel = customersList[index].AllLabels.FindIndex(l => l.Barcode == inLabel.Barcode);
                if (index < 0)
                {
                    return;
                }
                else
                {
                    var name = customersList[index].Name;
                    customersList[index].AllLabels.RemoveAt(indexLabel);
                    customersList[index].AllLabels.RemoveAll(item => item == null);
                    await firebase.Child("Customers").Child(name).PutAsync(customersList[index]);

                    App.CustomerPageViewModel.GenerateCustomerList();
                }
            }
            catch (Exception e)
            {
                var result = PMessageBox.Show("Failed to delete label for " + inLabel.Name + "\n\r Expection: " + e, "Failed to delete label for" + inLabel.Name, System.Windows.Forms.MessageBoxButtons.OK);
                Console.WriteLine(e);
            }
        }
        public TLabel DataSorter(string[] PageInformation)
        {
            TLabel label = new TLabel();

            int[] dp = DataPositions(PageInformation);

            //temp ID
            //label.ID = new Random().Next(1, 50);

            //Name
            label.Name = PageInformation[dp[0] + 2];

            //Address
            var tempAdArry = new List <string>();

            for (var i = (dp[0] + 3); i < (dp[1] - 2); i++)
            {
                tempAdArry.Add(PageInformation[i]);
            }
            label.Address = string.Join(",\r\n", tempAdArry.ToArray());

            //Barcode
            label.Barcode = PageInformation[dp[0] + 1];

            //Delivery Date
            label.DeliveryDate = PageInformation[dp[1] - 1];

            //Consignment Number
            label.ConsignmentNumber = PageInformation[dp[1] + 1];

            //PostCode
            label.PostCode = PageInformation[dp[1] + 3];

            //Telephone Number
            label.Telephone = PageInformation[dp[1] + 5];

            //Location
            label.Location = PageInformation[dp[2] - 2];


            //Location Number
            label.LocationNumber = PageInformation[dp[2] - 1];

            //Parcel Number
            label.ParcelNumber = PageInformation[dp[1] + 4];

            //Parcel Size
            label.ParcelSize = PageInformation[dp[2] - 3];

            //Weight
            label.Weight = PageInformation[dp[1] + 2];

            return(label);
        }
Example #3
0
        public async Task <List <TLabel> > FetchCustomerLabels(string customerKey)
        {
            List <TLabel> RetrievedList = new List <TLabel>();

            try
            {
                if (IsOnline)
                {
                    var Labels = await firebase.Child("Labels").Child(customerKey).OrderByKey().OnceAsync <TLabel>();

                    foreach (var l in Labels)
                    {
                        RetrievedList.Add(l.Object);
                    }
                }
                else
                {
                    /////Insert code for offline reading
                }
                return(RetrievedList);
            }
            catch (Exception e)
            {
                Console.Write(e);
                var t = new TLabel
                {
                    Name              = "error",
                    Address           = "error",
                    Barcode           = "error",
                    DeliveryDate      = "error",
                    ConsignmentNumber = "error",
                    PostCode          = "error",
                    Telephone         = "error",
                    Location          = "error",
                    LocationNumber    = "error",
                    ParcelNumber      = "error",
                    ParcelSize        = "error",
                    Weight            = "error"
                };
                RetrievedList.Add(t);
                return(RetrievedList);
            }
        }
        public void Print(TLabel tLabel)
        {
            var _toprint = PrinterErrorCheck(LabelLocation);

            if (_toprint == ToPrint.Yes)
            {
                DocumentClass document = new DocumentClass();
                document.Printed += new IPrintEvents_PrintedEventHandler(HandlePrinted);
                document.Open(LabelLocation);
                var barcodeIndex = document.GetBarcodeIndex("Barcode");

                #region Document Object Text
                document.GetObject("Name").Text    = tLabel.Name;
                document.GetObject("Address").Text = tLabel.Address;
                document.SetBarcodeData(barcodeIndex, tLabel.Barcode);
                document.GetObject("DeliveryDate").Text      = tLabel.DeliveryDate;
                document.GetObject("ConsignmentNumber").Text = tLabel.ConsignmentNumber;
                document.GetObject("PostCode").Text          = tLabel.PostCode;
                document.GetObject("Telephone").Text         = tLabel.Telephone;
                document.GetObject("Location").Text          = tLabel.Location;
                document.GetObject("Weight").Text            = tLabel.Weight;
                document.GetObject("LocationNumber").Text    = tLabel.LocationNumber;
                document.GetObject("ParcelNumber").Text      = tLabel.ParcelNumber;
                #endregion

                document.StartPrint((tLabel.Name + " Print Job"), PrintOptionConstants.bpoDefault);
                document.PrintOut(1, PrintOptionConstants.bpoDefault);
                int ErrorCode = document.ErrorCode;

                Console.WriteLine("Error Code > " + ErrorCode);

                document.EndPrint();
                document.Close();
            }
            else if (_toprint == ToPrint.Retry)
            {
                restartPrint(tLabel);
            }
        }
        public void ExtractData()
        {
            if (SourceLabels.Count > 0)
            {
                SourceLabels.Clear();
            }
            var SourceFiles = FileList(SourceFolder, new string[] { ".pdf" });

            foreach (var file in SourceFiles)
            {
                using (FileStream fileStream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read))
                    using (PdfReader reader = new PdfReader(fileStream))
                    {
                        for (int page = 1; page <= reader.NumberOfPages; page++)
                        {
                            string[] PageLines = new string[] { };
                            var      text      = PdfTextExtractor.GetTextFromPage(reader, page, new SimpleTextExtractionStrategy());
                            PageLines = text.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
                            TLabel tempLabel = DataSorter(PageLines);
                            var    add       = 0;
                            SourceLabels.ForEach(s =>
                            {
                                if (s.ConsignmentNumber == tempLabel.ConsignmentNumber)
                                {
                                    add++;
                                }
                            });
                            if (add == 0)
                            {
                                SourceLabels.Add(tempLabel);
                            }
                        }
                        Console.WriteLine("completed sourcelist update");
                    }
            }
        }
 public void restartPrint(TLabel tLabel)
 {
     Print(tLabel);
 }
Example #7
0
 public async void InsertLabel(TLabel inLabel)
 {
     //FindUID(inLabel.Name);
     //await firebase.Child("Labels").Child(inLabel.Key).PostAsync(inLabel, true);
 }