diff --git a/Common/.vs/config/applicationhost.config b/Common/.vs/config/applicationhost.config index ecc20ba7..a894c3cf 100644 --- a/Common/.vs/config/applicationhost.config +++ b/Common/.vs/config/applicationhost.config @@ -155,7 +155,7 @@ - + diff --git a/Common/CommonConsole/CommonConsole.csproj b/Common/CommonConsole/CommonConsole.csproj index 3b8f90d3..f4fdee99 100644 --- a/Common/CommonConsole/CommonConsole.csproj +++ b/Common/CommonConsole/CommonConsole.csproj @@ -78,12 +78,6 @@ - - - - - - diff --git a/Common/CommonConsole/Program.cs b/Common/CommonConsole/Program.cs index 6dc80691..897def4e 100644 --- a/Common/CommonConsole/Program.cs +++ b/Common/CommonConsole/Program.cs @@ -1,208 +1,11 @@ namespace CommonConsole { - using Newtonsoft.Json; using System; - using System.Collections.Generic; - using System.IO; - using Xylem.Common.Logic.SoftwareAccessHelper; public class Program { public static void Main() { - foreach (var drive in Directory.GetLogicalDrives()) - { - try - { - foreach (var vbpFile in Directory.GetFiles(drive, "*.vbp", SearchOption.AllDirectories)) - { - Console.WriteLine(vbpFile); - } - } - catch (Exception e) - { - Console.WriteLine(e); - } - } - } - - - //const string BASE_URL = "http://localhost:52822/LaaProductionWeb/api/cordonels/eolprogress"; - - //public static void Main() - //{ - // var pcbid = 1000000001; - // var model = new EOLProgressModel { PcbId = pcbid }; - // var response = $"{BASE_URL}/{pcbid}".GetAsJson(); - - // model = response.Value ?? new EOLProgressModel(); - - // LogErrors(response.Errors); - // LogModel(model); - - // model.RebootDone = "OK"; - // model.ExportDone = "OK"; - // model.ParameterizationDone = "OK"; - // model.ProductionStatusChecked = "FAIL"; - - // response = model.PutAsJson(BASE_URL); - - // model = response.Value ?? new EOLProgressModel(); - - // LogErrors(response.Errors); - // LogModel(model); - - // model.RebootDone = "FAIL"; - // model.ExportDone = "FAIL"; - // model.ParameterizationDone = "FAIL"; - // model.ProductionStatusChecked = "OK"; - - // response = model.PutAsJson(BASE_URL); - - // model = response.Value ?? new EOLProgressModel(); - - // LogErrors(response.Errors); - // LogModel(model); - - // model.SentinelDate = DateTime.Now; - // model.PasswordFileInstalled = "OK"; - // model.RequirementChecked = "OK"; - // model.StoreConfigurationDone = "NA"; - - // response = model.PutAsJson(BASE_URL); - - // model = response.Value ?? new EOLProgressModel(); - - // LogErrors(response.Errors); - // LogModel(model); - - // response = $"{BASE_URL}/{model.PcbId}/OK".PostAsJson(); - - // model = response.Value ?? new EOLProgressModel(); - - // LogErrors(response.Errors); - // LogModel(model); - - // response = $"{BASE_URL}/{model.PcbId}".DeleteAsJson(); - - // model = response.Value ?? new EOLProgressModel(); - - // LogErrors(response.Errors); - // LogModel(model); - //} - - private static void LogModel(EOLProgressModel model) - { - if (model != null) - { - Console.WriteLine(JsonConvert.SerializeObject(model, Formatting.Indented)); - } - } - - private static void LogErrors(Dictionary errors) - { - if (errors != null) - { - foreach (var kvp in errors) - { - Console.WriteLine($"{kvp.Key}: {kvp.Value}"); - } - } } } - - public class EOLProgressModel - { - public Int32 Id { get; set; } - - public Int32 PcbId { get; set; } - - public Int32? RequirementId { get; set; } - - public String RequirementChecked { get; set; } - - public String PasswordFileInstalled { get; set; } - - public String ProductionStatusChecked { get; set; } - - public String ParameterizationDone { get; set; } - - public String RebootDone { get; set; } - - public String StoreConfigurationDone { get; set; } - - public String ExportDone { get; set; } - - public Int64? RaioCheckId { get; set; } - - public DateTime? SentinelDate { get; set; } - - public String Completed { get; set; } - - public DateTime? CompleteDate { get; set; } - - public String CompleteHost { get; set; } - - public DateTime AddDate { get; set; } - - public String AddHost { get; set; } - } -} - -//--- Connected: COM9, 2400, 8, None, One -//>>> 01 -//<<< 01-39-34-37-30-35-36-38-36-00 -//>>> 07 -//<<< 01-00 -//>>> 13 -//<<< 01-30-30-30-30-30-31-30-31-00 -//>>> FD-3D -//<<< 01-87-F2-BA-00 -//>>> FD-64-00-F2-BA-BD-51-33-44-07-00 -//<<< 01 -//>>> FD-02 -//<<< 01-00-00-E1-84-06-00 -//>>> FD-25-00-00-E1-84-06-00-00-00-30-00-00-00-07 -//<<< 01 - -//--- Connected: COM9, 2400, 8, None, One -//>>> 01 -//<<< 01-39-34-37-30-35-36-38-33-00 -//>>> 07 -//<<< 01-00 -//>>> 13 -//<<< 01-30-30-30-30-30-33-37-38-00 -//>>> FD-3D -//<<< 01-0D-24-B3-00 -//>>> FD-64-00-24-B3-18-01-33-44-09-00 -//<<< 02 -//>>> 17 -//<<< 01-38-31-36-32-33-33-35-30-30-39-32-31-00 -//>>> FD-08 -//<<< 01-00 -//>>> FD-02 -//<<< 01-00-00-E1-84-06-00 -//>>> FD-25-00-00-E1-84-06-00-00-00-30-00-00-00-07 -//<<< 01 -//--- Disconnected: COM9, 2400, 8, None, One - -//--- Connected: COM9, 2400, 8, None, One -//>>> 01 -//<<< 01-39-34-37-30-35-36-38-32-00 -//>>> 07 -//<<< 01-00 -//>>> 13 -//<<< 01-30-30-30-30-30-30-39-39-00 -//>>> FD-3D -//<<< 01-CA-12-B3-00 -//>>> FD-64-00-12-B3-39-11-33-44-06-00 -//<<< 01 -//>>> 17 -//<<< 01-38-31-36-32-33-33-35-31-35-32-34-37-00 -//>>> FD-08 -//<<< 01-31 -//>>> FD-02 -//<<< 01-00-00-E1-84-06-00 -//>>> FD-25-00-00-E1-84-06-00-00-00-30-00-00-00-07 -//<<< 01 -//--- Disconnected: COM9, 2400, 8, None, One \ No newline at end of file +} \ No newline at end of file diff --git a/Common/OmniPlus/Exchange/SignalR/DataHub.cs b/Common/OmniPlus/Exchange/SignalR/DataHub.cs index 86f3caaf..dc589997 100644 --- a/Common/OmniPlus/Exchange/SignalR/DataHub.cs +++ b/Common/OmniPlus/Exchange/SignalR/DataHub.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Runtime.InteropServices; - + using System.Threading.Tasks; using Microsoft.AspNet.SignalR.Client; public delegate void DataReceivedHandler(DataDictionary data); @@ -23,8 +23,12 @@ [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] public interface IDataHubClient { + bool IsConnected { get; } + void Connect(string url); + void Disconnect(); + void Send(DataDictionary dictionary); } @@ -45,6 +49,23 @@ public event DataReceivedHandler DataReceived; public event StateHandler StateChanged; + public bool IsConnected + { + get + { + try + { + return this.connection.State == ConnectionState.Connected; + } + catch (Exception e) + { + this.NotifyStateChanged(e); + + return false; + } + } + } + public void Connect(string url) { this.connection = new HubConnection(url, queryString: $"key={Environment.MachineName}"); @@ -71,6 +92,30 @@ } } + public void Disconnect() + { + Task.Factory.StartNew(() => + { + try + { + this.disposable.Dispose(); + } + catch (Exception e) + { + this.NotifyStateChanged(e); + } + + try + { + this.connection.Stop(); + } + catch (Exception e) + { + this.NotifyStateChanged(e); + } + }); + } + public void Send(DataDictionary dictionary) { this.proxy.Invoke(nameof(this.Send), dictionary.Generic()); diff --git a/Common/OmniPlus/InspectionUI/InspectionUI.csproj b/Common/OmniPlus/InspectionUI/InspectionUI.csproj index fc987d30..c26ab542 100644 --- a/Common/OmniPlus/InspectionUI/InspectionUI.csproj +++ b/Common/OmniPlus/InspectionUI/InspectionUI.csproj @@ -61,9 +61,6 @@ - - PluginsWindow.xaml - @@ -94,10 +91,6 @@ MainWindow.xaml Code - - Designer - MSBuild:Compile - diff --git a/Common/OmniPlus/InspectionUI/PluginsWindow.xaml b/Common/OmniPlus/InspectionUI/PluginsWindow.xaml deleted file mode 100644 index 374abac7..00000000 --- a/Common/OmniPlus/InspectionUI/PluginsWindow.xaml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/Common/OmniPlus/InspectionUI/PluginsWindow.xaml.cs b/Common/OmniPlus/InspectionUI/PluginsWindow.xaml.cs deleted file mode 100644 index 32567585..00000000 --- a/Common/OmniPlus/InspectionUI/PluginsWindow.xaml.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace InspectionUI -{ - using System.Windows; - - public partial class PluginsWindow : Window - { - public PluginsWindow() - { - this.InitializeComponent(); - } - } -} diff --git a/LaaProductionWeb/LaaProductionWeb/API/Cordonel/CSRController.cs b/LaaProductionWeb/LaaProductionWeb/API/Cordonel/CSRController.cs new file mode 100644 index 00000000..4a7d13bb --- /dev/null +++ b/LaaProductionWeb/LaaProductionWeb/API/Cordonel/CSRController.cs @@ -0,0 +1,10 @@ +namespace LaaProductionWeb.API.Cordonel +{ + using System.Web.Http; + + [RoutePrefix("api/Cordonels/CSR")] + public class CSRController : ControllerBase + { + + } +} \ No newline at end of file diff --git a/LaaProductionWeb/LaaProductionWeb/API/Cordonel/EOLProgressController.cs b/LaaProductionWeb/LaaProductionWeb/API/Cordonel/EOLProgressController.cs index c2213183..733c9978 100644 --- a/LaaProductionWeb/LaaProductionWeb/API/Cordonel/EOLProgressController.cs +++ b/LaaProductionWeb/LaaProductionWeb/API/Cordonel/EOLProgressController.cs @@ -14,8 +14,8 @@ [RoutePrefix("api/Cordonels/EOLProgress")] public class EOLProgressController : ControllerBase { - const string PCBID_KEY = "PcbId"; - const string PCBID_ERROR = "PcbId should not be <= 0"; + //const string PCBID_KEY = "PcbId"; + //const string PCBID_ERROR = "PcbId should not be <= 0"; private readonly IEOLProgressService eolProgress; diff --git a/LaaProductionWeb/LaaProductionWeb/Hubs/DataHub.cs b/LaaProductionWeb/LaaProductionWeb/Hubs/DataHub.cs index d7b50571..ab981518 100644 --- a/LaaProductionWeb/LaaProductionWeb/Hubs/DataHub.cs +++ b/LaaProductionWeb/LaaProductionWeb/Hubs/DataHub.cs @@ -1,8 +1,10 @@ namespace LaaProductionWeb.Hubs { using LaaProduction.Http.Interfaces; + using LaaProduction.SQL.Interfaces; using LaaProductionDI; using LaaProductionWeb.API; + using Microsoft.AspNet.SignalR; using Microsoft.AspNet.SignalR.Hubs; @@ -10,6 +12,8 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Reflection; + using System.Security.Cryptography; + using System.Text; using System.Threading.Tasks; [HubName(nameof(DataHub))] @@ -111,5 +115,66 @@ }) .SendAsync(); } + + private static void SaveIni(Dictionary data) + { + var psnr = data.TryGetValue("psnr", out var _psnr) && _psnr is int nr ? nr : 0; + var host = data.TryGetValue("groupname", out var _host) ? _host as string : default(string); + var ini = data.TryGetValue("ini", out var _ini) ? _ini as string : default(string); + var iniBytes = Encoding.UTF8.GetBytes(ini); + var md5 = new MD5CryptoServiceProvider(); + var iniHashBytes = md5.ComputeHash(iniBytes); + var hash = Convert.ToBase64String(iniHashBytes); + + var iniId = LaaServiceProvider + .GetService() + .CreateCommand($@" + SELECT [Id] + FROM [Configurations] + WHERE [PsNr] = @{nameof(psnr)} + AND [Type] = 'INI' + ORDER BY [Id] DESC") + .SetParameter(nameof(psnr), psnr) + .FirstOrDefault(x => x.GetInt()); + + if (iniId <= 0) + { + LaaServiceProvider + .GetService() + .CreateCommand($@" + INSERT INTO [Configurations] + ( [PsNr] + , [Host] + , [Type] + , [Hash] + , [Content]) + VALUES (@{nameof(psnr)} + , @{nameof(host)} + , 'INI' + , @{nameof(hash)} + , @{nameof(ini)})") + .SetParameter(nameof(psnr), psnr) + .SetParameter(nameof(host), host) + .SetParameter(nameof(hash), hash) + .SetParameter(nameof(ini), ini) + .FirstOrDefault(x => x.GetInt()); + } + else + { + LaaServiceProvider + .GetService() + .CreateCommand($@" + UPDATE [Configurations] + SET [Host] = @{nameof(host)} + , [Hash] = @{nameof(hash)} + , [Content] = @{nameof(ini)} + WHERE [Id] = @{nameof(iniId)}") + .SetParameter(nameof(host), host) + .SetParameter(nameof(hash), hash) + .SetParameter(nameof(ini), ini) + .SetParameter(nameof(iniId), iniId) + .FirstOrDefault(x => x.GetInt()); + } + } } } \ No newline at end of file diff --git a/LaaProductionWeb/LaaProductionWeb/LaaProductionWeb.csproj b/LaaProductionWeb/LaaProductionWeb/LaaProductionWeb.csproj index c8ed9c42..7e7d0a3d 100644 --- a/LaaProductionWeb/LaaProductionWeb/LaaProductionWeb.csproj +++ b/LaaProductionWeb/LaaProductionWeb/LaaProductionWeb.csproj @@ -179,6 +179,7 @@ +