Fix style & renamed contacts

This commit is contained in:
Lucio Maranta
2019-10-23 16:48:02 +02:00
parent da6687cff1
commit 787582958c
14 changed files with 196 additions and 171 deletions
+55 -44
View File
@@ -55,7 +55,7 @@ namespace Step.Config
}
}
private static XDocument GetXmlHandlerWithValidator(string configSchemaFilePath, string configFilePath)
private static XDocument GetXmlHandlerWithValidator(string configSchemaFilePath, string configFilePath, bool isFullPath = false)
{
// Create new instance
XmlSchemaSet readerSettings = new XmlSchemaSet();
@@ -73,7 +73,7 @@ namespace Step.Config
actualFileName = configFilePath;
// Open file reader
XDocument xmlConfigFile = XDocument.Load(BASE_PATH + "\\" + configFilePath);
XDocument xmlConfigFile = XDocument.Load((!isFullPath ? BASE_PATH + "\\": "") + configFilePath);
// Validate file
xmlConfigFile.Validate(readerSettings, ValidationHandler);
@@ -346,7 +346,45 @@ namespace Step.Config
// Get Maintenances file handler
XDocument xmlConfigFile = GetXmlHandlerWithValidator(MAINTENANCES_CONFIG_SCHEMA_PATH, MAINTENANCES_CONFIG_PATH);
ReadContacts(xmlConfigFile);
ReadAssistanceConfig();
Contact2 = xmlConfigFile
.Descendants("contact1")
.Select(x =>
new ContactModel()
{
Name = x.Element("name").Value,
Email = x.Element("email").Value,
PhoneNumber = x.Element("phoneNumber").Value
})
.FirstOrDefault();
Contact1 = xmlConfigFile
.Descendants("contact2")
.Select(x =>
new ContactModel()
{
Name = x.Element("name").Value,
Email = x.Element("email").Value,
PhoneNumber = x.Element("phoneNumber").Value
})
.FirstOrDefault();
Contact3 = xmlConfigFile
.Descendants("contact3")
.Select(x =>
new ContactModel()
{
Name = x.Element("name").Value,
Email = x.Element("email").Value,
PhoneNumber = x.Element("phoneNumber").Value
})
.FirstOrDefault();
WebSiteUrl = xmlConfigFile
.Descendants("webSite")
.Select(x => x.Value)
.FirstOrDefault();
var ci = new CultureInfo("en-US");
var formats = new[] { "M-d-yyyy HH:mm", "dd-MM-yyyy HH:mm", "MM-dd-yyyy HH:mm", "M/d/yyyy HH:mm", "dd/MM/yyyy HH:mm", "MM/dd/yyyy HH:mm" }
@@ -374,10 +412,21 @@ namespace Step.Config
.ToList();
}
public static void ReadContacts(XDocument xmlConfigFile)
public static void ReadAssistanceConfig()
{
string filePath = MAINTENANCES_CONFIG_PATH;
string validator = MAINTENANCES_CONFIG_SCHEMA_PATH;
string key = "assistanceContact";
if (File.Exists(CUSTOMER_CONTACTS))
{
validator = CUSTOMER_CONTACTS_CONFIG_SCHEMA_PATH;
filePath = CUSTOMER_CONTACTS;
key = "assistanceConfig";
}
XDocument xmlConfigFile = GetXmlHandlerWithValidator(validator, filePath, true);
ContactConfig = xmlConfigFile
.Descendants("contact")
.Descendants(key)
.Select(x =>
new ContactModel()
{
@@ -386,44 +435,6 @@ namespace Step.Config
PhoneNumber = x.Element("phoneNumber").Value
})
.FirstOrDefault();
BackOfficeConfig = xmlConfigFile
.Descendants("backOfficeContact")
.Select(x =>
new ContactModel()
{
Name = x.Element("name").Value,
Email = x.Element("email").Value,
PhoneNumber = x.Element("phoneNumber").Value
})
.FirstOrDefault();
SparePartConfig = xmlConfigFile
.Descendants("sparePartsContact")
.Select(x =>
new ContactModel()
{
Name = x.Element("name").Value,
Email = x.Element("email").Value,
PhoneNumber = x.Element("phoneNumber").Value
})
.FirstOrDefault();
RetrofitConfig = xmlConfigFile
.Descendants("retrofitContact")
.Select(x =>
new ContactModel()
{
Name = x.Element("name").Value,
Email = x.Element("email").Value,
PhoneNumber = x.Element("phoneNumber").Value
})
.FirstOrDefault();
WebSiteUrl = xmlConfigFile
.Descendants("webSite")
.Select(x => x.Value)
.FirstOrDefault();
}
private static void ReadNcSoftKeys()
@@ -491,7 +502,7 @@ namespace Step.Config
{
AlarmId = Convert.ToInt32(x.Element("alarmId").Value),
PlcId = Convert.ToInt32(x.Element("plcId").Value),
RestoreIsActive = Convert.ToBoolean(x.Element("restoreIsActive").Value)
RestoreIsActive = Convert.ToBoolean(x.Element("restoreIsActive").Value)
})
.ToList();
}