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 static async Task CopyFromFortnox(
            // Trigger every six minutes.
            [TimerTrigger("0 */6 * * * *")] TimerInfo timer,
            ILogger logger)
        {
            try
            {
                var changeTracker = await FortnoxChangeTracker.Create(
                    logger,
                    TypedEnvironment.AzureWebJobsStorage);

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

                var configurations = configService.LoadEnabledFortnoxConfigurations();
                foreach (var configuration in configurations)
                {
                    var dateTimeBeforeSync = DateTime.UtcNow;
                    await changeTracker.EnqueueUpsertedItems(configuration.LastSuccessfulCopyFromErpHeartbeat, configuration);

                    await configService.UpdateLastSuccessfulCopyFromErpHeartbeat(configuration.WebcrmSystemId, dateTimeBeforeSync);
                }
            }
            catch (SwaggerException ex)
            {
                SwaggerExceptionLogger.Log(ex);
            }
        }
Beispiel #3
0
        public static async Task CopyFromPoweroffice(
            // Trigger every six minutes.
            [TimerTrigger("30 */6 * * * *")] TimerInfo timer,
            ILogger logger)
        {
            try
            {
                var configService = await PowerofficeConfigService.Create(TypedEnvironment.DatabaseCredentials);

                var powerofficeClientFactory = new PowerofficeClientFactory(TypedEnvironment.PowerofficeApiSettings);
                var powerofficeChangeTracker = await PowerofficeChangeTracker.Create(logger, TypedEnvironment.AzureWebJobsStorage, powerofficeClientFactory);

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

                    await powerofficeChangeTracker.EnqueueUpsertedItemsForOneSystem(configuration.LastSuccessfulCopyFromErpHeartbeat, configuration);

                    await configService.UpdateLastSuccessfulCopyFromErpHeartbeat(configuration.WebcrmSystemId, dateTimeBeforeSync);
                }
            }
            catch (SwaggerException ex)
            {
                SwaggerExceptionLogger.Log(ex);
            }
        }
Beispiel #4
0
        public static async Task Run(
            [QueueTrigger(Constants.FortnoxQueueName)] string queueItem,
            ILogger logger)
        {
            try
            {
                var webcrmClientFactory      = new WebcrmClientFactory(logger, TypedEnvironment.WebcrmApiBaseUrl);
                var fortnoxMessageDispatcher = await FortnoxMessageDispatcher.Create(logger, webcrmClientFactory, TypedEnvironment.DatabaseCredentials);

                var message = JsonConvert.DeserializeObject <FortnoxQueueMessage>(queueItem);
                await fortnoxMessageDispatcher.HandleDequeuedMessage(message);
            }
            catch (SwaggerException ex)
            {
                SwaggerExceptionLogger.Log(ex);
            }
        }
        public static async Task Run(
            [QueueTrigger(Constants.PowerofficeQueueName)] string queueItem,
            ILogger logger)
        {
            logger.LogTrace($"Dequeuing message from the '{Constants.PowerofficeQueueName}' queue.");

            try
            {
                var webcrmClientFactory      = new WebcrmClientFactory(logger, TypedEnvironment.WebcrmApiBaseUrl);
                var powerofficeClientFactory = new PowerofficeClientFactory(TypedEnvironment.PowerofficeApiSettings);
                var dispatcher = await PowerofficeMessageDispatcher.Create(logger, webcrmClientFactory, TypedEnvironment.DatabaseCredentials, powerofficeClientFactory);

                var message = JsonConvert.DeserializeObject <PowerofficeQueueMessage>(queueItem);
                await dispatcher.HandleDequeuedMessage(message);
            }
            catch (SwaggerException ex)
            {
                SwaggerExceptionLogger.Log(ex);
            }
        }