/// <summary> /// Loads the master config file from disk. /// This will first check for a registry key to locate the config.conf. /// If the file cannot be opened or cannot be found, a default config will be loaded /// </summary> /// <returns>True if a config file was successfully loaded. False if a default config had to be generated.</returns> public bool LoadConfig() { try { var regKey = Registry.LocalMachine.CreateSubKey(@"Software\CoApp\AutoBuild Service") ?? Registry.LocalMachine.OpenSubKey(@"Software\CoApp\AutoBuild Service"); if (regKey == null) { throw new Exception("Unable to load registry key."); } string configfile = (string)(regKey.GetValue("ConfigFile", null)); if (configfile == null) { configfile = @"C:\AutoBuild\config.conf"; regKey.SetValue("ConfigFile", configfile); } UrlEncodedMessage UEM = new UrlEncodedMessage(File.ReadAllText(configfile), AutoBuild.SerialSeperator, true); UEM.DeserializeTo(MasterConfig); MasterConfig.Changed += MasterChanged; return(true); } catch (Exception e) { WriteEvent("Unable to load master config:\n" + e.Message + "\n\nDefault config loaded.", EventLogEntryType.Error, 0, 0); MasterConfig = new AutoBuild_config(); MasterConfig.Changed += MasterChanged; return(false); } }
public AutoBuild() { Daemons = new List<Daemon>(); Waiting = new XDictionary<string, Timer>(); RunQueue = new Queue<string>(); Running = new List<string>(); Projects = new XDictionary<string, ProjectData>(); MasterConfig = new AutoBuild_config(); ServiceName = "AutoBuild"; EventLog.Log = "Application"; EventLog.Source = ServiceName; // Events to enable CanHandlePowerEvent = false; CanHandleSessionChangeEvent = false; CanPauseAndContinue = false; CanShutdown = true; CanStop = true; }
public AutoBuild() { Daemons = new List <Daemon>(); Waiting = new XDictionary <string, Timer>(); RunQueue = new Queue <string>(); Running = new List <string>(); Projects = new XDictionary <string, ProjectData>(); MasterConfig = new AutoBuild_config(); ServiceName = "AutoBuild"; EventLog.Log = "Application"; EventLog.Source = ServiceName; // Events to enable CanHandlePowerEvent = false; CanHandleSessionChangeEvent = false; CanPauseAndContinue = false; CanShutdown = true; CanStop = true; }
//A copy constructor, because I'm always annoyed when I can't find one. public AutoBuild_config(AutoBuild_config source) { _DefaultCleanRepo = source.DefaultCleanRepo; _UseGithubListener = source.UseGithubListener; _ProjectRoot = source.ProjectRoot; _OutputStore = source.OutputStore; _PreTriggerWait = source.PreTriggerWait; _MaxJobs = source.MaxJobs; VersionControlList = new XDictionary <string, VersionControl>(source.VersionControlList); DefaultCommands = new XDictionary <string, List <string> >(source.DefaultCommands); Commands = new XDictionary <string, CommandScript>(source.Commands); DefaultRefs = new ObservableCollection <string>(source.DefaultRefs); VersionControlList.Changed += VCSChanged; DefaultCommands.Changed += DefaultCommandsChanged; Commands.Changed += CommandsChanged; DefaultRefs.CollectionChanged += CollectionChanged; }
//A copy constructor, because I'm always annoyed when I can't find one. public AutoBuild_config(AutoBuild_config source) { _DefaultCleanRepo = source.DefaultCleanRepo; _UseGithubListener = source.UseGithubListener; _ProjectRoot = source.ProjectRoot; _OutputStore = source.OutputStore; _PreTriggerWait = source.PreTriggerWait; _MaxJobs = source.MaxJobs; VersionControlList = new XDictionary<string, VersionControl>(source.VersionControlList); DefaultCommands = new XDictionary<string, List<string>>(source.DefaultCommands); Commands = new XDictionary<string, CommandScript>(source.Commands); DefaultRefs = new ObservableCollection<string>(source.DefaultRefs); VersionControlList.Changed += VCSChanged; DefaultCommands.Changed += DefaultCommandsChanged; Commands.Changed += CommandsChanged; DefaultRefs.CollectionChanged += CollectionChanged; }
protected void MasterChanged(AutoBuild_config config) { SaveConfig(); }
/// <summary> /// Loads the master config file from disk. /// This will first check for a registry key to locate the config.conf. /// If the file cannot be opened or cannot be found, a default config will be loaded /// </summary> /// <returns>True if a config file was successfully loaded. False if a default config had to be generated.</returns> public bool LoadConfig() { try { var regKey = Registry.LocalMachine.CreateSubKey(@"Software\CoApp\AutoBuild Service") ?? Registry.LocalMachine.OpenSubKey(@"Software\CoApp\AutoBuild Service"); if (regKey == null) throw new Exception("Unable to load registry key."); string configfile = (string)(regKey.GetValue("ConfigFile", null)); if (configfile == null) { configfile = @"C:\AutoBuild\config.conf"; regKey.SetValue("ConfigFile", configfile); } UrlEncodedMessage UEM = new UrlEncodedMessage(File.ReadAllText(configfile), AutoBuild.SerialSeperator, true); UEM.DeserializeTo(MasterConfig); MasterConfig.Changed += MasterChanged; return true; } catch (Exception e) { WriteEvent("Unable to load master config:\n" + e.Message + "\n\nDefault config loaded.", EventLogEntryType.Error, 0, 0); MasterConfig = new AutoBuild_config(); MasterConfig.Changed += MasterChanged; return false; } }