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)
{
List<Notification> 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);

View File

@ -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);
}

View File

@ -1,13 +1,11 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<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="/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" />
<script src="/js/scripts/jquery-1.6.4.min.js"></script>
<script src="/js/scripts/jquery.signalR-2.4.3.min.js"></script>
@ -56,6 +54,8 @@
<script>
$(document).ready(function () {
const username = '';
const machineId = '';
const fromHtml = true;
const signalRUrl = "/signalr";
const windowLocationHRef = window.location.href;
@ -100,7 +100,7 @@
th: "Weightest Shortest Job First calculation (WSJF)",
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>

View File

@ -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

View File

@ -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();