Added First version of Process Manager in Client App

Added Javascript TestPage in wwwroot
This commit is contained in:
CMS3762\carminatini
2017-12-07 09:17:29 +01:00
parent 512a2200c6
commit e043ae2181
27 changed files with 1121 additions and 656 deletions
+78 -5
View File
@@ -2,6 +2,8 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -16,16 +18,15 @@ namespace Client.Config
public static void ReadStartupConfig()
{
//Read Exe Folder
String XmlConfigPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
// Read validation file
XmlSchemaSet readerSettings = new XmlSchemaSet();
// Add Schema
readerSettings.Add(null, XmlConfigPath + "\\" + Constants.STARTUP_CONFIG_SCHEMA_PATH);
readerSettings.Add(null, Constants.STARTUP_CONFIG_SCHEMA_PATH);
// Open file reader
XDocument xmlConfigFile = XDocument.Load(XmlConfigPath + "\\" + Constants.STARTUP_CONFIG_PATH);
XDocument xmlConfigFile = XDocument.Load(Constants.STARTUP_CONFIG_PATH);
// Validate file
xmlConfigFile.Validate(readerSettings, ValidationHandler);
@@ -42,7 +43,8 @@ namespace Client.Config
.Select(x => new SubModels.Connection()
{
Url = ValidateUrl(x.Element("Url").Value),
Id = ValidateClientID(x.Element("Id").Value)
Id = ValidateClientID(x.Element("Id").Value),
DeleteCahceFolderOnStartup = ValidateDelCache(x.Element("DeleteCahceFolderOnStartup").Value),
}).FirstOrDefault();
Config.VendorHmiConfig = xmlConfigFile
@@ -53,6 +55,18 @@ namespace Client.Config
Type = ValidateNcType(x.Element("Type").Value)
}).FirstOrDefault();
Config.ExtSoftwaresConfig = xmlConfigFile
.Descendants(Constants.EXTSFT_CONFIG_KEY)
.Elements("Software")
.Select(x => new SubModels.Software()
{
Path = ValidateSFTPath(x.Element("Path").Value),
LongName = ValidateSFTLName(x.Element("LongName").Value),
ShortName = ValidateSFTSName(x.Element("ShortName").Value),
IconBase64 = ExtractBase64Icon(x.Element("Path").Value)
}).ToArray();
// Read ARGS Config
if (!String.IsNullOrWhiteSpace(Arguments.Url))
@@ -141,6 +155,65 @@ namespace Client.Config
throw new Exception(@"Configuration Error: ""Connection - Id"" is not a valid Id of CMS-Client");
}
private static Boolean ValidateDelCache(String value)
{
Boolean DelCache;
if (Boolean.TryParse(value, out DelCache))
return DelCache;
else
throw new Exception(@"Configuration Error: ""Connection - DeleteCahceFolderOnStartup"" is not a valid Boolean Type");
}
private static String ValidateSFTPath(String value)
{
if(File.Exists(value))
return value;
else
throw new Exception(@"Configuration Error: File """+ value + @""" not found");
}
private static String ValidateSFTSName(String value)
{
if (!String.IsNullOrEmpty(value))
{
if (value.Count() <= 3)
return value;
else
throw new Exception(@"Configuration Error: Short Name """ + value + @""" cannot be over 3 Letters");
}
else
throw new Exception(@"Configuration Error: Software Short Name Must be setted");
}
private static String ValidateSFTLName(String value)
{
if (!String.IsNullOrEmpty(value))
return value;
else
throw new Exception(@"Configuration Error: Software Long Name Must be setted");
}
private static String ExtractBase64Icon(String value)
{
Image im = Icon.ExtractAssociatedIcon(value).ToBitmap();
MemoryStream m = new MemoryStream();
im.Save(m, ImageFormat.Png);
return "data:image/png;base64," + Convert.ToBase64String(m.ToArray());
}
#endregion