Beispiel #1
0
        public Task Execute(IJobExecutionContext context)
        {
            Logger.Info("Start enabling");

            var customers = _schedulerCustomers.GetItems();
            var dataMap   = context.MergedJobDataMap;

            customers = JobHelpers.FilterCustomers(customers, dataMap);
            var excludedUsers = dataMap.GetString(ExcludedUsersKey)?.Split(',');

            foreach (var customer in customers)
            {
                try
                {
                    if (context.CancellationToken.IsCancellationRequested)
                    {
                        break;
                    }

                    if (!context.CancellationToken.IsCancellationRequested)
                    {
                        ProcessCustomer(customer, excludedUsers, context.CancellationToken);
                    }
                }
                catch (Exception ex)
                {
                    ex.Data.Clear();
                    ex.Data.Add("CustomerCode", customer.CustomerName);
                    Logger.Error(ex, $"There was an error on customer code: {customer.CustomerName}", ex);
                }
            }

            Logger.Info("Finished enabling users");
            return(Task.CompletedTask);
        }
        async Task IJob.Execute(IJobExecutionContext context)
        {
            Logger.Info("Start sending notifications");
            var items = _schedulerCustomers.GetItems().ToArray();

            items = JobHelpers.FilterCustomers(items, context.MergedJobDataMap);
            var token = context.CancellationToken;

            foreach (var customer in items)
            {
                try
                {
                    if (token.IsCancellationRequested)
                    {
                        break;
                    }

                    var notificationIdsStatus = await ProcessCustomer(customer, token);
                }
                catch (Exception ex)
                {
                    Logger.Error(ex, "There was an error on customer code {customerCode}", customer.CustomerName);
                }
            }

            Logger.Info("End sending notifications");
        }
Beispiel #3
0
        public Task Execute(IJobExecutionContext context)
        {
            Logger.Info("Start cleanup notification queue");
            var items = _schedulerCustomers.GetItems();

            items = JobHelpers.FilterCustomers(items, context.MergedJobDataMap);
            foreach (var customer in items)
            {
                try
                {
                    ProcessCustomer(customer);
                }
                catch (Exception ex)
                {
                    Logger.Error(ex, "There was an error on customer code {customerCode}", customer.CustomerName);
                }
            }

            Logger.Info("End cleanup notification queue");
            return(Task.CompletedTask);
        }
Beispiel #4
0
        public Task Execute(IJobExecutionContext context)
        {
            Logger.Info("Start users synchronization");
            var items = _schedulerCustomers.GetItems();

            items = JobHelpers.FilterCustomers(items, context.MergedJobDataMap);
            foreach (var customer in items)
            {
                try
                {
                    ProcessCustomer(customer);
                }
                catch (Exception ex)
                {
                    Logger.Warn(ex, "There was an error while processing customer code: {customerCode}", customer.CustomerName);
                }
            }

            Logger.Info("End users synchronization");
            return(Task.CompletedTask);
        }
Beispiel #5
0
        public Task Execute(IJobExecutionContext context)
        {
            Logger.Info($"Start disabling inactive users");
            var customers = _schedulerCustomers.GetItems();

            var dataMap = context.MergedJobDataMap;

            customers = JobHelpers.FilterCustomers(customers, dataMap);
            var diff = dataMap.GetIntValue(InactivePeriodKey);

            if (diff <= 0)
            {
                Logger.Warn($"Task is cancelled because inactive period are {diff} days");
                return(Task.CompletedTask);
            }

            foreach (var customer in customers)
            {
                try
                {
                    if (!context.CancellationToken.IsCancellationRequested)
                    {
                        ProcessCustomer(customer, diff, context.CancellationToken);
                    }
                }
                catch (Exception ex)
                {
                    ex.Data.Clear();
                    ex.Data.Add("CustomerCode", customer.CustomerName);
                    Logger.Error(ex, $"There was an error on customer code: {customer.CustomerName}", ex);
                }
            }

            Logger.Info($"Finished disabling inactive users");
            return(Task.CompletedTask);
        }