/// <summary> /// Start monitoring plex /// </summary> internal void Start() { //Find the plex executable _executableFileName = getPlexExecutable(); if (string.IsNullOrEmpty(_executableFileName)) { OnPlexStatusChange(this, new StatusChangeEventArgs("Plex Media Server does not appear to be installed!", EventLogEntryType.Error)); OnPlexStop(this, new EventArgs()); State = PlexState.Stopped; } else { OnPlexStatusChange(this, new StatusChangeEventArgs("Plex executable found at " + _executableFileName)); startPlex(); //load the settings and start a thread that will attempt to bring up all the auxiliary processes Settings settings = SettingsHandler.Load(); _auxAppMonitors.Clear(); settings.AuxiliaryApplications.ForEach(x => _auxAppMonitors.Add(new AuxiliaryApplicationMonitor(x))); //hook up the state change event for all the applications _auxAppMonitors.ForEach(x => x.StatusChange += new AuxiliaryApplicationMonitor.StatusChangeHandler(OnPlexStatusChange)); _auxAppMonitors.AsParallel().ForAll(x => x.Start()); } }
/// <summary> /// Returns the settings file from the server as a json string /// </summary> /// <returns></returns> public string GetSettings() { return(SettingsHandler.Load().Serialize()); }
/// <summary> /// Write the settings to the server /// </summary> /// <param name="settings">Json serialised Settings instance</param> public void SetSettings(string settings) { SettingsHandler.Save(Settings.Deserialize(settings)); }