Username form process of VSCode

This commit is contained in:
Mike Phares 2025-01-31 14:25:34 -07:00
parent 304bf04afe
commit a343243576
5 changed files with 112 additions and 82 deletions

View File

@ -90,6 +90,7 @@ public class Aggregation
private static ReadOnlyCollection<Notification> GetNotifications(Settings settings, string directory) private static ReadOnlyCollection<Notification> GetNotifications(Settings settings, string directory)
{ {
List<Notification> results = new(); List<Notification> results = new();
string? key;
string text; string text;
string[] files; string[] files;
Notification? notification; Notification? notification;
@ -108,12 +109,13 @@ public class Aggregation
notification = JsonSerializer.Deserialize(text, NotificationSourceGenerationContext.Default.Notification); notification = JsonSerializer.Deserialize(text, NotificationSourceGenerationContext.Default.Notification);
if (notification is null || notification.Id == 0) if (notification is null || notification.Id == 0)
continue; continue;
if (string.IsNullOrEmpty(notification.RemoteIpAddress)) key = !string.IsNullOrEmpty(notification.Username) ? notification.Username : notification.RemoteIpAddress;
if (string.IsNullOrEmpty(key))
continue; continue;
if (!keyValuePairs.TryGetValue(notification.RemoteIpAddress, out collection)) if (!keyValuePairs.TryGetValue(key, out collection))
{ {
keyValuePairs.Add(notification.RemoteIpAddress, new()); keyValuePairs.Add(key, new());
if (!keyValuePairs.TryGetValue(notification.RemoteIpAddress, out collection)) if (!keyValuePairs.TryGetValue(key, out collection))
throw new Exception(); throw new Exception();
} }
collection.Add(notification); collection.Add(notification);

View File

@ -11,30 +11,36 @@ public class Notification
public Notification(int? fibonacci, public Notification(int? fibonacci,
int id, int id,
int? inverse, int? inverse,
string? machineId,
string page, string page,
string? remoteIpAddress, string? remoteIpAddress,
string? site, string? site,
long time, long time,
string? username,
int value) int value)
{ {
int? i = inverse is not null ? inverse : GetInverse(value); int? i = inverse is not null ? inverse : GetInverse(value);
Fibonacci = fibonacci is not null ? fibonacci : i is null ? null : GetFibonacci(i.Value); Fibonacci = fibonacci is not null ? fibonacci : i is null ? null : GetFibonacci(i.Value);
Id = id; Id = id;
Inverse = i; Inverse = i;
MachineId = machineId;
Page = page; Page = page;
RemoteIpAddress = remoteIpAddress is not null ? remoteIpAddress : null; RemoteIpAddress = remoteIpAddress is not null ? remoteIpAddress : null;
Site = site is not null ? site : "MES"; Site = site is not null ? site : "MES";
Time = time; Time = time;
Username = username;
Value = value; Value = value;
} }
[JsonPropertyName("id")] public int Id { get; } [JsonPropertyName("id")] public int Id { get; }
[JsonPropertyName("fibonacci")] public int? Fibonacci { get; } [JsonPropertyName("fibonacci")] public int? Fibonacci { get; }
[JsonPropertyName("inverse")] public int? Inverse { get; } [JsonPropertyName("inverse")] public int? Inverse { get; }
[JsonPropertyName("machineId")] public string? MachineId { get; }
[JsonPropertyName("page")] public string Page { get; } [JsonPropertyName("page")] public string Page { get; }
[JsonPropertyName("RemoteIpAddress")] public string? RemoteIpAddress { get; } [JsonPropertyName("RemoteIpAddress")] public string? RemoteIpAddress { get; }
[JsonPropertyName("site")] public string? Site { get; } [JsonPropertyName("site")] public string? Site { get; }
[JsonPropertyName("time")] public long Time { get; } [JsonPropertyName("time")] public long Time { get; }
[JsonPropertyName("username")] public string? Username { get; }
[JsonPropertyName("value")] public int Value { get; } [JsonPropertyName("value")] public int Value { get; }
internal static int? GetInverse(int value) => internal static int? GetInverse(int value) =>
@ -67,10 +73,12 @@ public class Notification
new(notification.Fibonacci, new(notification.Fibonacci,
notification.Id, notification.Id,
notification.Inverse, notification.Inverse,
notification.MachineId,
notification.Page, notification.Page,
remoteIpAddress ?? connectionId, remoteIpAddress ?? connectionId,
notification.Site, notification.Site,
notification.Time, notification.Time,
notification.Username,
notification.Value); notification.Value);
} }

View File

@ -1,13 +1,11 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />
<title>Infineon - Cost of Delay (CoD) (see @SCALE formula)</title> <title>Infineon - Cost of Delay (CoD) (see @SCALE formula)</title>
<link href="/styles/bootstrap.min.css?no-cache=2024-10-04-08-34" rel="stylesheet" /> <link href="/styles/bootstrap.min.css?no-cache=2024-10-04-08-34" rel="stylesheet" />
<link href="/igniteui/css/themes/bootstrap3/default/infragistics.theme.css?v=2025-01-22-10-49" rel="stylesheet" />
<link href="/igniteui/css/structure/infragistics.css?v=2025-01-22-10-49" rel="stylesheet" />
<link href="/styles/cod.css?no-cache=2024-10-04-08-34" rel="stylesheet" /> <link href="/styles/cod.css?no-cache=2024-10-04-08-34" rel="stylesheet" />
<script src="/js/scripts/jquery-1.6.4.min.js"></script> <script src="/js/scripts/jquery-1.6.4.min.js"></script>
<script src="/js/scripts/jquery.signalR-2.4.3.min.js"></script> <script src="/js/scripts/jquery.signalR-2.4.3.min.js"></script>
@ -56,6 +54,8 @@
<script> <script>
$(document).ready(function () { $(document).ready(function () {
const username = '';
const machineId = '';
const fromHtml = true; const fromHtml = true;
const signalRUrl = "/signalr"; const signalRUrl = "/signalr";
const windowLocationHRef = window.location.href; const windowLocationHRef = window.location.href;
@ -100,7 +100,7 @@
th: "Weightest Shortest Job First calculation (WSJF)", th: "Weightest Shortest Job First calculation (WSJF)",
span: "Weightest Shortest Job First calculation (see @SCALE formula)" span: "Weightest Shortest Job First calculation (see @SCALE formula)"
}; };
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);
}); });
</script> </script>

View File

@ -1,7 +1,9 @@
var _site = '';
var _chat = {}; var _chat = {};
var _site = '';
var _apiUrl = ''; var _apiUrl = '';
var _toggle = true; var _toggle = true;
var _username = '';
var _machineId = '';
var _windowLocationHRef = ''; var _windowLocationHRef = '';
var _connectionHubStartDone = false; var _connectionHubStartDone = false;
@ -177,7 +179,15 @@ function getRecords(b, r, t, c, e, w, data, dataB) {
} }
function sendValue(fromHtml, element, page, id) { 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") { if (fromHtml && notification.value !== "9") {
$("#AllTextarea").hide(); $("#AllTextarea").hide();
document.getElementById('AllTextarea').value = ''; document.getElementById('AllTextarea').value = '';
@ -360,15 +370,7 @@ function highlight(el, i) {
.fadeOut(1000 * i); .fadeOut(1000 * i);
} }
function setupSignalR(b, r, t, c, e, w, signalRUrl) { function updateWorkItem(b, r, t, c, e, w, page, workItem) {
$.connection.hub.logging = true;
$.connection.hub.url = signalRUrl;
_chat = $.connection.weightedShortestJobFirstHub;
if (_chat == undefined || _chat.server == undefined) {
alert("Error within handshake!");
}
else {
_chat.client.updateWorkItem = function (page, workItem) {
console.log(workItem); console.log(workItem);
var x = null; var x = null;
var aggregation = null; var aggregation = null;
@ -439,6 +441,18 @@ function setupSignalR(b, r, t, c, e, w, signalRUrl) {
} }
} }
}; };
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!');
}
else {
_chat.client.updateWorkItem = function (page, workItem) {
updateWorkItem(b, r, t, c, e, w, page, workItem);
};
// $.connection.hub.start({ transport: 'longPolling' }) // $.connection.hub.start({ transport: 'longPolling' })
$.connection.hub.start() $.connection.hub.start()
.done(function () { .done(function () {
@ -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; _apiUrl = apiUrl;
_username = username;
_machineId = machineId;
_windowLocationHRef = windowLocationHRef; _windowLocationHRef = windowLocationHRef;
if (!fromHtml) { if (!fromHtml) {
console.log(b); console.log(b);
@ -17038,6 +17054,8 @@ function getExampleDataB() {
// #region Test // #region Test
if (typeof document == 'undefined') { if (typeof document == 'undefined') {
const username = '';
const machineId = '';
const fromHtml = false; const fromHtml = false;
const signalRUrl = "/signalr"; const signalRUrl = "/signalr";
const apiUrl = "https://oi-metrology-viewer-prod.mes.infineon.com:4438/api/v1/ado/"; 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) if (dataA.length > 0)
console.log(dataA[0]); console.log(dataA[0]);
setRecords(fromHtml, b, r, t, c, e, w, records); 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 // #endregion Test

View File

@ -207,10 +207,12 @@ public class MESAFIBACKLOG
Notification notification = new(fibonacci: null, Notification notification = new(fibonacci: null,
id: 1107438888, id: 1107438888,
inverse: null, inverse: null,
machineId: Environment.MachineName,
page: "effort", page: "effort",
remoteIpAddress: "10.95.36.87", remoteIpAddress: "10.95.36.87",
site: "MES", site: "MES",
time: 1737573418926, time: 1737573418926,
username: Environment.UserName,
value: 1); value: 1);
weightedShortestJobFirstHub.NotifyAll(notification); weightedShortestJobFirstHub.NotifyAll(notification);
NonThrowTryCatch(); NonThrowTryCatch();