Beispiel #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 webcrmClientFactory     = new WebcrmClientFactory(logger, TypedEnvironment.WebcrmApiBaseUrl);
                var powerofficeQueueFactory = new PowerofficeQueueFactory(logger, TypedEnvironment.AzureWebJobsStorage);
                var webcrmChangeTracker     = await WebcrmToPowerofficeChangeTracker.Create(logger, webcrmClientFactory, powerofficeQueueFactory);

                var configService = await PowerofficeConfigService.Create(TypedEnvironment.DatabaseCredentials);

                var configurations = configService.LoadEnabledPowerofficeConfigurations();
                foreach (var configuration in configurations)
                {
                    var dateTimeBeforeSync = DateTime.UtcNow;
                    await webcrmChangeTracker.EnqueueUpsertedItemsToPoweroffice(configuration.LastSuccessfulCopyToErpHeartbeat, configuration);

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