public static void RefreshServiceConfig() { try { _serviceConfig = _configurator.GetServiceConfig(); JobQueueManager.Stop(); ConfigureMailNotifications(); if (!_serviceConfig.LogToDatabase) { SyncEngineLogger.DeregisterLogger(_databaseLogger); } if (!_serviceConfig.LogToFile) { SyncEngineLogger.DeregisterLogger(_textFileLogger); } JobQueueManager.Start(_serviceConfig.IntervalInSeconds); } catch (Exception ex) { EventViewerLogger.WriteToLog(ex); SyncEngineLogger.WriteExceptionToLog(ex); SyncEngineLogger.WriteToLog(LogEntryType.Warning, "The service config could not be refreshed and will occur the next time the service starts."); } }
public SelfContainedMigrator(string migrationName, Guid migrationId, string sourceName, string targetName) { JobQueueManager.Start(1); _integration = new Integration(migrationId, migrationName, Assembly.GetCallingAssembly().Location, sourceName, targetName); var loggingPath = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location) + @"\Logs"; var textFileLogger = new TextFileLogger(loggingPath); SyncEngineLogger.RegisterLogger(textFileLogger, LoggingLevel.ErrorsWarningsInfoDebugAndTrace, -1); }
public void Start(double intervalInSeconds) { try { JobQueueManager.Start(intervalInSeconds); } catch (Exception ex) { SyncEngineLogger.WriteExceptionToLog(ex, WEB_SERVICE_EXCEPTION_MESSAGE); throw; } }
// Start the Windows service. protected override void OnStart(string[] onStartArgs) { try { // get connection string from connectionStrings in App.config GetIntegrationDbConnectionString(); // test connection to the queue database TestIntegrationDbConnection(IntegrationDbConnectionString); _dbQueueLogger = new JobQueueDatabaseLogger(IntegrationDbConnectionString); _configurator = new SyncEngineDatabaseConfigurator(IntegrationDbConnectionString); JobQueueManager.Configurator = _configurator; _serviceConfig = _configurator.GetServiceConfig(); // reset the logger as a precaution SyncEngineLogger.Clear(); // configure mail notifications, if enabled if (_serviceConfig.EnableMailNotifications) { ConfigureMailNotifications(); } // add database and text file loggers RegisterLoggers(); // register integrations for the database and text file loggers RegisterIntegrations(); // associate the database logger with the queue manager JobQueueLogManager.AddLogger(_dbQueueLogger); // recover any job instances from a server or service restart; this will only apply to on-demand job instances _dbQueueLogger.RecoverJobInstancesFromQueueLog(); // add the next run times for each scheduled job; clear any existing scheduled jobs from the queue _scheduledJobManager = new ScheduledJobManager(_configurator); _scheduledJobManager.QueueScheduledJobs(clearExistingScheduledJobInstancesFromWaitingQueue: true); // once a scheduled job is complete (i.e. queue request), queue for the next run time JobQueueManager.JobQueueRequestStatusChanged += new EventHandler <JobQueueRequestStatusChangedArgs>((s, e) => { if (e.QueueRequest.Status == JobQueueRequestStatus.Completed && e.QueueRequest.InvocationSourceType == JobInvocationSourceType.Scheduled) { _scheduledJobManager.QueueJobForNextScheduledRunTime(e.QueueRequest.Job.Id); } }); JobQueueManager.MaxDelayedStartByJobPriority = _configurator.GetJobPriorityConfig(); JobQueueManager.Start(_serviceConfig.IntervalInSeconds); InitializeWebServiceHosts(); } catch (Exception ex) { EventViewerLogger.WriteToLog(ex); SyncEngineLogger.WriteExceptionToLog(ex); // stop the service this.Stop(); } }