From 6ca303dc908614754700795217ad710e9d34baf6 Mon Sep 17 00:00:00 2001 From: Stoyan Zlatev Date: Thu, 12 Mar 2026 08:53:39 +0100 Subject: [PATCH] register history with appnames --- Common/CommonConsole/CommonConsole.csproj | 8 +- Common/CommonConsole/Program.cs | 204 +++++++++++++++++- .../Model/PickingModel.cs | 5 +- 3 files changed, 205 insertions(+), 12 deletions(-) diff --git a/Common/CommonConsole/CommonConsole.csproj b/Common/CommonConsole/CommonConsole.csproj index 0ad05346..ceae4a65 100644 --- a/Common/CommonConsole/CommonConsole.csproj +++ b/Common/CommonConsole/CommonConsole.csproj @@ -37,6 +37,7 @@ false + @@ -82,7 +83,12 @@ - + + + + + + \ No newline at end of file diff --git a/Common/CommonConsole/Program.cs b/Common/CommonConsole/Program.cs index 1f5fb775..5fe318e5 100644 --- a/Common/CommonConsole/Program.cs +++ b/Common/CommonConsole/Program.cs @@ -3,20 +3,208 @@ using Common.Hardware.SIRT; using Common.Hardware.SIRT.Tasks; using Common.Hardware.WaterMeter.eRegister.Features; - using Common.Hardware.WaterMeter.eRegister.Telegrams; + + using LaaPackages.SqlClient; + + using Newtonsoft.Json; + using System; - using System.Net; + using System.Collections.Generic; + using System.IO; + using System.Linq; using System.Net.Http; + using System.Runtime.Serialization; public static partial class Program { + static void Main() + { + + } + + public class Apps : Dictionary + { + private readonly Dictionary apps = new Dictionary(); + + [OnDeserialized] + private void OnDeserialized(StreamingContext _) + { + foreach (var kvp in this) + { + var app = kvp.Value; + app.Name = kvp.Key; + this.apps[app.Id] = app; + } + } + + internal object GetAppName(int appId) + { + if (this.apps.TryGetValue(appId, out var app)) + { + return app.Name; + } + + return default(object); + } + + internal object GetRegName(int appId, int regId) + { + if (this.apps.TryGetValue(appId, out var app)) + { + return app.GetRegName(regId); + } + + return default(object); + } + } + + public class App + { + public int Id { get; set; } + + public string Name { get; set; } + + public Registers Registers { get; set; } = new Registers(); + + internal object GetRegName(int regId) + => this.Registers.GetRegName(regId); + } + + public class Registers : Dictionary + { + private readonly Dictionary registers = new Dictionary(); + + internal object GetRegName(int regId) + { + if (this.registers.TryGetValue(regId, out var reg)) + { + return reg.Name; + } + + return default(object); + } + + [OnDeserialized] + private void OnDeserialized(StreamingContext _) + { + foreach (var kvp in this) + { + var register = kvp.Value; + register.Name = kvp.Key; + this.registers[register.Id] = register; + } + } + } + + public class Register + { + public int Id { get; set; } + + public string Name { get; set; } + } + + static void Main_RegHistory() + { + var json = File.ReadAllText(@"..\..\all.json"); + var apps = JsonConvert.DeserializeObject(json); + var csv = new List>(); + + csv.Add(new List { "PcbId", "AppId", "AppName", "RegId", "RegName", "Value", "Date" }); + + SqlConnection + .CreateSqlConnection("Server=DELAZ1SQL01.world.fluidtechnology.net; Database=Auftrag; User ID=sa; Password=sqlserver;") + .CreateCommand(@" + SELECT x.PcbId + , CONVERT(INT, CONVERT(VARBINARY, LEFT(x.Address, 2), 2)) AS App + , CONVERT(INT, CONVERT(VARBINARY, RIGHT(x.Address, 2), 2)) AS Reg + , x.Value + , FORMAT(x.date, 'yyyy-MM-dd HH:mm:ss') AS Date + FROM (SELECT PcbId + , Address + , Value + , date + , ROW_NUMBER() OVER (PARTITION BY Address ORDER BY date DESC) AS RowNr + FROM GenesisMeterRegisterHistory + WHERE PcbId = '254620052' + AND Value <> 'NULL') + AS x + WHERE x.RowNr = 1") + .ExecuteReader(x => + { + var pcbId = x.GetValue(0); + var appId = x.GetValue(1); + var appName = apps.GetAppName(appId); + var regId = x.GetValue(2); + var regName = apps.GetRegName(appId, regId); + var value = x.GetValue(3); + var date = x.GetValue(4); + + csv.Add(new List { pcbId, appId, appName, regId, regName, value, date }); + }); + + File.WriteAllLines(@"..\..\254620052.csv", csv.Select(x => string.Join(";", x))); + } + + static void Main_Pwd() { - //ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => + //var Url = $"{ServiceUrls.KeyServerCustom()}keysetkeys/"; + //var Url = "https://nodes.sms-esaap.com/keygenproxy/api/v3/custom/keysets/devices"; + //var header = new Dictionary(); + //header.Add("Cache-Control", "no-cache"); + //header.Add("X-Node-Token", Token);//"d5b8c0b2-81f6-4421-80d0-44eb2093e616"); + + + + //string postData = $"[{{\"setId\":\"{KeySetID}\", \"orderNumber\":\"{orderNumber}\", \"radioAdress\":\"{radioAdress}\"}}]"; + //var postData = new MapKeySetItem() + //{ orderNumber = MeterOrderNumber.ToString(), radioAdress = MeterPassowrdIdent.ToString(), setId = KeySetID }; + + //var helpArray = new List() { postData }; + + + // return LocalWebRequest.PostRequestAsyncAndGetContent(url: Url, header: header, json: helpArray.ToArray(), timeoutMs: 20000); + + //using (var httpRequest = new HttpRequestMessage(HttpMethod.Post, "https://nodes.sms-esaap.com/keygenproxy/api/v3/custom/keysets/devices")) //{ - // return true; - //}; - using (var httpRequest = new HttpRequestMessage(HttpMethod.Get, "https://nodes.sms-esaap.com:8081/api/v3/custom/keysetkeys?orderNumber=3251950&radioAdress=10402032336")) + // httpRequest.Headers.Add("Cache-Control", "no-cache"); + // httpRequest.Headers.Add("X-Node-Token", "d5b8c0b2-81f6-4421-80d0-44eb2093e616"); + // httpRequest.Content = new StringContent(JsonConvert.SerializeObject(units)); + // httpRequest.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); + + // using (var httpResponse = new HttpClient().SendAsync(httpRequest).Result) + // { + // using (var httpContent = httpResponse.Content) + // { + // var content = httpContent.ReadAsStringAsync().Result; + // } + // } + //} + + // 43280002E023 + // 0ED6EE109B27B7C02E6A351C0F66B155649938996D7B45475F67A568CCBEC34E + // A15088A4B476B3F47A5F14F0D8DCDAE4F42D3279FD9B6D9AC995389251D0AEB6 + // 449E0701B6C2 + // 0B34274BE517CD86B7A378AD197D3AA0FC2C262C0B09ED4A530FAED7E52615CC + // 42ED98391C30EECA5CC500A3086BD4B0A20ACF387BB41613057FF476D7E4D822 + // 8C5FD08CC8D720344243D4059AD34982F2452C5123F42D7E417DB03B3C59D1D8 + // E18AFAF87B9301A5FF5F3539752BADA03389F1A1E9470EF99FC64F313351C485 + // F87DD657D1A11D1EBD3A8F21779DD2E60B4B8B4F5203A6680A5EBCE72DC7F771 + // 528B13015F205316381018A5CD16264266B58BB3F1A1DE09EB88D75132694834 + // C0E9DBBD18F1101F8AABC3C48B71996768E8F8C30E91E402A10627D42B8F734B + // 73C8A7C67600F91C66512FBED68610A25BBF2F2A5AFED40CDEA0C33C71F15535 + // 4B3DEEBFE79E1594BAF13A743CD252295B0D1C8200BD03C1F904850768FD145B + // A1F4FA7C71A5EAC60257480FF5DCE1FF5B076BF134DD67B13FF11A9309009E90 + var units = new List + { + new { orderNumber = 3251029, radioAdress = 10402023451, setId = "8d98dfc7-27ab-4a7b-b3e1-44206fe122c3" }, // 4B3DEEBFE79E + new { orderNumber = 3251029, radioAdress = 10402023470, setId = "2698c112-eb85-4408-a1b4-4bc1e64cbfc3" }, // A1F4FA7C71A5 + new { orderNumber = 3251029, radioAdress = 10402023476, setId = "5744f62e-f2d9-47be-8d9f-b25b9801de92" }, // 73C8A7C67600 + new { orderNumber = 3251029, radioAdress = 10402023479, setId = "67a66322-c19b-4b18-a24a-ada3e5c7f659" }, // C0E9DBBD18F1 + new { orderNumber = 3251029, radioAdress = 10402023480, setId = "438dc338-0c78-42fa-9436-1a9ad21c4e29" }, // 528B13015F20 + }.ToArray(); + + using (var httpRequest = new HttpRequestMessage(HttpMethod.Get, "https://nodes.sms-esaap.com:8081/api/v3/custom/keysetkeys?orderNumber=0&radioAdress=10402023480")) { httpRequest.Headers.Add("Cache-Control", "no-cache"); httpRequest.Headers.Add("X-Node-Token", "d5b8c0b2-81f6-4421-80d0-44eb2093e616"); @@ -25,6 +213,8 @@ using (var httpContent = httpResponse.Content) { var content = httpContent.ReadAsStringAsync().Result; + + Console.WriteLine(JsonConvert.SerializeObject(JsonConvert.DeserializeObject(content), Formatting.Indented)); } } } @@ -77,7 +267,7 @@ } - static void Main() // __CSD_Config() + static void Main__CSD_Config() { var alarmMask = 1 << AlarmMask.ALARM_REBOOT | 1 << AlarmMask.ALARM_LOW_BATTERY diff --git a/Common/CordonelAssemblyLine/Model/PickingModel.cs b/Common/CordonelAssemblyLine/Model/PickingModel.cs index 8e3533f9..a2705bfa 100644 --- a/Common/CordonelAssemblyLine/Model/PickingModel.cs +++ b/Common/CordonelAssemblyLine/Model/PickingModel.cs @@ -604,10 +604,7 @@ namespace CordonelAssemblyLine.Model sbMSG.AppendLine($"Totally drained battery load in % {genesisStatus.DrainedBatteryLoadPercent:F2}"); //restlaufzeit monate -RequiredLifeTimeYearsAssembly - - - // var hasFehlern = false; - + // restlaufzeit monate - RequiredLifeTimeYearsAssembly if (genesisStatus.RemainingLifeTimeYears < requirements.RequiredLifeTimeYearsAssembly) {