diff --git a/Common/CommonConsole/CommonConsole.csproj b/Common/CommonConsole/CommonConsole.csproj
index f4fdee99..3b8f90d3 100644
--- a/Common/CommonConsole/CommonConsole.csproj
+++ b/Common/CommonConsole/CommonConsole.csproj
@@ -78,6 +78,12 @@
+
+
+
+
+
+
diff --git a/Common/CommonConsole/Program.cs b/Common/CommonConsole/Program.cs
index 64aec244..6dc80691 100644
--- a/Common/CommonConsole/Program.cs
+++ b/Common/CommonConsole/Program.cs
@@ -3,75 +3,94 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
-
+ using System.IO;
using Xylem.Common.Logic.SoftwareAccessHelper;
public class Program
{
- 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);
+ 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)
diff --git a/Common/Ui/GenesisToolBox/Infrastructure/IIdentityForm.cs b/Common/Ui/GenesisToolBox/Infrastructure/IIdentityForm.cs
index e4233063..ff8051fb 100644
--- a/Common/Ui/GenesisToolBox/Infrastructure/IIdentityForm.cs
+++ b/Common/Ui/GenesisToolBox/Infrastructure/IIdentityForm.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Xylem.Common.Ui.GenesisToolBox.Infrastructure
+namespace Xylem.Common.Ui.GenesisToolBox.Infrastructure
{
interface IIdentityForm
{
diff --git a/Common/Ui/GenesisToolBox/Infrastructure/Software.cs b/Common/Ui/GenesisToolBox/Infrastructure/Software.cs
index fb4b6bca..a58d317f 100644
--- a/Common/Ui/GenesisToolBox/Infrastructure/Software.cs
+++ b/Common/Ui/GenesisToolBox/Infrastructure/Software.cs
@@ -4,8 +4,6 @@
using Logic.SoftwareAccessHelper;
- using Newtonsoft.Json;
-
using System;
using System.Collections.Generic;
using System.Linq;
@@ -19,7 +17,7 @@
///
internal static class Software
{
- const string Bearer = nameof(Bearer);
+ const String Bearer = nameof(Bearer);
private static String bearer;
private static LDAPUser user;
@@ -38,7 +36,7 @@
public static void Initialize()
{
- bearer = default(string);
+ bearer = default(String);
user = new LDAPUser();
var version = SoftwareVersion.Current;
@@ -50,7 +48,7 @@
MinorV = version.MinorV,
EmployeeId = user.EmployeeId
}
- .PostAsJson($"{ServiceUrls.LaaProductionAPI}/LaaProductionWeb/API/Login/AD");
+ .PostAsJson($"{ServiceUrls.LaaProductionAPI}/LaaProductionWeb/API/Login/AD");
if (response.HttpStatusCode == HttpStatusCode.Accepted)
{
@@ -134,7 +132,7 @@
?.Trim('"');
softwareFunctions = GetFunctions();
- if (!String.IsNullOrWhiteSpace(bearer))
+ if (!string.IsNullOrWhiteSpace(bearer))
{
UserName = $"{user.FirstName} {user.LastName}";
}
@@ -152,8 +150,8 @@
///
public static Boolean Login(String username, String password, out Dictionary errors)
{
- bearer = default(string);
- errors = new Dictionary();
+ bearer = default(String);
+ errors = new Dictionary();
var response = new UserLoginModel
{
@@ -164,7 +162,7 @@
MinorV = SoftwareVersion.Current.MinorV,
BuildV = SoftwareVersion.Current.BuildV,
}
- .PostAsJson($"{ServiceUrls.LaaProductionAPI}/LaaProductionWeb/API/Login/Local");
+ .PostAsJson($"{ServiceUrls.LaaProductionAPI}/LaaProductionWeb/API/Login/Local");
if (response.HttpStatusCode == HttpStatusCode.OK)
{
@@ -177,7 +175,7 @@
if (!string.IsNullOrWhiteSpace(bearer))
{
UserName = $"{ServiceUrls.LaaProductionAPI}/LaaProductionWeb/API/Login"
- .GetAsJson(headersHandler: headers =>
+ .GetAsJson(headersHandler: headers =>
{
headers.Authorization = $"{Bearer} {bearer}";
})
@@ -234,7 +232,7 @@
Initialize();
}
- internal static string ComputeBase64Hash(this string plainText)
+ internal static String ComputeBase64Hash(this String plainText)
{
if (string.IsNullOrWhiteSpace(plainText))
{
diff --git a/LaaProductionWeb/LaaProductionWeb/API/SendController.cs b/LaaProductionWeb/LaaProductionWeb/API/SendController.cs
index 08ce6290..de1214b4 100644
--- a/LaaProductionWeb/LaaProductionWeb/API/SendController.cs
+++ b/LaaProductionWeb/LaaProductionWeb/API/SendController.cs
@@ -94,40 +94,41 @@
private int AddRecord(string source, DateTime inDate, DateTime? outDate, string state, SendModel model)
{
- var recordId = LaaServiceProvider
- .GetService()
- .CreateCommand($@"
- INSERT
- INTO [Messages]
- ( [Source]
- , [InDate]
- , [StationNr]
- , [PCName]
- , [IPAddress]
- , [Trace]
- , [Sender]
- , [Subject]
- , [Body]
- , [IsHtml]
- , [Recipients]
- , [CC]
- , [OutDate]
- , [State])
- OUTPUT [Inserted].[Id]
- VALUES (@{nameof(source)}
- , @{nameof(inDate)}
- , @{nameof(model.StationNr)}
- , @{nameof(model.PCName)}
- , @{nameof(model.IPAddress)}
- , @{nameof(model.Trace)}
- , @{nameof(model.Sender)}
- , @{nameof(model.Subject)}
- , @{nameof(model.Body)}
- , @{nameof(model.IsHtml)}
- , @{nameof(model.Recipients)}
- , @{nameof(model.CC)}
- , @{nameof(outDate)}
- , @{nameof(state)})")
+ var connection = LaaServiceProvider.GetService();
+ var command = connection?.CreateCommand($@"
+ INSERT
+ INTO [Messages]
+ ( [Source]
+ , [InDate]
+ , [StationNr]
+ , [PCName]
+ , [IPAddress]
+ , [Trace]
+ , [Sender]
+ , [Subject]
+ , [Body]
+ , [IsHtml]
+ , [Recipients]
+ , [CC]
+ , [OutDate]
+ , [State])
+ OUTPUT [Inserted].[Id]
+ VALUES (@{nameof(source)}
+ , @{nameof(inDate)}
+ , @{nameof(model.StationNr)}
+ , @{nameof(model.PCName)}
+ , @{nameof(model.IPAddress)}
+ , @{nameof(model.Trace)}
+ , @{nameof(model.Sender)}
+ , @{nameof(model.Subject)}
+ , @{nameof(model.Body)}
+ , @{nameof(model.IsHtml)}
+ , @{nameof(model.Recipients)}
+ , @{nameof(model.CC)}
+ , @{nameof(outDate)}
+ , @{nameof(state)})");
+
+ var recordId = command
.SetParameter(nameof(source), source)
.SetParameter(nameof(inDate), inDate)
.SetParameter(nameof(model.StationNr), model.StationNr)
@@ -139,10 +140,10 @@
.SetParameter(nameof(model.Body), model.Body)
.SetParameter(nameof(model.IsHtml), model.IsHtml)
.SetParameter(nameof(model.Recipients), model.Recipients != null || model.Recipients.Length > 0 ? string.Join(", ", model.Recipients) : null)
- .SetParameter(nameof(model.CC), model.CC != null || model.CC.Length > 0 ? string.Join(", ", model.CC) : null)
+ .SetParameter(nameof(model.CC), model.CC != null && model.CC.Length > 0 ? string.Join(", ", model.CC) : null)
.SetParameter(nameof(outDate), outDate)
.SetParameter(nameof(state), state)
- .ExecuteScalar(x => x.GetInt());
+ .ExecuteScalar(x => x?.GetInt() ?? 0);
return recordId;
}
diff --git a/LaaProductionWeb/LaaProductionWeb/Global.asax.cs b/LaaProductionWeb/LaaProductionWeb/Global.asax.cs
index 85a7709a..de0afc86 100644
--- a/LaaProductionWeb/LaaProductionWeb/Global.asax.cs
+++ b/LaaProductionWeb/LaaProductionWeb/Global.asax.cs
@@ -16,7 +16,6 @@
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
- using System;
public class WebApiApplication : HttpApplication
{
diff --git a/LaaProductionWeb/LaaProductionWeb/Hubs/DataHub.cs b/LaaProductionWeb/LaaProductionWeb/Hubs/DataHub.cs
index 4314f4a8..d7b50571 100644
--- a/LaaProductionWeb/LaaProductionWeb/Hubs/DataHub.cs
+++ b/LaaProductionWeb/LaaProductionWeb/Hubs/DataHub.cs
@@ -1,17 +1,22 @@
namespace LaaProductionWeb.Hubs
{
+ using LaaProduction.Http.Interfaces;
+ using LaaProductionDI;
+ using LaaProductionWeb.API;
using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Hubs;
+ using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
+ using System.Reflection;
using System.Threading.Tasks;
[HubName(nameof(DataHub))]
public class DataHub : Hub
{
- private static readonly ConcurrentDictionary messageIds
- = new ConcurrentDictionary();
+ private static readonly ConcurrentDictionary> targets
+ = new ConcurrentDictionary>();
protected string ConnectionId
{
@@ -27,11 +32,10 @@
public void Send(Dictionary data)
{
- var messageId = messageIds.AddOrUpdate(this.ConnectionId, 1, (connectionId, msgId) => msgId + 1);
-
data["connectionid"] = this.ConnectionId;
data["groupname"] = this.GroupName;
- data["messageid"] = messageId;
+
+ ExecuteTargetIfExists(data);
this.Clients
.OthersInGroup(this.GroupName)
@@ -40,16 +44,72 @@
public override async Task OnConnected()
{
- _ = messageIds.GetOrAdd(this.ConnectionId, 0);
+ if (targets.Count <= 0)
+ {
+ this.LoadTargets();
+ }
await this.Groups.Add(this.ConnectionId, this.GroupName);
}
- public override async Task OnDisconnected(bool stopCalled)
+ private void LoadTargets()
{
- _ = messageIds.TryRemove(this.ConnectionId, out var _);
+ var _targets = typeof(DataHubTargets)
+ .GetMethods(BindingFlags.Static | BindingFlags.NonPublic);
- await this.Groups.Remove(this.ConnectionId, this.GroupName);
+ foreach (var target in _targets)
+ {
+ var targetName = target.Name.ToLower();
+
+ targets.GetOrAdd(targetName, target.Invoke);
+ }
+ }
+
+ public override async Task OnDisconnected(bool stopCalled)
+ => await this.Groups.Remove(this.ConnectionId, this.GroupName);
+
+ private static void ExecuteTargetIfExists(Dictionary data)
+ {
+ var target = default(string);
+
+ if (data.ContainsKey(nameof(target)))
+ {
+ target = data[nameof(target)] as string;
+ }
+
+ if (!string.IsNullOrWhiteSpace(target))
+ {
+ target = target.ToLower();
+ }
+
+ if (targets.TryGetValue(target, out var handler))
+ {
+ _ = handler.Invoke(null, new object[] { data });
+ }
+ }
+ }
+
+ public static class DataHubTargets
+ {
+ private static void SendMail(Dictionary data)
+ {
+ LaaServiceProvider
+ .GetService()
+ .Post("/Send/Email")
+ .WhitJsonBody(new SendModel
+ {
+ Body = data.TryGetValue("body", out var body) ? body as string : null,
+ CC = data.TryGetValue("cc", out var cc) ? (cc as string).Split(';') : null,
+ IPAddress = data.TryGetValue("ip", out var ip) ? ip as string : null,
+ IsHtml = false,
+ PCName = data.TryGetValue("pc", out var pc) ? pc as string : null,
+ Recipients = data.TryGetValue("to", out var to) ? (to as string).Split(';') : null,
+ Sender = data.TryGetValue("from", out var from) ? from as string : null,
+ StationNr = data.TryGetValue("ps", out var ps) ? ps as string : null,
+ Subject = data.TryGetValue("subject", out var subject) ? subject as string : null,
+ Trace = data.TryGetValue("trace", out var trace) ? trace as string : null,
+ })
+ .SendAsync