public void Run() { Logger.Info("QP8.ArticleScheduler starting..."); var unityConfig = new UnityContainerCustomizer(); _cancellationTokenSource = new CancellationTokenSource(); _task = new Task(() => { do { try { QPConfiguration.ConfigServiceUrl = _props.ConfigServiceUrl; QPConfiguration.ConfigServiceToken = _props.ConfigServiceToken; QPConfiguration.XmlConfigPath = _props.XmlConfigPath; var customers = QPConfiguration.GetCustomers(AppName) .Where(c => c.DbType == DatabaseType.SqlServer) .Where(c => !c.ExcludeFromSchedulers) .ToList(); new QpScheduler(unityConfig.UnityContainer, customers, _props.PrtgLoggerTasksQueueCheckShiftTime).Run(); } catch (Exception ex) { Logger.Error().Exception(ex).Message("There was an error while starting the service job").Write(); } } while (!_cancellationTokenSource.Token.WaitHandle.WaitOne(_props.RecurrentTimeout)); }, _cancellationTokenSource.Token, TaskCreationOptions.LongRunning); _task.Start(); Logger.Info("QP8.ArticleScheduler started"); }
public void Execute(IJobExecutionContext context) { var customers = QPConfiguration.GetCustomers(AppName).Where(c => !(c.ExcludeFromSchedulers || c.ExcludeFromSchedulersCdcElastic)).ToList(); var customersDictionary = new Dictionary <QaConfigCustomer, bool>(); var prtgErrorsHandlerVm = new PrtgErrorsHandlerViewModel(customers); var customersWithEnabledCdc = customers.Where(customer => { try { return(ShouldUseCdcForCustomerCode(customer)); } catch (Exception ex) { ex.Data.Clear(); ex.Data.Add("CustomerCode", customer.CustomerName); Logger.Log.Warn($"There was an error while reading customer code settings: {customer.CustomerName}", ex); prtgErrorsHandlerVm.EnqueueNewException(ex); } return(false); }).ToList(); foreach (var customer in customersWithEnabledCdc) { try { customersDictionary.Add(customer, IsCustomerQueueEmpty(customer)); } catch (Exception ex) { ex.Data.Clear(); ex.Data.Add("CustomerCode", customer.CustomerName); Logger.Log.Warn($"There was an error while reading customer code settings: {customer.CustomerName}", ex); prtgErrorsHandlerVm.EnqueueNewException(ex); } } CdcSynchronizationContext.ReplaceData(customersDictionary); _prtgLogger.LogMessage(prtgErrorsHandlerVm); }
public Task Execute(IJobExecutionContext context) { var customers = QPConfiguration.GetCustomers(AppName) .Where(c => c.DbType == DatabaseType.SqlServer) .Where(c => !(c.ExcludeFromSchedulers || c.ExcludeFromSchedulersCdcElastic)) .ToList(); var customersDictionary = new Dictionary <QaConfigCustomer, bool>(); var customersWithEnabledCdc = customers.Where(customer => { try { return(ShouldUseCdcForCustomerCode(customer)); } catch (Exception ex) { Logger.Warn(ex, "There was an error while reading customer code: {customerCode}", customer.CustomerName); } return(false); }).ToList(); foreach (var customer in customersWithEnabledCdc) { if (context.CancellationToken.IsCancellationRequested) { return(Task.FromCanceled(context.CancellationToken)); } try { customersDictionary.Add(customer, IsCustomerQueueEmpty(customer)); } catch (Exception ex) { Logger.Warn(ex, "There was an error while processing customer code: {customerCode}", customer.CustomerName); } } CdcSynchronizationContext.ReplaceData(customersDictionary); return(Task.CompletedTask); }
public void Run() { var unityConfig = new UnityContainerCustomizer(); var prtgLogger = new PrtgErrorsHandler(unityConfig.UnityContainer.Resolve <IPrtgNLogFactory>()); _cancellationTokenSource = new CancellationTokenSource(); _task = new Task(() => { do { try { var customers = QPConfiguration.GetCustomers(AppName).Where(c => !c.ExcludeFromSchedulers).ToList(); new QpScheduler(unityConfig.UnityContainer, prtgLogger, customers, _tasksQueueCheckShiftTime).Run(); } catch (Exception ex) { Logger.Log.Error("There was an error while starting the service job", ex); } } while (!_cancellationTokenSource.Token.WaitHandle.WaitOne(_recurrentTimeout)); }, _cancellationTokenSource.Token, TaskCreationOptions.LongRunning); _task.Start(); }
public IEnumerator <QaConfigCustomer> GetEnumerator() { return(QPConfiguration.GetCustomers(_descriptor.Name).Where(c => !c.ExcludeFromSchedulers).GetEnumerator()); }
public QaConfigCustomer[] GetItems() { return(QPConfiguration.GetCustomers(AppName).Where(c => !c.ExcludeFromSchedulers).ToArray()); }