public static void SaveSystemConfig() { if (SystemConfig != null) { // 'copy' the current details (nodes/elements/controllers) from the executing state // to the SystemConfig, so they're there for writing when we save // we may not want to always save the disabled devices to the config (ie. if the system is stopped at the // moment) since the disabled devices are inferred from the running status of active devices if (_state == RunState.Started) { SaveDisabledDevices(); } SystemConfig.OutputControllers = OutputControllers; SystemConfig.SmartOutputControllers = SmartOutputControllers; SystemConfig.Previews = Previews; SystemConfig.Elements = Elements; SystemConfig.Nodes = Nodes.GetRootNodes(); SystemConfig.ControllerLinking = ControllerLinking; SystemConfig.Filters = Filters; SystemConfig.DataFlow = DataFlow; SystemConfig.Save(); } if (ModuleStore != null) { ModuleStore.Save(); } }
/// <summary> /// Saves the system config. /// </summary> /// <returns>Queue of Tasks that are processing the saving. Can be monitored if next steps require saving to be complete.</returns> public static Queue <Task> SaveSystemConfig() { var taskQueue = new Queue <Task>(); if (SystemConfig != null) { // 'copy' the current details (nodes/elements/controllers) from the executing state // to the SystemConfig, so they're there for writing when we save // we may not want to always save the disabled devices to the config (ie. if the system is stopped at the // moment) since the disabled devices are inferred from the running status of active devices if (_state == RunState.Started) { SaveDisabledDevices(); } SystemConfig.OutputControllers = OutputControllers; //SystemConfig.SmartOutputControllers = SmartOutputControllers; SystemConfig.Previews = Previews; SystemConfig.Elements = Elements; SystemConfig.Nodes = Nodes.GetRootNodes(); SystemConfig.Filters = Filters; SystemConfig.DataFlow = DataFlow; taskQueue.Enqueue(Task.Factory.StartNew(() => SystemConfig.Save())); } if (ModuleStore != null) { taskQueue.Enqueue(Task.Factory.StartNew(() => ModuleStore.Save())); } return(taskQueue); }
public static async Task <bool> SaveSystemConfigAsync() { if (SystemConfig != null) { Logging.Info("Saving System Config."); if (_systemConfigSaving) { Logging.Error("System config is already being saved. Skipping duplicate request."); return(false); } _systemConfigSaving = true; // 'copy' the current details (nodes/elements/controllers) from the executing state // to the SystemConfig, so they're there for writing when we save // we may not want to always save the disabled devices to the config (ie. if the system is stopped at the // moment) since the disabled devices are inferred from the running status of active devices if (_state == RunState.Started) { SaveDisabledDevices(); } SystemConfig.OutputControllers = OutputControllers; //SystemConfig.SmartOutputControllers = SmartOutputControllers; SystemConfig.Previews = Previews; SystemConfig.Elements = Elements; SystemConfig.Nodes = Nodes.GetRootNodes(); SystemConfig.Filters = Filters; SystemConfig.DataFlow = DataFlow; return(await Task.Factory.StartNew(() => { SystemConfig.Save(); _systemConfigSaving = false; Logging.Info("System Config saved."); return true; })); } return(false); }