public AggregatorService(Options options) { ServiceName = ASC_MAIL_COLLECTION_SERVICE_NAME; EventLog.Log = "Application"; // These Flags set whether or not to handle that specific // type of event. Set to true if you need it, false otherwise. CanHandlePowerEvent = false; CanHandleSessionChangeEvent = false; CanPauseAndContinue = false; CanShutdown = true; CanStop = true; try { _log = LoggerFactory.GetLogger(LoggerFactory.LoggerType.Log4Net, "MainThread"); _logStat = LogManager.GetLogger("ASC.MAIL.STAT"); _tasksConfig = TasksConfig.FromConfig; _tasksConfig.DefaultFolders = MailQueueItemSettings.DefaultFolders; _tasksConfig.ImapFlags = MailQueueItemSettings.ImapFlags; _tasksConfig.PopUnorderedDomains = MailQueueItemSettings.PopUnorderedDomains; _tasksConfig.SkipImapFlags = MailQueueItemSettings.SkipImapFlags; _tasksConfig.SpecialDomainFolders = MailQueueItemSettings.SpecialDomainFolders; if (options.OnlyUsers != null) { _tasksConfig.WorkOnUsersOnly.AddRange(options.OnlyUsers.ToList()); } if (options.NoMessagesLimit) { _tasksConfig.MaxMessagesPerSession = -1; } _taskSecondsLifetime = TimeSpan.FromSeconds(ConfigurationManager.AppSettings["mail.task-process-lifetime-seconds"] != null ? Convert.ToInt32(ConfigurationManager.AppSettings["mail.task-process-lifetime-seconds"]) : 300); _queueManager = new QueueManager(_tasksConfig, _log); _resetEvent = new ManualResetEvent(false); _cancelTokenSource = new CancellationTokenSource(); _taskFactory = new TaskFactory(); _tsTaskStateCheckInterval = ConfigurationManager.AppSettings["mail.task-check-state-seconds"] != null ? TimeSpan.FromSeconds( Convert.ToInt32(ConfigurationManager.AppSettings["mail.task-check-state-seconds"])) : TimeSpan.FromSeconds(30); if (_tasksConfig.EnableSignalr) { _signalrWorker = new SignalrWorker(); } _workTimer = new Timer(workTimer_Elapsed, _cancelTokenSource.Token, Timeout.Infinite, Timeout.Infinite); _log.Info("Service is ready."); } catch (Exception ex) { _log.Fatal("CollectorService error under construct: {0}", ex.ToString()); } }