Example #1
0
        public static void Main(string[] args)
        {
            var configuration = BuildConfiguration();
            var services      = BuildServices(configuration);
            var logger        = services.GetService <ILoggerFactory>().CreateLogger <Program>();

            logger.LogWarning("Starting application");
            Parser.Default.ParseArguments <Options>(args)
            .WithParsed(o =>
            {
                switch (o.Action)
                {
                case "SyncVendors":
                    var fSyncVendors = new SynchVendors(services.GetService <IBlue10Client>(), o.FileName);
                    fSyncVendors.Synch(o.Company);
                    break;

                case "SyncGLAccounts":
                    var fSyncGLAccounts = new SynchGLAccounts(services.GetService <IBlue10Client>(), o.FileName);
                    fSyncGLAccounts.Synch(o.Company);
                    break;

                case "SyncCostCenters":
                    var fSynchCostCenters = new SynchCostCenters(services.GetService <IBlue10Client>(), o.FileName);
                    fSynchCostCenters.Synch(o.Company);
                    break;

                case "SyncVatCodes":
                    var fSynchVATCodes = new SynchVATCodes(services.GetService <IBlue10Client>(), o.FileName);
                    fSynchVATCodes.Synch(o.Company);
                    break;

                case "GetCompanies":
                    var fGetCompanies = new GetCompanies(services.GetService <IBlue10Client>());
                    Console.WriteLine(JsonSerializer.Serialize(fGetCompanies.GetAll()));
                    break;

                case "ProcessDocumentActions":
                    var fProcessDocumentActions = new ProcessDocumentActions(services.GetService <IBlue10Client>(), o.FileName);
                    fProcessDocumentActions.Process();
                    break;

                case "ProcessAdministrationActions":
                    var fProcessAdministrationActions = new ProcessAdministrationActions(services.GetService <IBlue10Client>());
                    fProcessAdministrationActions.Process("C:\\FileToVendors.csv");
                    break;
                }
            });
            logger.LogDebug("Ended successfully");
        }
Example #2
0
        public static void Main(string[] args)
        {
            var builder       = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
            var configuration = builder.Build();
            var apiKey        = configuration["ApiKey"];

            if (apiKey == "API-KEY")
            {
                Console.WriteLine("Please enter a valid ApiKey value in the appsettings.json file.");
                Console.ReadKey();
                return;
            }
            var apiUrl = configuration["ApiUrl"];

            if (string.IsNullOrEmpty(apiUrl))
            {
                apiUrl = "https://api.blue10.com/v2/";
            }
            if (!apiUrl.EndsWith('/'))
            {
                apiUrl += "/";
            }

            var client     = Blue10.CreateClient(apiKey, apiUrl);
            var loginCheck = new LoginCheck(client);

            if (!loginCheck.GetCheckLogin())
            {
                Console.WriteLine($"Couldn't login with given ApiKey / ApiUrl. Please enter a valid ApiKey/ApiUrl value in the appsettings.json file.");
                Console.ReadKey();
                return;
            }


            Console.WriteLine("Starting application");

            Parser.Default.ParseArguments <Options>(args)
            .WithParsed(o =>
            {
                switch (o.Action)
                {
                case "SyncVendors":
                    var fSyncVendors = new SynchVendors(client, o.FileName);
                    fSyncVendors.Synch(o.Company);
                    break;

                case "SyncGLAccounts":
                    var fSyncGLAccounts = new SynchGLAccounts(client, o.FileName);
                    fSyncGLAccounts.Synch(o.Company);
                    break;

                case "SyncCostCenters":
                    var fSynchCostCenters = new SynchCostCenters(client, o.FileName);
                    fSynchCostCenters.Synch(o.Company);
                    break;

                case "SyncVatCodes":
                    var fSynchVATCodes = new SynchVATCodes(client, o.FileName);
                    fSynchVATCodes.Synch(o.Company);
                    break;

                case "GetCompanies":
                    var fGetCompanies = new GetCompanies(client);
                    Console.WriteLine(JsonSerializer.Serialize(fGetCompanies.GetAll()));
                    break;

                case "ProcessDocumentActions":
                    var fProcessDocumentActions = new ProcessDocumentActions(client, o.FileName);
                    fProcessDocumentActions.Process();
                    break;

                case "ProcessAdministrationActions":
                    var fProcessAdministrationActions = new ProcessAdministrationActions(client);
                    fProcessAdministrationActions.Process("C:\\FileToVendors.csv");
                    break;
                }
            });
            Console.WriteLine("Ended successfully");
        }