WIP maintenances

This commit is contained in:
Lucio Maranta
2018-02-13 17:25:30 +01:00
parent 7cb5b901e9
commit ff11711599
27 changed files with 365 additions and 346 deletions
+41 -10
View File
@@ -1,13 +1,12 @@
using System;
using System.Xml.Schema;
using System.Xml.Linq;
using System.Linq;
using static Step.Config.ServerConfig;
using Step.Model.ConfigModels;
using static Step.Utils.Constants;
using Step.Model.ConfigModels;
using Step.Utils;
using System.Collections.Generic;
using System;
using System.Globalization;
using System.Linq;
using System.Xml.Linq;
using System.Xml.Schema;
using static Step.Config.ServerConfig;
using static Step.Utils.Constants;
namespace Step.Config
{
@@ -52,6 +51,24 @@ namespace Step.Config
.ToList()
.ForEach(x => SetAreaValueByName(x)); // Loop through elements
// Get Maintenances file handler
xmlConfigFile = GetXmlHandlerWithValidator(MAINTENANCES_CONFIG_SCHEMA_PATH, MAINTENANCES_CONFIG_PATH);
MaintenancesConfig = xmlConfigFile
.Root
.Elements()
.ToList()
.Select(x =>
new MaintenanceConfigModel()
{
Id = Convert.ToInt32(x.Element("id").Value),
LocalizedNames = x.Element("localizedNames").Elements().ToDictionary( // Read names list
y => y.Attribute("langKey").Value, y => y.Value
),
count = Convert.ToInt32(x.Element("interval").Value)
}
)
.ToList();
}
catch (Exception ex)
{
@@ -64,7 +81,7 @@ namespace Step.Config
// Create new instance
XmlSchemaSet readerSettings = new XmlSchemaSet();
// Add Schema
readerSettings.Add(null, BASE_PATH + "\\" + configSchemaFilePath );
readerSettings.Add(null, BASE_PATH + "\\" + configSchemaFilePath);
// Open file reader
XDocument xmlConfigFile = XDocument.Load(BASE_PATH + "\\" + configFilePath);
@@ -82,21 +99,27 @@ namespace Step.Config
case AREAS.PRODUCTION_KEY:
SetAreaValue(ref ProductionConfig, element);
break;
case AREAS.TOOLING_KEY:
SetAreaValue(ref ToolingConfig, element);
break;
case AREAS.REPORT_KEY:
SetAreaValue(ref ReportConfig, element);
break;
case AREAS.ALARMS_KEY:
SetAreaValue(ref AlarmsConfig, element);
break;
case AREAS.MAINTENANCE_KEY:
SetAreaValue(ref MaintenanceConfig, element);
break;
case AREAS.UTILITIES_KEY:
SetAreaValue(ref UtilitiesConfig, element);
break;
case AREAS.SCADA_KEY:
SetAreaValue(ref ScadaConfig, element);
break;
@@ -133,23 +156,31 @@ namespace Step.Config
{
case AREAS.PRODUCTION_KEY:
return ProductionConfig.Enabled;
case AREAS.TOOLING_KEY:
return ToolingConfig.Enabled;
case AREAS.REPORT_KEY:
return ProductionConfig.Enabled;
case AREAS.ALARMS_KEY:
return AlarmsConfig.Enabled;
case AREAS.MAINTENANCE_KEY:
return MaintenanceConfig.Enabled;
case AREAS.UTILITIES_KEY:
return UtilitiesConfig.Enabled;
case AREAS.SCADA_KEY:
return ScadaConfig.Enabled;
case AREAS.GENERAL_KEY:
return true;
default:
return false;
}
}
}
}
}