Exemplo n.º 1
0
        public ActionResult SyncSettingsAndEnables()
        {
            var settings = _settingsRepository.RetrieveSettings();

            var output = new SyncSettingsModel();

            output.PullFromAcumaticaEnabled = settings.PullFromAcumaticaEnabled;
            output.PullFromShopifyEnabled   = settings.PullFromShopifyEnabled;

            output.SyncOrdersEnabled    = settings.SyncOrdersEnabled;
            output.SyncInventoryEnabled = settings.SyncInventoryEnabled;
            output.SyncRefundsEnabled   = settings.SyncRefundsEnabled;
            output.SyncShipmentsEnabled = settings.SyncFulfillmentsEnabled;

            output.StartingOrderId        = settings.ShopifyOrderId;
            output.StartingOrderName      = settings.ShopifyOrderName.IsNullOrEmptyAlt("(not set)");
            output.StartOrderCreatedAtUtc = settings.ShopifyOrderCreatedAtUtc?.ToString() ?? "(not set)";

            if (settings.ShopifyOrderId.HasValue)
            {
                output.StartingOrderHref = _shopifyUrlService.ShopifyOrderUrl(settings.ShopifyOrderId.Value);
            }

            output.ReleasePaymentsOnSync     = settings.ReleasePaymentsOnSync;
            output.MaxParallelAcumaticaSyncs = settings.MaxParallelAcumaticaSyncs;
            output.MaxNumberOfOrders         = settings.MaxNumberOfOrders;
            output.ShopifyDelayMs            = settings.ShopifyDelayMs;

            output.InventorySyncAvailableQty = settings.InventorySyncAvailableQty;
            output.InventorySyncPrice        = settings.InventorySyncPrice;
            output.InventorySyncWeight       = settings.InventorySyncWeight;

            return(new JsonNetResult(output));
        }
 private void OkButton_Click(object sender, EventArgs e)
 {
     int daysToSync;
     int minutes;
     if (int.TryParse(SyncEveryMinutes.Text, out minutes) && int.TryParse(DaysToSync.Text, out daysToSync))
     {
         var model = new SyncSettingsModel();
         model.SyncDays = daysToSync;
         model.SyncMinutes = minutes;
         _repository.Save(model);
         this.Close();
     }
     else
     {
         MessageBox.Show("Es wurden keine gültigen Zahlen eingegeben", "Fehler", MessageBoxButtons.OK,
             MessageBoxIcon.Error);
     }
 }
Exemplo n.º 3
0
        public static bool SaveSynchronizationInfo(SyncSettingsModel info)
        {
            if (!Directory.Exists(ConfigRepositoryPath))
            {
                Directory.CreateDirectory(ConfigRepositoryPath);
            }

            var infoJson = SerializationService.JsonSerialize(info);

            using (var fs = new FileStream(SyncSettingsFilePath, FileMode.Create))
            {
                using (var sw = new StreamWriter(fs))
                {
                    sw.Write(infoJson);
                }
            }

            return(true);
        }
