Nancy
This commit is contained in:
@ -9,15 +9,14 @@ public class Notification
|
||||
|
||||
[JsonConstructor]
|
||||
public Notification(int? fibonacci,
|
||||
int id,
|
||||
string id,
|
||||
int? inverse,
|
||||
string? machineId,
|
||||
string page,
|
||||
string? remoteIpAddress,
|
||||
string? site,
|
||||
long time,
|
||||
string time,
|
||||
string? username,
|
||||
int value)
|
||||
string? value)
|
||||
{
|
||||
int? i = inverse is not null ? inverse : GetInverse(value);
|
||||
Fibonacci = fibonacci is not null ? fibonacci : i is null ? null : GetFibonacci(i.Value);
|
||||
@ -25,32 +24,30 @@ public class Notification
|
||||
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("id")] public string 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("time")] public string Time { get; }
|
||||
[JsonPropertyName("username")] public string? Username { get; }
|
||||
[JsonPropertyName("value")] public int Value { get; }
|
||||
[JsonPropertyName("value")] public string? Value { get; }
|
||||
|
||||
internal static int? GetInverse(int value) =>
|
||||
internal static int? GetInverse(string? value) =>
|
||||
value switch
|
||||
{
|
||||
1 => 5,
|
||||
2 => 4,
|
||||
3 => 3,
|
||||
4 => 2,
|
||||
5 => 1,
|
||||
"1" => 5,
|
||||
"2" => 4,
|
||||
"3" => 3,
|
||||
"4" => 2,
|
||||
"5" => 1,
|
||||
_ => null
|
||||
};
|
||||
|
||||
@ -69,18 +66,6 @@ public class Notification
|
||||
_ => null
|
||||
};
|
||||
|
||||
internal static Notification GetNotification(Notification notification, string? remoteIpAddress, string? connectionId) =>
|
||||
new(notification.Fibonacci,
|
||||
notification.Id,
|
||||
notification.Inverse,
|
||||
notification.MachineId,
|
||||
notification.Page,
|
||||
remoteIpAddress ?? connectionId,
|
||||
notification.Site,
|
||||
notification.Time,
|
||||
notification.Username,
|
||||
notification.Value);
|
||||
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||
|
Reference in New Issue
Block a user