Example #1
0
        /// <summary>
        /// Read the settings file
        /// </summary>
        private void ReadSettingsFile()
        {
            try
            {
                XElement xmlDoc = XElement.Load(this.configFile);

                foreach (var t in xmlDoc.Descendants("SensorTile"))
                {
                    SensorTileConfigurationEntry configEntry = new SensorTileConfigurationEntry();

                    configEntry.SensorName = t.Attribute("SensorName").Value != null ? t.Attribute("SensorName").Value : string.Empty;
                    configEntry.SensorCategory = t.Attribute("SensorCategory").Value != null ? t.Attribute("SensorCategory").Value : string.Empty;
                    configEntry.SensorType = t.Attribute("SensorType").Value != null ? t.Attribute("SensorType").Value : string.Empty;
                    configEntry.GridColumn = t.Attribute("GridColumn").Value != null ? XmlConvert.ToInt32(t.Attribute("GridColumn").Value) : default(int);
                    configEntry.GridRow = t.Attribute("GridRow").Value != null ? XmlConvert.ToInt32(t.Attribute("GridRow").Value) : default(int);

                    this.Tiles.Add(configEntry);
                }
            }
            catch (Exception ex)
            {
                var msg = DependencyFactory.Resolve<ILocalizerService>(ServiceNames.LocalizerService).GetLocalizedString("MainboardFanControlErrorReadingFanControllerTemplates");
                // Log-Exception
                DependencyFactory.Resolve<ILoggingService>(ServiceNames.LoggingService).LogException(msg, ex);
                // Show exception
                DependencyFactory.Resolve<IExceptionReporterService>(ServiceNames.ExceptionReporterService).ReportException(ex);
            }
        }
Example #2
0
        /// <summary>
        /// Insert new tile config
        /// </summary>
        /// <param name="sensorCategory">Sensor category</param>
        /// <param name="sensorName">Sensor name</param>
        /// <param name="sensorType">Sensor type</param>
        /// <param name="gridRow">The grid row</param>
        /// <param name="gridColumn">The grid column</param>
        public void InsertTileConfig(string sensorCategory, string sensorName, string sensorType, int gridRow, int gridColumn)
        {
            try
            {
                SensorTileConfigurationEntry configEntry = new SensorTileConfigurationEntry(sensorName, sensorCategory, sensorType, gridRow, gridColumn);

                XDocument xmlDoc = XDocument.Load(this.configFile);

                xmlDoc.Element("SensorTiles").Add(configEntry.ToXml());

                xmlDoc.Save(this.configFile);
            }
            catch (Exception ex)
            {
                var msg = DependencyFactory.Resolve<ILocalizerService>(ServiceNames.LocalizerService).GetLocalizedString("MainboardFanControlErrorReadingFanControllerTemplates");
                // Log-Exception
                DependencyFactory.Resolve<ILoggingService>(ServiceNames.LoggingService).LogException(msg, ex);
                // Show exception
                DependencyFactory.Resolve<IExceptionReporterService>(ServiceNames.ExceptionReporterService).ReportException(ex);
            }
        }