register history with appnames
This commit is contained in:
parent
c8ba81b1af
commit
6ca303dc90
@ -37,6 +37,7 @@
|
|||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL" />
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
@ -82,7 +83,12 @@
|
|||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="file.json" />
|
<None Include="3251029_10402023451.json" />
|
||||||
|
<None Include="3251029_10402023470.json" />
|
||||||
|
<None Include="3251029_10402023476.json" />
|
||||||
|
<None Include="3251029_10402023479.json" />
|
||||||
|
<None Include="3251029_10402023480.json" />
|
||||||
|
<None Include="all.json" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
@ -3,20 +3,208 @@
|
|||||||
using Common.Hardware.SIRT;
|
using Common.Hardware.SIRT;
|
||||||
using Common.Hardware.SIRT.Tasks;
|
using Common.Hardware.SIRT.Tasks;
|
||||||
using Common.Hardware.WaterMeter.eRegister.Features;
|
using Common.Hardware.WaterMeter.eRegister.Features;
|
||||||
using Common.Hardware.WaterMeter.eRegister.Telegrams;
|
|
||||||
|
using LaaPackages.SqlClient;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Net;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
public static partial class Program
|
public static partial class Program
|
||||||
{
|
{
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Apps : Dictionary<string, App>
|
||||||
|
{
|
||||||
|
private readonly Dictionary<int, App> apps = new Dictionary<int, App>();
|
||||||
|
|
||||||
|
[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<string, Register>
|
||||||
|
{
|
||||||
|
private readonly Dictionary<int, Register> registers = new Dictionary<int, Register>();
|
||||||
|
|
||||||
|
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<Apps>(json);
|
||||||
|
var csv = new List<List<object>>();
|
||||||
|
|
||||||
|
csv.Add(new List<object> { "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<int>(0);
|
||||||
|
var appId = x.GetValue<int>(1);
|
||||||
|
var appName = apps.GetAppName(appId);
|
||||||
|
var regId = x.GetValue<int>(2);
|
||||||
|
var regName = apps.GetRegName(appId, regId);
|
||||||
|
var value = x.GetValue<string>(3);
|
||||||
|
var date = x.GetValue<string>(4);
|
||||||
|
|
||||||
|
csv.Add(new List<object> { pcbId, appId, appName, regId, regName, value, date });
|
||||||
|
});
|
||||||
|
|
||||||
|
File.WriteAllLines(@"..\..\254620052.csv", csv.Select(x => string.Join(";", x)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void Main_Pwd()
|
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<String, String>();
|
||||||
|
//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<MapKeySetItem>() { 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;
|
// httpRequest.Headers.Add("Cache-Control", "no-cache");
|
||||||
//};
|
// httpRequest.Headers.Add("X-Node-Token", "d5b8c0b2-81f6-4421-80d0-44eb2093e616");
|
||||||
using (var httpRequest = new HttpRequestMessage(HttpMethod.Get, "https://nodes.sms-esaap.com:8081/api/v3/custom/keysetkeys?orderNumber=3251950&radioAdress=10402032336"))
|
// 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<object>
|
||||||
|
{
|
||||||
|
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("Cache-Control", "no-cache");
|
||||||
httpRequest.Headers.Add("X-Node-Token", "d5b8c0b2-81f6-4421-80d0-44eb2093e616");
|
httpRequest.Headers.Add("X-Node-Token", "d5b8c0b2-81f6-4421-80d0-44eb2093e616");
|
||||||
@ -25,6 +213,8 @@
|
|||||||
using (var httpContent = httpResponse.Content)
|
using (var httpContent = httpResponse.Content)
|
||||||
{
|
{
|
||||||
var content = httpContent.ReadAsStringAsync().Result;
|
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
|
var alarmMask = 1 << AlarmMask.ALARM_REBOOT
|
||||||
| 1 << AlarmMask.ALARM_LOW_BATTERY
|
| 1 << AlarmMask.ALARM_LOW_BATTERY
|
||||||
|
|||||||
@ -604,10 +604,7 @@ namespace CordonelAssemblyLine.Model
|
|||||||
sbMSG.AppendLine($"Totally drained battery load in % {genesisStatus.DrainedBatteryLoadPercent:F2}");
|
sbMSG.AppendLine($"Totally drained battery load in % {genesisStatus.DrainedBatteryLoadPercent:F2}");
|
||||||
|
|
||||||
//restlaufzeit monate -RequiredLifeTimeYearsAssembly
|
//restlaufzeit monate -RequiredLifeTimeYearsAssembly
|
||||||
|
|
||||||
|
|
||||||
// var hasFehlern = false;
|
|
||||||
|
|
||||||
// restlaufzeit monate - RequiredLifeTimeYearsAssembly
|
// restlaufzeit monate - RequiredLifeTimeYearsAssembly
|
||||||
if (genesisStatus.RemainingLifeTimeYears < requirements.RequiredLifeTimeYearsAssembly)
|
if (genesisStatus.RemainingLifeTimeYears < requirements.RequiredLifeTimeYearsAssembly)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user