/// <summary> /// Initializes the task scheduler with all configured scheduler tasks. /// </summary> /// <param name="dbSet">The set of active Mosaic databases.</param> /// <returns><c>true</c> if initialization was successful;<c>false</c> otherwise.</returns> public bool Initialize(DatabaseSet dbSet) { if (dbSet == null) { throw new ArgumentException("Invalid dbSet specified."); } this.Trace("Initializing task scheduler..."); _taskConverterStreams.Clear(); _taskConverterStreamConfig.Clear(); try { List<Component> componentList = dbSet.Productive.Query<Component>(new CommandFilter("Type", ComponentType.SchedulerTask.ToString())); foreach (Component component in componentList) { if (component.IsActive == false) { continue; } this.Info("Initializing scheduler task '{0}' with ID '{1}'.", component.Description, component.ID); ISchedulerTask task = ComponentLoader.LoadInterface<ISchedulerTask>(component.Assembly, component.ClassName); if (task == null) { this.Fatal("Scheduler task '{0}' with ID '{1}' in assembly '{2}' and class '{3}' could not be found.", component.Description, component.ID, component.Assembly, component.ClassName); return false; } if (task.Initialize(component.ID, dbSet.Productive.Query<ConfigurationValue>(new CommandFilter("ComponentID", component.ID)), dbSet) == false) { this.Error("Initializing scheduler task '{0}' with ID '{1}' failed.", component.Description, component.ID); return false; } List<int> converterConfiguration = new List<int>(); var connectedConverterList = dbSet.Productive.Query<Component>(new CommandFilter("ConnectedComponentID", component.ID)); foreach (var converter in connectedConverterList) { converterConfiguration.Add(converter.ID); } _taskConverterStreams.Add(task, new List<IConverterStream>()); _taskConverterStreamConfig.Add(task, converterConfiguration); } return true; } catch (Exception ex) { this.Error("Initializing scheduler tasks failed.", ex); } return false; }