示例#1
0
        private void GenRoutes(string inFilePAth)
        {
            using (var reader = new StreamReader(inFilePAth + "_GoodAddresses.csv"))
                using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
                {
                    var records = csv.GetRecords <TDayAddress>();

                    TDayAddress.GenerateRoutes(records, inFilePAth, new MsgOut(DebugOut));
                }
        }
示例#2
0
        private static void RunOptions(Options opts)
        {
            using (var reader = new StreamReader(opts.inputFile))
                using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
                {
                    var records = csv.GetRecords <TDayAddress>();

                    TDayAddress.GenerateRoutes(records, Path.GetDirectoryName(opts.inputFile), new MsgOut(DebugOut));
                }
            Console.WriteLine($"Results written to {Path.GetDirectoryName(opts.inputFile) + "/Deliveries.txt"}");
        }
示例#3
0
        private void CheckAddresses(string excelFile, string outPath)
        {
            DebugOut("Lets check some addresses!");

            var goodAddr = new ConcurrentBag <TDayAddress>();
            var badAddr  = new ConcurrentBag <TDayAddress>();

            Stopwatch sw = new Stopwatch();

            sw.Start();
            System.Text.Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            TDayAddress.ReadExcelFile(excelFile, outPath, goodAddr, badAddr, new MsgOut(DebugOut));
            sw.Stop();
            DebugOut($"\nValidate addresses time: {sw.Elapsed}  with {goodAddr.Count} good and {badAddr.Count} failed addresses");
        }
示例#4
0
        private static void RunOptions(Options opts)
        {
            Console.WriteLine("Lets check some addresses!");

            var goodAddr = new ConcurrentBag <TDayAddress>();
            var badAddr  = new ConcurrentBag <TDayAddress>();

            Stopwatch sw = new Stopwatch();

            sw.Start();
            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
            TDayAddress.ReadExcelFile(opts.excelFile, Path.GetDirectoryName(opts.excelFile), goodAddr, badAddr, new MsgOut(DebugOut));
            sw.Stop();
            string drcty = Path.GetDirectoryName(opts.excelFile);

            Console.WriteLine($"\nValidate addresses time: {sw.Elapsed}  with {goodAddr.Count} good and {badAddr.Count} failed addresses");
            Console.WriteLine($"\nData written to {drcty + "/GoodAddresses.csv"} and {drcty + "/Badddresses.csv"}");
        }
示例#5
0
        private void generateRoutesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Title  = "Select the Zip to Restaurant file";
            dlg.Filter = "Excel files(*.xlsx)| *.xlsx";

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                TDayAddress.LoadRestaurantZips(dlg.FileName);
            }

            dlg.Title = "Select the Address file";
            string excelFile, filePath;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                excelFile = dlg.FileName;
                filePath  = System.IO.Path.ChangeExtension(excelFile, null);
                DebugOut("Processing: " + excelFile);
                Task.Run(() => {
                    try
                    {
                        CheckAddresses(excelFile, filePath);
                        GenRoutes(filePath);
                        GenReport(filePath);
                    }
                    catch (Exception ex)
                    {
                        DebugOut("Error: " + ex.ToString());
                        if (ex.InnerException != null)
                        {
                            DebugOut("Inner: " + ex.InnerException.ToString());
                        }
                    }
                });
                //msgText.Buffer.Text += msgTextStr;
            }
        }