diff --git a/UCS_Status_Monitor.EventLogCreator/UCS_Status_Monitor.EventLogCreator.csproj b/UCS_Status_Monitor.EventLogCreator/UCS_Status_Monitor.EventLogCreator.csproj index 3cc0734..8db6517 100644 --- a/UCS_Status_Monitor.EventLogCreator/UCS_Status_Monitor.EventLogCreator.csproj +++ b/UCS_Status_Monitor.EventLogCreator/UCS_Status_Monitor.EventLogCreator.csproj @@ -2,13 +2,13 @@ Exe - net9.0 + net10.0 enable enable - + diff --git a/UCS_Status_Monitor.UnitTest/DataBaseModel_Test.cs b/UCS_Status_Monitor.UnitTest/DataBaseModel_Test.cs index fc645de..05d4f73 100644 --- a/UCS_Status_Monitor.UnitTest/DataBaseModel_Test.cs +++ b/UCS_Status_Monitor.UnitTest/DataBaseModel_Test.cs @@ -26,7 +26,8 @@ namespace UCS_Status_Monitor.UnitTest uCSSystem.ConnectionState = true; Assert.AreEqual("border-success", uCSSystem.TableColor()); - uCSSystem.Devices = [new UCSDevice() { State = true, Id = 1, UCSSystem = uCSSystem }]; + //uCSSystem.Devices = [new UCSDevice() { State = true, Id = 1, UCSSystem = uCSSystem }]; + uCSSystem.Devices.Add(new UCSDevice() { State = true, Id = 1, UCSSystem = uCSSystem }); Assert.AreEqual("border-success", uCSSystem.TableColor()); uCSSystem.Devices.Add(new UCSDevice() { State = false, Id = 2, UCSSystem = uCSSystem }); @@ -42,10 +43,11 @@ namespace UCS_Status_Monitor.UnitTest uCSSystem.ComputerName = "PXX-1234"; Assert.AreEqual("PXX-1234", uCSSystem.ComputerNameWithError()); - uCSSystem.Errors = - [ - new EventLogError() { Id = 1, Message = "error", UCSSystem = uCSSystem, Index = 123, TimeGenerated = DateTime.Now.AddDays(-2) }, - ]; + //uCSSystem.Errors = + //[ + // new EventLogError() { Id = 1, Message = "error", UCSSystem = uCSSystem, Index = 123, TimeGenerated = DateTime.Now.AddDays(-2) }, + //]; + uCSSystem.Errors.Add(new EventLogError() { Id = 1, Message = "error", UCSSystem = uCSSystem, Index = 123, TimeGenerated = DateTime.Now.AddDays(-2) }); Assert.AreEqual("PXX-1234", uCSSystem.ComputerNameWithError()); uCSSystem.Errors.Add(new EventLogError() { Id = 2, Message = "error", UCSSystem = uCSSystem, Index = 1234, TimeGenerated = DateTime.Now }); diff --git a/UCS_Status_Monitor.UnitTest/Teltonika_Test.cs b/UCS_Status_Monitor.UnitTest/Teltonika_Test.cs index 82f0d45..d20166e 100644 --- a/UCS_Status_Monitor.UnitTest/Teltonika_Test.cs +++ b/UCS_Status_Monitor.UnitTest/Teltonika_Test.cs @@ -129,7 +129,7 @@ namespace UCS_Status_Monitor.UnitTest string json = ""; string device = "testdevice"; string location = "somewhere"; - var message = MQTTDeviceMessage.Deserialize(json, device, location); + TeltonikaMessageV2? message = MQTTDeviceMessage.Deserialize(json, device, location); Assert.IsNull(message); json = "lufhy2q9478ry78aq39 f3g789fy egy 3ghuieg heasuhg egh eisulgh uielg hsalgire"; @@ -149,6 +149,7 @@ namespace UCS_Status_Monitor.UnitTest Assert.AreEqual(location, message.Location); //Temp + Assert.IsNotNull(message.GSM); Assert.AreEqual(380, message.GSM.Temperature); Assert.AreEqual(38.0, message.GSM.TempValue()); Assert.AreEqual("38℃", message.GSM.TempString()); @@ -164,7 +165,7 @@ namespace UCS_Status_Monitor.UnitTest //Assert.AreEqual("1 days 3 hours 58 min 0 sec", message.Base.UptimeString(new DateTime(2023, 10, 9, 0, 0, 00))); - + Assert.IsNotNull(message.Usage); //ThisMonthRX Assert.AreEqual((UInt64)30888399, message.Usage.Rx); //ThisMonthTX @@ -205,6 +206,7 @@ namespace UCS_Status_Monitor.UnitTest //Temp + Assert.IsNotNull(message.GSM); Assert.AreEqual(390, message.GSM.Temperature); Assert.AreEqual(39.0, message.GSM.TempValue()); Assert.AreEqual("39℃", message.GSM.TempString()); @@ -220,7 +222,7 @@ namespace UCS_Status_Monitor.UnitTest //Assert.AreEqual("1 days 3 hours 58 min 0 sec", message.Base.UptimeString(new DateTime(2023, 10, 9, 0, 0, 00))); - + Assert.IsNotNull(message.Usage); //ThisMonthRX Assert.AreEqual((UInt64)24069, message.Usage.Rx); //ThisMonthTX @@ -304,7 +306,7 @@ namespace UCS_Status_Monitor.UnitTest string device = "testdevice"; string location = "somewhere"; - var message = MQTTDeviceMessage.Deserialize(json, device, location); + TeltonikaMessageV2? message = MQTTDeviceMessage.Deserialize(json, device, location); Assert.IsNull(message); json = "lufhy2q9478ry78aq39 f3g789fy egy 3ghuieg heasuhg egh eisulgh uielg hsalgire"; @@ -324,6 +326,7 @@ namespace UCS_Status_Monitor.UnitTest Assert.AreEqual(location, message.Location); //Temp + Assert.IsNotNull(message.GSM); Assert.AreEqual(380, message.GSM.Temperature); Assert.AreEqual(38.0, message.GSM.TempValue()); Assert.AreEqual("38℃", message.GSM.TempString()); @@ -333,6 +336,7 @@ namespace UCS_Status_Monitor.UnitTest Assert.AreEqual("??℃", message.GSM.TempString()); //Uptime + Assert.IsNotNull(message.Base); Assert.AreEqual((uint)1698233689, message.Base.Time); Assert.AreEqual("2023-10-25 13:34:49", message.Base.LocalTime); @@ -341,7 +345,7 @@ namespace UCS_Status_Monitor.UnitTest //Assert.AreEqual("1 days 3 hours 58 min 0 sec", message.Base.UptimeString(new DateTime(2023, 10, 9, 0, 0, 00))); - + Assert.IsNotNull(message.Usage); //ThisMonthRX Assert.AreEqual((UInt64)30888399, message.Usage.Rx); //ThisMonthTX @@ -370,7 +374,7 @@ namespace UCS_Status_Monitor.UnitTest string json = File.ReadAllText(myfile); Debug.WriteLine(json); - TeltonikaMessageV2 message = MQTTDeviceMessage.Deserialize(json, device, location); + TeltonikaMessageV2? message = MQTTDeviceMessage.Deserialize(json, device, location); Assert.IsNotNull(message); Assert.IsInstanceOfType(message); @@ -378,6 +382,7 @@ namespace UCS_Status_Monitor.UnitTest Assert.AreEqual(location, message.Location); //Temp + Assert.IsNotNull(message.GSM); Assert.AreEqual(470, message.GSM.Temperature); Assert.AreEqual(47.0, message.GSM.TempValue()); Assert.AreEqual("47℃", message.GSM.TempString()); @@ -387,10 +392,12 @@ namespace UCS_Status_Monitor.UnitTest Assert.AreEqual("??℃", message.GSM.TempString()); //Time + Assert.IsNotNull(message.Base); Assert.AreEqual((uint)1748264319, message.Base.Time); Assert.AreEqual("2025-05-26 14:58:39", message.Base.LocalTime); //Usage + Assert.IsNotNull(message.Usage); Assert.AreEqual((UInt64)1450717947, message.Usage.Rx); Assert.AreEqual((UInt64)2629954194, message.Usage.Tx); diff --git a/UCS_Status_Monitor.UnitTest/UCS_Status_Monitor.UnitTest.csproj b/UCS_Status_Monitor.UnitTest/UCS_Status_Monitor.UnitTest.csproj index 2cff13f..51cde35 100644 --- a/UCS_Status_Monitor.UnitTest/UCS_Status_Monitor.UnitTest.csproj +++ b/UCS_Status_Monitor.UnitTest/UCS_Status_Monitor.UnitTest.csproj @@ -1,7 +1,7 @@ - net9.0-windows7.0 + net10.0-windows7.0 false @@ -31,12 +31,12 @@ - - + + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/UCS_Status_Monitor/Components/UCSSystems/Devices.razor b/UCS_Status_Monitor/Components/UCSSystems/Devices.razor index ef67509..aac9689 100644 --- a/UCS_Status_Monitor/Components/UCSSystems/Devices.razor +++ b/UCS_Status_Monitor/Components/UCSSystems/Devices.razor @@ -105,7 +105,7 @@ private async Task UpdateTable() { using MonitorDbContext db = await _contextFactory.CreateDbContextAsync(); - system = await db.UCSSystems.Where(i => i.UCSSystemId == Id).Include(d => d.Devices).SingleOrDefaultAsync(); + system = await db.UCSSystems.Where(i => i.UCSSystemId == Id).Include(d => d.Devices).SingleOrDefaultAsync() ?? new UCSSystem(); system.Devices = system.Devices.SortTable(sortOrder).ToList(); diff --git a/UCS_Status_Monitor/Models/Database/UCSSystem.cs b/UCS_Status_Monitor/Models/Database/UCSSystem.cs index 6831cd5..6b31afc 100644 --- a/UCS_Status_Monitor/Models/Database/UCSSystem.cs +++ b/UCS_Status_Monitor/Models/Database/UCSSystem.cs @@ -110,7 +110,7 @@ namespace UCS_Status_Monitor.Models.Database public DateTime LastMessageClient { get; set; } [Display(Name = "UCS uptime")] - public string Uptime { get; set; } = string.Empty; + public string Uptime { get; set; } = string.Empty; [Display(Name = "System uptime")] public string SystemUptime { get; set; } = string.Empty; @@ -160,8 +160,8 @@ namespace UCS_Status_Monitor.Models.Database public ICollection Devices { get; set; } = []; - public ICollection Loggings { get; set; } = []; + public ICollection Loggings { get; } = []; - public ICollection Errors { get; set; } = []; + public ICollection Errors { get; } = []; } } diff --git a/UCS_Status_Monitor/UCS_Status_Monitor.csproj b/UCS_Status_Monitor/UCS_Status_Monitor.csproj index 87d8dcd..900a271 100644 --- a/UCS_Status_Monitor/UCS_Status_Monitor.csproj +++ b/UCS_Status_Monitor/UCS_Status_Monitor.csproj @@ -1,7 +1,7 @@ - net9.0-windows7.0 + net10.0-windows7.0 2a38e861-2927-4c7f-97fa-7a31b346c61e SDN Engineering UCS Status Monitor @@ -35,15 +35,15 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + +