Username form process of VSCode

This commit is contained in:
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);
}