This commit is contained in:
Lucio Maranta
2018-12-19 17:10:11 +01:00
parent 355067e963
commit 4a27b1dba4
6 changed files with 221 additions and 66 deletions
+24 -51
View File
@@ -173,67 +173,40 @@ namespace Step.Config
}
}
#region Read config from file from configuration
private static void ReadScadaFile()
{
List<ScadaSchemaModel> a = new List<ScadaSchemaModel>();
DirectoryInfo d = new DirectoryInfo(SCADA_DIRECTORY);
FileInfo[] files = d.GetFiles("*.xml");
int i = 1;
// Cycle inside xml files
foreach (var file in files)
{
XDocument scadaFile = XDocument.Load(SCADA_DIRECTORY + file.Name);
StreamReader sr = new StreamReader(SCADA_DIRECTORY + file.Name);
XmlSerializer xmlSerializer = new XmlSerializer(typeof(ScadaSchemaModel));
ScadaSchemaModel schema = xmlSerializer.Deserialize(sr) as ScadaSchemaModel;
// Setup incremental ids
schema.Layers = schema.Layers.Select(x => new ScadaSchemaLayerModel()
{
Id = i++,
Buttons = x.Buttons.Select(y => { y.Id = i++; return y; }).ToArray(),
Images = x.Images.Select(y => { y.Id = i++; return y; }).ToArray(),
ProgressBars = x.ProgressBars.Select(y => { y.Id = i++; return y; }).ToArray(),
Inputs = x.Inputs.Select(y => { y.Id = i++; return y; }).ToArray()
})
.ToArray();
StreamReader sr = new StreamReader(SCADA_DIRECTORY + file.Name);
XmlSerializer xs = new XmlSerializer(typeof(ScadaSchemaModel));
ScadaSchemaModel f = xs.Deserialize(sr) as ScadaSchemaModel;
//ScadaSchemaModel schema = scadaFile
// .Elements()
// .Select(root => new ScadaSchemaModel()
// {
// Name = root.Element("name").Value,
// BackgroundImage = "fare il base 64 dell'immagine",
// IsInProductionPage = Convert.ToBoolean(root.Element("isInProductionPage").Value),
// Layers = root
// .Element("layers")?
// .Elements()
// .Select(layer => new ScadaSchemaLayerModel()
// {
// Id = Convert.ToInt32(layer.Element("id").Value),
// Buttons = layer.Element("buttons").Elements().Select(button => new ScadaSchemaButtonModel()
// {
// Id = Convert.ToInt32(button.Element("id").Value),
// Position = new ScadaSchemaPositionModel()
// {
// X = Convert.ToInt32(button.Element("position").Element("x").Value),
// Y = Convert.ToInt32(button.Element("position").Element("y").Value)
// },
// Size = new ScadaSchemaSizeModel()
// {
// X = Convert.ToInt32(button.Element("position").Element("x").Value),
// Y = Convert.ToInt32(button.Element("position").Element("y").Value)
// },
// Status = new ScadaSchemaStatusModel()
// {
// MemValueIndex = button.Element("status").Element("memClickIndex").Value,
// MemVisibleIndex = button.Element("status").Element("memEnabledIndex").Value
// },
// Label = button.Elements("label").Select(label => new ScadaSchemaLabelDataModel()
// {
// BackgroundColod = label.Element("backgroundColor").Value,
// TextAlign = label.Element("textAlign").Value,
// TextColor = label.Element("textColor").Value,
// TextContent = label.Element("textContent").Value,
// TextSize = Convert.ToInt32(label.Element("textSize").Value)
// }).FirstOrDefault()
// }).ToList()
// }).ToList()
// }).First();
if (schema.IsInProductionPage == true)
ProductionScada.Add(schema);
else
Scadas.Add(schema);
}
}
#region Read config from file from configuration
public static void ReadServerConfig()
{
// Get server file handler