示例#1
0
        // User management functions
        //
        public static void ProvisionNewUserAccount()
        {
            Console.WriteLine(
                Environment.NewLine + "Enter New User's Email Address (which will be used as User ID)");
            var email = Console.ReadLine();

            Console.WriteLine(Environment.NewLine + "Enter New User's Shopify Domain");
            var domain = Console.ReadLine();

            var msg = $"Create a new Account for User ID: {email} - Shopify Domain: {domain}";

            if (!CommandLineFuncs.Confirm(msg))
            {
                return;
            }

            Action <ILifetimeScope> process = scope =>
            {
                var service = scope.Resolve <ProvisioningService>();
                var user    = service.ProvisionNewAccount(email, domain).Result;
                Console.WriteLine(Environment.NewLine + "Created User...");
            };

            AutofacRunner.RunInScope(process);
        }
示例#2
0
        public static void RunViewAcumaticaTaxTransfer()
        {
            var instanceId    = CommandLineFuncs.SolicitInstanceId();
            var salesOrderNbr = CommandLineFuncs.SolicitAcumaticaSalesOrderId();

            AutofacRunner.RunInScope(scope =>
            {
                var logger           = scope.Resolve <IPushLogger>();
                var instanceContext  = scope.Resolve <InstanceContext>();
                var acumaticaContext = scope.Resolve <AcumaticaHttpContext>();
                var salesOrderClient = scope.Resolve <SalesOrderClient>();

                instanceContext.Initialize(instanceId);

                acumaticaContext.SessionRun(() =>
                {
                    var json = salesOrderClient
                               .RetrieveSalesOrder(salesOrderNbr, SalesOrderType.SO, Expand.Details_Totals);

                    var salesOrderObj = json.ToSalesOrderObj();
                    var taxSnapshot   = salesOrderObj.custom.Document.UsrTaxSnapshot;
                    var taxJson       = Compression.Unzip(taxSnapshot.value);

                    logger.Info("Acumatica Tax Transfer");
                    logger.Info(taxJson);
                });
            });
        }
示例#3
0
        public static void EnableInstance()
        {
            var instanceId = CommandLineFuncs.SolicitInstanceId();

            AutofacRunner.RunInScope(scope =>
            {
                var repository = scope.Resolve <MasterRepository>();
                repository.UpdateInstanceEnabled(instanceId, true);
            });
        }
示例#4
0
        public static void RunViewShopifyOrderAndTaxTransfer()
        {
            var instanceId     = CommandLineFuncs.SolicitInstanceId();
            var shopifyOrderId = CommandLineFuncs.SolicitShopifyId();

            AutofacRunner.RunInScope(scope =>
            {
                var logger          = scope.Resolve <IPushLogger>();
                var instanceContext = scope.Resolve <InstanceContext>();
                var shopifyOrderGet = scope.Resolve <ShopifyOrderGet>();
                var repository      = scope.Resolve <ShopifyOrderRepository>();
                var jsonService     = scope.Resolve <ShopifyJsonService>();


                instanceContext.Initialize(instanceId);

                shopifyOrderGet.Run(shopifyOrderId);
                var orderRecord  = repository.RetrieveOrder(shopifyOrderId);
                var shopifyOrder = jsonService.RetrieveOrder(orderRecord.ShopifyOrderId);

                logger.Info("Shopify Order JSON" + Environment.NewLine +
                            shopifyOrder.SerializeToJson() + Environment.NewLine);

                var taxTransfer = shopifyOrder.ToTaxTransfer();
                logger.Info("Shopify Tax Transfer: " + Environment.NewLine +
                            taxTransfer.SerializeToJson() + Environment.NewLine);

                var serializedTaxTransfer = taxTransfer.Serialize();
                logger.Info($"Shopify Tax Transfer Serialized:" + Environment.NewLine +
                            serializedTaxTransfer + Environment.NewLine);

                logger.Info($"Shopify Tax Transfer gzipped size: " +
                            $"{serializedTaxTransfer.ToBase64Zip().Length} bytes" +
                            Environment.NewLine);

                var deserializedTaxTransfer = serializedTaxTransfer.DeserializeTaxSnapshot();
                logger.Info($"Shopify Tax Transfer Deserialized:" + Environment.NewLine +
                            deserializedTaxTransfer.SerializeToJson() + Environment.NewLine);

                var lineItem = shopifyOrder.line_items[0];

                var testCalc = deserializedTaxTransfer.CalculateTax(lineItem.sku, lineItem.UnitPriceAfterDiscount, 1);

                logger.Info("Test Tax Calculation: " + Environment.NewLine +
                            testCalc.SerializeToJson() + Environment.NewLine);
            });
        }
示例#5
0
        public static void RegisterInstance()
        {
            Console.WriteLine(Environment.NewLine + "Enter Instance database name:");
            var database = Console.ReadLine();

            if (!CommandLineFuncs.Confirm(
                    $"Are you sure you want to register database: {database} as an Instance?"))
            {
                return;
            }

            AutofacRunner.RunInScope(scope =>
            {
                var repository = scope.Resolve <MasterRepository>();
                repository.InsertInstance(database, true);
            });

            Console.WriteLine($"Database {database} registered as an Instance..." + Environment.NewLine);
        }
示例#6
0
        public static void RunViewSalesPriceInquiry()
        {
            var instanceId = CommandLineFuncs.SolicitInstanceId();

            AutofacRunner.RunInScope(scope =>
            {
                var instanceContext    = scope.Resolve <InstanceContext>();
                var acumaticaContext   = scope.Resolve <AcumaticaHttpContext>();
                var distributionClient = scope.Resolve <DistributionClient>();
                var logger             = scope.Resolve <IPushLogger>();

                instanceContext.Initialize(instanceId);

                acumaticaContext.SessionRun(() =>
                {
                    var json = distributionClient.SalesPricesInquiry();
                    //logger.Info(json);
                });
            });
        }
示例#7
0
        public static void RunShopifyOrderGetToAcumaticaOrderPut()
        {
            var instanceId     = CommandLineFuncs.SolicitInstanceId();
            var shopifyOrderId = CommandLineFuncs.SolicitShopifyId();

            AutofacRunner.RunInScope(scope =>
            {
                var instanceContext = scope.Resolve <InstanceContext>();
                instanceContext.Initialize(instanceId);

                Console.WriteLine($"Processing Shopify Order Id: {shopifyOrderId}");

                var shopifyOrderGet = scope.Resolve <ShopifyOrderGet>();
                var order           = shopifyOrderGet.Run(shopifyOrderId).order;

                var orderSync = scope.Resolve <AcumaticaOrderPut>();

                var acumaticaContext = scope.Resolve <AcumaticaHttpContext>();
                acumaticaContext.SessionRun(() => orderSync.RunOrder(shopifyOrderId));
            });
        }