public void Dispose(bool bDisposing) { if (!_bDisposed) { if (bDisposing) { if (_logExchangerTimer != null) { _logExchangerTimer.Dispose(); _logExchangerTimer = null; } if (_contentExchangerTimer != null) { _contentExchangerTimer.Dispose(); _contentExchangerTimer = null; } if (_softwareUpdaterTimer != null) { _softwareUpdaterTimer.Dispose(); _softwareUpdaterTimer = null; } if (_eventLog != null) { _eventLog.Dispose(); _eventLog = null; } } _bDisposed = true; } }
private void ReadIntervalsSetTimerIntervals(OxigenTimer timer) { bool bErrorReadingGeneralData = false; // as a safety measure, before reading the file always set the processing intervals to safety values timer.Interval = timer.SafetyInterval; // read general data try { lock (generalDataObj) _generalData = (GeneralData)Serializer.Deserialize(typeof(GeneralData), _generalDataPath, _decryptionPassword); } catch { bErrorReadingGeneralData = true; _eventLog.WriteEntry(Resources.ErrorOpeningGeneralData, EventLogEntryType.Error); } // if general data's intervals have been read during the life of the service // but there was an error reading General Data now, // keep old values if (timer.IntervalsReadOnce && bErrorReadingGeneralData) { return; } // if general data have been read, process new values if (!bErrorReadingGeneralData) { double interval = -1; lock (generalDataObj) { interval = double.Parse(_generalData.Properties[timer.IntervalPropertyOnGeneralSettings]) * 1000; // convert to miliseconds // now clear references to General Data until next time they are needed _generalData = null; } // Note: there was going to be a logic implemented here that selects the safety interval // if interval on ss_general_data.dat is smaller than the safety interval // Now we always save the interval from the general data file. timer.Interval = interval; timer.IntervalsReadOnce = true; } else { timer.Interval = timer.SafetyInterval; } }
public ServiceOperations() { _debugFilePath = ConfigurationSettings.AppSettings["AppDataPath"] + "SettingsData\\OxigenDebug.txt"; _generalDataPath = ConfigurationSettings.AppSettings["AppDataPath"] + "SettingsData\\ss_general_data.dat"; _userSettingsPath = ConfigurationSettings.AppSettings["AppDataPath"] + "SettingsData\\UserSettings.dat"; _logExchangerPath = ConfigurationSettings.AppSettings["BinariesPath"] + "OxigenLE.exe"; _contentExchangerPath = ConfigurationSettings.AppSettings["BinariesPath"] + "OxigenCE.exe"; _softwareUpdaterPath = ConfigurationSettings.AppSettings["BinariesPath"] + "OxigenSU.exe"; _newSoftwareUpdaterPath = ConfigurationSettings.AppSettings["BinariesPath"] + "OxigenSU.new"; _eventLog = new EventLog(); _eventLog.Log = String.Empty; _eventLog.Source = "Oxigen Service"; _logExchangerTimer = new OxigenTimer("logExchangerProcessingInterval"); _contentExchangerTimer = new OxigenTimer("contentExchangerProcessingInterval"); _softwareUpdaterTimer = new OxigenTimer("softwareUpdaterProcessingInterval"); }