From fc2ddeeb54e3a71380b98531ab51c5e24c18369a Mon Sep 17 00:00:00 2001 From: Nicola Carminati Date: Tue, 20 Aug 2019 17:31:54 +0200 Subject: [PATCH 01/11] First Commit --- .../GatewayNewtorkConfigurationBuilder.cs | 99 +++ .../GatewayProxyConfigurationBuilder.cs | 93 +++ Step.CmsConnect/Builders/iBuilder.cs | 79 +++ Step.CmsConnect/CmsConnectAdapter.cs | 668 ++++++++++++++++++ .../Events/RebootEventHandlerArgs.cs | 20 + .../Exceptions/GatewayException.cs | 15 + .../Models/GatewayConfiguration.cs | 33 + Step.CmsConnect/Properties/AssemblyInfo.cs | 36 + Step.CmsConnect/Step.CmsConnect.csproj | 63 ++ Step.CmsConnect/packages.config | 5 + Step.sln | 445 ++++++------ .../WebApi/CmsConnectController.cs | 23 + 12 files changed, 1364 insertions(+), 215 deletions(-) create mode 100644 Step.CmsConnect/Builders/GatewayNewtorkConfigurationBuilder.cs create mode 100644 Step.CmsConnect/Builders/GatewayProxyConfigurationBuilder.cs create mode 100644 Step.CmsConnect/Builders/iBuilder.cs create mode 100644 Step.CmsConnect/CmsConnectAdapter.cs create mode 100644 Step.CmsConnect/Events/RebootEventHandlerArgs.cs create mode 100644 Step.CmsConnect/Exceptions/GatewayException.cs create mode 100644 Step.CmsConnect/Models/GatewayConfiguration.cs create mode 100644 Step.CmsConnect/Properties/AssemblyInfo.cs create mode 100644 Step.CmsConnect/Step.CmsConnect.csproj create mode 100644 Step.CmsConnect/packages.config create mode 100644 Step/Controllers/WebApi/CmsConnectController.cs diff --git a/Step.CmsConnect/Builders/GatewayNewtorkConfigurationBuilder.cs b/Step.CmsConnect/Builders/GatewayNewtorkConfigurationBuilder.cs new file mode 100644 index 00000000..337d1451 --- /dev/null +++ b/Step.CmsConnect/Builders/GatewayNewtorkConfigurationBuilder.cs @@ -0,0 +1,99 @@ +using Step.CmsConnect.Builders; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace Step.CmsConnect +{ + public class GatewayNetworkConfigurationBuilder : iBuilder + { + private GatewayNetworkConfiguration config; + + public GatewayNetworkConfigurationBuilder() + { + config = new GatewayNetworkConfiguration(); + } + + public GatewayNetworkConfigurationBuilder HasDhcp(Boolean useDhcp) + { + config.hasDhcp = useDhcp; + return this; + } + + public GatewayNetworkConfigurationBuilder IpAddress(IPAddress ipAddress) + { + config.ipAddress = ipAddress; + return this; + } + + public GatewayNetworkConfigurationBuilder NetMaskAddress(IPAddress netMask) + { + config.netMaskAddress = netMask; + return this; + } + + public GatewayNetworkConfigurationBuilder DefaultGatewayAddress(IPAddress gateway) + { + config.defaultGatewayAddress = gateway; + return this; + } + + public GatewayNetworkConfigurationBuilder DnsAddresses(IEnumerable dns) + { + config.dnsAddresses = dns; + return this; + } + + public GatewayNetworkConfigurationBuilder DnsPrefixes(IEnumerable dnsPrefixes) + { + config.dnsPrefixes = dnsPrefixes; + return this; + } + + public GatewayNetworkConfiguration GenerateConfiguration() + { + + //If DHCP enabled go out + if (config.hasDhcp) + { + config.ipAddress = null; + config.netMaskAddress = null; + config.defaultGatewayAddress = null; + } + else + { + //Controls not NULL + CheckNotNull(config.ipAddress, "IpAddress"); + CheckNotNull(config.netMaskAddress, "NetMaskAddress"); + CheckNotNull(config.defaultGatewayAddress, "DefaultGatewayAddress"); + + //Controls address + CheckIpAddress(config.ipAddress); + CheckNetmaskAddress(config.netMaskAddress); + CheckIpAddress(config.defaultGatewayAddress); + + } + + //Controls DNS Address + if (config.dnsAddresses != null) + { + foreach (IPAddress addr in config.dnsAddresses) + CheckIpAddress(addr); + } + + //Controls empty spaces + if (config.dnsPrefixes != null) + { + foreach (string str in config.dnsPrefixes) + CheckNoEmptySpaces(str, "DnsPrefixes"); + } + + return config; + } + + + } +} diff --git a/Step.CmsConnect/Builders/GatewayProxyConfigurationBuilder.cs b/Step.CmsConnect/Builders/GatewayProxyConfigurationBuilder.cs new file mode 100644 index 00000000..57d9b0ed --- /dev/null +++ b/Step.CmsConnect/Builders/GatewayProxyConfigurationBuilder.cs @@ -0,0 +1,93 @@ +using Step.CmsConnect.Builders; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace Step.CmsConnect +{ + public class GatewayProxyConfigurationBuilder : iBuilder + { + private GatewayProxyConfiguration config; + + public GatewayProxyConfigurationBuilder() + { + config = new GatewayProxyConfiguration(); + } + + public GatewayProxyConfigurationBuilder HasProxy(Boolean useProxy) + { + config.hasProxy = useProxy; + return this; + } + + public GatewayProxyConfigurationBuilder Address(string address) + { + config.address = address; + return this; + } + + public GatewayProxyConfigurationBuilder Address(IPAddress address) + { + CheckIpAddress(address); + config.address = address.ToString(); + return this; + } + + public GatewayProxyConfigurationBuilder Port(uint port) + { + config.port = port; + return this; + } + + public GatewayProxyConfigurationBuilder Username(string username) + { + config.username = username; + return this; + } + + public GatewayProxyConfigurationBuilder Password(string password) + { + config.password = password; + return this; + } + + public GatewayProxyConfigurationBuilder NoproxyAddresses(IEnumerable addresses) + { + config.noproxyAddresses = addresses; + return this; + } + + public GatewayProxyConfiguration GenerateConfiguration() + { + + //If DHCP enabled go out + if (!config.hasProxy) + { + config.address = null; + config.port = 0; + config.username = null; + config.password = null; + config.noproxyAddresses = null; + return config; + } + + //Controls not NULL + CheckNotNull(config.address, "Address"); + + //Controls empty spaces + CheckNoEmptySpaces(config.address, "Address"); + if(config.username != null) + CheckNoEmptySpaces(config.username, "Username"); + if (config.password != null) + CheckNoEmptySpaces(config.password, "Password"); + foreach (string str in config.noproxyAddresses) + CheckNoEmptySpaces(str, "NoproxyAddresses"); + + return config; + } + + } +} diff --git a/Step.CmsConnect/Builders/iBuilder.cs b/Step.CmsConnect/Builders/iBuilder.cs new file mode 100644 index 00000000..c68f8e7a --- /dev/null +++ b/Step.CmsConnect/Builders/iBuilder.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace Step.CmsConnect.Builders +{ + public abstract class iBuilder + { + //------------------------------------ To Implement ------------------------------------ + #region ToImplement_Functions + + + + #endregion + + //------------------------------------ Controls ------------------------------------ + #region Control_Functions + + internal void CheckIpAddress(IPAddress ipAddress) + { + byte[] byteIP = ipAddress.GetAddressBytes(); + + //IP must be NE 0.0.0.0 + if (byteIP[0] == 0 && byteIP[1] == 0 && byteIP[2] == 0 && byteIP[3] == 0) + throw new ArgumentException("IP must be different from 0.0.0.0"); + + } + + internal void CheckNetmaskAddress(IPAddress netmaskAddress) + { + byte[] byteIP = netmaskAddress.GetAddressBytes(); + + //NETMASK must be NE 0.0.0.0 + if (byteIP[0] == 0 && byteIP[1] == 0 && byteIP[2] == 0 && byteIP[3] == 0) + throw new ArgumentException("NETMASK must be different from 0.0.0.0"); + + //NETMASK first number must be NE 0 + if (byteIP[0] == 0) + throw new ArgumentException("NETMASK starting address must be different from 0. Eg: xx.0.0.0 "); + + } + + internal void CheckNotNull(object objToCheck, string paramName) + { + if (objToCheck == null) + throw new FormatException("BAD FORMAT - param \"" + paramName + "\" is mandatory"); + + } + + internal void CheckNoEmptySpaces(string strToCheck,string paramName) + { + if (strToCheck.Contains(" ")) + throw new FormatException("BAD FORMAT - param \"" + paramName + "\" must be without empty spaces"); + + } + + + private bool EvaluateIPV4(string stringValue, out IPAddress address) + { + Regex rgx = new Regex(@"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"); + + if (rgx.IsMatch(stringValue)) + { + IPAddress.TryParse(stringValue, out address); + return true; + } + + address = new IPAddress(0); + return false; + } + + #endregion + + } +} diff --git a/Step.CmsConnect/CmsConnectAdapter.cs b/Step.CmsConnect/CmsConnectAdapter.cs new file mode 100644 index 00000000..db090945 --- /dev/null +++ b/Step.CmsConnect/CmsConnectAdapter.cs @@ -0,0 +1,668 @@ +using Renci.SshNet; +using Renci.SshNet.Common; +using Step.CmsConnect.Events; +using Step.CmsConnect.Exceptions; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; + +namespace Step.CmsConnect +{ + public class CmsConnectAdapter : IDisposable + { + //Internal Constant + private const string SSH_SET_PROXY_COMMAND = "sudo ./setProxy.sh "; + private const string SSH_SET_DNSIP_COMMAND = "sudo ./setDnsIp.sh "; + private const string SSH_SET_DNSSUFFIX_COMMAND = "sudo ./setDnsSuffix.sh "; + private const string SSH_SET_NETWORK_COMMAND = "sudo ./setNetwork.sh "; + private const string SSH_GET_NETWORK_COMMAND = "sudo ./getNetworkConfiguration.sh "; + private const string SSH_GET_PROXY_COMMAND = "sudo ./getProxyConfiguration.sh "; + private const string SSH_GW_REBOOT_COMMAND = "sudo ./gatewayReboot.sh "; + + const string IP_ADDR_LABEL = "IP_ADDRESS="; + const string GATEWAY_LABEL = "DEFAULT_GATEWAY="; + const string DNSIP_LABEL = "DNS_IP="; + const string DNSPREFIX_LABEL = "DNS_SUFFIX="; + const string PROXY_ADDR_LABEL = "PROXY="; + const string NO_PROXY_LABEL = "NO_PROXY="; + const string UNDEF_VALUE = "none"; + + const int REBOOT_MINUTES_MAX = 2; + + + //Internal Private Variable + private string host; + private string username; + private string password; + + //--------------------------------------------------------------------------------------------------- + #region Public_methods + + /// + /// Simple constructor. + /// Create an instance with this configuration: hostname: localhost, username: root, password: root. + /// + public CmsConnectAdapter() + { + this.host = "localhost"; + this.username = "root"; + this.password = "root"; + } + + + /// + /// Advanced constructor. + /// Create an instance with the configuration passed by arguments + /// + /// Name (or IP-Address) of the gateway + /// Username for Gateway Login + /// Password for Gateway Login + /// Thrown when one parameter is null + public CmsConnectAdapter(string hostname, string username, string password) + { + setup(hostname, username, password); + } + + + /// + /// Setup parameters Method. + /// + /// Name (or IP-Address) of the gateway + /// Username for Gateway Login + /// Password for Gateway Login + /// Thrown when one parameter is null + public void setup(string hostname, string username, string password) + { + this.host = hostname ?? throw new NullReferenceException("hostname is mandatory"); + this.username = username ?? throw new NullReferenceException("username is mandatory"); + this.password = password ?? throw new NullReferenceException("password is mandatory"); + } + + + /// + /// Write Proxy-Configuration on Gateway. + /// See for generate the configuration. + /// + /// Configuration of the proxy. + /// + public void WriteGatewayProxyConfiguration(GatewayProxyConfiguration proxyConfiguration) + { + String Command = GenerateSshProxyCommand(proxyConfiguration); + SendSSHCommand(Command); + } + + + /// + /// Write Newtork-Configuration on Gateway. + /// See for generate the configuration. + /// + /// Configuration of the network. + /// + public void WriteGatewayNetworkConfiguration(GatewayNetworkConfiguration networkConfiguration) + { + String NetworkCommand = GenerateSshNetworkCommand(networkConfiguration); + String DnsIpCommand = GenerateSshDnsCommand(networkConfiguration); + String DnsSuffixCommand = GenerateSshDnsSuffxCommand(networkConfiguration); + + SendSSHCommand(new List() { NetworkCommand, DnsIpCommand, DnsSuffixCommand }); + } + + + /// + /// Read Newtork-Configuration saved on Gateway. + /// + /// See + /// + /// + public GatewayNetworkConfiguration ReadGatewayNetworkConfiguration() + { + return ElaborateConfigFromSshNetworkCommand( SendSSHCommand(SSH_GET_NETWORK_COMMAND) ); + } + + + /// + /// Read Proxy-Configuration saved on Gateway. + /// + /// See + /// + /// + public GatewayProxyConfiguration ReadGatewayProxyConfiguration() + { + return ElaborateConfigFromSshProxyCommand(SendSSHCommand(SSH_GET_PROXY_COMMAND)); + } + + + /// + /// Reboot asynchronously the Gateway. + /// + /// Serconds to delay before reboot + /// Handler Callback when the operation is finished or an error occours. + /// See + /// + public void RebootGatewayAsync(int delay, EventHandler handler) + { + //Create the Action + Action> action = (int del, EventHandler hand) => + { + RebootEventHandlerArgs ev = new RebootEventHandlerArgs(); + try + { + this.SendSSHReboot(del); + } + catch (Exception e) + { + ev.errorStatus = true; + ev.errorMessage = e.Message; + } + hand(this, ev); + }; + + // Create a task and not start it. + Task t = new Task (() => action(delay, handler)); + t.Start(); + } + + + /// + /// Reboot and wait a new session of the Gateway. + /// + /// Seconds to delay before reboot + /// + public void RebootGateway(int delay) + { + //Send Command + this.SendSSHReboot(delay); + } + + + public void Dispose() + { + } + + + public override string ToString() + { + return "CmsConnectAdapter - Host:" + this.host; + } + + #endregion + + //--------------------------------------------------------------------------------------------------- + #region SSH_commands_preparations_sub_methods + + //SSH command generator for Proxy setting + private string GenerateSshProxyCommand(GatewayProxyConfiguration configuration) + { + StringBuilder command = new StringBuilder(SSH_SET_PROXY_COMMAND); + + //Call the script without an argument will disable the Proxy + if (configuration.hasProxy) + { + /* 1St parameter. Must be one of these: + * - Address:Port + * - User:Password@Address:Port + */ + + //Setup Username & password if needed + if (!String.IsNullOrWhiteSpace(configuration.username) && !String.IsNullOrWhiteSpace(configuration.password)) + command.Append(configuration.username).Append(":").Append(configuration.password).Append("@"); + + //Setup Address & Port + command.Append(configuration.address).Append(":").Append(configuration.port).Append(" "); + + + /* 2nd parameter. Must be: + * "no_proxy1,no_proxy2,…,no_proxyN" + */ + if (configuration.noproxyAddresses != null) + { + command.Append("\""); + command.Append(string.Join(",", configuration.noproxyAddresses)); + command.Append("\""); + } + } + + return command.ToString(); + } + + + //SSH command generator for Network setting + private string GenerateSshNetworkCommand(GatewayNetworkConfiguration configuration) + { + StringBuilder command = new StringBuilder(SSH_SET_NETWORK_COMMAND); + + if (configuration.hasDhcp) + { + command.Append("DHCP"); + } + else + { + //Set IP address / Netmask + IPNetwork tempIpNetw = IPNetwork.Parse(configuration.ipAddress, configuration.netMaskAddress); + command.Append(configuration.ipAddress).Append("/").Append(tempIpNetw.Cidr).Append(" "); + + if(configuration.defaultGatewayAddress != null) + command.Append(configuration.defaultGatewayAddress); + + } + + return command.ToString(); + } + + + //SSH command generator for Dns setting + private string GenerateSshDnsCommand(GatewayNetworkConfiguration configuration) + { + StringBuilder command = new StringBuilder(SSH_SET_DNSIP_COMMAND); + + if (configuration.dnsAddresses != null) + command.Append(string.Join(",", configuration.dnsAddresses)); + + return command.ToString(); + } + + + //SSH command generator for Dns-Suffix setting + private string GenerateSshDnsSuffxCommand(GatewayNetworkConfiguration configuration) + { + StringBuilder command = new StringBuilder(SSH_SET_DNSSUFFIX_COMMAND); + + if(configuration.dnsPrefixes != null) + command.Append(string.Join(",", configuration.dnsPrefixes)); + + return command.ToString(); + } + + #endregion + + //--------------------------------------------------------------------------------------------------- + #region elaborate_SSH_values_sub_methods + + private GatewayNetworkConfiguration ElaborateConfigFromSshNetworkCommand(List lines) + { + GatewayNetworkConfiguration configuration = new GatewayNetworkConfiguration(); + foreach (string line in lines) + { + if (line.StartsWith(IP_ADDR_LABEL)) + DecodeNetworkIPAddress(line.Remove(0, IP_ADDR_LABEL.Length).Trim(), ref configuration); + else if (line.StartsWith(GATEWAY_LABEL)) + DecodeNetworkDefGateway(line.Remove(0, GATEWAY_LABEL.Length).Trim(), ref configuration); + else if (line.StartsWith(DNSIP_LABEL)) + DecodeNetworkDnsIp(line.Remove(0, DNSIP_LABEL.Length).Trim(), ref configuration); + else if (line.StartsWith(DNSPREFIX_LABEL)) + DecodeNetworkDnsPrefix(line.Remove(0, DNSPREFIX_LABEL.Length).Trim(), ref configuration); + } + return configuration; + } + + private GatewayProxyConfiguration ElaborateConfigFromSshProxyCommand(List lines) + { + GatewayProxyConfiguration configuration = new GatewayProxyConfiguration(); + foreach (string line in lines) + { + if (line.StartsWith(PROXY_ADDR_LABEL)) + DecodeProxyAddress(line.Remove(0, PROXY_ADDR_LABEL.Length).Trim(), ref configuration); + else if (line.StartsWith(NO_PROXY_LABEL)) + DecodeNoProxyUrls(line.Remove(0, NO_PROXY_LABEL.Length).Trim(), ref configuration); + } + return configuration; + } + + #endregion + + //--------------------------------------------------------------------------------------------------- + #region decode_SSH_values_sub_methods + + private void DecodeNetworkIPAddress(string stringValue, ref GatewayNetworkConfiguration configuration) + { + //Check if has DHCP + if (stringValue == "DHCP") + configuration.hasDhcp = true; + else + { + configuration.hasDhcp = false; + + //Check if has / for netmask + if (!stringValue.Contains('/')) + throw new GatewayException("Internal Gateway Error during read (bad format): " + IP_ADDR_LABEL + stringValue); + + string [] tempAddr = stringValue.Split('/'); + //Check if has lenght == 2 + if (tempAddr.Length != 2) + throw new GatewayException("Internal Gateway Error during read (bad format): " + IP_ADDR_LABEL + stringValue); + + + //Set the IPAddress / Netmask + IPAddress tempIp; + if (!EvaluateIPV4(tempAddr[0], out tempIp)) + throw new GatewayException("Internal Gateway Error during read (bad format): " + IP_ADDR_LABEL + stringValue); + + IPNetwork tempIpNetw; + if (!IPNetwork.TryParse(stringValue, out tempIpNetw)) + throw new GatewayException("Internal Gateway Error during read (bad format): " + IP_ADDR_LABEL + stringValue); + + + configuration.ipAddress = tempIp; + configuration.netMaskAddress = tempIpNetw.Netmask; + } + } + + + private void DecodeNetworkDefGateway(string stringValue, ref GatewayNetworkConfiguration configuration) + { + //check if is defined + if (stringValue == UNDEF_VALUE) + configuration.defaultGatewayAddress = null; + else + { + IPAddress tempIp; + if (!EvaluateIPV4(stringValue, out tempIp)) + throw new GatewayException("Internal Gateway Error during read (bad format): " + GATEWAY_LABEL + stringValue); + configuration.defaultGatewayAddress = tempIp; + } + } + + + private void DecodeNetworkDnsIp(string stringValue, ref GatewayNetworkConfiguration configuration) + { + //check if is defined + if (stringValue == UNDEF_VALUE) + configuration.dnsAddresses = null; + else + { + string[] tempStr = stringValue.Split(' '); + if (tempStr.Length == 0) + configuration.dnsAddresses = null; + else + { + IPAddress tempIp; + List tempDns = new List(); + foreach (string str in tempStr) + { + if (string.IsNullOrEmpty(str)) + continue; + if (!EvaluateIPV4(str, out tempIp)) + throw new GatewayException("Internal Gateway Error during read (bad format): " + DNSIP_LABEL + stringValue); + tempDns.Add(tempIp); + } + configuration.dnsAddresses = tempDns; + } + + } + } + + + private void DecodeNetworkDnsPrefix(string stringValue, ref GatewayNetworkConfiguration configuration) + { + //check if is defined + if (stringValue == UNDEF_VALUE) + configuration.dnsPrefixes = null; + else + { + string[] tempStr = stringValue.Split(' '); + if (tempStr.Length == 0) + configuration.dnsPrefixes = null; + else + configuration.dnsPrefixes = tempStr.Where(X=> !String.IsNullOrEmpty(X)).ToList(); + } + } + + + private void DecodeProxyAddress(string stringValue, ref GatewayProxyConfiguration configuration) + { + //check if is defined + if (stringValue == UNDEF_VALUE) + configuration.hasProxy = false; + else + { + configuration.hasProxy = true; + + /* Must be one of these: + * - Address:Port + * - User:Password@Address:Port + */ + if (!stringValue.Contains("@")) + { + //Set username & password + configuration.username = null; + configuration.password = null; + + //Check if has : + if (!stringValue.Contains(':')) + throw new GatewayException("Internal Gateway Error during read (bad format): " + PROXY_ADDR_LABEL + stringValue); + string[] tempAddr = stringValue.Split(':'); + + //Check if has lenght == 2 + if (tempAddr.Length != 2) + throw new GatewayException("Internal Gateway Error during read (bad format): " + PROXY_ADDR_LABEL + stringValue); + + //Set the address + configuration.address = tempAddr[0]; + + //Set the port + UInt32 tempPort; + if (!UInt32.TryParse(tempAddr[1], out tempPort)) + throw new GatewayException("Internal Gateway Error during read (bad format): " + PROXY_ADDR_LABEL + stringValue); + configuration.port = tempPort; + + } + else + { + string[] splitted = stringValue.Split('@'); + + //Check if has lenght == 2 + if (splitted.Length != 2) + throw new GatewayException("Internal Gateway Error during read (bad format): " + PROXY_ADDR_LABEL + stringValue); + + //Check if has : + if (!splitted[0].Contains(':')) + throw new GatewayException("Internal Gateway Error during read (bad format): " + PROXY_ADDR_LABEL + stringValue); + if (!splitted[1].Contains(':')) + throw new GatewayException("Internal Gateway Error during read (bad format): " + PROXY_ADDR_LABEL + stringValue); + + string[] tempLogin = splitted[0].Split(':'); + string[] tempAddr = splitted[1].Split(':'); + + //Check if has lenght == 2 + if (tempLogin.Length != 2) + throw new GatewayException("Internal Gateway Error during read (bad format): " + PROXY_ADDR_LABEL + stringValue); + if (tempAddr.Length != 2) + throw new GatewayException("Internal Gateway Error during read (bad format): " + PROXY_ADDR_LABEL + stringValue); + + //Set the username + configuration.username = tempLogin[0]; + //Set the password + configuration.password = tempLogin[1]; + //Set the address + configuration.address = tempAddr[0]; + + //Set the port + UInt32 tempPort; + if (!UInt32.TryParse(tempAddr[1], out tempPort)) + throw new GatewayException("Internal Gateway Error during read (bad format): " + PROXY_ADDR_LABEL + stringValue); + configuration.port = tempPort; + } + + } + } + + + private void DecodeNoProxyUrls(string stringValue, ref GatewayProxyConfiguration configuration) + { + //check if is defined + if (stringValue == UNDEF_VALUE) + configuration.noproxyAddresses = null; + else + { + string[] tempStr = stringValue.Trim('"').Split(','); + + for (int i=0;i SendSSHCommand(string command) + { + return SendSSHCommand(new List {command}); + } + + + //Send multiple SSH Command + private List SendSSHCommand(IEnumerable command) + { + SshCommand sshCmd; + List returnedValues = new List(); + + //Create the SSH Gateway + SshClient _sshGateway = new SshClient(this.host, this.username, this.password); + try + { + //Connect + _sshGateway.Connect(); + foreach(string cmd in command) + { + //Run command + sshCmd = _sshGateway.RunCommand(cmd); + + //Add return values if esists + returnedValues.AddRange(sshCmd.Result.Split(new[] { "\n" }, StringSplitOptions.None)); + + //Check for errors + if (sshCmd.ExitStatus != 0) + { + _sshGateway.Disconnect(); + throw new GatewayException("Internal Gateway Error: " + sshCmd.Error); + } + } + + //Disconnect + _sshGateway.Disconnect(); + } + catch (SocketException e) + { + throw new GatewayException("Connection Error: - Host:" + this.host); + } + catch (SshConnectionException e) + { + throw new GatewayException("Connection Error: - Host:" + this.host); + } + catch (ProxyException e) + { + throw new GatewayException("Proxy Error: - Host:" + this.host); + } + catch (SshAuthenticationException e) + { + throw new GatewayException("Authentication Error: - Host:" + this.host); + } + catch (SshException e) + { + throw new GatewayException("Internal command Error: - Host:" + this.host); + } + catch (GatewayException e) + { + throw new GatewayException(e.Message); + } + catch (Exception e) + { + throw new GatewayException("Unknown Error: " + e); + } + + return returnedValues; + } + + + //Send REBOOT Command + private void SendSSHReboot(int seconds) + { + //Send SSH Command + SendSSHCommand(SSH_GW_REBOOT_COMMAND + seconds); + + //Wait the time for reboot + Thread.Sleep((seconds + 5) * 1000); + + //Save actual timestamp + DateTime nowAfterReboot = DateTime.Now; + + //Create the Instance + SshClient _sshGateway = new SshClient(this.host, this.username, this.password); + bool connected = false; + + //Try Connection Cycle + do + { + try + { + //If TimeSpan > TOT MIN -> Exception + if((DateTime.Now - nowAfterReboot) > TimeSpan.FromMinutes(REBOOT_MINUTES_MAX)) + throw new GatewayException("Timeout Error during reboot"); + + //Try Connection + _sshGateway.Connect(); + connected = true; + } + catch (SocketException e) + { + //Not Connected + Thread.Sleep(500); + } + catch (SshConnectionException e) + { + //Not Connected + Thread.Sleep(500); + } + catch (SshException e) + { + //Not Connected + Thread.Sleep(500); + } + catch (GatewayException e) + { + //Error + throw new GatewayException(e.Message); + } + catch (Exception e) + { + //Error + throw new GatewayException("Unknown Error during reboot: " + e); + } + } while (!connected); + + _sshGateway.Disconnect(); + } + + #endregion + + } +} diff --git a/Step.CmsConnect/Events/RebootEventHandlerArgs.cs b/Step.CmsConnect/Events/RebootEventHandlerArgs.cs new file mode 100644 index 00000000..5f17ae3b --- /dev/null +++ b/Step.CmsConnect/Events/RebootEventHandlerArgs.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Step.CmsConnect.Events +{ + public class RebootEventHandlerArgs : EventArgs + { + public Boolean errorStatus { get; internal set; } + public String errorMessage { get; internal set; } + + public RebootEventHandlerArgs() + { + errorStatus = false; + errorMessage = ""; + } + } +} diff --git a/Step.CmsConnect/Exceptions/GatewayException.cs b/Step.CmsConnect/Exceptions/GatewayException.cs new file mode 100644 index 00000000..c1e77e8e --- /dev/null +++ b/Step.CmsConnect/Exceptions/GatewayException.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Step.CmsConnect.Exceptions +{ + public class GatewayException: Exception + { + public GatewayException(string message): base(message) + { + } + } +} diff --git a/Step.CmsConnect/Models/GatewayConfiguration.cs b/Step.CmsConnect/Models/GatewayConfiguration.cs new file mode 100644 index 00000000..56a597f1 --- /dev/null +++ b/Step.CmsConnect/Models/GatewayConfiguration.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Net; + +namespace Step.CmsConnect +{ + + + public class GatewayNetworkConfiguration + { + internal GatewayNetworkConfiguration() {} + public Boolean hasDhcp { get; internal set;} + public IPAddress ipAddress { get; internal set; } + public IPAddress netMaskAddress { get; internal set; } + public IPAddress defaultGatewayAddress { get; internal set; } + public IEnumerable dnsAddresses { get; internal set; } + public IEnumerable dnsPrefixes { get; internal set; } + } + + public class GatewayProxyConfiguration + { + internal GatewayProxyConfiguration(){} + public Boolean hasProxy { get; internal set; } + public string address { get; internal set; } + public uint port { get; internal set; } + public string username { get; internal set; } + public string password { get; internal set; } + public IEnumerable noproxyAddresses { get; internal set; } + } +} diff --git a/Step.CmsConnect/Properties/AssemblyInfo.cs b/Step.CmsConnect/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..83a2b4c1 --- /dev/null +++ b/Step.CmsConnect/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Le informazioni generali relative a un assembly sono controllate dal seguente +// set di attributi. Modificare i valori di questi attributi per modificare le informazioni +// associate a un assembly. +[assembly: AssemblyTitle("Step.CmsConnect")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Step.CmsConnect")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili +// ai componenti COM. Se è necessario accedere a un tipo in questo assembly da +// COM, impostare su true l'attributo ComVisible per tale tipo. +[assembly: ComVisible(false)] + +// Se il progetto viene esposto a COM, il GUID seguente verrà utilizzato come ID della libreria dei tipi +[assembly: Guid("49b04d99-0ecd-4900-86d3-7098d61314d7")] + +// Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori: +// +// Versione principale +// Versione secondaria +// Numero di build +// Revisione +// +// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build +// usando l'asterisco '*' come illustrato di seguito: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Step.CmsConnect/Step.CmsConnect.csproj b/Step.CmsConnect/Step.CmsConnect.csproj new file mode 100644 index 00000000..406ede17 --- /dev/null +++ b/Step.CmsConnect/Step.CmsConnect.csproj @@ -0,0 +1,63 @@ + + + + + Debug + AnyCPU + {49B04D99-0ECD-4900-86D3-7098D61314D7} + Library + Properties + Step.CmsConnect + Step.CmsConnect + v4.6.1 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\SSH.NET.2016.1.0\lib\net40\Renci.SshNet.dll + + + + + ..\packages\IPNetwork2.2.4.0.126\lib\net46\System.Net.IPNetwork.dll + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Step.CmsConnect/packages.config b/Step.CmsConnect/packages.config new file mode 100644 index 00000000..4660ea73 --- /dev/null +++ b/Step.CmsConnect/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Step.sln b/Step.sln index e210113d..fb0b9df1 100644 --- a/Step.sln +++ b/Step.sln @@ -1,215 +1,230 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26730.12 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step", "Step\Step.csproj", "{AFED34E1-77DB-4D81-830A-A8D0A190573D}" - ProjectSection(ProjectDependencies) = postProject - {3F5C2483-FC87-43EF-92A8-66FF7D0E440F} = {3F5C2483-FC87-43EF-92A8-66FF7D0E440F} - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.Model", "Step.Model\Step.Model.csproj", "{631375DD-06D3-49BB-8130-D9DDB34C429D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.UI", "Step.UI\Step.UI.csproj", "{20FC0937-E7CA-4693-95F9-7A948EFD173B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.Database", "Step.Database\Step.Database.csproj", "{357D5EE1-FFC8-489B-9232-22CF474D9A6F}" - ProjectSection(ProjectDependencies) = postProject - {3F5C2483-FC87-43EF-92A8-66FF7D0E440F} = {3F5C2483-FC87-43EF-92A8-66FF7D0E440F} - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.Config", "Step.Config\Step.Config.csproj", "{3F5C2483-FC87-43EF-92A8-66FF7D0E440F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "Client\Client.csproj", "{66FA29DB-925A-402B-A4C7-D3D780FB1BC3}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.Utils", "Step.Utils\Step.Utils.csproj", "{CBEB631B-ABFA-4042-9779-C0060B0DFEFE}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CMS.Client", "CMS.Client", "{2F873243-A483-40B6-A0F7-65FC3541A269}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CMS.Step", "CMS.Step", "{0769EE3C-4259-4C72-97B4-0CCAEBFA7724}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Config", "Client.Config\Client.Config.csproj", "{205A6ADE-FB5A-45CB-9C51-9817E7BB8939}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Utils", "Client.Utils\Client.Utils.csproj", "{34434B22-D546-4A5C-B575-49720C77643A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.Core", "Step.Core\Step.Core.csproj", "{DE54FF4C-8390-4489-882A-1BC7D99EF185}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.NC", "Step.NC\Step.NC.csproj", "{B2366B08-96BD-4F6B-B748-B45089B87A14}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Chromium", "Client.Chromium\Client.Chromium.csproj", "{F9F17F23-660E-488C-A7FA-6A5B35D64313}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Debug|x64.ActiveCfg = Debug|Any CPU - {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Debug|x64.Build.0 = Debug|Any CPU - {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Debug|x86.ActiveCfg = Debug|Any CPU - {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Debug|x86.Build.0 = Debug|Any CPU - {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Release|Any CPU.Build.0 = Release|Any CPU - {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Release|x64.ActiveCfg = Release|Any CPU - {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Release|x64.Build.0 = Release|Any CPU - {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Release|x86.ActiveCfg = Release|Any CPU - {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Release|x86.Build.0 = Release|Any CPU - {631375DD-06D3-49BB-8130-D9DDB34C429D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {631375DD-06D3-49BB-8130-D9DDB34C429D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {631375DD-06D3-49BB-8130-D9DDB34C429D}.Debug|x64.ActiveCfg = Debug|Any CPU - {631375DD-06D3-49BB-8130-D9DDB34C429D}.Debug|x64.Build.0 = Debug|Any CPU - {631375DD-06D3-49BB-8130-D9DDB34C429D}.Debug|x86.ActiveCfg = Debug|Any CPU - {631375DD-06D3-49BB-8130-D9DDB34C429D}.Debug|x86.Build.0 = Debug|Any CPU - {631375DD-06D3-49BB-8130-D9DDB34C429D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {631375DD-06D3-49BB-8130-D9DDB34C429D}.Release|Any CPU.Build.0 = Release|Any CPU - {631375DD-06D3-49BB-8130-D9DDB34C429D}.Release|x64.ActiveCfg = Release|Any CPU - {631375DD-06D3-49BB-8130-D9DDB34C429D}.Release|x64.Build.0 = Release|Any CPU - {631375DD-06D3-49BB-8130-D9DDB34C429D}.Release|x86.ActiveCfg = Release|Any CPU - {631375DD-06D3-49BB-8130-D9DDB34C429D}.Release|x86.Build.0 = Release|Any CPU - {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Debug|x64.ActiveCfg = Debug|Any CPU - {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Debug|x64.Build.0 = Debug|Any CPU - {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Debug|x86.ActiveCfg = Debug|Any CPU - {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Debug|x86.Build.0 = Debug|Any CPU - {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Release|Any CPU.Build.0 = Release|Any CPU - {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Release|x64.ActiveCfg = Release|Any CPU - {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Release|x64.Build.0 = Release|Any CPU - {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Release|x86.ActiveCfg = Release|Any CPU - {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Release|x86.Build.0 = Release|Any CPU - {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Debug|x64.ActiveCfg = Debug|Any CPU - {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Debug|x64.Build.0 = Debug|Any CPU - {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Debug|x86.ActiveCfg = Debug|Any CPU - {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Debug|x86.Build.0 = Debug|Any CPU - {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Release|Any CPU.Build.0 = Release|Any CPU - {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Release|x64.ActiveCfg = Release|Any CPU - {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Release|x64.Build.0 = Release|Any CPU - {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Release|x86.ActiveCfg = Release|Any CPU - {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Release|x86.Build.0 = Release|Any CPU - {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Debug|x64.ActiveCfg = Debug|Any CPU - {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Debug|x64.Build.0 = Debug|Any CPU - {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Debug|x86.ActiveCfg = Debug|Any CPU - {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Debug|x86.Build.0 = Debug|Any CPU - {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Release|Any CPU.Build.0 = Release|Any CPU - {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Release|x64.ActiveCfg = Release|Any CPU - {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Release|x64.Build.0 = Release|Any CPU - {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Release|x86.ActiveCfg = Release|Any CPU - {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Release|x86.Build.0 = Release|Any CPU - {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Debug|x64.ActiveCfg = Debug|x64 - {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Debug|x64.Build.0 = Debug|x64 - {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Debug|x86.ActiveCfg = Debug|x86 - {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Debug|x86.Build.0 = Debug|x86 - {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Release|Any CPU.Build.0 = Release|Any CPU - {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Release|x64.ActiveCfg = Release|x64 - {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Release|x64.Build.0 = Release|x64 - {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Release|x86.ActiveCfg = Release|Any CPU - {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Release|x86.Build.0 = Release|Any CPU - {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Debug|x64.ActiveCfg = Debug|Any CPU - {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Debug|x64.Build.0 = Debug|Any CPU - {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Debug|x86.ActiveCfg = Debug|Any CPU - {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Debug|x86.Build.0 = Debug|Any CPU - {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Release|Any CPU.Build.0 = Release|Any CPU - {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Release|x64.ActiveCfg = Release|Any CPU - {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Release|x64.Build.0 = Release|Any CPU - {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Release|x86.ActiveCfg = Release|Any CPU - {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Release|x86.Build.0 = Release|Any CPU - {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Debug|Any CPU.Build.0 = Debug|Any CPU - {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Debug|x64.ActiveCfg = Debug|Any CPU - {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Debug|x64.Build.0 = Debug|Any CPU - {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Debug|x86.ActiveCfg = Debug|Any CPU - {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Debug|x86.Build.0 = Debug|Any CPU - {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Release|Any CPU.ActiveCfg = Release|Any CPU - {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Release|Any CPU.Build.0 = Release|Any CPU - {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Release|x64.ActiveCfg = Release|Any CPU - {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Release|x64.Build.0 = Release|Any CPU - {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Release|x86.ActiveCfg = Release|Any CPU - {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Release|x86.Build.0 = Release|Any CPU - {34434B22-D546-4A5C-B575-49720C77643A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {34434B22-D546-4A5C-B575-49720C77643A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {34434B22-D546-4A5C-B575-49720C77643A}.Debug|x64.ActiveCfg = Debug|Any CPU - {34434B22-D546-4A5C-B575-49720C77643A}.Debug|x64.Build.0 = Debug|Any CPU - {34434B22-D546-4A5C-B575-49720C77643A}.Debug|x86.ActiveCfg = Debug|Any CPU - {34434B22-D546-4A5C-B575-49720C77643A}.Debug|x86.Build.0 = Debug|Any CPU - {34434B22-D546-4A5C-B575-49720C77643A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {34434B22-D546-4A5C-B575-49720C77643A}.Release|Any CPU.Build.0 = Release|Any CPU - {34434B22-D546-4A5C-B575-49720C77643A}.Release|x64.ActiveCfg = Release|Any CPU - {34434B22-D546-4A5C-B575-49720C77643A}.Release|x64.Build.0 = Release|Any CPU - {34434B22-D546-4A5C-B575-49720C77643A}.Release|x86.ActiveCfg = Release|Any CPU - {34434B22-D546-4A5C-B575-49720C77643A}.Release|x86.Build.0 = Release|Any CPU - {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Debug|x64.ActiveCfg = Debug|Any CPU - {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Debug|x64.Build.0 = Debug|Any CPU - {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Debug|x86.ActiveCfg = Debug|Any CPU - {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Debug|x86.Build.0 = Debug|Any CPU - {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Release|Any CPU.Build.0 = Release|Any CPU - {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Release|x64.ActiveCfg = Release|Any CPU - {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Release|x64.Build.0 = Release|Any CPU - {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Release|x86.ActiveCfg = Release|Any CPU - {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Release|x86.Build.0 = Release|Any CPU - {B2366B08-96BD-4F6B-B748-B45089B87A14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B2366B08-96BD-4F6B-B748-B45089B87A14}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B2366B08-96BD-4F6B-B748-B45089B87A14}.Debug|x64.ActiveCfg = Debug|Any CPU - {B2366B08-96BD-4F6B-B748-B45089B87A14}.Debug|x64.Build.0 = Debug|Any CPU - {B2366B08-96BD-4F6B-B748-B45089B87A14}.Debug|x86.ActiveCfg = Debug|Any CPU - {B2366B08-96BD-4F6B-B748-B45089B87A14}.Debug|x86.Build.0 = Debug|Any CPU - {B2366B08-96BD-4F6B-B748-B45089B87A14}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B2366B08-96BD-4F6B-B748-B45089B87A14}.Release|Any CPU.Build.0 = Release|Any CPU - {B2366B08-96BD-4F6B-B748-B45089B87A14}.Release|x64.ActiveCfg = Release|Any CPU - {B2366B08-96BD-4F6B-B748-B45089B87A14}.Release|x64.Build.0 = Release|Any CPU - {B2366B08-96BD-4F6B-B748-B45089B87A14}.Release|x86.ActiveCfg = Release|Any CPU - {B2366B08-96BD-4F6B-B748-B45089B87A14}.Release|x86.Build.0 = Release|Any CPU - {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Debug|x64.ActiveCfg = Debug|Any CPU - {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Debug|x64.Build.0 = Debug|Any CPU - {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Debug|x86.ActiveCfg = Debug|Any CPU - {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Debug|x86.Build.0 = Debug|Any CPU - {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Release|Any CPU.Build.0 = Release|Any CPU - {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Release|x64.ActiveCfg = Release|Any CPU - {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Release|x64.Build.0 = Release|Any CPU - {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Release|x86.ActiveCfg = Release|Any CPU - {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Release|x86.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {AFED34E1-77DB-4D81-830A-A8D0A190573D} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724} - {631375DD-06D3-49BB-8130-D9DDB34C429D} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724} - {20FC0937-E7CA-4693-95F9-7A948EFD173B} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724} - {357D5EE1-FFC8-489B-9232-22CF474D9A6F} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724} - {3F5C2483-FC87-43EF-92A8-66FF7D0E440F} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724} - {66FA29DB-925A-402B-A4C7-D3D780FB1BC3} = {2F873243-A483-40B6-A0F7-65FC3541A269} - {CBEB631B-ABFA-4042-9779-C0060B0DFEFE} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724} - {205A6ADE-FB5A-45CB-9C51-9817E7BB8939} = {2F873243-A483-40B6-A0F7-65FC3541A269} - {34434B22-D546-4A5C-B575-49720C77643A} = {2F873243-A483-40B6-A0F7-65FC3541A269} - {DE54FF4C-8390-4489-882A-1BC7D99EF185} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724} - {B2366B08-96BD-4F6B-B748-B45089B87A14} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724} - {F9F17F23-660E-488C-A7FA-6A5B35D64313} = {2F873243-A483-40B6-A0F7-65FC3541A269} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {51D459FB-B45B-4A47-984E-46C35F933A82} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step", "Step\Step.csproj", "{AFED34E1-77DB-4D81-830A-A8D0A190573D}" + ProjectSection(ProjectDependencies) = postProject + {3F5C2483-FC87-43EF-92A8-66FF7D0E440F} = {3F5C2483-FC87-43EF-92A8-66FF7D0E440F} + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.Model", "Step.Model\Step.Model.csproj", "{631375DD-06D3-49BB-8130-D9DDB34C429D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.UI", "Step.UI\Step.UI.csproj", "{20FC0937-E7CA-4693-95F9-7A948EFD173B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.Database", "Step.Database\Step.Database.csproj", "{357D5EE1-FFC8-489B-9232-22CF474D9A6F}" + ProjectSection(ProjectDependencies) = postProject + {3F5C2483-FC87-43EF-92A8-66FF7D0E440F} = {3F5C2483-FC87-43EF-92A8-66FF7D0E440F} + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.Config", "Step.Config\Step.Config.csproj", "{3F5C2483-FC87-43EF-92A8-66FF7D0E440F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "Client\Client.csproj", "{66FA29DB-925A-402B-A4C7-D3D780FB1BC3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.Utils", "Step.Utils\Step.Utils.csproj", "{CBEB631B-ABFA-4042-9779-C0060B0DFEFE}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CMS.Client", "CMS.Client", "{2F873243-A483-40B6-A0F7-65FC3541A269}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CMS.Step", "CMS.Step", "{0769EE3C-4259-4C72-97B4-0CCAEBFA7724}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Config", "Client.Config\Client.Config.csproj", "{205A6ADE-FB5A-45CB-9C51-9817E7BB8939}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Utils", "Client.Utils\Client.Utils.csproj", "{34434B22-D546-4A5C-B575-49720C77643A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.Core", "Step.Core\Step.Core.csproj", "{DE54FF4C-8390-4489-882A-1BC7D99EF185}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.NC", "Step.NC\Step.NC.csproj", "{B2366B08-96BD-4F6B-B748-B45089B87A14}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Chromium", "Client.Chromium\Client.Chromium.csproj", "{F9F17F23-660E-488C-A7FA-6A5B35D64313}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.CmsConnect", "Step.CmsConnect\Step.CmsConnect.csproj", "{49B04D99-0ECD-4900-86D3-7098D61314D7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Debug|x64.ActiveCfg = Debug|Any CPU + {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Debug|x64.Build.0 = Debug|Any CPU + {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Debug|x86.ActiveCfg = Debug|Any CPU + {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Debug|x86.Build.0 = Debug|Any CPU + {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Release|Any CPU.Build.0 = Release|Any CPU + {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Release|x64.ActiveCfg = Release|Any CPU + {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Release|x64.Build.0 = Release|Any CPU + {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Release|x86.ActiveCfg = Release|Any CPU + {AFED34E1-77DB-4D81-830A-A8D0A190573D}.Release|x86.Build.0 = Release|Any CPU + {631375DD-06D3-49BB-8130-D9DDB34C429D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {631375DD-06D3-49BB-8130-D9DDB34C429D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {631375DD-06D3-49BB-8130-D9DDB34C429D}.Debug|x64.ActiveCfg = Debug|Any CPU + {631375DD-06D3-49BB-8130-D9DDB34C429D}.Debug|x64.Build.0 = Debug|Any CPU + {631375DD-06D3-49BB-8130-D9DDB34C429D}.Debug|x86.ActiveCfg = Debug|Any CPU + {631375DD-06D3-49BB-8130-D9DDB34C429D}.Debug|x86.Build.0 = Debug|Any CPU + {631375DD-06D3-49BB-8130-D9DDB34C429D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {631375DD-06D3-49BB-8130-D9DDB34C429D}.Release|Any CPU.Build.0 = Release|Any CPU + {631375DD-06D3-49BB-8130-D9DDB34C429D}.Release|x64.ActiveCfg = Release|Any CPU + {631375DD-06D3-49BB-8130-D9DDB34C429D}.Release|x64.Build.0 = Release|Any CPU + {631375DD-06D3-49BB-8130-D9DDB34C429D}.Release|x86.ActiveCfg = Release|Any CPU + {631375DD-06D3-49BB-8130-D9DDB34C429D}.Release|x86.Build.0 = Release|Any CPU + {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Debug|x64.ActiveCfg = Debug|Any CPU + {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Debug|x64.Build.0 = Debug|Any CPU + {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Debug|x86.ActiveCfg = Debug|Any CPU + {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Debug|x86.Build.0 = Debug|Any CPU + {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Release|Any CPU.Build.0 = Release|Any CPU + {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Release|x64.ActiveCfg = Release|Any CPU + {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Release|x64.Build.0 = Release|Any CPU + {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Release|x86.ActiveCfg = Release|Any CPU + {20FC0937-E7CA-4693-95F9-7A948EFD173B}.Release|x86.Build.0 = Release|Any CPU + {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Debug|x64.ActiveCfg = Debug|Any CPU + {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Debug|x64.Build.0 = Debug|Any CPU + {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Debug|x86.ActiveCfg = Debug|Any CPU + {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Debug|x86.Build.0 = Debug|Any CPU + {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Release|Any CPU.Build.0 = Release|Any CPU + {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Release|x64.ActiveCfg = Release|Any CPU + {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Release|x64.Build.0 = Release|Any CPU + {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Release|x86.ActiveCfg = Release|Any CPU + {357D5EE1-FFC8-489B-9232-22CF474D9A6F}.Release|x86.Build.0 = Release|Any CPU + {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Debug|x64.ActiveCfg = Debug|Any CPU + {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Debug|x64.Build.0 = Debug|Any CPU + {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Debug|x86.ActiveCfg = Debug|Any CPU + {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Debug|x86.Build.0 = Debug|Any CPU + {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Release|Any CPU.Build.0 = Release|Any CPU + {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Release|x64.ActiveCfg = Release|Any CPU + {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Release|x64.Build.0 = Release|Any CPU + {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Release|x86.ActiveCfg = Release|Any CPU + {3F5C2483-FC87-43EF-92A8-66FF7D0E440F}.Release|x86.Build.0 = Release|Any CPU + {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Debug|x64.ActiveCfg = Debug|x64 + {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Debug|x64.Build.0 = Debug|x64 + {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Debug|x86.ActiveCfg = Debug|x86 + {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Debug|x86.Build.0 = Debug|x86 + {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Release|Any CPU.Build.0 = Release|Any CPU + {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Release|x64.ActiveCfg = Release|x64 + {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Release|x64.Build.0 = Release|x64 + {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Release|x86.ActiveCfg = Release|Any CPU + {66FA29DB-925A-402B-A4C7-D3D780FB1BC3}.Release|x86.Build.0 = Release|Any CPU + {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Debug|x64.ActiveCfg = Debug|Any CPU + {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Debug|x64.Build.0 = Debug|Any CPU + {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Debug|x86.ActiveCfg = Debug|Any CPU + {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Debug|x86.Build.0 = Debug|Any CPU + {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Release|Any CPU.Build.0 = Release|Any CPU + {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Release|x64.ActiveCfg = Release|Any CPU + {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Release|x64.Build.0 = Release|Any CPU + {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Release|x86.ActiveCfg = Release|Any CPU + {CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Release|x86.Build.0 = Release|Any CPU + {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Debug|Any CPU.Build.0 = Debug|Any CPU + {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Debug|x64.ActiveCfg = Debug|Any CPU + {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Debug|x64.Build.0 = Debug|Any CPU + {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Debug|x86.ActiveCfg = Debug|Any CPU + {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Debug|x86.Build.0 = Debug|Any CPU + {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Release|Any CPU.ActiveCfg = Release|Any CPU + {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Release|Any CPU.Build.0 = Release|Any CPU + {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Release|x64.ActiveCfg = Release|Any CPU + {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Release|x64.Build.0 = Release|Any CPU + {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Release|x86.ActiveCfg = Release|Any CPU + {205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Release|x86.Build.0 = Release|Any CPU + {34434B22-D546-4A5C-B575-49720C77643A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {34434B22-D546-4A5C-B575-49720C77643A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {34434B22-D546-4A5C-B575-49720C77643A}.Debug|x64.ActiveCfg = Debug|Any CPU + {34434B22-D546-4A5C-B575-49720C77643A}.Debug|x64.Build.0 = Debug|Any CPU + {34434B22-D546-4A5C-B575-49720C77643A}.Debug|x86.ActiveCfg = Debug|Any CPU + {34434B22-D546-4A5C-B575-49720C77643A}.Debug|x86.Build.0 = Debug|Any CPU + {34434B22-D546-4A5C-B575-49720C77643A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {34434B22-D546-4A5C-B575-49720C77643A}.Release|Any CPU.Build.0 = Release|Any CPU + {34434B22-D546-4A5C-B575-49720C77643A}.Release|x64.ActiveCfg = Release|Any CPU + {34434B22-D546-4A5C-B575-49720C77643A}.Release|x64.Build.0 = Release|Any CPU + {34434B22-D546-4A5C-B575-49720C77643A}.Release|x86.ActiveCfg = Release|Any CPU + {34434B22-D546-4A5C-B575-49720C77643A}.Release|x86.Build.0 = Release|Any CPU + {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Debug|x64.ActiveCfg = Debug|Any CPU + {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Debug|x64.Build.0 = Debug|Any CPU + {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Debug|x86.ActiveCfg = Debug|Any CPU + {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Debug|x86.Build.0 = Debug|Any CPU + {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Release|Any CPU.Build.0 = Release|Any CPU + {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Release|x64.ActiveCfg = Release|Any CPU + {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Release|x64.Build.0 = Release|Any CPU + {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Release|x86.ActiveCfg = Release|Any CPU + {DE54FF4C-8390-4489-882A-1BC7D99EF185}.Release|x86.Build.0 = Release|Any CPU + {B2366B08-96BD-4F6B-B748-B45089B87A14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B2366B08-96BD-4F6B-B748-B45089B87A14}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B2366B08-96BD-4F6B-B748-B45089B87A14}.Debug|x64.ActiveCfg = Debug|Any CPU + {B2366B08-96BD-4F6B-B748-B45089B87A14}.Debug|x64.Build.0 = Debug|Any CPU + {B2366B08-96BD-4F6B-B748-B45089B87A14}.Debug|x86.ActiveCfg = Debug|Any CPU + {B2366B08-96BD-4F6B-B748-B45089B87A14}.Debug|x86.Build.0 = Debug|Any CPU + {B2366B08-96BD-4F6B-B748-B45089B87A14}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B2366B08-96BD-4F6B-B748-B45089B87A14}.Release|Any CPU.Build.0 = Release|Any CPU + {B2366B08-96BD-4F6B-B748-B45089B87A14}.Release|x64.ActiveCfg = Release|Any CPU + {B2366B08-96BD-4F6B-B748-B45089B87A14}.Release|x64.Build.0 = Release|Any CPU + {B2366B08-96BD-4F6B-B748-B45089B87A14}.Release|x86.ActiveCfg = Release|Any CPU + {B2366B08-96BD-4F6B-B748-B45089B87A14}.Release|x86.Build.0 = Release|Any CPU + {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Debug|x64.ActiveCfg = Debug|Any CPU + {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Debug|x64.Build.0 = Debug|Any CPU + {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Debug|x86.ActiveCfg = Debug|Any CPU + {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Debug|x86.Build.0 = Debug|Any CPU + {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Release|Any CPU.Build.0 = Release|Any CPU + {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Release|x64.ActiveCfg = Release|Any CPU + {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Release|x64.Build.0 = Release|Any CPU + {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Release|x86.ActiveCfg = Release|Any CPU + {F9F17F23-660E-488C-A7FA-6A5B35D64313}.Release|x86.Build.0 = Release|Any CPU + {49B04D99-0ECD-4900-86D3-7098D61314D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {49B04D99-0ECD-4900-86D3-7098D61314D7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {49B04D99-0ECD-4900-86D3-7098D61314D7}.Debug|x64.ActiveCfg = Debug|Any CPU + {49B04D99-0ECD-4900-86D3-7098D61314D7}.Debug|x64.Build.0 = Debug|Any CPU + {49B04D99-0ECD-4900-86D3-7098D61314D7}.Debug|x86.ActiveCfg = Debug|Any CPU + {49B04D99-0ECD-4900-86D3-7098D61314D7}.Debug|x86.Build.0 = Debug|Any CPU + {49B04D99-0ECD-4900-86D3-7098D61314D7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {49B04D99-0ECD-4900-86D3-7098D61314D7}.Release|Any CPU.Build.0 = Release|Any CPU + {49B04D99-0ECD-4900-86D3-7098D61314D7}.Release|x64.ActiveCfg = Release|Any CPU + {49B04D99-0ECD-4900-86D3-7098D61314D7}.Release|x64.Build.0 = Release|Any CPU + {49B04D99-0ECD-4900-86D3-7098D61314D7}.Release|x86.ActiveCfg = Release|Any CPU + {49B04D99-0ECD-4900-86D3-7098D61314D7}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {AFED34E1-77DB-4D81-830A-A8D0A190573D} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724} + {631375DD-06D3-49BB-8130-D9DDB34C429D} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724} + {20FC0937-E7CA-4693-95F9-7A948EFD173B} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724} + {357D5EE1-FFC8-489B-9232-22CF474D9A6F} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724} + {3F5C2483-FC87-43EF-92A8-66FF7D0E440F} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724} + {66FA29DB-925A-402B-A4C7-D3D780FB1BC3} = {2F873243-A483-40B6-A0F7-65FC3541A269} + {CBEB631B-ABFA-4042-9779-C0060B0DFEFE} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724} + {205A6ADE-FB5A-45CB-9C51-9817E7BB8939} = {2F873243-A483-40B6-A0F7-65FC3541A269} + {34434B22-D546-4A5C-B575-49720C77643A} = {2F873243-A483-40B6-A0F7-65FC3541A269} + {DE54FF4C-8390-4489-882A-1BC7D99EF185} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724} + {B2366B08-96BD-4F6B-B748-B45089B87A14} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724} + {F9F17F23-660E-488C-A7FA-6A5B35D64313} = {2F873243-A483-40B6-A0F7-65FC3541A269} + {49B04D99-0ECD-4900-86D3-7098D61314D7} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {51D459FB-B45B-4A47-984E-46C35F933A82} + EndGlobalSection +EndGlobal diff --git a/Step/Controllers/WebApi/CmsConnectController.cs b/Step/Controllers/WebApi/CmsConnectController.cs new file mode 100644 index 00000000..711cb50f --- /dev/null +++ b/Step/Controllers/WebApi/CmsConnectController.cs @@ -0,0 +1,23 @@ +using Step.CmsConnect; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Web.Http; + +namespace Step.Controllers.WebApi +{ + [RoutePrefix("api/cms_connect")] + class CmsConnectController : ApiController + { + [Route("setup"), HttpPut] + public IHttpActionResult Setup() + { + GatewayNetworkConfiguration a = new GatewayNetworkConfigurationBuilder().HasDhcp(false).GenerateConfiguration(); + if(a.hasDhcp) + return Ok(); + return Ok(); + } + } +} From 5b4a44dfae193556a2e6a75f5790f8c5c1b997ae Mon Sep 17 00:00:00 2001 From: Nicola Carminati Date: Tue, 20 Aug 2019 17:38:11 +0200 Subject: [PATCH 02/11] Fix Namespace --- .../Builders/GatewayNewtorkConfigurationBuilder.cs | 4 ++-- .../Builders/GatewayProxyConfigurationBuilder.cs | 4 ++-- Step.CmsConnect/Builders/iBuilder.cs | 2 +- Step.CmsConnect/CmsConnectAdapter.cs | 6 +++--- Step.CmsConnect/Events/RebootEventHandlerArgs.cs | 2 +- Step.CmsConnect/Exceptions/GatewayException.cs | 2 +- Step.CmsConnect/Models/GatewayConfiguration.cs | 2 +- ...Step.CmsConnect.csproj => Step.CmsConnectGateway.csproj} | 0 Step.sln | 2 +- Step/Step.csproj | 4 ++++ 10 files changed, 16 insertions(+), 12 deletions(-) rename Step.CmsConnect/{Step.CmsConnect.csproj => Step.CmsConnectGateway.csproj} (100%) diff --git a/Step.CmsConnect/Builders/GatewayNewtorkConfigurationBuilder.cs b/Step.CmsConnect/Builders/GatewayNewtorkConfigurationBuilder.cs index 337d1451..0f1b2ae8 100644 --- a/Step.CmsConnect/Builders/GatewayNewtorkConfigurationBuilder.cs +++ b/Step.CmsConnect/Builders/GatewayNewtorkConfigurationBuilder.cs @@ -1,4 +1,4 @@ -using Step.CmsConnect.Builders; +using Step.CmsConnectGateway.Builders; using System; using System.Collections.Generic; using System.Linq; @@ -6,7 +6,7 @@ using System.Net; using System.Text; using System.Threading.Tasks; -namespace Step.CmsConnect +namespace Step.CmsConnectGateway { public class GatewayNetworkConfigurationBuilder : iBuilder { diff --git a/Step.CmsConnect/Builders/GatewayProxyConfigurationBuilder.cs b/Step.CmsConnect/Builders/GatewayProxyConfigurationBuilder.cs index 57d9b0ed..e76096d3 100644 --- a/Step.CmsConnect/Builders/GatewayProxyConfigurationBuilder.cs +++ b/Step.CmsConnect/Builders/GatewayProxyConfigurationBuilder.cs @@ -1,4 +1,4 @@ -using Step.CmsConnect.Builders; +using Step.CmsConnectGateway.Builders; using System; using System.Collections.Generic; using System.Linq; @@ -6,7 +6,7 @@ using System.Net; using System.Text; using System.Threading.Tasks; -namespace Step.CmsConnect +namespace Step.CmsConnectGateway { public class GatewayProxyConfigurationBuilder : iBuilder { diff --git a/Step.CmsConnect/Builders/iBuilder.cs b/Step.CmsConnect/Builders/iBuilder.cs index c68f8e7a..8a920757 100644 --- a/Step.CmsConnect/Builders/iBuilder.cs +++ b/Step.CmsConnect/Builders/iBuilder.cs @@ -6,7 +6,7 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; -namespace Step.CmsConnect.Builders +namespace Step.CmsConnectGateway.Builders { public abstract class iBuilder { diff --git a/Step.CmsConnect/CmsConnectAdapter.cs b/Step.CmsConnect/CmsConnectAdapter.cs index db090945..e4434bc1 100644 --- a/Step.CmsConnect/CmsConnectAdapter.cs +++ b/Step.CmsConnect/CmsConnectAdapter.cs @@ -1,7 +1,7 @@ using Renci.SshNet; using Renci.SshNet.Common; -using Step.CmsConnect.Events; -using Step.CmsConnect.Exceptions; +using Step.CmsConnectGateway.Events; +using Step.CmsConnectGateway.Exceptions; using System; using System.Collections.Generic; using System.Linq; @@ -12,7 +12,7 @@ using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; -namespace Step.CmsConnect +namespace Step.CmsConnectGateway { public class CmsConnectAdapter : IDisposable { diff --git a/Step.CmsConnect/Events/RebootEventHandlerArgs.cs b/Step.CmsConnect/Events/RebootEventHandlerArgs.cs index 5f17ae3b..79e5d321 100644 --- a/Step.CmsConnect/Events/RebootEventHandlerArgs.cs +++ b/Step.CmsConnect/Events/RebootEventHandlerArgs.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Step.CmsConnect.Events +namespace Step.CmsConnectGateway.Events { public class RebootEventHandlerArgs : EventArgs { diff --git a/Step.CmsConnect/Exceptions/GatewayException.cs b/Step.CmsConnect/Exceptions/GatewayException.cs index c1e77e8e..f9986cc8 100644 --- a/Step.CmsConnect/Exceptions/GatewayException.cs +++ b/Step.CmsConnect/Exceptions/GatewayException.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Step.CmsConnect.Exceptions +namespace Step.CmsConnectGateway.Exceptions { public class GatewayException: Exception { diff --git a/Step.CmsConnect/Models/GatewayConfiguration.cs b/Step.CmsConnect/Models/GatewayConfiguration.cs index 56a597f1..56b4bf03 100644 --- a/Step.CmsConnect/Models/GatewayConfiguration.cs +++ b/Step.CmsConnect/Models/GatewayConfiguration.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading.Tasks; using System.Net; -namespace Step.CmsConnect +namespace Step.CmsConnectGateway { diff --git a/Step.CmsConnect/Step.CmsConnect.csproj b/Step.CmsConnect/Step.CmsConnectGateway.csproj similarity index 100% rename from Step.CmsConnect/Step.CmsConnect.csproj rename to Step.CmsConnect/Step.CmsConnectGateway.csproj diff --git a/Step.sln b/Step.sln index fb0b9df1..6a8ee0a5 100644 --- a/Step.sln +++ b/Step.sln @@ -37,7 +37,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.NC", "Step.NC\Step.NC. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Chromium", "Client.Chromium\Client.Chromium.csproj", "{F9F17F23-660E-488C-A7FA-6A5B35D64313}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.CmsConnect", "Step.CmsConnect\Step.CmsConnect.csproj", "{49B04D99-0ECD-4900-86D3-7098D61314D7}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.CmsConnectGateway", "Step.CmsConnect\Step.CmsConnectGateway.csproj", "{49B04D99-0ECD-4900-86D3-7098D61314D7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Step/Step.csproj b/Step/Step.csproj index 3f2b7250..0896d7e3 100644 --- a/Step/Step.csproj +++ b/Step/Step.csproj @@ -16122,6 +16122,10 @@ + + {49b04d99-0ecd-4900-86d3-7098d61314d7} + Step.CmsConnectGateway + {3f5c2483-fc87-43ef-92a8-66ff7d0e440f} Step.Config From 5eb6ad7c7b9a4e2d507b1fb8034e659c4e65a91f Mon Sep 17 00:00:00 2001 From: Nicola Carminati Date: Wed, 21 Aug 2019 12:02:31 +0200 Subject: [PATCH 03/11] Added functionality. Test Connection + Fix other things --- .../GatewayNewtorkConfigurationBuilder.cs | 0 .../GatewayProxyConfigurationBuilder.cs | 0 .../Builders/iBuilder.cs | 0 .../Events/GatewayRebootEventHandlerArgs.cs | 4 +- .../Exceptions/GatewayException.cs | 0 .../GatewayAdapter.cs | 121 +++++++++++++++--- .../Models/GatewayConfiguration.cs | 4 +- .../Properties/AssemblyInfo.cs | 0 .../Step.CmsConnectGateway.csproj | 8 +- .../packages.config | 0 Step.sln | 2 +- Step/Step.csproj | 2 +- 12 files changed, 117 insertions(+), 24 deletions(-) rename {Step.CmsConnect => Step.CmsConnectGateway}/Builders/GatewayNewtorkConfigurationBuilder.cs (100%) rename {Step.CmsConnect => Step.CmsConnectGateway}/Builders/GatewayProxyConfigurationBuilder.cs (100%) rename {Step.CmsConnect => Step.CmsConnectGateway}/Builders/iBuilder.cs (100%) rename Step.CmsConnect/Events/RebootEventHandlerArgs.cs => Step.CmsConnectGateway/Events/GatewayRebootEventHandlerArgs.cs (74%) rename {Step.CmsConnect => Step.CmsConnectGateway}/Exceptions/GatewayException.cs (100%) rename Step.CmsConnect/CmsConnectAdapter.cs => Step.CmsConnectGateway/GatewayAdapter.cs (82%) rename {Step.CmsConnect => Step.CmsConnectGateway}/Models/GatewayConfiguration.cs (90%) rename {Step.CmsConnect => Step.CmsConnectGateway}/Properties/AssemblyInfo.cs (100%) rename {Step.CmsConnect => Step.CmsConnectGateway}/Step.CmsConnectGateway.csproj (90%) rename {Step.CmsConnect => Step.CmsConnectGateway}/packages.config (100%) diff --git a/Step.CmsConnect/Builders/GatewayNewtorkConfigurationBuilder.cs b/Step.CmsConnectGateway/Builders/GatewayNewtorkConfigurationBuilder.cs similarity index 100% rename from Step.CmsConnect/Builders/GatewayNewtorkConfigurationBuilder.cs rename to Step.CmsConnectGateway/Builders/GatewayNewtorkConfigurationBuilder.cs diff --git a/Step.CmsConnect/Builders/GatewayProxyConfigurationBuilder.cs b/Step.CmsConnectGateway/Builders/GatewayProxyConfigurationBuilder.cs similarity index 100% rename from Step.CmsConnect/Builders/GatewayProxyConfigurationBuilder.cs rename to Step.CmsConnectGateway/Builders/GatewayProxyConfigurationBuilder.cs diff --git a/Step.CmsConnect/Builders/iBuilder.cs b/Step.CmsConnectGateway/Builders/iBuilder.cs similarity index 100% rename from Step.CmsConnect/Builders/iBuilder.cs rename to Step.CmsConnectGateway/Builders/iBuilder.cs diff --git a/Step.CmsConnect/Events/RebootEventHandlerArgs.cs b/Step.CmsConnectGateway/Events/GatewayRebootEventHandlerArgs.cs similarity index 74% rename from Step.CmsConnect/Events/RebootEventHandlerArgs.cs rename to Step.CmsConnectGateway/Events/GatewayRebootEventHandlerArgs.cs index 79e5d321..50c76768 100644 --- a/Step.CmsConnect/Events/RebootEventHandlerArgs.cs +++ b/Step.CmsConnectGateway/Events/GatewayRebootEventHandlerArgs.cs @@ -6,12 +6,12 @@ using System.Threading.Tasks; namespace Step.CmsConnectGateway.Events { - public class RebootEventHandlerArgs : EventArgs + public class GatewayRebootEventHandlerArgs : EventArgs { public Boolean errorStatus { get; internal set; } public String errorMessage { get; internal set; } - public RebootEventHandlerArgs() + public GatewayRebootEventHandlerArgs() { errorStatus = false; errorMessage = ""; diff --git a/Step.CmsConnect/Exceptions/GatewayException.cs b/Step.CmsConnectGateway/Exceptions/GatewayException.cs similarity index 100% rename from Step.CmsConnect/Exceptions/GatewayException.cs rename to Step.CmsConnectGateway/Exceptions/GatewayException.cs diff --git a/Step.CmsConnect/CmsConnectAdapter.cs b/Step.CmsConnectGateway/GatewayAdapter.cs similarity index 82% rename from Step.CmsConnect/CmsConnectAdapter.cs rename to Step.CmsConnectGateway/GatewayAdapter.cs index e4434bc1..406bed8d 100644 --- a/Step.CmsConnect/CmsConnectAdapter.cs +++ b/Step.CmsConnectGateway/GatewayAdapter.cs @@ -14,7 +14,7 @@ using System.Threading.Tasks; namespace Step.CmsConnectGateway { - public class CmsConnectAdapter : IDisposable + public class GatewayAdapter : IDisposable { //Internal Constant private const string SSH_SET_PROXY_COMMAND = "sudo ./setProxy.sh "; @@ -23,6 +23,7 @@ namespace Step.CmsConnectGateway private const string SSH_SET_NETWORK_COMMAND = "sudo ./setNetwork.sh "; private const string SSH_GET_NETWORK_COMMAND = "sudo ./getNetworkConfiguration.sh "; private const string SSH_GET_PROXY_COMMAND = "sudo ./getProxyConfiguration.sh "; + private const string SSH_TEST_CONNECTION_COMMAND = "sudo ./testConnection.sh "; private const string SSH_GW_REBOOT_COMMAND = "sudo ./gatewayReboot.sh "; const string IP_ADDR_LABEL = "IP_ADDRESS="; @@ -32,8 +33,12 @@ namespace Step.CmsConnectGateway const string PROXY_ADDR_LABEL = "PROXY="; const string NO_PROXY_LABEL = "NO_PROXY="; const string UNDEF_VALUE = "none"; + const string CONNECTION_OK_VALUE = "OK"; + const string CONNECTION_NOWEB_VALUE = "NO_WEB"; + const string CONNECTION_NOPORT_VALUE = "NO_PORTS"; const int REBOOT_MINUTES_MAX = 2; + const int REBOOT_MSWAIT_BETWEEN_OP = 500; //Internal Private Variable @@ -48,7 +53,7 @@ namespace Step.CmsConnectGateway /// Simple constructor. /// Create an instance with this configuration: hostname: localhost, username: root, password: root. /// - public CmsConnectAdapter() + public GatewayAdapter() { this.host = "localhost"; this.username = "root"; @@ -64,7 +69,7 @@ namespace Step.CmsConnectGateway /// Username for Gateway Login /// Password for Gateway Login /// Thrown when one parameter is null - public CmsConnectAdapter(string hostname, string username, string password) + public GatewayAdapter(string hostname, string username, string password) { setup(hostname, username, password); } @@ -138,19 +143,36 @@ namespace Step.CmsConnectGateway } + /// + /// Test connection to SCM/CMS Server, on Gateway. + /// + /// Seconds timeout for the request + /// + public GatewayConnectionStatus TestGatewayConnection(int timeout) + { + if (timeout < 0) + throw new ArgumentOutOfRangeException("Timeout must be > 0"); + + return ElaborateTestConnectionCommand(SendSSHCommand(SSH_TEST_CONNECTION_COMMAND + timeout)); + } + + /// /// Reboot asynchronously the Gateway. /// /// Serconds to delay before reboot /// Handler Callback when the operation is finished or an error occours. - /// See + /// See /// - public void RebootGatewayAsync(int delay, EventHandler handler) + public void RebootGatewayAsync(int delay, EventHandler handler) { + if (delay < 0) + throw new ArgumentOutOfRangeException("Delay must be > 0"); + //Create the Action - Action> action = (int del, EventHandler hand) => + Action> action = (int del, EventHandler hand) => { - RebootEventHandlerArgs ev = new RebootEventHandlerArgs(); + GatewayRebootEventHandlerArgs ev = new GatewayRebootEventHandlerArgs(); try { this.SendSSHReboot(del); @@ -176,6 +198,9 @@ namespace Step.CmsConnectGateway /// public void RebootGateway(int delay) { + if (delay < 0) + throw new ArgumentOutOfRangeException("Delay must be > 0"); + //Send Command this.SendSSHReboot(delay); } @@ -314,6 +339,17 @@ namespace Step.CmsConnectGateway return configuration; } + private GatewayConnectionStatus ElaborateTestConnectionCommand(List lines) + { + GatewayConnectionStatus status = new GatewayConnectionStatus(); + foreach (string line in lines) + { + if (!String.IsNullOrWhiteSpace(line)) + DecodeConnectionStatus(line.Trim(), ref status); + } + return status; + } + #endregion //--------------------------------------------------------------------------------------------------- @@ -512,6 +548,20 @@ namespace Step.CmsConnectGateway } } + + private void DecodeConnectionStatus(string stringValue, ref GatewayConnectionStatus status) + { + if (stringValue == CONNECTION_OK_VALUE) + status = GatewayConnectionStatus.OK; + else if (stringValue == CONNECTION_NOWEB_VALUE) + status = GatewayConnectionStatus.WEB_ERROR; + else if (stringValue == CONNECTION_NOPORT_VALUE) + status = GatewayConnectionStatus.PORT_ERROR; + else + throw new GatewayException("Internal Gateway Error during Connection-Test (bad format): " + stringValue); + } + + private bool EvaluateIPV4(string stringValue,out IPAddress address) { Regex rgx = new Regex(@"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"); @@ -525,8 +575,6 @@ namespace Step.CmsConnectGateway address = new IPAddress(0); return false; } - - #endregion //--------------------------------------------------------------------------------------------------- @@ -617,16 +665,59 @@ namespace Step.CmsConnectGateway //Create the Instance SshClient _sshGateway = new SshClient(this.host, this.username, this.password); - bool connected = false; - //Try Connection Cycle + //Phase 1 Wait Disconnection Cycle + bool disconnected = false; + do + { + try + { + //If TimeSpan > TOT MIN -> Exception + if ((DateTime.Now - nowAfterReboot) > TimeSpan.FromMinutes(REBOOT_MINUTES_MAX)) + throw new GatewayException("Timeout Error during reboot - Gateway has never been rebooted"); + + //Try Connection + _sshGateway.Connect(); + Thread.Sleep(REBOOT_MSWAIT_BETWEEN_OP); + _sshGateway.Disconnect(); + } + catch (SocketException e) + { + //Not Connected + disconnected = true; + } + catch (SshConnectionException e) + { + //Not Connected + disconnected = true; + } + catch (SshException e) + { + //Not Connected + disconnected = true; + } + catch (GatewayException e) + { + //Error + throw new GatewayException(e.Message); + } + catch (Exception e) + { + //Error + throw new GatewayException("Unknown Error during reboot: " + e); + } + } while (!disconnected); + + + //Phase 2 Wait Re-connection Cycle + bool connected = false; do { try { //If TimeSpan > TOT MIN -> Exception if((DateTime.Now - nowAfterReboot) > TimeSpan.FromMinutes(REBOOT_MINUTES_MAX)) - throw new GatewayException("Timeout Error during reboot"); + throw new GatewayException("Timeout Error during reboot - Gateway not found during reboot"); //Try Connection _sshGateway.Connect(); @@ -635,17 +726,17 @@ namespace Step.CmsConnectGateway catch (SocketException e) { //Not Connected - Thread.Sleep(500); + Thread.Sleep(REBOOT_MSWAIT_BETWEEN_OP); } catch (SshConnectionException e) { //Not Connected - Thread.Sleep(500); + Thread.Sleep(REBOOT_MSWAIT_BETWEEN_OP); } catch (SshException e) { //Not Connected - Thread.Sleep(500); + Thread.Sleep(REBOOT_MSWAIT_BETWEEN_OP); } catch (GatewayException e) { diff --git a/Step.CmsConnect/Models/GatewayConfiguration.cs b/Step.CmsConnectGateway/Models/GatewayConfiguration.cs similarity index 90% rename from Step.CmsConnect/Models/GatewayConfiguration.cs rename to Step.CmsConnectGateway/Models/GatewayConfiguration.cs index 56b4bf03..f94a78de 100644 --- a/Step.CmsConnect/Models/GatewayConfiguration.cs +++ b/Step.CmsConnectGateway/Models/GatewayConfiguration.cs @@ -7,7 +7,9 @@ using System.Net; namespace Step.CmsConnectGateway { - + + + public enum GatewayConnectionStatus { OK = 0, WEB_ERROR = 1, PORT_ERROR = 2 }; public class GatewayNetworkConfiguration { diff --git a/Step.CmsConnect/Properties/AssemblyInfo.cs b/Step.CmsConnectGateway/Properties/AssemblyInfo.cs similarity index 100% rename from Step.CmsConnect/Properties/AssemblyInfo.cs rename to Step.CmsConnectGateway/Properties/AssemblyInfo.cs diff --git a/Step.CmsConnect/Step.CmsConnectGateway.csproj b/Step.CmsConnectGateway/Step.CmsConnectGateway.csproj similarity index 90% rename from Step.CmsConnect/Step.CmsConnectGateway.csproj rename to Step.CmsConnectGateway/Step.CmsConnectGateway.csproj index 406ede17..eaab3452 100644 --- a/Step.CmsConnect/Step.CmsConnectGateway.csproj +++ b/Step.CmsConnectGateway/Step.CmsConnectGateway.csproj @@ -7,8 +7,8 @@ {49B04D99-0ECD-4900-86D3-7098D61314D7} Library Properties - Step.CmsConnect - Step.CmsConnect + Step.CmsConnectGateway + Step.CmsConnectGateway v4.6.1 512 @@ -47,8 +47,8 @@ - - + + diff --git a/Step.CmsConnect/packages.config b/Step.CmsConnectGateway/packages.config similarity index 100% rename from Step.CmsConnect/packages.config rename to Step.CmsConnectGateway/packages.config diff --git a/Step.sln b/Step.sln index 6a8ee0a5..f4646718 100644 --- a/Step.sln +++ b/Step.sln @@ -37,7 +37,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.NC", "Step.NC\Step.NC. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Chromium", "Client.Chromium\Client.Chromium.csproj", "{F9F17F23-660E-488C-A7FA-6A5B35D64313}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.CmsConnectGateway", "Step.CmsConnect\Step.CmsConnectGateway.csproj", "{49B04D99-0ECD-4900-86D3-7098D61314D7}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.CmsConnectGateway", "Step.CmsConnectGateway\Step.CmsConnectGateway.csproj", "{49B04D99-0ECD-4900-86D3-7098D61314D7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Step/Step.csproj b/Step/Step.csproj index 0896d7e3..a803959c 100644 --- a/Step/Step.csproj +++ b/Step/Step.csproj @@ -16122,7 +16122,7 @@ - + {49b04d99-0ecd-4900-86d3-7098d61314d7} Step.CmsConnectGateway From c31cbf3babace590be2f7ae62fc7158bfe959dcb Mon Sep 17 00:00:00 2001 From: Nicola Carminati Date: Wed, 21 Aug 2019 14:06:17 +0200 Subject: [PATCH 04/11] Fix "Setup" void name --- Step.CmsConnectGateway/GatewayAdapter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Step.CmsConnectGateway/GatewayAdapter.cs b/Step.CmsConnectGateway/GatewayAdapter.cs index 406bed8d..897ab378 100644 --- a/Step.CmsConnectGateway/GatewayAdapter.cs +++ b/Step.CmsConnectGateway/GatewayAdapter.cs @@ -71,7 +71,7 @@ namespace Step.CmsConnectGateway /// Thrown when one parameter is null public GatewayAdapter(string hostname, string username, string password) { - setup(hostname, username, password); + Setup(hostname, username, password); } @@ -82,7 +82,7 @@ namespace Step.CmsConnectGateway /// Username for Gateway Login /// Password for Gateway Login /// Thrown when one parameter is null - public void setup(string hostname, string username, string password) + public void Setup(string hostname, string username, string password) { this.host = hostname ?? throw new NullReferenceException("hostname is mandatory"); this.username = username ?? throw new NullReferenceException("username is mandatory"); From baf8ca05102444ff3c0082f18747fb77eef3a769 Mon Sep 17 00:00:00 2001 From: Nicola Carminati Date: Wed, 21 Aug 2019 16:03:37 +0200 Subject: [PATCH 05/11] Added ToString Method --- .../Models/GatewayConfiguration.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Step.CmsConnectGateway/Models/GatewayConfiguration.cs b/Step.CmsConnectGateway/Models/GatewayConfiguration.cs index f94a78de..089e3f59 100644 --- a/Step.CmsConnectGateway/Models/GatewayConfiguration.cs +++ b/Step.CmsConnectGateway/Models/GatewayConfiguration.cs @@ -20,6 +20,16 @@ namespace Step.CmsConnectGateway public IPAddress defaultGatewayAddress { get; internal set; } public IEnumerable dnsAddresses { get; internal set; } public IEnumerable dnsPrefixes { get; internal set; } + + public override string ToString() + { + return "hasDhcp: " + hasDhcp + Environment.NewLine + + "ipAddress: " + (ipAddress != null ? ipAddress.ToString() : "null") + Environment.NewLine + + "netMaskAddress: " + (netMaskAddress != null ? netMaskAddress.ToString() : "null") + Environment.NewLine + + "defaultGatewayAddress: " + (defaultGatewayAddress != null ? defaultGatewayAddress.ToString() : "null") + Environment.NewLine + + "dnsAddresses: " + (dnsAddresses != null ? string.Join(",", dnsAddresses) : "null") + Environment.NewLine + + "dnsPrefixes: " + (dnsPrefixes != null ? string.Join(",", dnsPrefixes) : "null"); + } } public class GatewayProxyConfiguration @@ -31,5 +41,16 @@ namespace Step.CmsConnectGateway public string username { get; internal set; } public string password { get; internal set; } public IEnumerable noproxyAddresses { get; internal set; } + + public override string ToString() + { + + return "hasProxy: " + hasProxy + Environment.NewLine + + "address: " + (address != null ? address.ToString() : "null") + Environment.NewLine + + "port: " + (port != 0 ? port.ToString() : "null") + Environment.NewLine + + "username: " + (username != null ? username : "null") + Environment.NewLine + + "password: " + (password != null ? password : "null") + Environment.NewLine + + "noproxyAddresses: " + (noproxyAddresses != null ? string.Join(",", noproxyAddresses) : "null"); + } } } From eea1ecb6d23675dd828cf24dd86dac1386912315 Mon Sep 17 00:00:00 2001 From: Nicola Carminati Date: Thu, 22 Aug 2019 10:41:57 +0200 Subject: [PATCH 06/11] Added Server CMSConnect Config --- Step.Config/Config/cmsConnectConfig.xml | 10 ++ .../Config/cmsConnectConfigValidator.xsd | 24 +++ Step.Config/Config/serverConfig.xml | 1 - Step.Config/Config/serverConfigValidator.xsd | 3 +- Step.Config/ServerConfig.cs | 1 + Step.Config/ServerConfigController.cs | 48 +++++- Step.Config/Step.Config.csproj | 8 + Step.Core/ThreadsFunctions.cs | 2 +- .../ConfigModels/CmsConnectConfigModel.cs | 28 +++ Step.Model/ConfigModels/ServerConfigModel.cs | 1 - Step.Model/Constants.cs | 3 + Step.Model/Step.Model.csproj | 1 + Step.Utils/supportFunctions.cs | 159 +++++++++++++++++- 13 files changed, 280 insertions(+), 9 deletions(-) create mode 100644 Step.Config/Config/cmsConnectConfig.xml create mode 100644 Step.Config/Config/cmsConnectConfigValidator.xsd create mode 100644 Step.Model/ConfigModels/CmsConnectConfigModel.cs diff --git a/Step.Config/Config/cmsConnectConfig.xml b/Step.Config/Config/cmsConnectConfig.xml new file mode 100644 index 00000000..0fe16b37 --- /dev/null +++ b/Step.Config/Config/cmsConnectConfig.xml @@ -0,0 +1,10 @@ + + + + true + +
192.168.214.200
+ gsHOP9H9aJHqgVzxruZg/T3XiZ9AfS1NdS/y/JFl05y8nCY9rmrCssxSONSyN/xkkLRvEcEYd/kf0HrluGX6MGrv8qLlCIIZXS6uKQNz7mtG4HokLFqIrHKdu3u3P6jI +
+
+
\ No newline at end of file diff --git a/Step.Config/Config/cmsConnectConfigValidator.xsd b/Step.Config/Config/cmsConnectConfigValidator.xsd new file mode 100644 index 00000000..fdf6760a --- /dev/null +++ b/Step.Config/Config/cmsConnectConfigValidator.xsd @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Step.Config/Config/serverConfig.xml b/Step.Config/Config/serverConfig.xml index 2ae275c9..6949760e 100644 --- a/Step.Config/Config/serverConfig.xml +++ b/Step.Config/Config/serverConfig.xml @@ -24,7 +24,6 @@ false C:\CMS\MTC\ADAPTER\ SCMA - true 50000 5000 diff --git a/Step.Config/Config/serverConfigValidator.xsd b/Step.Config/Config/serverConfigValidator.xsd index bb2e14ef..3bc53d0c 100644 --- a/Step.Config/Config/serverConfigValidator.xsd +++ b/Step.Config/Config/serverConfigValidator.xsd @@ -36,8 +36,7 @@ - - + diff --git a/Step.Config/ServerConfig.cs b/Step.Config/ServerConfig.cs index b7336c29..c60ffd61 100644 --- a/Step.Config/ServerConfig.cs +++ b/Step.Config/ServerConfig.cs @@ -24,6 +24,7 @@ namespace Step.Config public static List InitialAlarmsConfig; public static List HeadsConfig; public static ToolManagerConfigModel ToolManagerConfig; + public static CmsConnectConfigModel CmsConnectConfig; public static AreasConfigModel ProductionConfig; public static AreasConfigModel ToolingConfig; diff --git a/Step.Config/ServerConfigController.cs b/Step.Config/ServerConfigController.cs index 3021db0d..ff8dcc42 100644 --- a/Step.Config/ServerConfigController.cs +++ b/Step.Config/ServerConfigController.cs @@ -33,6 +33,7 @@ namespace Step.Config ReadAlarmsConfig(); ReadHeadsConfig(); ReadToolManagerConfig(); + ReadCMSConnectConfig(); ReadMacros(); ReadScadaFile(); //ReadMainProgram(); @@ -306,8 +307,7 @@ namespace Step.Config MTCFolderPath = x.Element("MTCFolderPath").Value, MTCApplicationName = x.Element("MTCApplicationName").Value, MaxAlarmsRows = Convert.ToInt32(x.Element("maxAlarmsRows").Value), - AlarmToDelete = Convert.ToInt32(x.Element("alarmToDelete").Value), - CMSConnectReady = Convert.ToBoolean(x.Element("CMSConnectReady").Value) + AlarmToDelete = Convert.ToInt32(x.Element("alarmToDelete").Value), }).FirstOrDefault(); int softwareId = 0; @@ -547,6 +547,50 @@ namespace Step.Config .ToList(); } + + private static void ReadCMSConnectConfig() + { + String _tempUSR, _tempPSW; + XDocument xmlConfigFile = GetXmlHandlerWithValidator(CMS_CONNECT_CONFIG_SCHEMA_PATH, CMS_CONNECT_CONFIG_PATH); + + XElement l = xmlConfigFile + .Root + .Descendants("cmsConnectConfig") + .FirstOrDefault(); + + // Read config from XML file + CmsConnectConfig = xmlConfigFile + .Root + .Descendants("cmsConnectConfig") + .Select(x => new CmsConnectConfigModel() + { + Enabled = Convert.ToBoolean(x.Element("enabled").Value) + }) + .FirstOrDefault(); + + // Read config from XML file for Gateway + GatewayConfigModel tempGatewayConfigModel = xmlConfigFile + .Root + .Descendants("gateway") + .Select(x => new GatewayConfigModel() + { + Address = x.Element("address").Value, + Token = x.Element("token").Value + }) + .FirstOrDefault(); + + if (DecodeCMSConnectGatewayLogin(tempGatewayConfigModel.Token, out _tempUSR, out _tempPSW)) + { + tempGatewayConfigModel.Username = _tempUSR; + tempGatewayConfigModel.Password = _tempPSW; + } + else + throw new Exception("Error while reading \""+ CMS_CONNECT_CONFIG_PATH + "\": Gateway Token not valid"); + + CmsConnectConfig.Gateway = tempGatewayConfigModel; + } + + public static void ReadMacros() { XDocument xmlConfigFile = GetXmlHandlerWithValidator(MACROS_CONFIG_SCHEMA_PATH, MACROS_CONFIG_PATH); diff --git a/Step.Config/Step.Config.csproj b/Step.Config/Step.Config.csproj index 60932e76..8f51832a 100644 --- a/Step.Config/Step.Config.csproj +++ b/Step.Config/Step.Config.csproj @@ -42,6 +42,9 @@
+ + PreserveNewest + PreserveNewest @@ -144,5 +147,10 @@ Designer + + + Designer + + \ No newline at end of file diff --git a/Step.Core/ThreadsFunctions.cs b/Step.Core/ThreadsFunctions.cs index 074ed7a1..92cec6e1 100644 --- a/Step.Core/ThreadsFunctions.cs +++ b/Step.Core/ThreadsFunctions.cs @@ -834,7 +834,7 @@ public static class ThreadsFunctions foreach (M154DataModel m154 in data) { - if(ServerStartupConfig.CMSConnectReady) + if(CmsConnectConfig.Enabled) { if (m154.Parameters.Count() >= 2 && m154.Parameters[0] == "SOUR") diff --git a/Step.Model/ConfigModels/CmsConnectConfigModel.cs b/Step.Model/ConfigModels/CmsConnectConfigModel.cs new file mode 100644 index 00000000..2b615c61 --- /dev/null +++ b/Step.Model/ConfigModels/CmsConnectConfigModel.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Step.Model.ConfigModels +{ + public class CmsConnectConfigModel + { + public CmsConnectConfigModel() + { + Gateway = new GatewayConfigModel(); + } + public bool Enabled { get; set; } + + public GatewayConfigModel Gateway { get; set; } + } + + public class GatewayConfigModel + { + public string Address { get; set; } + public string Token { get; set; } + public string Username { get; set; } + public string Password { get; set; } + + } +} diff --git a/Step.Model/ConfigModels/ServerConfigModel.cs b/Step.Model/ConfigModels/ServerConfigModel.cs index a2f5dbb7..1479bafd 100644 --- a/Step.Model/ConfigModels/ServerConfigModel.cs +++ b/Step.Model/ConfigModels/ServerConfigModel.cs @@ -18,7 +18,6 @@ namespace Step.Model.ConfigModels public string MTCFolderPath { get; set; } public string MTCApplicationName { get; set; } - public Boolean CMSConnectReady { get; set; } public int MaxAlarmsRows { get; set; } public int AlarmToDelete { get; set; } diff --git a/Step.Model/Constants.cs b/Step.Model/Constants.cs index 1a8abe06..ca6e47ac 100644 --- a/Step.Model/Constants.cs +++ b/Step.Model/Constants.cs @@ -184,6 +184,9 @@ namespace Step.Model public const string TOOL_MANAGER_CONFIG_SCHEMA_PATH = RESOURCE_DIRECTORY + "toolManagerConfigValidator.xsd"; public const string TOOL_MANAGER_CONFIG_PATH = CONFIG_DIRECTORY + "toolManagerConfig.xml"; + public const string CMS_CONNECT_CONFIG_SCHEMA_PATH = RESOURCE_DIRECTORY + "cmsConnectConfigValidator.xsd"; + public const string CMS_CONNECT_CONFIG_PATH = CONFIG_DIRECTORY + "cmsConnectConfig.xml"; + public const string MACROS_CONFIG_SCHEMA_PATH = RESOURCE_DIRECTORY + "macrosConfigValidator.xsd"; public const string MACROS_CONFIG_PATH = CONFIG_DIRECTORY + "macrosConfig.xml"; diff --git a/Step.Model/Step.Model.csproj b/Step.Model/Step.Model.csproj index d49b564b..3332d080 100644 --- a/Step.Model/Step.Model.csproj +++ b/Step.Model/Step.Model.csproj @@ -64,6 +64,7 @@ + diff --git a/Step.Utils/supportFunctions.cs b/Step.Utils/supportFunctions.cs index ac142322..2ad16536 100644 --- a/Step.Utils/supportFunctions.cs +++ b/Step.Utils/supportFunctions.cs @@ -8,6 +8,8 @@ using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; +using System.Security.Cryptography; +using System.Text; using static CMS_CORE_Library.Models.DataStructures; using static Step.Model.Constants; @@ -15,6 +17,8 @@ namespace Step.Utils { public static class SupportFunctions { + private static readonly string CMSCONNECT_TOKEN = "59f1qik5PYfiJLiXZ4xZ05pjzx5E9FscQWtj4lmfLKXaF1OAxkvu7ziBzXFBuuVQ"; + public static SOFTKEY_TYPE GetSoftKeyType(string type) { switch (type) @@ -399,7 +403,158 @@ namespace Step.Utils } return ""; - } - + } + + + public static Boolean DecodeCMSConnectGatewayLogin(string encryptedString, out string login, out string password) + { + login = ""; + password = ""; + + //Check if is null + if (String.IsNullOrEmpty(encryptedString)) + return false; + + //Decode it + String decodedLogin = StringCipher.Decrypt(encryptedString, CMSCONNECT_TOKEN); + + //Check if contains the Space + if (!decodedLogin.Contains(" ")) + return false; + + //Split it and check + String[] tempLogin = decodedLogin.Split(' '); + if (tempLogin.Length != 2) + return false; + + //Set the variable + login = tempLogin[0]; + password = tempLogin[1]; + + return true; + } + + + + public static Boolean EncodeCMSConnectGatewayLogin(out string encryptedString, string login, string password) + { + encryptedString = ""; + + //Check if contains the Space + if (String.IsNullOrEmpty(login) || login.Contains(" ")) + return false; + + //Check if contains the Space + if (String.IsNullOrEmpty(password) || password.Contains(" ")) + return false; + + encryptedString = StringCipher.Encrypt(login + " " + password, CMSCONNECT_TOKEN); + return true; + } + + //----- Chipher Private Class --------------------------------- + #region Chipher_Private_Class + + private static class StringCipher + { + // This constant is used to determine the keysize of the encryption algorithm in bits. + // We divide this by 8 within the code below to get the equivalent number of bytes. + private const int Keysize = 256; + + // This constant determines the number of iterations for the password bytes generation function. + private const int DerivationIterations = 1000; + + public static string Encrypt(string plainText, string passPhrase) + { + // Salt and IV is randomly generated each time, but is preprended to encrypted cipher text + // so that the same Salt and IV values can be used when decrypting. + var saltStringBytes = Generate256BitsOfRandomEntropy(); + var ivStringBytes = Generate256BitsOfRandomEntropy(); + var plainTextBytes = Encoding.UTF8.GetBytes(plainText); + using (var password = new Rfc2898DeriveBytes(passPhrase, saltStringBytes, DerivationIterations)) + { + var keyBytes = password.GetBytes(Keysize / 8); + using (var symmetricKey = new RijndaelManaged()) + { + symmetricKey.BlockSize = 256; + symmetricKey.Mode = CipherMode.CBC; + symmetricKey.Padding = PaddingMode.PKCS7; + using (var encryptor = symmetricKey.CreateEncryptor(keyBytes, ivStringBytes)) + { + using (var memoryStream = new MemoryStream()) + { + using (var cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write)) + { + cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length); + cryptoStream.FlushFinalBlock(); + // Create the final bytes as a concatenation of the random salt bytes, the random iv bytes and the cipher bytes. + var cipherTextBytes = saltStringBytes; + cipherTextBytes = cipherTextBytes.Concat(ivStringBytes).ToArray(); + cipherTextBytes = cipherTextBytes.Concat(memoryStream.ToArray()).ToArray(); + memoryStream.Close(); + cryptoStream.Close(); + return Convert.ToBase64String(cipherTextBytes); + } + } + } + } + } + } + + public static string Decrypt(string cipherText, string passPhrase) + { + // Get the complete stream of bytes that represent: + // [32 bytes of Salt] + [32 bytes of IV] + [n bytes of CipherText] + var cipherTextBytesWithSaltAndIv = Convert.FromBase64String(cipherText); + // Get the saltbytes by extracting the first 32 bytes from the supplied cipherText bytes. + var saltStringBytes = cipherTextBytesWithSaltAndIv.Take(Keysize / 8).ToArray(); + // Get the IV bytes by extracting the next 32 bytes from the supplied cipherText bytes. + var ivStringBytes = cipherTextBytesWithSaltAndIv.Skip(Keysize / 8).Take(Keysize / 8).ToArray(); + // Get the actual cipher text bytes by removing the first 64 bytes from the cipherText string. + var cipherTextBytes = cipherTextBytesWithSaltAndIv.Skip((Keysize / 8) * 2).Take(cipherTextBytesWithSaltAndIv.Length - ((Keysize / 8) * 2)).ToArray(); + + using (var password = new Rfc2898DeriveBytes(passPhrase, saltStringBytes, DerivationIterations)) + { + var keyBytes = password.GetBytes(Keysize / 8); + using (var symmetricKey = new RijndaelManaged()) + { + symmetricKey.BlockSize = 256; + symmetricKey.Mode = CipherMode.CBC; + symmetricKey.Padding = PaddingMode.PKCS7; + using (var decryptor = symmetricKey.CreateDecryptor(keyBytes, ivStringBytes)) + { + using (var memoryStream = new MemoryStream(cipherTextBytes)) + { + using (var cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read)) + { + var plainTextBytes = new byte[cipherTextBytes.Length]; + var decryptedByteCount = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length); + memoryStream.Close(); + cryptoStream.Close(); + return Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount); + } + } + } + } + } + } + + private static byte[] Generate256BitsOfRandomEntropy() + { + var randomBytes = new byte[32]; // 32 Bytes will give us 256 bits. + using (var rngCsp = new RNGCryptoServiceProvider()) + { + // Fill the array with cryptographically secure random bytes. + rngCsp.GetBytes(randomBytes); + } + return randomBytes; + } + } + + #endregion } + + + + } \ No newline at end of file From 457192c0320d787b0773ca5077acd7fa9347c077 Mon Sep 17 00:00:00 2001 From: Nicola Carminati Date: Thu, 22 Aug 2019 18:03:54 +0200 Subject: [PATCH 07/11] WIP --- .../DTOModels/DTOClientConfigurationModel.cs | 3 +- .../WebApi/ConfigurationController.cs | 3 +- Step/wwwroot/assets/styles/base/modals.less | 86 +++++++++++++++++++ Step/wwwroot/assets/styles/style.css | 78 +++++++++++++++++ Step/wwwroot/src/app.business-logic.ts | 14 +-- .../components/cmsconnect-info-dialog.ts | 30 +++++++ .../components/cmsconnect-info-dialog.vue | 70 +++++++++++++++ .../machine/components/user-info.ts | 5 ++ .../machine/components/user-info.vue | 6 +- Step/wwwroot/src/app_modules/machine/index.ts | 4 +- Step/wwwroot/src/services/machineService.ts | 3 +- Step/wwwroot/src/store/machineInfo.store.ts | 2 + 12 files changed, 294 insertions(+), 10 deletions(-) create mode 100644 Step/wwwroot/src/app_modules/machine/components/cmsconnect-info-dialog.ts create mode 100644 Step/wwwroot/src/app_modules/machine/components/cmsconnect-info-dialog.vue diff --git a/Step.Model/DTOModels/DTOClientConfigurationModel.cs b/Step.Model/DTOModels/DTOClientConfigurationModel.cs index ec11a196..aa6859fc 100644 --- a/Step.Model/DTOModels/DTOClientConfigurationModel.cs +++ b/Step.Model/DTOModels/DTOClientConfigurationModel.cs @@ -14,7 +14,8 @@ namespace Step.Model.DTOModels public bool ProdEnabled { get; set; } public string ProdPath { get; set; } public bool Autorun { get; set; } - public bool MgiOption { get; set; } + public bool MgiOption { get; set; } + public bool CmsConnectReady { get; set; } public List ExtSoftwares { get; set; } public CultureInfo DefaultLanguage diff --git a/Step/Controllers/WebApi/ConfigurationController.cs b/Step/Controllers/WebApi/ConfigurationController.cs index 84644f68..e45328f9 100644 --- a/Step/Controllers/WebApi/ConfigurationController.cs +++ b/Step/Controllers/WebApi/ConfigurationController.cs @@ -46,7 +46,8 @@ namespace Step.Controllers.WebApi ProdPath = SoftwareProdConfig.Path, ExtSoftwares = ExtSoftwaresConfig, Autorun = ServerStartupConfig.AutoOpenCmsClient, - MgiOption = NcConfig.MgiOption + MgiOption = NcConfig.MgiOption, + CmsConnectReady = CmsConnectConfig.Enabled }; return Ok(clientConfiguration); diff --git a/Step/wwwroot/assets/styles/base/modals.less b/Step/wwwroot/assets/styles/base/modals.less index fbcfa4ff..5af14c5f 100644 --- a/Step/wwwroot/assets/styles/base/modals.less +++ b/Step/wwwroot/assets/styles/base/modals.less @@ -26,6 +26,8 @@ @modal-job-add-parameter-height: 608px; @modal-edit-job-width: 952px; @modal-edit-job-height: 872px; +@modal-cmsconnect-width: 952px; +@modal-cmsconnect-height: 872px; @modal-add-offset-tool-width: 1320px; @modal-add-offset-tool-height: 670px; @modal-missing-tools-width: 896px; @@ -299,6 +301,89 @@ } } +.@{modal}.cmsconnect-info { + width: @modal-cmsconnect-width; + height: @modal-cmsconnect-height; + top: calc(~"50%" - @modal-cmsconnect-height / 2); + left: calc(~"50%" - @modal-cmsconnect-width / 2); + header { + background-color: @color-darkish-blue; + color: @color-white; + font-family: @font-family; + font-weight: 600; + font-size: 24px; + text-align: left; + padding: 0px 23px; + } + .body{ + height: calc(~"100%" - ((@modal-header-height/2)+1)); + display: flex; + width: 100%; + .menu{ + width: 20%; + background-color: #e7e7e7; + + button { + width: 100%; + text-align: left; + font-size: 16px; + border: 0; + height: 62px; + border-bottom: 1px solid #cacaca ; + background-color: #e7e7e7; + &.selected{ + background-color: #fff; + } + } + } + .container{ + width: 80%; + display: flex; + flex-flow: row; + justify-content: center; + + .status{ + width: 90%; + margin-top: 10px; + display: flex; + flex-flow: column; + justify-content: flex-start; + + .btn-container{ + text-align: center; + margin-bottom: 30px; + } + + .status-container{ + background-color: #f1f1f1; + display: flex; + flex-flow: row; + justify-content: space-between; + height: 100px; + margin-bottom: 20px; + .text{ + width: 100%; + padding: 0 10px; + display: flex; + align-items: center; + *>b{ + line-height: 1.5em; + } + } + .icon{ + height: 100px; + width: 100px; + text-align: center; + line-height: 100px; + font-size: 47px; + color: #1791ff; + } + } + } + } + } +} + .@{modal}.machine-info { width: @modal-machine-width; height: @modal-machine-height; @@ -1901,6 +1986,7 @@ } } + .@{modal}.modal-edit-job { width: @modal-edit-job-width; height: @modal-edit-job-height; diff --git a/Step/wwwroot/assets/styles/style.css b/Step/wwwroot/assets/styles/style.css index 29a98a89..2bd5fee7 100644 --- a/Step/wwwroot/assets/styles/style.css +++ b/Step/wwwroot/assets/styles/style.css @@ -236,6 +236,84 @@ margin: 0 0 5px 0; font-size: 18px; } +.modal.cmsconnect-info { + width: 952px; + height: 872px; + top: calc(50% - 436px); + left: calc(50% - 476px); +} +.modal.cmsconnect-info header { + background-color: #002680; + color: #fff; + font-family: 'Work Sans', sans-serif; + font-weight: 600; + font-size: 24px; + text-align: left; + padding: 0px 23px; +} +.modal.cmsconnect-info .body { + height: calc(100% - 33px); + display: flex; + width: 100%; +} +.modal.cmsconnect-info .body .menu { + width: 20%; + background-color: #e7e7e7; +} +.modal.cmsconnect-info .body .menu button { + width: 100%; + text-align: left; + font-size: 16px; + border: 0; + height: 62px; + border-bottom: 1px solid #cacaca ; + background-color: #e7e7e7; +} +.modal.cmsconnect-info .body .menu button.selected { + background-color: #fff; +} +.modal.cmsconnect-info .body .container { + width: 80%; + display: flex; + flex-flow: row; + justify-content: center; +} +.modal.cmsconnect-info .body .container .status { + width: 90%; + margin-top: 10px; + display: flex; + flex-flow: column; + justify-content: flex-start; +} +.modal.cmsconnect-info .body .container .status .btn-container { + text-align: center; + margin-bottom: 30px; +} +.modal.cmsconnect-info .body .container .status .status-container { + background-color: #f1f1f1; + display: flex; + flex-flow: row; + justify-content: space-between; + height: 100px; + margin-bottom: 20px; +} +.modal.cmsconnect-info .body .container .status .status-container .text { + width: 100%; + padding: 0 10px; + display: flex; + align-items: center; +} +.modal.cmsconnect-info .body .container .status .status-container .text * > b { + line-height: 1.5em; +} +.modal.cmsconnect-info .body .container .status .status-container .icon { + height: 100px; + width: 100px; + text-align: center; + line-height: 100px; + font-size: 47px; + color: #1791ff; +} .modal.machine-info { width: 600px; height: 730px; diff --git a/Step/wwwroot/src/app.business-logic.ts b/Step/wwwroot/src/app.business-logic.ts index 74f548b4..87b02d03 100644 --- a/Step/wwwroot/src/app.business-logic.ts +++ b/Step/wwwroot/src/app.business-logic.ts @@ -5,7 +5,7 @@ import { loginService } from "src/services/loginService"; import { store, AppModel, MachineStatusModel, machineStatusActions, localizationModelActions, machineInfoActions } from "src/store"; -import { UserInfoDialog, MachineInfoDialog, AxesCalibration, ContactInfoDialog, Login } from "src/app_modules/machine"; +import { UserInfoDialog, MachineInfoDialog, AxesCalibration, ContactInfoDialog, Login, CmsconnectInfoDialog } from "src/app_modules/machine"; import { AreaModel } from "src/store/machineStatus.store"; @@ -16,6 +16,9 @@ import { MaintenanceService } from "./services/maintenanceService"; import { localizationService, LocalizationService } from "./services/localizationService"; import { DEBUG_CONFIGURATION, USE_RUNTIME_CONFIGURATION } from "./config"; import { ModalHelper } from "./components/modals"; + + + import Vue from "vue"; import { scadaService } from "./services/scadaService"; import { Hub } from "./services"; @@ -47,6 +50,7 @@ let RerenderInterval; messageService.subscribeToChannel("show-user-info", () => { ModalHelper.ShowModal(UserInfoDialog); }); messageService.subscribeToChannel("show-machine-info", () => { ModalHelper.ShowModal(MachineInfoDialog); }); messageService.subscribeToChannel("show-contact-info", () => { ModalHelper.ShowModal(ContactInfoDialog); }); +messageService.subscribeToChannel("show-cmsconnect-info", () => { ModalHelper.ShowModal(CmsconnectInfoDialog); }); messageService.subscribeToChannel("show-axes-calibration", () => { ModalHelper.ShowNcModal(AxesCalibration); }); messageService.subscribeToChannel("hide-axes-calibration", () => { ModalHelper.HideNcModal(AxesCalibration); }); messageService.subscribeToChannel("show-m155-questions", () => { ModalHelper.ShowNextM155Modal(); }); @@ -89,10 +93,10 @@ async function loadMachineConfig() { // set vendor type switch (vendor) { - case "siemens": machineInfoActions.updateMachineInfo(store, { isSiemens: true, isFanuc: false, isOsai: false, defaultLanguage: mcresult.defaultLanguage, isSCMVisualStyle: isSCM, mgiOption : false }); break; - case "fanuc": machineInfoActions.updateMachineInfo(store, { isSiemens: false, isFanuc: true, isOsai: false, defaultLanguage: mcresult.defaultLanguage, isSCMVisualStyle: isSCM, mgiOption: mcresult.mgiOption }); break; - case "osai": machineInfoActions.updateMachineInfo(store, { isSiemens: false, isFanuc: false, isOsai: true, defaultLanguage: mcresult.defaultLanguage, isSCMVisualStyle: isSCM, mgiOption: false }); break; - default: machineInfoActions.updateMachineInfo(store, { isSiemens: false, isFanuc: false, isOsai: false, defaultLanguage: mcresult.defaultLanguage, isSCMVisualStyle: isSCM }); break; + case "siemens": machineInfoActions.updateMachineInfo(store, { isSiemens: true, isFanuc: false, isOsai: false, defaultLanguage: mcresult.defaultLanguage, isSCMVisualStyle: isSCM, mgiOption : false, cmsConnectReady: mcresult.cmsConnectReady }); break; + case "fanuc": machineInfoActions.updateMachineInfo(store, { isSiemens: false, isFanuc: true, isOsai: false, defaultLanguage: mcresult.defaultLanguage, isSCMVisualStyle: isSCM, mgiOption: mcresult.mgiOption, cmsConnectReady: mcresult.cmsConnectReady }); break; + case "osai": machineInfoActions.updateMachineInfo(store, { isSiemens: false, isFanuc: false, isOsai: true, defaultLanguage: mcresult.defaultLanguage, isSCMVisualStyle: isSCM, mgiOption: false, cmsConnectReady: mcresult.cmsConnectReady }); break; + default: machineInfoActions.updateMachineInfo(store, { isSiemens: false, isFanuc: false, isOsai: false, defaultLanguage: mcresult.defaultLanguage, isSCMVisualStyle: isSCM, cmsConnectReady: mcresult.cmsConnectReady }); break; } machineInfoActions.updateMachineInfo(store, { clientDefaultLanguage: mcresult.defaultLanguage }); diff --git a/Step/wwwroot/src/app_modules/machine/components/cmsconnect-info-dialog.ts b/Step/wwwroot/src/app_modules/machine/components/cmsconnect-info-dialog.ts new file mode 100644 index 00000000..7c5bea2b --- /dev/null +++ b/Step/wwwroot/src/app_modules/machine/components/cmsconnect-info-dialog.ts @@ -0,0 +1,30 @@ +import Vue from "vue"; +import { Modal, ModalHelper } from "src/components/modals"; +import { machineService } from "src/services/machineService"; +import { Factory, messageService } from "src/_base"; +import moment from "moment"; +import Component from "vue-class-component"; + +@Component({ + components: { + modal: Modal + } +}) +export default class CmsconnectInfoDialog extends Vue { + selectedTab = "status"; + + close() { + messageService.deleteChannel("esc_pressed"); + ModalHelper.HideModal(); + } + + confirm() { + messageService.deleteChannel("esc_pressed"); + ModalHelper.HideModal(); + } + + selectTab(value) { + this.selectedTab = value; + } + +}; diff --git a/Step/wwwroot/src/app_modules/machine/components/cmsconnect-info-dialog.vue b/Step/wwwroot/src/app_modules/machine/components/cmsconnect-info-dialog.vue new file mode 100644 index 00000000..78157bac --- /dev/null +++ b/Step/wwwroot/src/app_modules/machine/components/cmsconnect-info-dialog.vue @@ -0,0 +1,70 @@ + + diff --git a/Step/wwwroot/src/app_modules/machine/components/user-info.ts b/Step/wwwroot/src/app_modules/machine/components/user-info.ts index 93a797b7..c1b2be64 100644 --- a/Step/wwwroot/src/app_modules/machine/components/user-info.ts +++ b/Step/wwwroot/src/app_modules/machine/components/user-info.ts @@ -30,6 +30,11 @@ export default class UserInfo extends Vue { return (this.$store.state as AppModel).currentUser; } + get cmsConnectReady() { + return (this.$store.state as AppModel).machineInfo.cmsConnectReady; + } + + getColor(nome,cognome){ return getColorFromName(nome,cognome); } diff --git a/Step/wwwroot/src/app_modules/machine/components/user-info.vue b/Step/wwwroot/src/app_modules/machine/components/user-info.vue index eb3da213..a659af6f 100644 --- a/Step/wwwroot/src/app_modules/machine/components/user-info.vue +++ b/Step/wwwroot/src/app_modules/machine/components/user-info.vue @@ -5,8 +5,12 @@ --> +