diff --git a/Adaptation/FileHandlers/Priority/Aggregation.cs b/Adaptation/FileHandlers/Priority/Aggregation.cs index b172e80..d568a2b 100644 --- a/Adaptation/FileHandlers/Priority/Aggregation.cs +++ b/Adaptation/FileHandlers/Priority/Aggregation.cs @@ -90,6 +90,7 @@ public class Aggregation private static ReadOnlyCollection GetNotifications(Settings settings, string directory) { List results = new(); + string? key; string text; string[] files; Notification? notification; @@ -108,12 +109,13 @@ public class Aggregation notification = JsonSerializer.Deserialize(text, NotificationSourceGenerationContext.Default.Notification); if (notification is null || notification.Id == 0) continue; - if (string.IsNullOrEmpty(notification.RemoteIpAddress)) + key = !string.IsNullOrEmpty(notification.Username) ? notification.Username : notification.RemoteIpAddress; + if (string.IsNullOrEmpty(key)) continue; - if (!keyValuePairs.TryGetValue(notification.RemoteIpAddress, out collection)) + if (!keyValuePairs.TryGetValue(key, out collection)) { - keyValuePairs.Add(notification.RemoteIpAddress, new()); - if (!keyValuePairs.TryGetValue(notification.RemoteIpAddress, out collection)) + keyValuePairs.Add(key, new()); + if (!keyValuePairs.TryGetValue(key, out collection)) throw new Exception(); } collection.Add(notification); diff --git a/Adaptation/FileHandlers/Priority/Notification.cs b/Adaptation/FileHandlers/Priority/Notification.cs index 805de18..7933fc1 100644 --- a/Adaptation/FileHandlers/Priority/Notification.cs +++ b/Adaptation/FileHandlers/Priority/Notification.cs @@ -11,30 +11,36 @@ public class Notification public Notification(int? fibonacci, int id, int? inverse, + string? machineId, string page, string? remoteIpAddress, string? site, long time, + string? username, int value) { int? i = inverse is not null ? inverse : GetInverse(value); Fibonacci = fibonacci is not null ? fibonacci : i is null ? null : GetFibonacci(i.Value); Id = id; Inverse = i; + MachineId = machineId; Page = page; RemoteIpAddress = remoteIpAddress is not null ? remoteIpAddress : null; Site = site is not null ? site : "MES"; Time = time; + Username = username; Value = value; } [JsonPropertyName("id")] public int Id { get; } [JsonPropertyName("fibonacci")] public int? Fibonacci { get; } [JsonPropertyName("inverse")] public int? Inverse { get; } + [JsonPropertyName("machineId")] public string? MachineId { get; } [JsonPropertyName("page")] public string Page { get; } [JsonPropertyName("RemoteIpAddress")] public string? RemoteIpAddress { get; } [JsonPropertyName("site")] public string? Site { get; } [JsonPropertyName("time")] public long Time { get; } + [JsonPropertyName("username")] public string? Username { get; } [JsonPropertyName("value")] public int Value { get; } internal static int? GetInverse(int value) => @@ -67,10 +73,12 @@ public class Notification new(notification.Fibonacci, notification.Id, notification.Inverse, + notification.MachineId, notification.Page, remoteIpAddress ?? connectionId, notification.Site, notification.Time, + notification.Username, notification.Value); } diff --git a/Adaptation/FileHandlers/json/StaticSite/html/cod-b.html b/Adaptation/FileHandlers/json/StaticSite/html/cod-b.html index 6d5beb9..e867c58 100644 --- a/Adaptation/FileHandlers/json/StaticSite/html/cod-b.html +++ b/Adaptation/FileHandlers/json/StaticSite/html/cod-b.html @@ -1,13 +1,11 @@ - + Infineon - Cost of Delay (CoD) (see @SCALE formula) - - @@ -56,6 +54,8 @@ diff --git a/Adaptation/FileHandlers/json/StaticSite/js/cod-b.js b/Adaptation/FileHandlers/json/StaticSite/js/cod-b.js index 05c5425..b296ff6 100644 --- a/Adaptation/FileHandlers/json/StaticSite/js/cod-b.js +++ b/Adaptation/FileHandlers/json/StaticSite/js/cod-b.js @@ -1,7 +1,9 @@ -var _site = ''; var _chat = {}; +var _site = ''; var _apiUrl = ''; var _toggle = true; +var _username = ''; +var _machineId = ''; var _windowLocationHRef = ''; var _connectionHubStartDone = false; @@ -177,7 +179,15 @@ function getRecords(b, r, t, c, e, w, data, dataB) { } function sendValue(fromHtml, element, page, id) { - var notification = { time: new Date().getTime(), site: _site, page: page, id: id, value: element.value }; + var notification = { + id: id, + machineId: _machineId, + page: page, + site: _site, + time: new Date().getTime(), + username: _username, + value: element.value, + }; if (fromHtml && notification.value !== "9") { $("#AllTextarea").hide(); document.getElementById('AllTextarea').value = ''; @@ -360,84 +370,88 @@ function highlight(el, i) { .fadeOut(1000 * i); } +function updateWorkItem(b, r, t, c, e, w, page, workItem) { + console.log(workItem); + var x = null; + var aggregation = null; + if (page === b.page) { + x = b; + aggregation = workItem.BusinessValue; + } + else if (page === r.page) { + x = r; + aggregation = workItem.RiskReductionOpportunityEnablement; + } + else if (page === t.page) { + x = t; + aggregation = workItem.TimeCriticality; + } + else if (page === e.page) { + x = e; + aggregation = workItem.Effort; + } + if (x == undefined) + alert("Error with page!"); + else { + $('#' + x.page + workItem.Id).text('!' + myRound(aggregation.FibonacciAverage, 100)); + if (workItem.WeightedShortestJobFirst != undefined) { + $('#' + w.page + workItem.Id).text('!' + myRound(workItem.WeightedShortestJobFirst, 100)); + } + if (workItem.CostOfDelay != undefined) { + var element = $('#' + c.page + workItem.Id); + element.text('!' + myRound(workItem.CostOfDelay, 100)); + if (_windowLocationHRef.indexOf('=LIVE') > -1) { + if (workItem.SortBeforeId != undefined) { + var found = 0; + var row = element.parents("tr:first"); + var next = row; + for (var i = 0; i < 150; i++) { + next = next.next(); + if (next == undefined) + break; + if (next.attr('id') != 'tr' + workItem.SortBeforeId) + continue; + console.log("Moved " + i + " down"); + row.insertAfter(next); + found = i; + break; + } + if (!found) { + var prev = row; + for (var i = 0; i < 150; i++) { + prev = prev.prev(); + if (prev == undefined) + break; + if (prev.attr('id') != 'tr' + workItem.SortBeforeId) + continue; + console.log("Moved " + i + " up"); + row.insertAfter(prev); + found = i; + break; + } + } + if (found != 0) { + highlight(row, found); + } + else { + console.log("Not found!"); + } + } + } + } + } +}; + function setupSignalR(b, r, t, c, e, w, signalRUrl) { $.connection.hub.logging = true; $.connection.hub.url = signalRUrl; _chat = $.connection.weightedShortestJobFirstHub; if (_chat == undefined || _chat.server == undefined) { - alert("Error within handshake!"); + alert('Error within handshake!'); } else { _chat.client.updateWorkItem = function (page, workItem) { - console.log(workItem); - var x = null; - var aggregation = null; - if (page === b.page) { - x = b; - aggregation = workItem.BusinessValue; - } - else if (page === r.page) { - x = r; - aggregation = workItem.RiskReductionOpportunityEnablement; - } - else if (page === t.page) { - x = t; - aggregation = workItem.TimeCriticality; - } - else if (page === e.page) { - x = e; - aggregation = workItem.Effort; - } - if (x == undefined) - alert("Error with page!"); - else { - $('#' + x.page + workItem.Id).text('!' + myRound(aggregation.FibonacciAverage, 100)); - if (workItem.WeightedShortestJobFirst != undefined) { - $('#' + w.page + workItem.Id).text('!' + myRound(workItem.WeightedShortestJobFirst, 100)); - } - if (workItem.CostOfDelay != undefined) { - var element = $('#' + c.page + workItem.Id); - element.text('!' + myRound(workItem.CostOfDelay, 100)); - if (_windowLocationHRef.indexOf('=LIVE') > -1) { - if (workItem.SortBeforeId != undefined) { - var found = 0; - var row = element.parents("tr:first"); - var next = row; - for (var i = 0; i < 150; i++) { - next = next.next(); - if (next == undefined) - break; - if (next.attr('id') != 'tr' + workItem.SortBeforeId) - continue; - console.log("Moved " + i + " down"); - row.insertAfter(next); - found = i; - break; - } - if (!found) { - var prev = row; - for (var i = 0; i < 150; i++) { - prev = prev.prev(); - if (prev == undefined) - break; - if (prev.attr('id') != 'tr' + workItem.SortBeforeId) - continue; - console.log("Moved " + i + " up"); - row.insertAfter(prev); - found = i; - break; - } - } - if (found != 0) { - highlight(row, found); - } - else { - console.log("Not found!"); - } - } - } - } - } + updateWorkItem(b, r, t, c, e, w, page, workItem); }; // $.connection.hub.start({ transport: 'longPolling' }) $.connection.hub.start() @@ -456,8 +470,10 @@ function setupSignalR(b, r, t, c, e, w, signalRUrl) { } } -function initIndex(fromHtml, windowLocationHRef, workItems, b, r, t, c, e, w, apiUrl, signalRUrl) { +function initIndex(fromHtml, username, machineId, windowLocationHRef, workItems, b, r, t, c, e, w, apiUrl, signalRUrl) { _apiUrl = apiUrl; + _username = username; + _machineId = machineId; _windowLocationHRef = windowLocationHRef; if (!fromHtml) { console.log(b); @@ -17038,6 +17054,8 @@ function getExampleDataB() { // #region Test if (typeof document == 'undefined') { + const username = ''; + const machineId = ''; const fromHtml = false; const signalRUrl = "/signalr"; const apiUrl = "https://oi-metrology-viewer-prod.mes.infineon.com:4438/api/v1/ado/"; @@ -17090,7 +17108,7 @@ if (typeof document == 'undefined') { if (dataA.length > 0) console.log(dataA[0]); setRecords(fromHtml, b, r, t, c, e, w, records); - initIndex(fromHtml, windowLocationHRef, workItems, b, r, t, c, e, w, apiUrl, signalRUrl); + initIndex(fromHtml, username, machineId, windowLocationHRef, workItems, b, r, t, c, e, w, apiUrl, signalRUrl); } // #endregion Test \ No newline at end of file diff --git a/Adaptation/_Tests/Extract/Development/v2.58.0/MESAFIBACKLOG.cs b/Adaptation/_Tests/Extract/Development/v2.58.0/MESAFIBACKLOG.cs index 01280dd..8d7a6c0 100644 --- a/Adaptation/_Tests/Extract/Development/v2.58.0/MESAFIBACKLOG.cs +++ b/Adaptation/_Tests/Extract/Development/v2.58.0/MESAFIBACKLOG.cs @@ -207,10 +207,12 @@ public class MESAFIBACKLOG Notification notification = new(fibonacci: null, id: 1107438888, inverse: null, + machineId: Environment.MachineName, page: "effort", remoteIpAddress: "10.95.36.87", site: "MES", time: 1737573418926, + username: Environment.UserName, value: 1); weightedShortestJobFirstHub.NotifyAll(notification); NonThrowTryCatch();