/// <summary> /// Read Fan-Controller-Templates /// </summary> private void ReadFanControllerTemplates() { ObservableCollection <FanControllerTemplate> templates = new ObservableCollection <FanControllerTemplate>(); try { XElement xmlDoc = XElement.Load(DirectoryConstants.FanControllerTemplatesConfig); foreach (var t in xmlDoc.Descendants("FanControllerTemplate")) { FanControllerTemplate template = new FanControllerTemplate(); template.Name = t.Attribute("Name").Value != null?t.Attribute("Name").Value : "n.a."; foreach (var s in t.Descendants("Setting")) { double x = s.Attribute("Temperature").Value != null?XmlConvert.ToDouble(s.Attribute("Temperature").Value) : default(double); double y = s.Attribute("FanVoltageInPercent").Value != null?XmlConvert.ToDouble(s.Attribute("FanVoltageInPercent").Value) : default(double); template.DataPoints.Add(new DataPoint(x, y)); } templates.Add(template); } this.FanControllerTemplates = templates; } 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); } }
/// <summary> /// Read Fan-Controller-Templates /// </summary> private void ReadFanControllerTemplates() { ObservableCollection<FanControllerTemplate> templates = new ObservableCollection<FanControllerTemplate>(); try { XElement xmlDoc = XElement.Load(DirectoryConstants.FanControllerTemplatesConfig); foreach (var t in xmlDoc.Descendants("FanControllerTemplate")) { FanControllerTemplate template = new FanControllerTemplate(); template.Name = t.Attribute("Name").Value != null ? t.Attribute("Name").Value : "n.a."; foreach (var s in t.Descendants("Setting")) { double x = s.Attribute("Temperature").Value != null ? XmlConvert.ToDouble(s.Attribute("Temperature").Value) : default(double); double y = s.Attribute("FanVoltageInPercent").Value != null ? XmlConvert.ToDouble(s.Attribute("FanVoltageInPercent").Value) : default(double); template.DataPoints.Add(new DataPoint(x, y)); } templates.Add(template); } this.FanControllerTemplates = templates; } 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); } }