diff --git a/Step.CmsConnectGateway/Builders/GatewayNewtorkConfigurationBuilder.cs b/Step.CmsConnectGateway/Builders/GatewayNewtorkConfigurationBuilder.cs new file mode 100644 index 00000000..0f1b2ae8 --- /dev/null +++ b/Step.CmsConnectGateway/Builders/GatewayNewtorkConfigurationBuilder.cs @@ -0,0 +1,99 @@ +using Step.CmsConnectGateway.Builders; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace Step.CmsConnectGateway +{ + 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.CmsConnectGateway/Builders/GatewayProxyConfigurationBuilder.cs b/Step.CmsConnectGateway/Builders/GatewayProxyConfigurationBuilder.cs new file mode 100644 index 00000000..e76096d3 --- /dev/null +++ b/Step.CmsConnectGateway/Builders/GatewayProxyConfigurationBuilder.cs @@ -0,0 +1,93 @@ +using Step.CmsConnectGateway.Builders; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace Step.CmsConnectGateway +{ + 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.CmsConnectGateway/Builders/iBuilder.cs b/Step.CmsConnectGateway/Builders/iBuilder.cs new file mode 100644 index 00000000..8a920757 --- /dev/null +++ b/Step.CmsConnectGateway/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.CmsConnectGateway.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.CmsConnectGateway/Events/GatewayRebootEventHandlerArgs.cs b/Step.CmsConnectGateway/Events/GatewayRebootEventHandlerArgs.cs new file mode 100644 index 00000000..50c76768 --- /dev/null +++ b/Step.CmsConnectGateway/Events/GatewayRebootEventHandlerArgs.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Step.CmsConnectGateway.Events +{ + public class GatewayRebootEventHandlerArgs : EventArgs + { + public Boolean errorStatus { get; internal set; } + public String errorMessage { get; internal set; } + + public GatewayRebootEventHandlerArgs() + { + errorStatus = false; + errorMessage = ""; + } + } +} diff --git a/Step.CmsConnectGateway/Exceptions/GatewayException.cs b/Step.CmsConnectGateway/Exceptions/GatewayException.cs new file mode 100644 index 00000000..f9986cc8 --- /dev/null +++ b/Step.CmsConnectGateway/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.CmsConnectGateway.Exceptions +{ + public class GatewayException: Exception + { + public GatewayException(string message): base(message) + { + } + } +} diff --git a/Step.CmsConnectGateway/GatewayAdapter.cs b/Step.CmsConnectGateway/GatewayAdapter.cs new file mode 100644 index 00000000..897ab378 --- /dev/null +++ b/Step.CmsConnectGateway/GatewayAdapter.cs @@ -0,0 +1,759 @@ +using Renci.SshNet; +using Renci.SshNet.Common; +using Step.CmsConnectGateway.Events; +using Step.CmsConnectGateway.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.CmsConnectGateway +{ + public class GatewayAdapter : 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_TEST_CONNECTION_COMMAND = "sudo ./testConnection.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 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 + 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 GatewayAdapter() + { + 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 GatewayAdapter(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)); + } + + + /// + /// 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 + /// + 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) => + { + GatewayRebootEventHandlerArgs ev = new GatewayRebootEventHandlerArgs(); + 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) + { + if (delay < 0) + throw new ArgumentOutOfRangeException("Delay must be > 0"); + + //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; + } + + 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 + + //--------------------------------------------------------------------------------------------------- + #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); + + //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 - Gateway not found during reboot"); + + //Try Connection + _sshGateway.Connect(); + connected = true; + } + catch (SocketException e) + { + //Not Connected + Thread.Sleep(REBOOT_MSWAIT_BETWEEN_OP); + } + catch (SshConnectionException e) + { + //Not Connected + Thread.Sleep(REBOOT_MSWAIT_BETWEEN_OP); + } + catch (SshException e) + { + //Not Connected + Thread.Sleep(REBOOT_MSWAIT_BETWEEN_OP); + } + 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.CmsConnectGateway/Models/GatewayConfiguration.cs b/Step.CmsConnectGateway/Models/GatewayConfiguration.cs new file mode 100644 index 00000000..089e3f59 --- /dev/null +++ b/Step.CmsConnectGateway/Models/GatewayConfiguration.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Net; + +namespace Step.CmsConnectGateway +{ + + + public enum GatewayConnectionStatus { OK = 0, WEB_ERROR = 1, PORT_ERROR = 2 }; + + 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 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 + { + 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; } + + 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"); + } + } +} diff --git a/Step.CmsConnectGateway/Properties/AssemblyInfo.cs b/Step.CmsConnectGateway/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..83a2b4c1 --- /dev/null +++ b/Step.CmsConnectGateway/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.CmsConnectGateway/Step.CmsConnectGateway.csproj b/Step.CmsConnectGateway/Step.CmsConnectGateway.csproj new file mode 100644 index 00000000..eaab3452 --- /dev/null +++ b/Step.CmsConnectGateway/Step.CmsConnectGateway.csproj @@ -0,0 +1,63 @@ + + + + + Debug + AnyCPU + {49B04D99-0ECD-4900-86D3-7098D61314D7} + Library + Properties + Step.CmsConnectGateway + Step.CmsConnectGateway + 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.CmsConnectGateway/packages.config b/Step.CmsConnectGateway/packages.config new file mode 100644 index 00000000..4660ea73 --- /dev/null +++ b/Step.CmsConnectGateway/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file 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 ba99af4a..cad482a9 100644 --- a/Step.Config/Config/serverConfig.xml +++ b/Step.Config/Config/serverConfig.xml @@ -25,7 +25,6 @@ C:\Windows\System32\notepad.exe C:\CMS\MTC\ADAPTER\ SCMA - true 50000 5000 diff --git a/Step.Config/Config/serverConfigValidator.xsd b/Step.Config/Config/serverConfigValidator.xsd index ad613015..9b87ed9f 100644 --- a/Step.Config/Config/serverConfigValidator.xsd +++ b/Step.Config/Config/serverConfigValidator.xsd @@ -37,8 +37,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 bd071ea4..8002a5eb 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(); @@ -307,8 +308,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; @@ -548,6 +548,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..cdaaf09f 100644 --- a/Step.Core/ThreadsFunctions.cs +++ b/Step.Core/ThreadsFunctions.cs @@ -7,9 +7,11 @@ using Step.Model.DTOModels.AlarmModels; using Step.Model.DTOModels.Scada; using Step.Model.DTOModels.ToolModels; using Step.NC; +using Step.Utils; using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.IO; using System.Linq; using System.Runtime.InteropServices; @@ -25,7 +27,7 @@ public static class ThreadsFunctions public static bool reconnectionIsRunning = false; private static long ReadAlarmsTimer = 0, ReadAlarmsTimes = 0; private static long ReadAxesTimer = 0, ReadAxesTimes = 0; - private static long ReadPowerOnTimer = 0, ReadPowerOnTimes = 0; + private static long ReadPowerOnTimer = 0, ReadPowerOnTimes = 0; private static long ReadProcPPTimer = 0, ReadProcPPTimes = 0; private static long ReadFunctionTimer = 0, ReadFunctionTimes = 0; private static long ReadMaintenanceTimer = 0, ReadMaintenanceTimes = 0; @@ -154,8 +156,8 @@ public static class ThreadsFunctions sw.Stop(); // Update thread timer - ReadPowerOnTimer += sw.ElapsedMilliseconds; - ReadPowerOnTimes++; + ReadPowerOnTimer += sw.ElapsedMilliseconds; + ReadPowerOnTimes++; // Wait Thread.Sleep(CalcSleepTime(400, (int)sw.ElapsedMilliseconds)); @@ -514,9 +516,9 @@ public static class ThreadsFunctions try { // Try connection - CmsError libraryError = ncHandler.Connect(); + CmsError libraryError = ncHandler.Connect(); if (libraryError.errorCode != 0) - ManageLibraryError(libraryError); + ManageLibraryError(libraryError); while (true) { @@ -570,7 +572,7 @@ public static class ThreadsFunctions if (ncHandler.numericalControl.NC_IsConnected()) { // Get Data from config and PLC - libraryError = ncHandler.GetActiveProgramInfo(out DTOActiveProgramDataModel active); + libraryError = ncHandler.GetActiveProgramInfo(out DTOActiveProgramDataModel active); if (libraryError.IsError()) ManageLibraryError(libraryError); @@ -672,7 +674,7 @@ public static class ThreadsFunctions MessageServices.Current.Publish(NC_MAGAZINE_IS_ACTIVE, null, status); - if(NcConfig.NcVendor != NC_VENDOR.SIEMENS) + if (NcConfig.NcVendor != NC_VENDOR.SIEMENS) { libraryError = ncHandler.ReadAssistedToolingProcedure(out DTOAssistedToolingEndValueModel data); if (libraryError.IsError()) @@ -705,14 +707,14 @@ public static class ThreadsFunctions // Try connection CmsError libraryError = ncHandler.Connect(); if (libraryError.errorCode != 0) - ManageLibraryError(libraryError); + ManageLibraryError(libraryError); while (true) { sw.Restart(); // Check if client is connected - if (ncHandler.numericalControl.NC_IsConnected()) + if (ncHandler.numericalControl.NC_IsConnected()) { // Read data libraryError = ncHandler.UpdateQueue(); @@ -772,7 +774,7 @@ public static class ThreadsFunctions sw.Stop(); // Wait - Thread.Sleep(CalcSleepTime(500, (int)sw.ElapsedMilliseconds)); + Thread.Sleep(CalcSleepTime(500, (int)sw.ElapsedMilliseconds)); } } catch (ThreadAbortException) @@ -783,7 +785,7 @@ public static class ThreadsFunctions public static void ReadM154Data() { - NcHandler ncHandler = new NcHandler(); + NcHandler ncHandler = new NcHandler(); Stopwatch sw = new Stopwatch(); try @@ -791,7 +793,7 @@ public static class ThreadsFunctions // Try connection CmsError libraryError = ncHandler.Connect(); if (libraryError.errorCode != 0) - ManageLibraryError(libraryError); + ManageLibraryError(libraryError); while (true) { @@ -833,8 +835,8 @@ public static class ThreadsFunctions } foreach (M154DataModel m154 in data) - { - if(ServerStartupConfig.CMSConnectReady) + { + if (CmsConnectConfig.Enabled) { if (m154.Parameters.Count() >= 2 && m154.Parameters[0] == "SOUR") @@ -866,7 +868,7 @@ public static class ThreadsFunctions notif += m154.Parameters[2]; RedisController.WriteProductionNotification(m154.Process, notif); break; - } + } } // Write ack @@ -883,7 +885,7 @@ public static class ThreadsFunctions if (m154.Parameters[0] == "MTC") { // Convert tag string in Pascal Case and add to result string - switch (m154.Parameters[1].ToLower()) + switch (m154.Parameters[1].ToLower()) { case "currprog": stringVal += "CurrProg"; @@ -908,7 +910,7 @@ public static class ThreadsFunctions string outputFileName = ServerStartupConfig.MTCFolderPath + "\\DATA\\CmsGeneralStatus.mtc"; // Create file if not exits if (!File.Exists(outputFileName)) - using (var f = File.Create(outputFileName)) { }; + using (var f = File.Create(outputFileName)) { }; // Read file List fileLines = File.ReadAllLines(outputFileName).ToList(); string[] parametersInLine; @@ -952,6 +954,68 @@ public static class ThreadsFunctions } } + + public static void SetupCmsConnect(){ + NcHandler ncHandler = new NcHandler(); + try + { + List availableLanguages = LanguageController.GetLanguageListFromDirectory(); + if (availableLanguages == null) + return ; + + ICollection cultureInfos = new List(); + + // Get nc available language + CmsError cmsError = ncHandler.numericalControl.NC_GetAvailableLanguages(ref cultureInfos); + if (cmsError.IsError()) + ManageLibraryError(cmsError); + + // Filter available language with + availableLanguages = availableLanguages.Where(x => cultureInfos.Any(y => y.TwoLetterISOLanguageName == x.IsoId)).ToList(); + + // Fill redis DB + int count = 1; + Dictionary defAlarmsNamesEn = null; + Dictionary defAlarmsNamesIt = null; + foreach (DTOLanguageModel lang in availableLanguages) + { + Dictionary alarmsNames = GetPlcAlarmsTranslations(lang.IsoId); + + if(lang.IsoId.ToLower() == "en") + { + defAlarmsNamesEn = alarmsNames; + if(!RedisController.WriteAlarmsConfigEn(alarmsNames)) + Manage(ERROR_LEVEL.FATAL, CMS_CONNECT_SETUP_ALARM_MESSAGE); + } + else if (lang.IsoId.ToLower() == "it") + { + defAlarmsNamesIt = alarmsNames; + if (!RedisController.WriteAlarmsConfigIt(alarmsNames)) + Manage(ERROR_LEVEL.FATAL, CMS_CONNECT_SETUP_ALARM_MESSAGE); + } + else + if (!RedisController.WriteAlarmsConfigCurr(alarmsNames)) + Manage(ERROR_LEVEL.FATAL, CMS_CONNECT_SETUP_ALARM_MESSAGE); + + if (count == 3) + break; + else + count++; + } + + if (availableLanguages.Count < 3 && defAlarmsNamesEn != null) + if (!RedisController.WriteAlarmsConfigCurr(defAlarmsNamesEn)) + Manage(ERROR_LEVEL.FATAL, CMS_CONNECT_SETUP_ALARM_MESSAGE); + else if (availableLanguages.Count < 3 && defAlarmsNamesIt != null) + if (!RedisController.WriteAlarmsConfigCurr(defAlarmsNamesIt)) + Manage(ERROR_LEVEL.FATAL, CMS_CONNECT_SETUP_ALARM_MESSAGE); + + } + catch (ThreadAbortException) + { + ncHandler.Dispose(); + } + } #endregion Functions #region SupportFunctions @@ -1212,6 +1276,39 @@ public static class ThreadsFunctions return false; } + private static Dictionary GetPlcAlarmsTranslations(string language) + { + using (NcHandler ncHandler = new NcHandler()) + { + Dictionary returnValue = new Dictionary(); + + Dictionary messages = new Dictionary(); + // Read data from CN + ncHandler.numericalControl.NC_GetTranslatedPlcMessages(language, ref messages); // Avoid checking error because in the worst case "messages" is empty + + // Id start from 1 + for (int i = 1; i <= 1024; i++) + { + // Get configurated alarms + var tmpAlarmConfig = InitialAlarmsConfig.Where(x => x.PlcId == i).FirstOrDefault(); + // Default string + string message = string.Format(NOT_CONFIGURATED_ALARM_MESSAGE, i); + // If is configurated + if (tmpAlarmConfig != null) + { + // Find translated string + message = messages.Where(x => x.Key == tmpAlarmConfig.AlarmId).FirstOrDefault().Value; + if (message == null) + message = string.Format(NOT_FOUND_ALARM_MESSAGE, i); + } + // Add to dictionary + returnValue.Add(i.ToString("D6") + "|900",message); + } + return returnValue; + } + } + + [DllImport("user32.dll")] static extern bool SetForegroundWindow(IntPtr hWnd); diff --git a/Step.Core/ThreadsHandler.cs b/Step.Core/ThreadsHandler.cs index 98b01429..6fbf69f1 100644 --- a/Step.Core/ThreadsHandler.cs +++ b/Step.Core/ThreadsHandler.cs @@ -29,6 +29,7 @@ namespace Step.Core ThreadsFunctions.ReadM154Data // ThreadsFunctions.ReadNcSoftKeysData, }; + private static Action ThreadSetupCmsConnect = ThreadsFunctions.SetupCmsConnect; private volatile static List RunningThreadsList = new List(); public static Thread StartClient; @@ -38,6 +39,14 @@ namespace Step.Core public static void Start() { ThreadsFunctions.RestoreConnection(); + + //Setup CMS Connect + if(Config.ServerConfig.CmsConnectConfig.Enabled) + { + Thread t = new Thread(() => ThreadSetupCmsConnect()); + t.Start(); + } + } public static void StartWorkers() diff --git a/Step.Database/Controllers/RedisController.cs b/Step.Database/Controllers/RedisController.cs index cbc6c94e..bcbce2fb 100644 --- a/Step.Database/Controllers/RedisController.cs +++ b/Step.Database/Controllers/RedisController.cs @@ -13,6 +13,9 @@ namespace Step.Database.Controllers private const String redisProdNameAddress = "Machine:ProductionProcesses:%NN%:Programs:01:Name"; private const String redisRepsTargetAddress = "Machine:ProductionProcesses:%NN%:Programs:01:RepsTarget"; private const String redisRepsDoneAddress = "Machine:ProductionProcesses:%NN%:Programs:01:RepsDone"; + private const String redisAlmCurr = "AdpConf:Plc:Condition:Curr"; + private const String redisAlmIt = "AdpConf:Plc:Condition:It"; + private const String redisAlmEn = "AdpConf:Plc:Condition:En"; public static void WriteProductionNotification(uint ProductionProcess, string Notification) { @@ -38,6 +41,24 @@ namespace Step.Database.Controllers redUtil.man.setRSV(redisHash, RepsDone); } + public static bool WriteAlarmsConfigCurr(Dictionary alarms) + { + string redisHash = redUtil.man.redHash(redisAlmCurr); + return redUtil.man.redSaveHashDict(redisHash, alarms); + } + + public static bool WriteAlarmsConfigEn(Dictionary alarms) + { + string redisHash = redUtil.man.redHash(redisAlmEn); + return redUtil.man.redSaveHashDict(redisHash, alarms); + } + + public static bool WriteAlarmsConfigIt(Dictionary alarms) + { + string redisHash = redUtil.man.redHash(redisAlmIt); + return redUtil.man.redSaveHashDict(redisHash, alarms); + } + } } 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 9a567482..e7da4c0e 100644 --- a/Step.Model/ConfigModels/ServerConfigModel.cs +++ b/Step.Model/ConfigModels/ServerConfigModel.cs @@ -19,7 +19,7 @@ namespace Step.Model.ConfigModels public string MTCFolderPath { get; set; } public string MTCApplicationName { get; set; } - public bool 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..fb16ec81 100644 --- a/Step.Model/Constants.cs +++ b/Step.Model/Constants.cs @@ -8,6 +8,7 @@ namespace Step.Model public static bool IS_BETA = true; public static string NOT_FOUND_ALARM_MESSAGE = "Alarm_id_{0} : Message not found"; public static string NOT_CONFIGURATED_ALARM_MESSAGE = "Alarm_id_{0} : Message not configurated"; + public static string CMS_CONNECT_SETUP_ALARM_MESSAGE = "Error during CMS-Connect setup: Redis Db Not Found"; public static int DATABASE_PROCESS_TIMEOUT = 5; //Costanti Tipo metreica utensili @@ -184,6 +185,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"; @@ -203,6 +207,7 @@ namespace Step.Model public const string SEND_STOP_THREADS = "SEND_STOP_THREADS"; public const string SEND_NC_STATUS = "NC_STATUS"; public const string SEND_THREADS_STATUS = "THREAD_STATUS"; + public const string SEND_CMSCONNECT_GW_REBOOT_STATUS = "SEND_CMSCONNECT_GW_REBOOT_STATUS"; public const string SHOW_MSG_UI = "SHOW_MSG_UI"; public const string SEND_ERROR_TO_UI = "SEND_ERROR_TO_UI"; diff --git a/Step.Model/DTOModels/DTOClientConfigurationModel.cs b/Step.Model/DTOModels/DTOClientConfigurationModel.cs index 7fddd062..42d7ac88 100644 --- a/Step.Model/DTOModels/DTOClientConfigurationModel.cs +++ b/Step.Model/DTOModels/DTOClientConfigurationModel.cs @@ -15,7 +15,8 @@ namespace Step.Model.DTOModels public string ProdPath { get; set; } public string EditorPath { 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.Model/DTOModels/DTOCmsConnectGateway.cs b/Step.Model/DTOModels/DTOCmsConnectGateway.cs new file mode 100644 index 00000000..d07a4a6b --- /dev/null +++ b/Step.Model/DTOModels/DTOCmsConnectGateway.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Step.Model.DTOModels +{ + public class DTOCmsConnectGatewayNetworkModel + { + public Boolean hasDhcp; + public string ipAddress; + public string netMaskAddress; + public string defaultGatewayAddress; + public IEnumerable dnsAddresses; + public IEnumerable dnsPrefixes; + } + + public class DTOCmsConnectGatewayProxyModel + { + public Boolean hasProxy; + public string address; + public uint port; + public string username; + public string password; + public IEnumerable noproxyAddresses; + } +} diff --git a/Step.Model/Step.Model.csproj b/Step.Model/Step.Model.csproj index d49b564b..bb361ece 100644 --- a/Step.Model/Step.Model.csproj +++ b/Step.Model/Step.Model.csproj @@ -64,6 +64,7 @@ + @@ -108,6 +109,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 diff --git a/Step.sln b/Step.sln index e210113d..f4646718 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.CmsConnectGateway", "Step.CmsConnectGateway\Step.CmsConnectGateway.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..1ed39239 --- /dev/null +++ b/Step/Controllers/WebApi/CmsConnectController.cs @@ -0,0 +1,244 @@ +using Step.CmsConnectGateway; +using Step.CmsConnectGateway.Events; +using Step.CmsConnectGateway.Exceptions; +using Step.Model.DTOModels; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; +using System.Web.Http; +using TeamDev.SDK.MVVM; +using static Step.Model.Constants; + +namespace Step.Controllers.WebApi +{ + [RoutePrefix("api/cms_connect")] + public class CmsConnectController : ApiController + { + [Route("runConnectionTest"), HttpGet] + public IHttpActionResult RunConnectionTest() + { + using(GatewayAdapter Adp = new GatewayAdapter(Config.ServerConfig.CmsConnectConfig.Gateway.Address, Config.ServerConfig.CmsConnectConfig.Gateway.Username, Config.ServerConfig.CmsConnectConfig.Gateway.Password)) + { + + try + { + GatewayConnectionStatus sts = Adp.TestGatewayConnection(1); + return Ok(sts.ToString()); + } + catch (GatewayException e) + { + return InternalServerError(e); + } + } + } + + private void endRebootHandler(object sender, GatewayRebootEventHandlerArgs e) + { + MessageServices.Current.Publish(SEND_CMSCONNECT_GW_REBOOT_STATUS, null, e.errorMessage); + } + + [Route("rebootGateway"), HttpGet] + public IHttpActionResult RebootGateway() + { + using (GatewayAdapter Adp = new GatewayAdapter(Config.ServerConfig.CmsConnectConfig.Gateway.Address, Config.ServerConfig.CmsConnectConfig.Gateway.Username, Config.ServerConfig.CmsConnectConfig.Gateway.Password)) + { + + try + { + Adp.RebootGatewayAsync(1, endRebootHandler); + return Ok(); + } + catch (GatewayException e) + { + return InternalServerError(e); + } + } + } + + + [Route("getGatewayNetworkSetup"), HttpGet] + public IHttpActionResult GetGatewayNetworkSetup() + { + using (GatewayAdapter Adp = new GatewayAdapter(Config.ServerConfig.CmsConnectConfig.Gateway.Address, Config.ServerConfig.CmsConnectConfig.Gateway.Username, Config.ServerConfig.CmsConnectConfig.Gateway.Password)) + { + + try + { + GatewayNetworkConfiguration config = Adp.ReadGatewayNetworkConfiguration(); + + DTOCmsConnectGatewayNetworkModel model = new DTOCmsConnectGatewayNetworkModel() + { + hasDhcp = config.hasDhcp, + ipAddress = config.ipAddress != null ? config.ipAddress.ToString() : "", + netMaskAddress = config.netMaskAddress != null ? config.netMaskAddress.ToString() : "", + defaultGatewayAddress = config.defaultGatewayAddress != null ? config.defaultGatewayAddress.ToString() : "", + dnsAddresses = config.dnsAddresses != null? config.dnsAddresses.Select(i => i.ToString()) : new List(), + dnsPrefixes = config.dnsPrefixes != null ? config.dnsPrefixes : new List() + }; + + return Ok(model); + } + catch (GatewayException e) + { + return InternalServerError(e); + } + } + } + + + [Route("getGatewayProxySetup"), HttpGet] + public IHttpActionResult GetGatewayProxySetup() + { + using (GatewayAdapter Adp = new GatewayAdapter(Config.ServerConfig.CmsConnectConfig.Gateway.Address, Config.ServerConfig.CmsConnectConfig.Gateway.Username, Config.ServerConfig.CmsConnectConfig.Gateway.Password)) + { + + + try + { + GatewayProxyConfiguration config = Adp.ReadGatewayProxyConfiguration(); + + DTOCmsConnectGatewayProxyModel model = new DTOCmsConnectGatewayProxyModel() + { + hasProxy = config.hasProxy, + address = config.address != null ? config.address : "", + port = config.port, + username = config.address != null ? config.username : "", + password = config.address != null ? config.password : "", + noproxyAddresses = config.noproxyAddresses != null ? config.noproxyAddresses : new List() + }; + + return Ok(model); + } + catch (GatewayException e) + { + return InternalServerError(e); + } + } + } + + + [Route("setGatewayNetworkSetup"), HttpPut] + public IHttpActionResult SetGatewayNetworkSetup([FromBody][Required]DTOCmsConnectGatewayNetworkModel dtoGatewayNetworkModel) + { + using (GatewayAdapter Adp = new GatewayAdapter(Config.ServerConfig.CmsConnectConfig.Gateway.Address, Config.ServerConfig.CmsConnectConfig.Gateway.Username, Config.ServerConfig.CmsConnectConfig.Gateway.Password)) + { + try + { + GatewayNetworkConfigurationBuilder builder = new GatewayNetworkConfigurationBuilder(); + + if (dtoGatewayNetworkModel.hasDhcp) + builder.HasDhcp(true); + else + { + builder.HasDhcp(false); + + IPAddress addr; + if (IPAddress.TryParse(dtoGatewayNetworkModel.ipAddress, out addr)) + builder.IpAddress(addr); + else + throw new ArgumentException("IP Address not ok"); + + if (IPAddress.TryParse(dtoGatewayNetworkModel.netMaskAddress, out addr)) + builder.NetMaskAddress(addr); + else + throw new ArgumentException("Netmask Address not ok"); + + if (IPAddress.TryParse(dtoGatewayNetworkModel.defaultGatewayAddress, out addr)) + builder.DefaultGatewayAddress(addr); + else + throw new ArgumentException("D.Gateway Address not ok"); + } + + if(dtoGatewayNetworkModel.dnsAddresses != null) + { + List dnsAddr = new List(); + foreach (string addr in dtoGatewayNetworkModel.dnsAddresses) + { + if(!string.IsNullOrWhiteSpace(addr)) + dnsAddr.Add(IPAddress.Parse(addr)); + } + builder.DnsAddresses(dnsAddr); + } + + if (dtoGatewayNetworkModel.dnsPrefixes != null) + { + List dnsPref = new List(); + foreach (string addr in dtoGatewayNetworkModel.dnsPrefixes) + { + if (!string.IsNullOrWhiteSpace(addr)) + dnsPref.Add(addr.Trim()); + } + builder.DnsPrefixes(dnsPref); + } + + Adp.WriteGatewayNetworkConfiguration(builder.GenerateConfiguration()); + + return Ok(dtoGatewayNetworkModel); + } + catch (Exception e) + { + return InternalServerError(e); + } + } + } + + [Route("setGatewayProxySetup"), HttpPut] + public IHttpActionResult SetGatewayProxySetup([FromBody][Required]DTOCmsConnectGatewayProxyModel dtoGatewayProxyModel) + { + using (GatewayAdapter Adp = new GatewayAdapter(Config.ServerConfig.CmsConnectConfig.Gateway.Address, Config.ServerConfig.CmsConnectConfig.Gateway.Username, Config.ServerConfig.CmsConnectConfig.Gateway.Password)) + { + try + { + GatewayProxyConfigurationBuilder builder = new GatewayProxyConfigurationBuilder(); + + if (!dtoGatewayProxyModel.hasProxy) + builder.HasProxy(false); + else + { + builder.HasProxy(true); + if (dtoGatewayProxyModel.address != null && !string.IsNullOrWhiteSpace(dtoGatewayProxyModel.address)) + builder.Address(dtoGatewayProxyModel.address); + else + throw new ArgumentException("Address not ok"); + + if (dtoGatewayProxyModel.port != null && dtoGatewayProxyModel.port != 0) + builder.Port(dtoGatewayProxyModel.port); + else + throw new ArgumentException("Port not ok"); + } + + if (dtoGatewayProxyModel.username != null && !string.IsNullOrWhiteSpace(dtoGatewayProxyModel.username)) + builder.Username(dtoGatewayProxyModel.username); + + if (dtoGatewayProxyModel.password != null && !string.IsNullOrWhiteSpace(dtoGatewayProxyModel.password)) + builder.Username(dtoGatewayProxyModel.password); + + if (dtoGatewayProxyModel.noproxyAddresses != null) + { + List noProx = new List(); + foreach (string addr in dtoGatewayProxyModel.noproxyAddresses) + { + if (!string.IsNullOrWhiteSpace(addr)) + noProx.Add(addr.Trim()); + } + builder.NoproxyAddresses(noProx); + } + + + Adp.WriteGatewayProxyConfiguration(builder.GenerateConfiguration()); + + return Ok(dtoGatewayProxyModel); + } + catch (Exception e) + { + return InternalServerError(e); + } + } + } + + } +} diff --git a/Step/Controllers/WebApi/ConfigurationController.cs b/Step/Controllers/WebApi/ConfigurationController.cs index 473065b8..3e7256e1 100644 --- a/Step/Controllers/WebApi/ConfigurationController.cs +++ b/Step/Controllers/WebApi/ConfigurationController.cs @@ -47,7 +47,8 @@ namespace Step.Controllers.WebApi ExtSoftwares = ExtSoftwaresConfig, Autorun = ServerStartupConfig.AutoOpenCmsClient, EditorPath = ServerStartupConfig.TextEditorPath, - MgiOption = NcConfig.MgiOption + MgiOption = NcConfig.MgiOption, + CmsConnectReady = CmsConnectConfig.Enabled }; return Ok(clientConfiguration); diff --git a/Step/Listeners/ListenersHandler.cs b/Step/Listeners/ListenersHandler.cs index b0767748..09525d72 100644 --- a/Step/Listeners/ListenersHandler.cs +++ b/Step/Listeners/ListenersHandler.cs @@ -95,6 +95,10 @@ namespace Step.Listeners { SignalRListener.SendScadaData(a); })); + infos.Add(MessageServices.Current.Subscribe(SEND_CMSCONNECT_GW_REBOOT_STATUS, (a, b) => + { + SignalRListener.SetGatewayRebootStatus(a); + })); //////////////////////////// Database infos.Add(MessageServices.Current.Subscribe(UPDATE_TOOLS_DATA, (a, b) => diff --git a/Step/Listeners/SignalR/SignalRListener.cs b/Step/Listeners/SignalR/SignalRListener.cs index 15e560fe..2affb864 100644 --- a/Step/Listeners/SignalR/SignalRListener.cs +++ b/Step/Listeners/SignalR/SignalRListener.cs @@ -286,8 +286,19 @@ namespace Step.Listeners.SignalR var context = GlobalHost.ConnectionManager.GetHubContext(); context.Clients.Group("ncData").scadaData(scadaVal); } + } + + public static void SetGatewayRebootStatus(object status) + { + string msg = status.ToString(); + if (String.IsNullOrEmpty(msg)) + msg = "REBOOT_OK"; + else + msg = "REBOOT_ERROR;" + msg; + + var context = GlobalHost.ConnectionManager.GetHubContext(); + context.Clients.Group("ncData").cmsConnectGatewayRebbot(msg); } - private volatile static object _broadcastlock = new Object(); public static void BroadcastData() diff --git a/Step/Step.csproj b/Step/Step.csproj index 3f2b7250..53d7a656 100644 --- a/Step/Step.csproj +++ b/Step/Step.csproj @@ -219,6 +219,7 @@ + @@ -16122,6 +16123,10 @@ + + {49b04d99-0ecd-4900-86d3-7098d61314d7} + Step.CmsConnectGateway + {3f5c2483-fc87-43ef-92a8-66ff7d0e440f} Step.Config diff --git a/Step/wwwroot/assets/styles/base/input.less b/Step/wwwroot/assets/styles/base/input.less index b75e114e..3148125b 100644 --- a/Step/wwwroot/assets/styles/base/input.less +++ b/Step/wwwroot/assets/styles/base/input.less @@ -37,6 +37,22 @@ sans-serif; padding-left: 20px; width: calc(~'100% - 20px'); } + textarea { + box-sizing: border-box; + resize: none; + display: block; + border-radius: 2px; + border: solid 1px #dfdfdf; + height: 120px; + font-family: @font-family; + color: @color-input-light; + font-size: 16px; + background-color: @color-input-background; + margin: 0 0px; + padding-right: 0; + width: 100%; + padding: 10px 5px; + } select { padding: 0; width: 100%; diff --git a/Step/wwwroot/assets/styles/base/modals.less b/Step/wwwroot/assets/styles/base/modals.less index 54b1f933..20c9b0d6 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,252 @@ } } +.@{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); + color: #4b4b4b; + 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; + display: flex; + align-items: center; + color: #4b4b4b; + &.selected{ + background-color: #fff; + color: black; + } + i{ + font-size: 2em; + padding-right: 15px; + } + } + } + + .container{ + width: 80%; + display: flex; + flex-flow: row; + justify-content: center; + position: relative; + + .err-container{ + background-color: @color-scarlet; + color: white; + font-weight: bold; + position: absolute; + width: 100%; + height: 0px; + box-shadow: 0 3px 5px 0 rgba(0, 0, 0, 0.4); + overflow: hidden; + transition: 0.4s; + + div{ + padding: 10px 10px; + } + &.visible{ + height: 40px; + cursor: pointer; + } + } + .status{ + width: 95%; + margin-top: 15px; + display: flex; + flex-flow: column; + justify-content: flex-start; + + .btn-container{ + text-align: center; + margin-top: 30px; + } + + .status-container{ + background-color: #f8f8f8; + display: flex; + flex-flow: row; + justify-content: space-between; + height: 100px; + margin-bottom: 20px; + border-radius: 2px; + border: solid 1px #dfdfdf; + .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: @color-clear-blue; + &.green{ + color: @color-green; + } + &.red{ + color: @color-scarlet; + } + &.std{ + color: #4b4b4b; + } + + + } + } + } + + .reboot{ + width: 95%; + margin-top: 15px; + display: flex; + flex-flow: column; + justify-content: flex-start; + .reboot-container{ + background-color: #f8f8f8; + display: flex; + flex-flow: column; + justify-content: center; + align-items: center; + height: 200px; + margin-bottom: 20px; + border-radius: 2px; + border: solid 1px #dfdfdf; + i{ + font-size: 100px; + margin-top: 20px; + &.green{ + color: @color-green; + } + &.red{ + color: @color-scarlet; + } + &.blue{ + color: @color-clear-blue; + } + } + .progress-line { + height: 30px; + width: 592px; + margin: auto; + progress { + width: 552px; + height: 12px; + font-size: 14px; + float: left; + background-color: white; // color: @progress-white-color; + position: relative; + } + progress[value]::-webkit-progress-value { + color: @progress-white-color; + background-color: @progress-back-color; + border-radius: 4px; + } + progress[value]::-webkit-progress-bar { + background-color: #fff; + border-radius: 4px; + box-shadow: inset 0 1px 3px 0 rgba(0, 0, 0, 0.5); + } + } + } + .btn-container{ + text-align: center; + margin-top: 30px; + } + } + + .network{ + width: 95%; + margin-top: 15px; + display: flex; + flex-flow: column; + justify-content: flex-start; + .form-group-row{ + display: flex; + flex-flow: row; + align-items: stretch; + flex-wrap: wrap; + + .form-group{ + padding: 0px 10px; + margin-bottom: 20px; + flex: 1; + input[type=text]{ + padding-left: 5px; + } + input:disabled{ + background-color: @color-whitethree; + } + textarea:disabled{ + background-color: @color-whitethree; + } + .togglebutton{ + height: 52px; + display: flex; + align-items: center; + } + label{ + margin-bottom: 5px; + } + } + .break { + flex-basis: 100%; + height: 0; + } + } + .footer{ + position: absolute; + bottom: 0; + width: 100%; + left: 0; + height: 60px; + .pull-right{ + display: flex; + flex-flow: row; + .success{ + height: 48px; + margin-right: 10px; + font-size: 45px; + display: flex; + justify-content: center; + align-items: center; + color: @color-green; + } + } + } + } + } + } +} + .@{modal}.machine-info { width: @modal-machine-width; height: @modal-machine-height; @@ -1941,6 +2189,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 de0deb09..5138d237 100644 --- a/Step/wwwroot/assets/styles/style.css +++ b/Step/wwwroot/assets/styles/style.css @@ -236,6 +236,240 @@ margin: 0 0 5px 0; font-size: 18px; } +.modal.cmsconnect-info { + width: 952px; + height: 872px; + top: calc(50% - 436px); + left: calc(50% - 476px); + color: #4b4b4b; +} +.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; + display: flex; + align-items: center; + color: #4b4b4b; +} +.modal.cmsconnect-info .body .menu button.selected { + background-color: #fff; + color: black; +} +.modal.cmsconnect-info .body .menu button i { + font-size: 2em; + padding-right: 15px; +} +.modal.cmsconnect-info .body .container { + width: 80%; + display: flex; + flex-flow: row; + justify-content: center; + position: relative; +} +.modal.cmsconnect-info .body .container .err-container { + background-color: #d0021b; + color: white; + font-weight: bold; + position: absolute; + width: 100%; + height: 0px; + box-shadow: 0 3px 5px 0 rgba(0, 0, 0, 0.4); + overflow: hidden; + transition: 0.4s; +} +.modal.cmsconnect-info .body .container .err-container div { + padding: 10px 10px; +} +.modal.cmsconnect-info .body .container .err-container.visible { + height: 40px; + cursor: pointer; +} +.modal.cmsconnect-info .body .container .status { + width: 95%; + margin-top: 15px; + display: flex; + flex-flow: column; + justify-content: flex-start; +} +.modal.cmsconnect-info .body .container .status .btn-container { + text-align: center; + margin-top: 30px; +} +.modal.cmsconnect-info .body .container .status .status-container { + background-color: #f8f8f8; + display: flex; + flex-flow: row; + justify-content: space-between; + height: 100px; + margin-bottom: 20px; + border-radius: 2px; + border: solid 1px #dfdfdf; +} +.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.cmsconnect-info .body .container .status .status-container .icon.green { + color: #7ed321; +} +.modal.cmsconnect-info .body .container .status .status-container .icon.red { + color: #d0021b; +} +.modal.cmsconnect-info .body .container .status .status-container .icon.std { + color: #4b4b4b; +} +.modal.cmsconnect-info .body .container .reboot { + width: 95%; + margin-top: 15px; + display: flex; + flex-flow: column; + justify-content: flex-start; +} +.modal.cmsconnect-info .body .container .reboot .reboot-container { + background-color: #f8f8f8; + display: flex; + flex-flow: column; + justify-content: center; + align-items: center; + height: 200px; + margin-bottom: 20px; + border-radius: 2px; + border: solid 1px #dfdfdf; +} +.modal.cmsconnect-info .body .container .reboot .reboot-container i { + font-size: 100px; + margin-top: 20px; +} +.modal.cmsconnect-info .body .container .reboot .reboot-container i.green { + color: #7ed321; +} +.modal.cmsconnect-info .body .container .reboot .reboot-container i.red { + color: #d0021b; +} +.modal.cmsconnect-info .body .container .reboot .reboot-container i.blue { + color: #1791ff; +} +.modal.cmsconnect-info .body .container .reboot .reboot-container .progress-line { + height: 30px; + width: 592px; + margin: auto; +} +.modal.cmsconnect-info .body .container .reboot .reboot-container .progress-line progress { + width: 552px; + height: 12px; + font-size: 14px; + float: left; + background-color: white; + position: relative; +} +.modal.cmsconnect-info .body .container .reboot .reboot-container .progress-line progress[value]::-webkit-progress-value { + color: #fff; + background-color: #1791ff; + border-radius: 4px; +} +.modal.cmsconnect-info .body .container .reboot .reboot-container .progress-line progress[value]::-webkit-progress-bar { + background-color: #fff; + border-radius: 4px; + box-shadow: inset 0 1px 3px 0 rgba(0, 0, 0, 0.5); +} +.modal.cmsconnect-info .body .container .reboot .btn-container { + text-align: center; + margin-top: 30px; +} +.modal.cmsconnect-info .body .container .network { + width: 95%; + margin-top: 15px; + display: flex; + flex-flow: column; + justify-content: flex-start; +} +.modal.cmsconnect-info .body .container .network .form-group-row { + display: flex; + flex-flow: row; + align-items: stretch; + flex-wrap: wrap; +} +.modal.cmsconnect-info .body .container .network .form-group-row .form-group { + padding: 0px 10px; + margin-bottom: 20px; + flex: 1; +} +.modal.cmsconnect-info .body .container .network .form-group-row .form-group input[type=text] { + padding-left: 5px; +} +.modal.cmsconnect-info .body .container .network .form-group-row .form-group input:disabled { + background-color: #e7e7e7; +} +.modal.cmsconnect-info .body .container .network .form-group-row .form-group textarea:disabled { + background-color: #e7e7e7; +} +.modal.cmsconnect-info .body .container .network .form-group-row .form-group .togglebutton { + height: 52px; + display: flex; + align-items: center; +} +.modal.cmsconnect-info .body .container .network .form-group-row .form-group label { + margin-bottom: 5px; +} +.modal.cmsconnect-info .body .container .network .form-group-row .break { + flex-basis: 100%; + height: 0; +} +.modal.cmsconnect-info .body .container .network .footer { + position: absolute; + bottom: 0; + width: 100%; + left: 0; + height: 60px; +} +.modal.cmsconnect-info .body .container .network .footer .pull-right { + display: flex; + flex-flow: row; +} +.modal.cmsconnect-info .body .container .network .footer .pull-right .success { + height: 48px; + margin-right: 10px; + font-size: 45px; + display: flex; + justify-content: center; + align-items: center; + color: #7ed321; +} .modal.machine-info { width: 600px; height: 730px; @@ -3259,6 +3493,22 @@ padding-left: 20px; width: calc(100% - 20px); } +.form-group textarea { + box-sizing: border-box; + resize: none; + display: block; + border-radius: 2px; + border: solid 1px #dfdfdf; + height: 120px; + font-family: 'Work Sans', sans-serif; + color: #4b4b4b; + font-size: 16px; + background-color: #f8f8f8; + margin: 0 0px; + padding-right: 0; + width: 100%; + padding: 10px 5px; +} .form-group select { padding: 0; width: 100%; diff --git a/Step/wwwroot/src/@types/cmsConnect.d.ts b/Step/wwwroot/src/@types/cmsConnect.d.ts new file mode 100644 index 00000000..5feaa235 --- /dev/null +++ b/Step/wwwroot/src/@types/cmsConnect.d.ts @@ -0,0 +1,22 @@ +declare module server { + + export interface CmsConnectGatewayNetwork { + hasDhcp: boolean, + ipAddress: string, + netMaskAddress: string, + defaultGatewayAddress: string, + dnsAddresses: string[], + dnsPrefixes: string[] + } + + + export interface CmsConnectGatewayProxy { + hasProxy: boolean, + address: string, + port: number, + username: string, + password: string, + noproxyAddresses: string[] + } + +} \ No newline at end of file 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..c6b67c68 --- /dev/null +++ b/Step/wwwroot/src/app_modules/machine/components/cmsconnect-info-dialog.ts @@ -0,0 +1,251 @@ +import Vue from "vue"; +import { Modal, ModalHelper } from "src/components/modals"; +import { machineService } from "src/services/machineService"; +import { Factory, messageService,awaiter } from "src/_base"; +import moment from "moment"; +import Component from "vue-class-component"; +import { CmsConnectService } from "src/services"; +import { Watch } from "vue-property-decorator"; + +@Component({ + components: { + modal: Modal + } +}) +export default class CmsconnectInfoDialog extends Vue { + selectedTab = "connectionStatus"; + connectionStatus = '' + rebootStatus = '' + errorStatus = '' + requestRunning = false; + configurationSaved = false; + configurationSavedHandler = 0; + allDisabled = false; + + networkConfig = {hasDhcp: true} as server.CmsConnectGatewayNetwork; + proxyConfig = {hasProxy: false} as server.CmsConnectGatewayProxy; + dnsAddresses = ""; + noproxyAddresses = ""; + dnsPrefixes = ""; + debounceHandler = 0; + rebootCountDownMax = 120; //Sec + rebootCountDown = 0; + rebootCountDownHandler = 0; + + + mounted(){ + messageService.subscribeToChannel("reboot-gateway-end", (args)=>{ + this.rebootGatewayEnd(args) + }); + } + + close() { + messageService.deleteChannel("esc_pressed"); + ModalHelper.HideModal(); + } + + + selectTab(value) { + this.selectedTab = value; + this.networkConfig = {hasDhcp: true} as server.CmsConnectGatewayNetwork; + this.proxyConfig = {hasProxy: false} as server.CmsConnectGatewayProxy; + this.dnsAddresses = ""; + this.dnsPrefixes = ""; + this.noproxyAddresses = ""; + this.rebootStatus = ''; + this.connectionStatus = ''; + this.rebootCountDown = 0; + this.allDisabled = false; + + clearTimeout(this.debounceHandler); + if(this.selectedTab == 'networkConfiguration') + this.debounceLoadNetworkConfig(); + if(this.selectedTab == 'proxyConfiguration') + this.debounceLoadProxyConfig(); + } + + debounceLoadNetworkConfig(){ + this.allDisabled = true; + this.debounceHandler = setTimeout(this.loadNetworkConfiguration,300); + } + debounceLoadProxyConfig(){ + this.allDisabled = true; + this.debounceHandler = setTimeout(this.loadProxyConfiguration,300); + } + + ShowConfigOk(){ + this.configurationSaved = true; + this.configurationSavedHandler = setTimeout(this.HideConfigOk,3000); + } + + HideConfigOk(){ + clearTimeout(this.configurationSavedHandler) + this.configurationSaved = false; + } + + runConnectionTest() { + awaiter (new CmsConnectService().RunConnectionTest()).then(this.runConnectionSuccess).catch(this.manageError); + this.hideErrors(); + this.connectionStatus = 'RUNNING'; + this.requestRunning = true; + } + + loadNetworkConfiguration() { + awaiter (new CmsConnectService().GetGatewayNetworkSetup()).then(this.loadNetworkConfigurationSuccess).catch(this.manageError); + this.hideErrors(); + this.requestRunning = true; + } + + writeNetworkConfiguration() { + this.networkConfig.dnsAddresses = this.JoinList(this.dnsAddresses); + this.networkConfig.dnsPrefixes = this.JoinList(this.dnsPrefixes); + awaiter (new CmsConnectService().SetGatewayNetworkSetup(this.networkConfig)).then(this.writeNetworkConfigurationSuccess).catch(this.manageError); + this.hideErrors(); + this.requestRunning = true; + this.HideConfigOk(); + } + + loadProxyConfiguration() { + awaiter (new CmsConnectService().GetGatewayProxySetup()).then(this.loadProxyConfigurationSuccess).catch(this.manageError); + this.hideErrors(); + this.requestRunning = true; + } + + writeProxyConfiguration() { + this.proxyConfig.noproxyAddresses = this.JoinList(this.noproxyAddresses); + awaiter (new CmsConnectService().SetGatewayProxySetup(this.proxyConfig)).then(this.writeProxyConfigurationSuccess).catch(this.manageError); + this.hideErrors(); + this.requestRunning = true; + this.HideConfigOk(); + } + + rebootGateway() { + awaiter (new CmsConnectService().RebootGateway()).then(this.rebootGatewaySuccess).catch(this.manageError); + this.hideErrors(); + } + + runConnectionSuccess(response) { + this.connectionStatus = response; + this.requestRunning = false; + } + + loadNetworkConfigurationSuccess(response) { + this.allDisabled = false; + this.networkConfig = response; + this.dnsAddresses = this.splitList(this.networkConfig.dnsAddresses); + this.dnsPrefixes = this.splitList(this.networkConfig.dnsPrefixes); + this.requestRunning = false; + } + + writeNetworkConfigurationSuccess(response) { + this.networkConfig = response; + this.dnsAddresses = this.splitList(this.networkConfig.dnsAddresses); + this.dnsPrefixes = this.splitList(this.networkConfig.dnsPrefixes); + this.requestRunning = false; + this.ShowConfigOk(); + } + + loadProxyConfigurationSuccess(response) { + this.allDisabled = false; + this.proxyConfig = response; + this.noproxyAddresses = this.splitList(this.proxyConfig.noproxyAddresses); + this.requestRunning = false; + } + + writeProxyConfigurationSuccess(response) { + this.proxyConfig = response; + this.noproxyAddresses = this.splitList(this.proxyConfig.noproxyAddresses); + this.requestRunning = false; + this.ShowConfigOk(); + } + + rebootGatewaySuccess(response) { + this.rebootStatus = 'RUNNING'; + this.requestRunning = true; + + this.rebootCountDown = this.rebootCountDownMax; + this.rebootCountDownHandler = setInterval(this.rebootTimer,1000); + + } + + rebootTimer() { + if(this.rebootCountDown > 0){ + this.rebootCountDown --; + } + + else { + clearInterval(this.rebootCountDownHandler); + this.rebootStatus = 'ERROR'; + this.requestRunning = false; + this.manageError("Timeout internval. Reboot Gateway manually") + } + } + + + rebootGatewayEnd(arg) { + this.requestRunning = false; + clearInterval(this.rebootCountDownHandler); + this.rebootCountDown = 0; + + let msg = (arg[0] as string).split(";"); + if(msg[0] == "REBOOT_OK"){ + this.rebootStatus = 'FINISH'; + } + else if(msg[0] == "REBOOT_ERROR"){ + this.rebootStatus = 'ERROR'; + this.manageError(msg[1]); + } + else{ + this.rebootStatus = 'ERROR'; + this.manageError(arg[0]); + } + } + + toggleConfigHasDhcp(){ + this.networkConfig.hasDhcp = !this.networkConfig.hasDhcp; + } + toggleConfigHasProxy(){ + this.proxyConfig.hasProxy = !this.proxyConfig.hasProxy; + } + + splitList(arrayValues){ + let sret = ""; + for (let index = 0; index < arrayValues.length; index++) { + sret += arrayValues[index]; + if(index != (arrayValues.length-1)) + sret += "\n" + } + return sret + } + + JoinList(stringValue : string){ + return stringValue.split("\n"); + } + + + manageError(error) { + this.allDisabled = false; + this.requestRunning = false; + clearInterval(this.rebootCountDownHandler); + if(error.data && error.data.exceptionMessage){ + if(error.data.exceptionMessage.startsWith("Connection Error")) + this.errorStatus = "Error: Gateway not found"; + else if(error.data.exceptionMessage.startsWith("Authentication Error")) + this.errorStatus = "Error: Gateway credentials not OK"; + else if(error.data.exceptionMessage.startsWith("Internal Error")) + this.errorStatus = "Error: Internal Gateway problems"; + else + this.errorStatus = error.data.exceptionMessage; + } + else if(error.statusText) + this.errorStatus = error.statusText; + else + this.errorStatus = error; + + this.connectionStatus = '' + } + + hideErrors(){ + this.errorStatus = ''; + } +}; 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..f4bd4c25 --- /dev/null +++ b/Step/wwwroot/src/app_modules/machine/components/cmsconnect-info-dialog.vue @@ -0,0 +1,200 @@ + + 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 @@ --> +