Пример #1
0
        public static async Task CopyToPoweroffice(
            // Trigger every six minutes, offset by three.
            [TimerTrigger("30 3-59/6 * * * *")] TimerInfo timer,
            ILogger logger)
        {
            try
            {
                var configService = await PowerofficeConfigService.Create(TypedEnvironment.DatabaseCredentials);

                var webcrmClientFactory = new WebcrmClientFactory(logger, TypedEnvironment.WebcrmApiBaseUrl);
                var webcrmChangeTracker = await WebcrmChangeTracker.Create(logger, webcrmClientFactory, TypedEnvironment.AzureWebJobsStorage);

                var configurations = configService.LoadEnabledPowerofficeConfigurations();
                foreach (var configuration in configurations)
                {
                    var dateTimeBeforeSync = DateTime.UtcNow;

                    await webcrmChangeTracker.EnqueueUpsertedItemsForOneSystem(configuration.LastSuccessfulCopyToErpHeartbeat, configuration);

                    await configService.UpdateLastSuccessfulCopyToErpHeartbeat(configuration.WebcrmSystemId, dateTimeBeforeSync);
                }
            }
            catch (SwaggerException ex)
            {
                SwaggerExceptionLogger.Log(ex);
            }
        }
Пример #2
0
 public WebcrmChangeTrackerTester(ITestOutputHelper output) : base(output)
 {
     // It's safe to use .Result in the tests.
     ChangeTracker = Task.Run(() => WebcrmChangeTracker.Create(
                                  OutputLogger,
                                  TestWebcrmClientFactory,
                                  TestTypedEnvironment.AzureWebJobsStorage)).Result;
 }