Exemplo n.º 4
0
        public override void Configure(IFunctionsHostBuilder builder)
        {
            builder.Services.AddLogging();

            builder.Services.AddOptions <AppSettingsModel>()
            .Configure <IConfiguration>((settings, configuration) =>
            {
                configuration.Bind(settings);
            });

            builder.Services.AddHttpClient();
            builder.Services.AddHttpClient <IPexApiClient, PexApiClient>((client) =>
            {
                client.BaseAddress = new Uri(Environment.GetEnvironmentVariable("PEXAPIBaseURL", EnvironmentVariableTarget.Process));
            })
            .AddPolicyHandler(GetPexRetryPolicy());

            builder.Services.AddScoped <IStorageMappingService>(
                provider => new StorageMappingService(
                    provider.GetService <IDataProtectionProvider>()
                    ));

            string storageConnectionString = Environment.GetEnvironmentVariable("StorageConnectionString", EnvironmentVariableTarget.Process);

            builder.Services.AddSingleton(provider =>
                                          new Pex2AplosMappingStorage(
                                              Environment.GetEnvironmentVariable("StorageConnectionString", EnvironmentVariableTarget.Process),
                                              provider.GetService <IStorageMappingService>(),
                                              provider.GetService <ILogger <Pex2AplosMappingStorage> >())
                                          .InitTable());
            builder.Services.AddSingleton(provider => new PexOAuthSessionStorage(Environment.GetEnvironmentVariable("StorageConnectionString", EnvironmentVariableTarget.Process)).InitTable());
            builder.Services.AddSingleton(provider => new Pex2AplosMappingQueue(Environment.GetEnvironmentVariable("StorageConnectionString", EnvironmentVariableTarget.Process)).InitQueue());
            builder.Services.AddSingleton(provider => new SyncResultStorage(Environment.GetEnvironmentVariable("StorageConnectionString", EnvironmentVariableTarget.Process)).InitTable());

            builder.Services.AddScoped <IAccessTokenDecryptor>(provider => new AplosAccessTokenDecryptor());

            builder.Services.AddSingleton(provider =>
            {
                var syncTransactionsInterval =
                    Environment.GetEnvironmentVariable("SyncTransactionsIntervalDays", EnvironmentVariableTarget.Process);
                if (!int.TryParse(syncTransactionsInterval, out var syncTransactionsIntervalDays))
                {
                    syncTransactionsIntervalDays = 60;
                }

                var result = new SyncSettingsModel
                {
                    SyncTransactionsIntervalDays = syncTransactionsIntervalDays
                };
                return(result);
            });

            builder.Services.AddScoped <IAplosApiClientFactory>(provider => new AplosApiClientFactory(
                                                                    provider.GetService <IHttpClientFactory>(),
                                                                    provider.GetService <IAccessTokenDecryptor>(),
                                                                    provider.GetService <ILogger <AplosApiClientFactory> >()));

            builder.Services.AddScoped <IAplosIntegrationMappingService>(provider => new AplosIntegrationMappingService());
            builder.Services.AddScoped <IAplosIntegrationService>(provider => new AplosIntegrationService(
                                                                      provider.GetService <IOptions <AppSettingsModel> >(),
                                                                      provider.GetService <IAplosApiClientFactory>(),
                                                                      provider.GetService <IAplosIntegrationMappingService>(),
                                                                      provider.GetService <IPexApiClient>(),
                                                                      provider.GetService <SyncResultStorage>(),
                                                                      provider.GetService <Pex2AplosMappingStorage>()));

            var dataProtectionApplicationName = Environment.GetEnvironmentVariable("DataProtectionApplicationName", EnvironmentVariableTarget.Process);
            var dataProtectionBlobContainer   = Environment.GetEnvironmentVariable("DataProtectionBlobContainer", EnvironmentVariableTarget.Process);
            var dataProtectionBlobName        = Environment.GetEnvironmentVariable("DataProtectionBlobName", EnvironmentVariableTarget.Process);
            var dataProtectionKeyIdentifier   = Environment.GetEnvironmentVariable("DataProtectionKeyIdentifier", EnvironmentVariableTarget.Process);

            var                storageAccount = CloudStorageAccount.Parse(storageConnectionString);
            CloudBlobClient    blobClient     = storageAccount.CreateCloudBlobClient();
            CloudBlobContainer blobContainer  = blobClient.GetContainerReference(dataProtectionBlobContainer);

            blobContainer.CreateIfNotExistsAsync();

            var keyVaultClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(new AzureServiceTokenProvider().KeyVaultTokenCallback));

            builder.Services
            .AddDataProtection()
            .SetApplicationName(dataProtectionApplicationName)
            .PersistKeysToAzureBlobStorage(
                blobContainer,
                dataProtectionBlobName)
            .ProtectKeysWithAzureKeyVault(
                keyVaultClient,
                dataProtectionKeyIdentifier)
            .DisableAutomaticKeyGeneration();
        }