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> SaveModuleConfigAsync() { if (ModuleStore != null) { if (_moduleConfigSaving) { Logging.Error("Module config is already being saved. Skipping duplicate request."); return(false); } _moduleConfigSaving = true; Logging.Info("Saving Module Config."); return(await Task.Factory.StartNew(() => { ModuleStore.Save(); _moduleConfigSaving = false; Logging.Info("Module Config saved."); return true; })); } return(false); }