コード例 #1
0
ファイル: Program.cs プロジェクト: delormej/trucks
        private static void Process(SettlementService settlementService, ExcelConverter converter, PantherClient panther)
        {
            var conversionTask = Task <IEnumerable <ConversionJob> > .Run(() =>
                                                                          settlementService.StartConversion(panther, converter, int.MaxValue));

            conversionTask.Wait();
            foreach (var result in conversionTask.Result)
            {
                System.Console.WriteLine($"Settlement {result.SettlementId} uploaded for conversion.");
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: delormej/trucks
        static void Main(string[] args)
        {
            ShowUsage(args);

            string company       = Environment.GetEnvironmentVariable("TRUCKCOMPANY");
            string password      = Environment.GetEnvironmentVariable("TRUCKPASSWORD");
            string convertApiKey = Environment.GetEnvironmentVariable("ZAMZARKEY");

            if (string.IsNullOrWhiteSpace(company) ||
                string.IsNullOrWhiteSpace(password) ||
                string.IsNullOrWhiteSpace(convertApiKey))
            {
                System.Console.WriteLine("Must set TRUCKCOMPANY, TRUCKPASSWORD, ZAMZARKEY env variables.");
                return;
            }

            SettlementService settlementService = new SettlementService();
            PantherClient     panther           = new PantherClient(company, password);

            if (args.Length < 1)
            {
                ExcelConverter converter = new ExcelConverter(convertApiKey);
                Process(settlementService, converter, panther);
            }
            else
            {
                string command = args[0].ToLower();
                if (command == "uploaded")
                {
                    ProcessUploaded(panther, convertApiKey);
                }
                else if (command == "downloaded")
                {
                    ProcessDownloaded(panther, convertApiKey);
                }
                else if (command == "update")
                {
                    settlementService.UpdateHeadersFromPanther(panther);
                }
                else if (command == "updateall")
                {
                    settlementService.UpdateAll();
                }
                else if (command == "report")
                {
                    GetReport();
                }
                else if (command == "settlement")
                {
                    int year = int.Parse(args[1]);
                    int week = int.Parse(args[2]);
                    int truck;
                    if (args.Length > 3 && int.TryParse(args[3], out truck))
                    {
                        settlementService.CreateSettlementStatement(year, new int[] { week }, truck);
                    }
                    else
                    {
                        settlementService.CreateSettlementStatement(year, new int[] { week });
                    }
                }
                else if (command == "year")
                {
                    settlementService.CreateSettlementsForYear(int.Parse(args[1]));
                }
                else if (command == "fixtemplate")
                {
                    FixTemplate(args[1]);
                }
                else if (command == "savefuel")
                {
                    SaveFuelCharges(args[1]);
                }
                else if (command == "get")
                {
                    PrintSettlementHeader(args[1], args[2]);
                }
                else if (command == "setup")
                {
                    Setup();
                }
            }
        }