gtb: pwd change, register

This commit is contained in:
Stoyan Zlatev
2024-02-20 12:17:07 +01:00
parent a90459f5d4
commit 3110e3a051
72 changed files with 1927 additions and 981 deletions
+2 -2
View File
@@ -14,5 +14,5 @@ using System.Reflection;
//[assembly: AssemblyVersion("1.2.*.0")]
[assembly: AssemblyVersion("2.6.8.*")]
[assembly: AssemblyFileVersion("2.6.8.0")]
[assembly: AssemblyVersion("2.6.7.*")]
[assembly: AssemblyFileVersion("2.6.7.0")]
+137
View File
@@ -187,6 +187,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlExtensions", "OmniPlus\S
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InspectionUI", "OmniPlus\InspectionUI\InspectionUI.csproj", "{01A28A70-D5E6-4898-8C22-E64400A3B80F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{8BDA6853-0E0E-427F-AB49-546600A28944}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plugins.Abstraction", "Plugins.Abstraction\Plugins.Abstraction.csproj", "{D96612D9-5B00-42CB-9779-FE5C251BB78F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plugins.OMNI", "Plugins.OMNI\Plugins.OMNI.csproj", "{A04A3FE3-1443-45B2-9917-E90168567101}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Utils\DateTimeServerShared\DateTimeServerShared.projitems*{4806d89a-fbfb-41bc-aaa7-2242444bf55a}*SharedItemsImports = 4
@@ -4381,6 +4387,134 @@ Global
{01A28A70-D5E6-4898-8C22-E64400A3B80F}.XP32bit|x64.Build.0 = Release|Any CPU
{01A28A70-D5E6-4898-8C22-E64400A3B80F}.XP32bit|x86.ActiveCfg = Release|Any CPU
{01A28A70-D5E6-4898-8C22-E64400A3B80F}.XP32bit|x86.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}._MANUAL_CONTROL|Any CPU.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}._MANUAL_CONTROL|Any CPU.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}._MANUAL_CONTROL|Mixed Platforms.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}._MANUAL_CONTROL|x64.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}._MANUAL_CONTROL|x64.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}._MANUAL_CONTROL|x86.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}._MANUAL_CONTROL|x86.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.COM|Any CPU.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.COM|Any CPU.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.COM|Mixed Platforms.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.COM|Mixed Platforms.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.COM|x64.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.COM|x64.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.COM|x86.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.COM|x86.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.Debug|x64.ActiveCfg = Debug|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.Debug|x64.Build.0 = Debug|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.Debug|x86.ActiveCfg = Debug|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.Debug|x86.Build.0 = Debug|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.GenesisDisplayTool_V01|Any CPU.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.GenesisDisplayTool_V01|Any CPU.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.GenesisDisplayTool_V01|Mixed Platforms.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.GenesisDisplayTool_V01|Mixed Platforms.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.GenesisDisplayTool_V01|x64.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.GenesisDisplayTool_V01|x64.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.GenesisDisplayTool_V01|x86.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.GenesisDisplayTool_V01|x86.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.PerformTest|Any CPU.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.PerformTest|Any CPU.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.PerformTest|Mixed Platforms.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.PerformTest|Mixed Platforms.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.PerformTest|x64.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.PerformTest|x64.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.PerformTest|x86.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.PerformTest|x86.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.Release|Any CPU.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.Release|x64.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.Release|x64.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.Release|x86.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.Release|x86.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.ReleaseTest|Any CPU.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.ReleaseTest|Any CPU.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.ReleaseTest|Mixed Platforms.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.ReleaseTest|Mixed Platforms.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.ReleaseTest|x64.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.ReleaseTest|x64.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.ReleaseTest|x86.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.ReleaseTest|x86.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.XP32bit|Any CPU.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.XP32bit|Any CPU.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.XP32bit|Mixed Platforms.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.XP32bit|Mixed Platforms.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.XP32bit|x64.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.XP32bit|x64.Build.0 = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.XP32bit|x86.ActiveCfg = Release|Any CPU
{D96612D9-5B00-42CB-9779-FE5C251BB78F}.XP32bit|x86.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}._MANUAL_CONTROL|Any CPU.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}._MANUAL_CONTROL|Any CPU.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}._MANUAL_CONTROL|Mixed Platforms.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}._MANUAL_CONTROL|x64.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}._MANUAL_CONTROL|x64.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}._MANUAL_CONTROL|x86.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}._MANUAL_CONTROL|x86.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.COM|Any CPU.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.COM|Any CPU.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.COM|Mixed Platforms.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.COM|Mixed Platforms.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.COM|x64.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.COM|x64.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.COM|x86.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.COM|x86.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.Debug|x64.ActiveCfg = Debug|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.Debug|x64.Build.0 = Debug|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.Debug|x86.ActiveCfg = Debug|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.Debug|x86.Build.0 = Debug|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.GenesisDisplayTool_V01|Any CPU.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.GenesisDisplayTool_V01|Any CPU.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.GenesisDisplayTool_V01|Mixed Platforms.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.GenesisDisplayTool_V01|Mixed Platforms.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.GenesisDisplayTool_V01|x64.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.GenesisDisplayTool_V01|x64.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.GenesisDisplayTool_V01|x86.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.GenesisDisplayTool_V01|x86.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.PerformTest|Any CPU.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.PerformTest|Any CPU.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.PerformTest|Mixed Platforms.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.PerformTest|Mixed Platforms.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.PerformTest|x64.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.PerformTest|x64.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.PerformTest|x86.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.PerformTest|x86.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.Release|Any CPU.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.Release|x64.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.Release|x64.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.Release|x86.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.Release|x86.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.ReleaseTest|Any CPU.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.ReleaseTest|Any CPU.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.ReleaseTest|Mixed Platforms.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.ReleaseTest|Mixed Platforms.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.ReleaseTest|x64.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.ReleaseTest|x64.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.ReleaseTest|x86.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.ReleaseTest|x86.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.XP32bit|Any CPU.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.XP32bit|Any CPU.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.XP32bit|Mixed Platforms.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.XP32bit|Mixed Platforms.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.XP32bit|x64.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.XP32bit|x64.Build.0 = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.XP32bit|x86.ActiveCfg = Release|Any CPU
{A04A3FE3-1443-45B2-9917-E90168567101}.XP32bit|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -4465,6 +4599,9 @@ Global
{F8D84B9A-0FCF-4083-B067-8C39B7314152} = {68323534-4337-4E3A-89BC-11D8BB55343A}
{B8523894-2C40-4FF0-A399-B7A91FAE45EA} = {68323534-4337-4E3A-89BC-11D8BB55343A}
{01A28A70-D5E6-4898-8C22-E64400A3B80F} = {68323534-4337-4E3A-89BC-11D8BB55343A}
{8BDA6853-0E0E-427F-AB49-546600A28944} = {68323534-4337-4E3A-89BC-11D8BB55343A}
{D96612D9-5B00-42CB-9779-FE5C251BB78F} = {8BDA6853-0E0E-427F-AB49-546600A28944}
{A04A3FE3-1443-45B2-9917-E90168567101} = {8BDA6853-0E0E-427F-AB49-546600A28944}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4BCB7B69-696C-436A-86F7-C91EA5588164}
+105 -21
View File
@@ -7,37 +7,121 @@
using System.Text;
using System.Threading.Tasks;
public class Program
public partial class Program
{
private static readonly HttpClient httpClient = new HttpClient();
public static void Main()
{
Task.Factory
.StartNew(async () =>
{
using (var httpRequestMessage = new HttpRequestMessage())
{
httpRequestMessage.Content = new StringContent("{}", Encoding.UTF8, "application/json");
httpRequestMessage.Method = HttpMethod.Post;
httpRequestMessage.RequestUri = new Uri("http://localhost:52822/LaaProductionWeb/api/Login/AD");
//Task.Factory
// .StartNew(async () =>
// {
// using (var httpRequestMessage = new HttpRequestMessage())
// {
// httpRequestMessage.Content = new StringContent("{}", Encoding.UTF8, "application/json");
// httpRequestMessage.Method = HttpMethod.Post;
// httpRequestMessage.RequestUri = new Uri("http://localhost:52822/LaaProductionWeb/api/Login/AD");
using (var httpResponseMessage = await httpClient.SendAsync(httpRequestMessage))
{
Console.WriteLine(httpResponseMessage);
// //using (var httpResponseMessage = await httpClient.SendAsync(httpRequestMessage))
// //{
// // Console.WriteLine(httpResponseMessage);
using (var httpContent = httpResponseMessage.Content)
{
var content = await httpContent.ReadAsStringAsync();
var obj = JsonConvert.DeserializeObject(content);
// // using (var httpContent = httpResponseMessage.Content)
// // {
// // var content = await httpContent.ReadAsStringAsync();
// // var obj = JsonConvert.DeserializeObject(content);
Console.WriteLine(JsonConvert.SerializeObject(obj, Formatting.Indented));
}
}
}
});
// // Console.WriteLine(JsonConvert.SerializeObject(obj, Formatting.Indented));
// // }
// //}
// }
// });
Console.ReadKey();
}
}
}
/**
public void SaveMeterState()
{
if (this.MeterNr == NA)
{
return;
}
if (OmniContext.Current.Exists(this.MeterNr))
{
return;
}
var commands = new List<byte[]>
{
new byte[] { 0x01 },
new byte[] { 0x03 },
new byte[] { 0x05 },
new byte[] { 0x07 },
new byte[] { 0x09 },
new byte[] { 0x0B },
new byte[] { 0x0D },
new byte[] { 0x0F },
new byte[] { 0x11 },
new byte[] { 0x13 },
new byte[] { 0x15 },
new byte[] { 0x17 },
new byte[] { 0x1F },
new byte[] { 0x21 },
new byte[] { 0x25 },
new byte[] { 0x27 },
new byte[] { 0x29 },
new byte[] { 0x2B },
new byte[] { 0xFD, 0x02 },
new byte[] { 0xFD, 0x05 },
new byte[] { 0xFD, 0x06 },
new byte[] { 0xFD, 0x08 },
new byte[] { 0xFD, 0x0A },
new byte[] { 0xFD, 0x0E },
new byte[] { 0xFD, 0x10 },
new byte[] { 0xFD, 0x12 },
new byte[] { 0xFD, 0x14 },
new byte[] { 0xFD, 0x22 },
new byte[] { 0xFD, 0x24 },
new byte[] { 0xFD, 0x26 },
new byte[] { 0xFD, 0x28 },
new byte[] { 0xFD, 0x39 },
new byte[] { 0xFD, 0x3D },
new byte[] { 0xFD, 0x55 },
new byte[] { 0xFD, 0x63 },
new byte[] { 0xFD, 0x7B },
new byte[] { 0xFD, 0x7E, 0x00 },
new byte[] { 0xFD, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
new byte[] { 0xFD, 0x8B },
new byte[] { 0xFD, 0xA9 },
new byte[] { 0xFD, 0xAA },
new byte[] { 0xFD, 0xAC },
new byte[] { 0xFD, 0xB7 },
new byte[] { 0xFD, 0xBC },
new byte[] { 0xFD, 0xC2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
new byte[] { 0xFD, 0xC3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
new byte[] { 0xFD, 0xC4, 0x00 },
new byte[] { 0xFD, 0xC6 },
new byte[] { 0xFD, 0xC7 }
};
var meterState = new StringBuilder();
foreach (var cmd in commands)
{
var response = this.connection.Send(cmd);
var entry = $"{BitConverter.ToString(cmd)}:{BitConverter.ToString(response)};";
meterState.Append(entry);
}
OmniContext.Current.Add(this.MeterNr, meterState.ToString());
this.WriteToLog();
}
*/
@@ -200,8 +200,8 @@ namespace Xylem.Common.CommonCore.Configuration
= "http://sla12iis01.emea.sensus.net/MeterProcessState/api/CordonelPressureSensorTest/GetTestResults/{0}";
public const string LaaProductionAPI
#if DEBUG == false // when false uses always the production url.
= "http://localhost:59768";
#if DEBUG //== false // when false uses always the production url.
= "http://localhost:52822";
#else
= "http://sla12iis01.emea.sensus.net";
#endif
@@ -10,7 +10,5 @@ namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore
Cordonel,
MagFlux,
eRegister,
}
}
@@ -1 +1 @@
bf6bb8fceb3db5a9977dadc407cf576684bf7127
89102b0142e574de38a9f47d370f3334e5e6c268
+2 -12
View File
@@ -1,22 +1,12 @@
namespace InspectionUI
{
using InspectionUI.Models;
using OmniPlus;
using System;
using System.IO;
using System.Windows;
public partial class App : Application
{
public App()
{
//ServiceProvider
// .ServiceCollection
// .AddSingleton(new OmniContext(Appsettings.OmniDB, Appsettings.OutputDirectory));
OmniContext.Create(Appsettings.OmniDB, Appsettings.OutputDirectory);
}
public static readonly string CurrentDirectory = new FileInfo(typeof(App).Assembly.Location).DirectoryName;
internal static event Action Exiting;
@@ -59,9 +59,12 @@
<Compile Include="ItemsGrid.xaml.cs">
<DependentUpon>ItemsGrid.xaml</DependentUpon>
</Compile>
<Compile Include="Models\AppLogger.cs" />
<Compile Include="Models\Appsettings.cs" />
<Compile Include="Models\CompilerServices.cs" />
<Compile Include="PluginsWindow.xaml.cs">
<DependentUpon>PluginsWindow.xaml</DependentUpon>
</Compile>
<Compile Include="ViewModels\PluginsVM.cs" />
<Compile Include="ViewModels\DefaultsHeaderRow.cs" />
<Compile Include="ViewModels\DefaultsRowVM.cs" />
<Compile Include="ViewModels\HeadersRowVM.cs" />
@@ -91,6 +94,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="PluginsWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
@@ -125,6 +132,10 @@
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Plugins.Abstraction\Plugins.Abstraction.csproj">
<Project>{d96612d9-5b00-42cb-9779-fe5c251bb78f}</Project>
<Name>Plugins.Abstraction</Name>
</ProjectReference>
<ProjectReference Include="..\ExchangeHub\ExchangeHub.csproj">
<Project>{6033FF0C-CF32-4BC5-8EFE-4774CCDC663D}</Project>
<Name>ExchangeHub</Name>
+31 -14
View File
@@ -6,6 +6,9 @@
Icon="MainWindow.png"
Height="600"
Width="977">
<Window.Resources>
</Window.Resources>
<Window.DataContext>
<VM:MainVM />
</Window.DataContext>
@@ -51,34 +54,48 @@
FontFamily="Consolas"
FontWeight="Bold"
Grid.Column="2"
ItemsSource="{Binding Sizes}"
Margin="5, 5, 0, 5"
Padding="5"
SelectedIndex="{Binding Size}"
Style="{DynamicResource ComboBoxStyle}" >
<ComboBoxItem Content="1½&quot;" Padding="10, 5" IsSelected="True" />
<ComboBoxItem Content="2&quot;" Padding="10, 5" />
SelectedValue="{Binding Size}"
Style="{DynamicResource ComboBoxStyle}"
VerticalContentAlignment="Center">
<ComboBox.ItemTemplate>
<DataTemplate>
<Label Content="{Binding}" Padding="10, 5" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<ComboBox Background="White"
BorderBrush="White"
FontFamily="Consolas"
FontWeight="Bold"
Grid.Column="3"
ItemsSource="{Binding Types}"
Margin="5, 5, 0, 5"
Padding="5"
SelectedValue="{Binding Type}"
SelectedValuePath="Content"
Style="{DynamicResource ComboBoxStyle}" >
<ComboBoxItem Content="C2" Padding="10, 5" IsSelected="True" />
<ComboBoxItem Content="R2" Padding="10, 5" />
<ComboBoxItem Content="T2" Padding="10, 5" />
Style="{DynamicResource ComboBoxStyle}"
VerticalContentAlignment="Center">
<ComboBox.ItemTemplate>
<DataTemplate>
<Label Content="{Binding}" Padding="10, 5" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<CheckBox Content="Korakturfaktor beibehalten?"
<ComboBox Background="White"
BorderBrush="White"
FontFamily="Consolas"
FontWeight="Bold"
Grid.Column="4"
IsChecked="{Binding KeepCorrection}"
Margin="5, 5, 0, 5"
Padding="5, 0"
VerticalAlignment="Center"/>
Padding="5"
SelectedIndex="{Binding ConnectionType}"
Style="{DynamicResource ComboBoxStyle}"
VerticalContentAlignment="Center">
<ComboBoxItem Content="IRDA" Padding="10, 5" IsSelected="True" />
<ComboBoxItem Content="UniPro" Padding="10, 5" />
</ComboBox>
<Button Command="{Binding StartInspection}"
Content="Prüfung starten"
Cursor="Hand"
@@ -111,7 +128,7 @@
CanContentScroll="True"
IsDeferredScrollingEnabled="True"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Hidden">
HorizontalScrollBarVisibility="Auto">
<Local:ItemsGrid ItemsSource="{Binding MetersPool}" Margin="10, 0, 10, 10" />
</ScrollViewer>
</Grid>
@@ -1,37 +0,0 @@
namespace InspectionUI.Models
{
using System;
using System.Collections.Concurrent;
using System.IO;
using static System.Environment;
public class AppLogger
{
private static readonly string app_state = Path.Combine(Appsettings.OutputDirectory, $"{nameof(app_state)}.txt");
private static readonly ConcurrentQueue<object> statesQueue = new ConcurrentQueue<object>();
private static bool dequeuing;
public static void Log(object state)
{
statesQueue.Enqueue(state);
DequeueStates();
}
private static void DequeueStates()
{
if (!dequeuing)
{
dequeuing = true;
while (statesQueue.TryDequeue(out var state))
{
File.AppendAllText(app_state, $"[{DateTime.Now}] {state}{NewLine}");
}
dequeuing = false;
}
}
}
}
@@ -1,17 +1,29 @@
namespace InspectionUI.Models
{
using System;
using System.Configuration;
using System.IO;
public class Appsettings
{
private static readonly string exeLocation
= typeof(App).Assembly.Location;
private static readonly Configuration configuration
= ConfigurationManager.OpenExeConfiguration(exeLocation);
private static readonly KeyValueConfigurationCollection appsettings
= configuration.AppSettings.Settings;
private static string ExeFilePath
{
get => typeof(App).Assembly.Location;
}
private static Configuration ExeConfiguration
{
get => ConfigurationManager.OpenExeConfiguration(ExeFilePath);
}
private static KeyValueConfigurationCollection Settings
{
get => ExeConfiguration.AppSettings.Settings;
}
public static string CurrentDirectory
{
get => new FileInfo(ExeFilePath).DirectoryName;
}
public static string COMPorts
{
@@ -28,30 +40,18 @@
get => GetSetting(nameof(HubURL));
}
public static string OutputDirectory
{
get
{
var currentDirectory = new FileInfo(exeLocation).DirectoryName;
var outputDirectoryToday = Path.Combine(currentDirectory, "Debug", $"{DateTime.Now:yyyy-MM-dd}");
return Directory.CreateDirectory(outputDirectoryToday).FullName;
}
}
public static string PSNR
{
get => GetSetting(nameof(PSNR));
}
private static string GetSetting(string setting)
{
var appsettingsSection = configuration.AppSettings.SectionInformation.Name;
var appsettingsSection = ExeConfiguration.AppSettings.SectionInformation.Name;
ConfigurationManager.RefreshSection(appsettingsSection);
return appsettings[setting].Value;
return Settings[setting].Value;
}
}
}
@@ -0,0 +1,43 @@
<Window x:Class="InspectionUI.PluginsWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:VM="clr-namespace:InspectionUI.ViewModels"
xmlns:Local="clr-namespace:InspectionUI"
FontFamily="Consolas"
Height="450"
Width="800">
<Window.DataContext>
<VM:PluginsVM />
</Window.DataContext>
<ScrollViewer HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<ItemsControl ItemsSource="{Binding ItemsSource}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type VM:PluginVM}">
<Border Background="WhiteSmoke"
BorderBrush="LightGray"
BorderThickness="1"
CornerRadius="3"
Margin="10, 10, 0, 0"
Padding="10">
<StackPanel>
<Label Content="{Binding Title}" FontWeight="Bold" Padding="0, 0, 0, 3" />
<Label Content="{Binding Description}" Padding="0, 0, 0, 3"/>
<Label Content="{Binding Company}" Padding="0, 0, 0, 3" />
<Label Content="{Binding Product}" Padding="0, 0, 0, 3" />
<Label Content="{Binding Copyright}" Padding="0, 0, 0, 3" />
<Label Content="{Binding Trademark}" Padding="0, 0, 0, 3" />
<Label Content="{Binding Culture}" Padding="0, 0, 0, 3" />
<Label Content="{Binding Version}" Padding="0, 0, 0, 3" />
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Window>
@@ -0,0 +1,12 @@
namespace InspectionUI
{
using System.Windows;
public partial class PluginsWindow : Window
{
public PluginsWindow()
{
this.InitializeComponent();
}
}
}
@@ -1,7 +1,5 @@
namespace InspectionUI.ViewModels
{
using InspectionUI.Models;
using OmniPlus;
public class DefaultsHeaderRow : ItemsGridRowVM
@@ -1,7 +1,5 @@
namespace InspectionUI.ViewModels
{
using InspectionUI.Models;
using OmniPlus;
public class DefaultsRowVM : ItemsGridRowVM
@@ -5,7 +5,7 @@
public abstract class ItemsGridVM : VM, IEnumerable<ItemsGridRowVM>
{
private readonly IList<ItemsGridRowVM> rows;
private readonly List<ItemsGridRowVM> rows;
protected ItemsGridVM() : base()
{
@@ -1,8 +1,8 @@
namespace InspectionUI.ViewModels
{
using OmniPlus;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Input;
public class MainVM : VM
@@ -13,13 +13,18 @@
this.Reload = new Command(this.ReloadCommand);
this.StartInspection = new Command(this.StartInspectionCommand);
this.CancelInspection = new Command(this.CancelInspectionCommand);
this.MetersPool = new MetersPoolVM(this.ConnectionType);
this.Sizes = this.MetersPool.LoadSizes();
this.Size = this.Sizes.FirstOrDefault();
this.Types = this.MetersPool.LoadTypes();
this.Type = this.Types.FirstOrDefault();
}
private int size;
public int Size
private string size;
public string Size
{
get => Math.Max(this.size - 5, 0);
set => this.Set(() => this.size = value + 5);
get => this.size;
set => this.Set(() => this.size = value);
}
private string type;
@@ -36,6 +41,13 @@
set => this.Set(() => this.suchnr = value);
}
private int connectionType;
public int ConnectionType
{
get => this.connectionType;
set => this.Set(() => this.connectionType = value);
}
private bool keepCorrection;
public bool KeepCorrection
{
@@ -83,29 +95,40 @@
private set => this.Set(() => this.metersPoolVM = value);
}
public IList<string> Sizes { get; }
public IList<string> Types { get; }
private void ReloadCommand()
{
this.EnableButtons(false);
this.IsReloadEnabled = false;
this.Errors = default(string);
if (this.MetersPool != null)
{
this.MetersPool.Dispose();
}
this.MetersPool = new MetersPoolVM();
if (!string.IsNullOrWhiteSpace(this.SuchNr))
{
this.MetersPool.LoadAuftrag(this.SuchNr);
if (!this.MetersPool.HasPruefpunkte)
{
this.IsReloadEnabled = true;
this.Errors = $"Keine daten gefunden für FertigungauftragsNr: {this.suchnr}";
}
}
else if (this.size >= 0 && !string.IsNullOrWhiteSpace(this.type))
else if (!string.IsNullOrWhiteSpace(this.size) && !string.IsNullOrWhiteSpace(this.type))
{
this.MetersPool.LoadAuftrag((byte)this.size, this.type);
this.MetersPool.LoadAuftrag(this.size, this.type);
if (!this.MetersPool.HasPruefpunkte)
{
this.IsReloadEnabled = true;
this.Errors = $"Keine daten gefunden für Größe: {this.size} und Typ: {this.type}";
}
}
else
{
this.IsReloadEnabled = true;
this.Errors = "FertigungauftragsNr oder Größe und Typ eingeben!";
}
@@ -122,10 +145,6 @@
this.EnableButtons(true);
});
}
else
{
this.EnableButtons(true);
}
}
private void StartInspectionCommand()
@@ -3,6 +3,8 @@
using OmniPlus;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
@@ -10,13 +12,20 @@
public class MeterVM : ItemsGridRowVM
{
private readonly Queue<string> states;
private readonly OmniMeter meter;
private readonly Thread logger;
private int uinr = 0;
private int uinr;
private bool active;
public MeterVM(OmniMeter meter) : base()
{
this.meter = meter;
this.meter.StateChanged += this.Meter_StateChanged;
this.states = new Queue<string>();
this.logger = this.OpenLogging();
this.logger.Start(this);
this.Add(new ItemsGridHeaderVM { Value = $"{this.meter.SlotNr, 2}." });
this.Add(new ItemsGridCellVM());
@@ -56,6 +65,35 @@
set => this.Set(() => this.serialNr = value, value, "{0}", 2);
}
internal Task ConnectAsync(int connectionType, CancellationToken cancellationToken)
{
void Connect(object state)
{
if (state is MeterVM vm)
{
vm.meter.Connect(connectionType);
}
}
return this.StartTask(Connect, cancellationToken);
}
public Task IdentifySelfAsync(CancellationToken cancellationToken)
{
void IdentifySelf(object state)
{
if (state is MeterVM vm)
{
vm.meter.IdentifySelf();
vm.MeterNr = vm.meter.MeterNr;
vm.active = vm.meter.IsActive;
}
}
return this.StartTask(IdentifySelf, cancellationToken);
}
public override void Dispose()
{
try
@@ -64,7 +102,16 @@
}
catch (Exception e)
{
this.meter.NotifyStateChanged($"[{DateTime.Now}] {e}");
this.meter.NotifyStateChanged(e);
}
try
{
this.logger.Abort();
}
catch (Exception)
{
}
base.Dispose();
@@ -74,18 +121,13 @@
{
void LoadTestRun(object state)
{
if (state is MeterVM meterVM)
if (state is MeterVM vm && vm.active)
{
if (!meterVM.meter.IsConnected)
{
return;
}
meterVM.meter.LoadTestRun();
vm.meter.LoadTestRun();
}
}
return this.StartNewTask(LoadTestRun, this, cancellationToken);
return this.StartTask(LoadTestRun, cancellationToken);
}
public Task InitializeInspectionAsync(bool keepCorrection, CancellationToken cancellationToken)
@@ -97,87 +139,67 @@
void InitializeInspection(object state)
{
if (state is MeterVM meterVM)
if (state is MeterVM vm && vm.active)
{
meterVM.uinr = 0;
vm.uinr = 0;
var meter = meterVM.meter;
if (!meter.IsConnected)
{
return;
}
var meter = vm.meter;
meter.InitializeForInspection(keepCorrection);
meterVM.Set(meter.TestRun.CrrfBefore, "{0:0.0}", 3);
vm.Set(meter.TestRun.CrrfBefore, "{0:0.0}", 3);
}
}
return this.StartNewTask(InitializeInspection, this, cancellationToken);
return this.StartTask(InitializeInspection, cancellationToken);
}
public Task StartCalibrationAsync(OmniPruefpunkt pp, CancellationToken cancellationToken)
{
void StartCalibration(object state)
{
if (state is MeterVM meterVM)
if (state is MeterVM vm && vm.active)
{
meterVM.uinr++;
vm.uinr++;
var _pp = pp;
var meter = meterVM.meter;
if (!meter.IsConnected)
{
return;
}
var meter = vm.meter;
meter.StartCalibration((ushort)_pp.Rotations, (ushort)_pp.Duration);
meterVM.ShowRestTime(_pp.Duration, meterVM.uinr * 3 + 1);
vm.ShowRestTime(_pp.Duration, vm.uinr * 3 + 1);
}
}
return this.StartNewTask(StartCalibration, this, cancellationToken);
return this.StartTask(StartCalibration, cancellationToken);
}
public Task StopCalibrationAsync(OmniPruefpunkt pp, double refm3s, CancellationToken cancellationToken)
{
void StopCalibration(object state)
{
if (state is MeterVM meterVM)
if (state is MeterVM vm && vm.active)
{
var _pp = pp;
var meter = meterVM.meter;
if (!meter.IsConnected)
{
return;
}
var meter = vm.meter;
var response = meter.StopCalibration(_pp, refm3s);
var index = meterVM.uinr * 3 + 1;
var index = vm.uinr * 3 + 1;
meterVM.Set(response.Item2, "{0}", index);
meterVM.Set(response.Item1, "{0:0.0000000}", index + 1);
meterVM.Set(response.Item3, "{0:0.00}", index + 2);
vm.Set(response.Item2, "{0}", index);
vm.Set(response.Item1, "{0:0.0000000}", index + 1);
vm.Set(response.Item3, "{0:0.00}", index + 2);
}
}
return this.StartNewTask(StopCalibration, this, cancellationToken);
return this.StartTask(StopCalibration, cancellationToken);
}
public Task FinishInspectionAsync(CancellationToken cancellationToken)
{
void FinishInspection(object state)
{
if (state is MeterVM meterVM)
if (state is MeterVM vm && vm.active)
{
var meter = meterVM.meter;
if (!meter.IsConnected)
{
return;
}
var meter = vm.meter;
meter.FinishInspection();
@@ -186,16 +208,16 @@
? Brushes.Green
: Brushes.Red;
meterVM.Set(x => x.Foreground = foreground, meterVM.LastIndex);
meterVM.Set(crrf, "{0:0.0}", meterVM.LastIndex);
meterVM.uinr = 1;
vm.Set(x => x.Foreground = foreground, vm.LastIndex);
vm.Set(crrf, "{0:0.0}", vm.LastIndex);
vm.uinr = 1;
foreach (var testedPP in meter.TestRun.TestedPoints)
{
var index = meterVM.uinr * 3 + 1 + 2;
var index = vm.uinr * 3 + 1 + 2;
meterVM.Set(testedPP.Acc, "{0:0.00}", index);
meterVM.Set(x =>
vm.Set(testedPP.Acc, "{0:0.00}", index);
vm.Set(x =>
{
foreground = testedPP.Succeeded == true
? Brushes.Green
@@ -203,12 +225,12 @@
x.Foreground = foreground;
}, index);
meterVM.uinr++;
vm.uinr++;
}
}
}
return this.StartNewTask(FinishInspection, this, cancellationToken);
return this.StartTask(FinishInspection, cancellationToken);
}
private void ShowRestTime(int duration, int index)
@@ -246,5 +268,49 @@
this.Set(default(string), "{0}", index);
}
private Task StartTask(Action<object> executable, CancellationToken cancellationToken)
{
return this
.StartNewTask(executable, this, cancellationToken)
.ContinueWith(t =>
{
if (t.Exception != null && t.AsyncState is MeterVM vm)
{
vm.meter.NotifyStateChanged(t.Exception);
}
});
}
private void Meter_StateChanged(object state)
{
this.states.Enqueue($"[{DateTime.Now:HH:mm:ss.fff}] {state}{Environment.NewLine}");
}
private Thread OpenLogging()
{
return new Thread(state =>
{
if (state is MeterVM vm)
{
var root = Directory.CreateDirectory(App.CurrentDirectory);
var ps = root.CreateSubdirectory($"{vm.meter.PSNR ?? "0000"}");
var slot = ps.CreateSubdirectory($"{vm.meter.SlotNr}");
var file = Path.Combine(slot.FullName, $"{DateTime.Now:yyyyMMddHHmmss}.txt");
var awaiter = new ManualResetEventSlim();
while (true)
{
while (vm.states.Count > 0)
{
File.AppendAllText(file, vm.states.Dequeue());
}
awaiter.Wait(1000);
awaiter.Reset();
}
}
});
}
}
}
@@ -4,6 +4,7 @@
using OmniPlus;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@@ -12,19 +13,34 @@
public class MetersPoolVM : ItemsGridVM
{
private readonly OmniContext omniContext;
private readonly int connectionType;
private CancellationTokenSource cancellationTokenSource;
private ReferenceMeterVM referenceMeter;
public MetersPoolVM() : base()
public MetersPoolVM(int connectionType) : base()
{
this.omniContext = OmniContext.Current;
this.connectionType = connectionType;
this.omniContext = OmniContext.Create(Appsettings.OmniDB, Appsettings.CurrentDirectory);
}
public Boolean HasPruefpunkte { get; private set; }
internal IList<String> LoadTypes()
{
return this.omniContext.LoadTypes();
}
internal IList<String> LoadSizes()
{
return this.omniContext.LoadSizes();
}
public void CancelInspection()
{
this.cancellationTokenSource?.Cancel();
this.referenceMeter?.Stop();
this.Dispose();
}
public override void Dispose()
@@ -36,9 +52,15 @@
public void LoadMetersAsync()
{
if (!this.HasPruefpunkte)
{
return;
}
this.referenceMeter = new ReferenceMeterVM(OmniContext.Current);
this.Add(this.referenceMeter);
this.omniContext.LoadMeters(Appsettings.COMPorts, Appsettings.PSNR);
foreach (var meter in this.omniContext.Meters)
@@ -47,32 +69,55 @@
}
this.NotifyPropertyChanged();
this.cancellationTokenSource = new CancellationTokenSource();
var cancellationToken = this.cancellationTokenSource.Token;
var tasks = new List<Task>();
var metersVM = this
.Select(x => x is MeterVM m ? m : null)
.Where(x => x != null)
.ToArray();
foreach (var vm in metersVM)
{
tasks.Add(vm.ConnectAsync(this.connectionType, cancellationToken));
}
this.WaitAll(tasks);
foreach (var vm in metersVM)
{
tasks.Add(vm.IdentifySelfAsync(cancellationToken));
}
this.WaitAll(tasks);
this.NotifyPropertyChanged();
}
public void RunInspection(bool keepCorrection = false)
{
// show reference meter seconds
this.cancellationTokenSource = new CancellationTokenSource();
var cancellationToken = this.cancellationTokenSource.Token;
var tasks = new List<Task>();
var meters = this
var metersVM = this
.Select(x => x is MeterVM m ? m : null)
.Where(x => x != null)
.ToArray();
foreach (var meterVM in meters)
foreach (var vm in metersVM)
{
tasks.Add(meterVM.LoadTestRunAsync(cancellationToken));
tasks.Add(vm.LoadTestRunAsync(cancellationToken));
}
this.ContinueWhenAll(tasks);
this.WaitAll(tasks);
foreach (var meterVM in meters)
foreach (var vm in metersVM)
{
tasks.Add(meterVM.InitializeInspectionAsync(keepCorrection, cancellationToken));
tasks.Add(vm.InitializeInspectionAsync(keepCorrection, cancellationToken));
}
this.ContinueWhenAll(tasks);
this.WaitAll(tasks);
var pruefpunkte = this.omniContext
.Auftrag
@@ -92,12 +137,12 @@
break;
}
foreach (var meterVM in meters)
foreach (var vm in metersVM)
{
tasks.Add(meterVM.StartCalibrationAsync(pp, cancellationToken));
tasks.Add(vm.StartCalibrationAsync(pp, cancellationToken));
}
this.ContinueWhenAll(tasks);
this.WaitAll(tasks);
if (cancellationToken.IsCancellationRequested)
{
@@ -111,12 +156,12 @@
break;
}
foreach (var meterVM in meters)
foreach (var vm in metersVM)
{
tasks.Add(meterVM.StopCalibrationAsync(pp, refm3s, cancellationToken));
tasks.Add(vm.StopCalibrationAsync(pp, refm3s, cancellationToken));
}
this.ContinueWhenAll(tasks);
this.WaitAll(tasks);
if (cancellationToken.IsCancellationRequested)
{
@@ -126,26 +171,42 @@
this.referenceMeter.Stop();
foreach (var meterVM in meters)
foreach (var vm in metersVM)
{
tasks.Add(meterVM.FinishInspectionAsync(cancellationToken));
tasks.Add(vm.FinishInspectionAsync(cancellationToken));
}
this.ContinueWhenAll(tasks);
this.WaitAll(tasks);
}
internal void LoadAuftrag(byte size, string type)
internal void LoadAuftrag(string size, string type)
{
this.Dispose();
this.NotifyPropertyChanged();
this.omniContext.LoadAuftrag(size, type);
this.UpdateItemsGridHeaders();
this.HasPruefpunkte = this.omniContext.Pruefpunkte.Any();
if (this.HasPruefpunkte)
{
this.UpdateItemsGridHeaders();
}
}
internal void LoadAuftrag(string suchNr)
{
this.Dispose();
this.NotifyPropertyChanged();
this.omniContext.LoadAuftrag(suchNr);
this.UpdateItemsGridHeaders();
this.HasPruefpunkte = this.omniContext.Pruefpunkte.Any();
if (this.HasPruefpunkte)
{
this.UpdateItemsGridHeaders();
}
}
private void UpdateItemsGridHeaders()
@@ -0,0 +1,206 @@
namespace InspectionUI.ViewModels
{
using InspectionUI.Models;
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Reflection;
public class PluginsVM : VM
{
const string Plugins = nameof(Plugins);
const string Abstraction = nameof(Abstraction);
private readonly FileSystemWatcher fileSystemWatcher;
private readonly DirectoryInfo pluginsDirectory;
private readonly string basePlugin;
public PluginsVM()
{
var pluginsPath = Path.Combine(Appsettings.CurrentDirectory, Plugins);
this.pluginsDirectory = Directory.CreateDirectory(pluginsPath);
this.basePlugin = Path.Combine(this.pluginsDirectory.Parent.FullName, $"{Plugins}.{Abstraction}.dll");
this.fileSystemWatcher = new FileSystemWatcher()
{
Path = this.pluginsDirectory.FullName,
EnableRaisingEvents = true,
Filter = $"{Plugins}.*.dll",
IncludeSubdirectories = false,
NotifyFilter = NotifyFilters.CreationTime
| NotifyFilters.FileName,
};
this.fileSystemWatcher.Created += this.FileSystemWatcher_PluginAdded;
this.fileSystemWatcher.Deleted += this.FileSystemWatcher_PluginDeleted;
this.fileSystemWatcher.Changed += this.FileSystemWatcher_PluginUpdated;
this.fileSystemWatcher.Renamed += this.FileSystemWatcher_PluginUpdated;
this.ItemsSource = new ObservableCollection<PluginVM>();
this.LoadExistingPlugins();
}
public ObservableCollection<PluginVM> ItemsSource { get; }
private void FileSystemWatcher_PluginAdded(object sender, FileSystemEventArgs args)
{
if (args.ChangeType == WatcherChangeTypes.Created)
{
var plugin = this.LoadPlugin(args.FullPath);
if (plugin != null)
{
this.DispatcherInvoke(() =>
{
this.ItemsSource.Add(plugin);
});
}
}
}
private void FileSystemWatcher_PluginUpdated(object sender, FileSystemEventArgs args)
{
if (args.ChangeType == WatcherChangeTypes.Changed || args.ChangeType == WatcherChangeTypes.Renamed)
{
var plugin = this.LoadPlugin(args.FullPath);
if (plugin != null)
{
this.DispatcherInvoke(() =>
{
this.ItemsSource.Add(plugin);
});
}
}
}
private void FileSystemWatcher_PluginDeleted(object sender, FileSystemEventArgs args)
{
if (args.ChangeType == WatcherChangeTypes.Deleted)
{
var plugin = this.ItemsSource.FirstOrDefault(x => x.Path == args.FullPath);
if (plugin != null)
{
this.DispatcherInvoke(() =>
{
this.ItemsSource.Remove(plugin);
});
}
}
}
private void LoadExistingPlugins()
{
foreach (var fileInfo in this.pluginsDirectory.GetFiles())
{
if (fileInfo.Name.StartsWith(Plugins) && fileInfo.Extension.EndsWith("dll"))
{
var plugin = this.LoadPlugin(fileInfo.FullName);
if (plugin != null)
{
this.DispatcherInvoke(() =>
{
this.ItemsSource.Add(plugin);
});
}
}
}
}
private PluginVM LoadPlugin(string pluginDLL)
{
if (pluginDLL == this.basePlugin)
{
return default(PluginVM);
}
try
{
var domain = AppDomain.CreateDomain($"{Guid.NewGuid()}");
//var abstraction = domain.Load(new AssemblyName { CodeBase = this.basePlugin });
var plugin = domain.Load(new AssemblyName { CodeBase = pluginDLL });
var pluginAttributes = plugin.GetCustomAttributes(true);
var pluginVM = new PluginVM
{
Path = pluginDLL,
Version = plugin.GetName().Version.ToString()
};
var pluginVMProperties = typeof(PluginVM)
.GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (var property in pluginVMProperties)
{
var propertyName = property.Name;
try
{
if (property.GetValue(pluginVM, null) is null)
{
foreach (var attribute in pluginAttributes)
{
var attributeType = attribute.GetType();
if (attributeType.Name == $"Assembly{propertyName}Attribute")
{
var attributeProperty = attributeType.GetProperty(propertyName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
if (attributeProperty != null)
{
var attributeValue = attributeType
.GetProperty(propertyName)
?.GetValue(attribute, null)
?.ToString();
property.SetValue(pluginVM, attributeValue, null);
}
}
}
}
}
catch (Exception e)
{
}
}
try
{
AppDomain.Unload(domain);
}
catch (Exception e)
{
}
return pluginVM;
}
catch (Exception e)
{
return default(PluginVM);
}
}
}
public class PluginVM : VM
{
public string Path { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string Company { get; set; }
public string Product { get; set; }
public string Copyright { get; set; }
public string Trademark { get; set; }
public string Culture { get; set; }
public string Version { get; set; }
}
}
@@ -22,7 +22,6 @@
{
this.omniContext = omniContext;
this.signarR = new ExchangeConnection();
this.signarR.StateChanged += this.SignarR_StateChanged;
this.signarR.Connect(Appsettings.HubURL);
this.ppnr = 1;
@@ -193,8 +192,6 @@
waitHandle.Wait(timeout * interval);
waitHandle.Reset();
// OmniPlusFormulas.OutDebugM3S(ref referenceV);
this.signarR.StopReferenceMessurement -= ReceiveFlow;
timer.Elapsed -= TimerElapsed;
@@ -220,19 +217,14 @@
this.signarR.SendStopFlow();
this.signarR.Disconnect();
}
catch (Exception e)
catch (Exception)
{
AppLogger.Log($"[...] {e}");
}
base.Dispose();
}
private void SignarR_StateChanged(string value, string groupName)
{
AppLogger.Log($"[{groupName}] {value}");
}
private void LoadHeaders()
{
this.DispatcherInvoke(() =>
+3 -27
View File
@@ -1,7 +1,5 @@
namespace InspectionUI.ViewModels
{
using InspectionUI.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -28,7 +26,7 @@
App.Exiting -= this.Dispose;
}
protected void ContinueWhenAll(List<Task> tasks, Action continuationCallback = null)
protected void WaitAll(List<Task> tasks, Action continuationCallback = null)
{
if (tasks is null || tasks.Count == 0)
{
@@ -38,14 +36,6 @@
Task.Factory
.ContinueWhenAll(tasks.ToArray(), _tasks =>
{
foreach (var task in _tasks)
{
if (task.Exception != null)
{
AppLogger.Log(task.Exception);
}
}
tasks.Clear();
continuationCallback?.Invoke();
})
@@ -89,28 +79,14 @@
{
return Task
.Factory
.StartNew(action, cancellationToken)
.ContinueWith(task =>
{
if (task.Exception != null)
{
AppLogger.Log(task.Exception);
}
}, cancellationToken);
.StartNew(action, cancellationToken);
}
protected Task StartNewTask(Action<object> action, object state, CancellationToken cancellationToken = default(CancellationToken))
{
return Task
.Factory
.StartNew(action, state, cancellationToken)
.ContinueWith(task =>
{
if (task.Exception != null)
{
AppLogger.Log(task.Exception);
}
}, cancellationToken);
.StartNew(action, state, cancellationToken);
}
protected class Command : ICommand
@@ -27,12 +27,16 @@
{
get
{
if (this.IsOpen)
try
{
return this.serialPort.BytesToRead;
}
catch (Exception e)
{
this.NotifyStateChanged($"--- {e}");
return default(int);
return default(int);
}
}
}
@@ -40,17 +44,23 @@
{
get
{
if (this.serialPort is null)
try
{
return false;
return this.serialPort.IsOpen;
}
catch (Exception e)
{
this.NotifyStateChanged($"--- {e}");
return this.serialPort.IsOpen;
return default(bool);
}
}
}
public virtual void Close()
{
this.DiscardInOut();
try
{
if (this.serialPort != null)
@@ -90,6 +100,8 @@
{
this.NotifyStateChanged($"--- {e}");
}
this.DiscardInOut();
}
public override string ToString()
@@ -121,16 +133,51 @@
protected void Read(byte[] bytes, int start, int length)
{
this.serialPort.Read(bytes, start, length);
try
{
this.serialPort.Read(bytes, start, length);
}
catch (Exception e)
{
this.NotifyStateChanged($"--- {e}");
}
}
protected void Write(byte[] bytes, int start, int length)
{
var lock_object = new object();
lock (lock_object)
try
{
this.serialPort.Write(bytes, 0, length);
var lock_object = new object();
lock (lock_object)
{
this.serialPort.Write(bytes, 0, length);
}
}
catch (Exception e)
{
this.NotifyStateChanged($"--- {e}");
}
}
private void DiscardInOut()
{
try
{
this.serialPort.DiscardInBuffer();
}
catch (Exception e)
{
this.NotifyStateChanged($"--- {e}");
}
try
{
this.serialPort.DiscardOutBuffer();
}
catch (Exception e)
{
this.NotifyStateChanged($"--- {e}");
}
}
}
@@ -1,29 +1,37 @@
namespace OmniPlus.Inspection
{
using System;
using System.Linq;
public static class OmniPlusFormulas
{
public static double MilliliterPerRotation(byte intPart, ushort fraction, short correctionFactor)
public static double MilliliterPerPulse(int intPart, int fraction, int correctionFactor)
{
const int FRACTION_FACTOR = ushort.MaxValue + 1;
const int PULSES_PER_ROTATION = 8;
var fractionPart = (double)fraction / FRACTION_FACTOR;
var mlPulse = intPart + fractionPart;
var mlr = mlPulse * PULSES_PER_ROTATION;
if (double.IsNaN(mlr) || double.IsInfinity(mlr))
if (double.IsNaN(mlPulse) || double.IsInfinity(mlPulse))
{
return default(double);
}
return mlr;
return mlPulse;
}
public static double MilliliterPerRotation(this OmniPlusType type)
public static double MilliliterPerRotation(byte intPart, int fraction, short correctionFactor)
{
return MilliliterPerRotation(type.IntPart, type.Fraction, type.CorrectionFactor);
const int PULSES_PER_ROTATION = 8;
var mlPerRotation = MilliliterPerPulse(intPart, fraction, correctionFactor) * PULSES_PER_ROTATION;
if (double.IsNaN(mlPerRotation) || double.IsInfinity(mlPerRotation))
{
return default(double);
}
return mlPerRotation;
}
public static double GPM2M3H(this double gal_min)
@@ -123,66 +131,74 @@
return m3s;
}
public static double MeterFlowM3S(this OmniPlusTestPoint point, OmniPlusTest test)
{
return MeterFlowM3S(test.Rotations, point.MLR, test.Duration);
}
public static double GetCorrectionFactor(this double[] points, out bool succeeded)
public static double GetCalibrationFactor(this double[] points, out bool succeeded)
{
succeeded = false;
var crrf = default(double);
var crrf = 0D;
if (points is null || points.Length != 3)
if (points is null || points.Length < 3)
{
return crrf;
}
var teil = points.Skip(1);
var min = points[0];
var mid = points[1];
var max = points[2];
var _min = teil.Min();
var _avg = teil.Average();
var _max = teil.Max();
if (min == 0 || mid == 0 || max == 0)
if (Math.Abs(_max - _min) <= 3 && Math.Abs(_max - min) <= 6.5)
{
return crrf;
}
if (Math.Abs(mid - max) <= 3 && Math.Max(mid, max) - min <= 6.5)
{
var avgMidMax = (mid + max) / 2;
if (100 - avgMidMax + min < 95)
if (100 - _avg + min < 95)
{
crrf = 95 - min;
}
else
{
crrf = 100 - avgMidMax;
crrf = 100 - _avg;
}
succeeded = Math.Abs(crrf) <= 12;
}
else
{
var avgMidMax = (mid + max) / 2;
if (100 - avgMidMax + min < 95)
if (double.IsNaN(crrf) || double.IsInfinity(crrf))
{
crrf = 95 - min;
crrf = 0D;
}
else
{
crrf = 100 - avgMidMax;
}
}
if (double.IsNaN(crrf) || double.IsInfinity(crrf))
{
crrf = default(double);
}
return crrf;
}
public static int CalculateTargetDuration(this OmniPruefpunkt pp)
{
if (pp != null && pp.Defaults != null)
{
var m3h = pp.FlowM3H;
var m3s = m3h / 3600;
var rotations = pp.Rotations;
var defaults = pp.Defaults;
var mlPerPulse = MilliliterPerRotation(defaults.IntPart, defaults.Fraction, defaults.Factor);
var secondsPerRotation = mlPerPulse / m3s * 100;
var duration = secondsPerRotation * rotations;
if (double.IsNaN(duration) || double.IsInfinity(duration))
{
duration = 0;
}
return (int)(Math.Truncate(duration) + 1);
}
return default(int);
}
public static double OrRandom(this double value)
{
//if (value == 0)
//{
// return 0.0456 * (1 + new Random().Next(1, 3) / 100D);
//}
return value;
}
}
}
@@ -1,44 +0,0 @@
namespace OmniPlus.Inspection
{
using System;
public struct OmniPlusTestPoint : IComparable<OmniPlusTestPoint>
{
private double gpm;
public double GPM
{
get => this.gpm;
set
{
this.gpm = value;
this.RequiredFlowM3H = this.gpm.GPM2M3H();
}
}
public ushort rotations;
public ushort Rotations
{
get => this.rotations;
set
{
this.rotations = value;
this.Duration = this.rotations.DurationInSeconds(this.MLR, this.RequiredFlowM3H);
}
}
public double MLR { get; set; }
public ushort Duration { get; set; }
public double MinDiff { get; set; }
public double MaxDiff { get; set; }
public double RequiredFlowM3H { get; private set; }
public int CompareTo(OmniPlusTestPoint other)
{
return this.GPM.CompareTo(other.GPM);
}
}
}
@@ -1,51 +0,0 @@
namespace OmniPlus.Inspection
{
using OmniPlus.Features;
using System.Collections.Generic;
public class OmniPlusType
{
public byte OmniId { get; set; }
public byte Size
{
get => this.InputVolume.Size;
set => this.InputVolume.Size = value;
}
public byte Range
{
get => this.InputVolume.Range;
set => this.InputVolume.Range = value;
}
public byte Direction
{
get => this.InputVolume.Direction;
set => this.InputVolume.Direction = value;
}
public byte IntPart
{
get => this.InputVolume.IntPart;
set => this.InputVolume.IntPart = value;
}
public ushort Fraction
{
get => this.InputVolume.Fraction;
set => this.InputVolume.Fraction = value;
}
public double PulsePerRotation { get; set; }
public short CorrectionFactor { get; set; }
public InputVolume InputVolume { get; }
= new InputVolume();
public List<OmniPlusTestPoint> TestPoints { get; }
= new List<OmniPlusTestPoint>();
}
}
+28 -50
View File
@@ -1,39 +1,26 @@
namespace OmniPlus
{
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading;
using System.Threading.Tasks;
public class OmniContext : IDisposable
{
private readonly ConcurrentDictionary<int, OmniMeter> meters;
private IDictionary<int, OmniMeter> meters;
private readonly OmniDatabase database;
private readonly string outputDirectory;
private int slotNr;
public static void Create(String omniDB, String outputDirectory)
{
Current = new OmniContext(omniDB, outputDirectory);
}
private int runId;
private OmniContext(string connectionString, string outputDirectory)
{
this.outputDirectory = outputDirectory;
this.meters = new Dictionary<int, OmniMeter>();
this.database = new OmniDatabase(connectionString, outputDirectory);
this.meters = new ConcurrentDictionary<int, OmniMeter>();
}
public OmniAuftrag Auftrag { get; set; }
public OmniParameter Defaults
{
get => this.Auftrag?.TypParameter ?? new OmniParameter();
get => this.Auftrag?.TypeParameters ?? new OmniParameter();
}
public IEnumerable<OmniPruefpunkt> Pruefpunkte
@@ -41,14 +28,19 @@
get => this.Auftrag?.Pruefpunkte ?? new OmniPruefpunkt[] { };
}
public ReadOnlyCollection<OmniMeter> Meters
public IList<String> LoadTypes()
{
get => this.meters.Values as ReadOnlyCollection<OmniMeter>;
return this.database.LoadTypes();
}
public void Add(string meterNr, string meterState)
public IList<String> LoadSizes()
{
_ = this.database.OmniPlus_Insert(meterNr, meterState);
return this.database.LoadSizes();
}
public IEnumerable<OmniMeter> Meters
{
get => this.meters.Values;
}
public OmniPruefgang AddTestRun(string psnr, int slotnr, string meterNr)
@@ -66,18 +58,13 @@
this.meters.Clear();
}
public bool Exists(string meterNr)
{
return this.database.OmniPlus_Exists(meterNr);
}
public void LoadAuftrag(string suchnr)
{
this.Auftrag = this.database.LoadAuftrag(suchnr);
this.runId = this.database.GetNextRunId();
}
public void LoadAuftrag(byte size, string type)
public void LoadAuftrag(string size, string type)
{
this.Auftrag = this.database.LoadAuftrag(size, type);
this.runId = this.database.GetNextRunId();
@@ -85,34 +72,18 @@
public void LoadMeters(string portNames, string psnr)
{
this.Dispose();
this.meters?.Clear();
this.meters = new Dictionary<int, OmniMeter>();
this.slotNr = 1;
var portnames = portNames.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
var length = portnames.Length;
var slotNr = default(int);
var i = default(int);
var tasks = new List<Task>();
foreach (var portName in portNames.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries))
for (i = 0, slotNr = 1; i < length; i++, slotNr++)
{
tasks
.Add(Task.Factory
.StartNew(state =>
{
if (state is OmniContext context)
{
var meter = new OmniMeter(psnr, context.slotNr, portName, context.outputDirectory);
meter.ConnectIrda();
context.meters.AddOrUpdate(slotNr, meter, (_, _1) => meter);
}
}, this, CancellationToken.None));
slotNr++;
this.meters[slotNr] = new OmniMeter(psnr, slotNr, portnames[i]);
}
Task.Factory
.ContinueWhenAll(tasks.ToArray(), _ => { })
.Wait();
}
internal int UpdateTestRun(IDictionary<string, object> parameters, int id, byte slotNr)
@@ -121,5 +92,12 @@
}
public static OmniContext Current { get; private set; }
public static OmniContext Create(String omniDB, String outputDirectory)
{
Current = new OmniContext(omniDB, outputDirectory);
return Current;
}
}
}
+63 -28
View File
@@ -61,11 +61,15 @@
, [OTP].[Duration] -- 24
, [OTP].[MinAccuracy] -- 25
, [OTP].[MaxAccuracy] -- 26
FROM [AlleAuftragPositionen] AS [APP]
JOIN [Identnr] AS [IDN] ON [IDN].[IdentNr] = [APP].[IdentNr]
JOIN [OmniTypes] AS [OT] ON [IDN].[Typzusatz] LIKE '%' + [OT].[Type] + '%'
JOIN [OmniTestPoints] AS [OTP] ON [OTP].[OmniTypeId] = [OT].[TypeId] AND [IDN].[Typzusatz] LIKE '%' + [OTP].[OmniVariant] + '%'
WHERE [APP].[FertigungsauftragNr] = @{nameof(suchNr)}
FROM [AlleAuftragPositionen] AS [APP]
JOIN [Identnr] AS [IDN]
ON [IDN].[IdentNr] = [APP].[IdentNr]
JOIN [OmniTypes] AS [OT]
ON REPLACE([IDN].[Typzusatz], '²', '2') LIKE '%' + REPLACE([OT].[Type], '²', '2') + '%'
JOIN [OmniTestPoints] AS [OTP]
ON [OTP].[OmniTypeId] = [OT].[TypeId]
AND REPLACE([IDN].[Typzusatz], '²', '2') LIKE '%' + REPLACE([OTP].[OmniVariant], '²', '2') + '%'
WHERE [APP].[FertigungsauftragNr] = @{nameof(suchNr)}
ORDER BY [OTP].[GalPerMin] DESC")
.SetParameter(nameof(suchNr), suchNr)
.ExecuteReader(reader =>
@@ -89,9 +93,9 @@
};
}
if (auftrag.TypParameter is null)
if (auftrag.TypeParameters is null)
{
auftrag.TypParameter = new OmniParameter
auftrag.TypeParameters = new OmniParameter
{
TypeId = reader.GetTinyint(10),
Type = reader.GetString(11),
@@ -120,19 +124,41 @@
Duration = reader.GetSmallint(24),
MinAccuracy = reader.GetValue<double>(25),
MaxAccuracy = reader.GetValue<double>(26),
Defaults = auftrag.TypeParameters
});
});
if (auftrag is null)
{
auftrag = new OmniAuftrag
{
TypeParameters = new OmniParameter(),
Pruefpunkte = new List<OmniPruefpunkt>()
};
}
auftrag.GiveAllTestPointsNr();
return auftrag ?? new OmniAuftrag
{
TypParameter = new OmniParameter(),
Pruefpunkte = new List<OmniPruefpunkt>()
};
return auftrag;
}
public OmniAuftrag LoadAuftrag(byte size, string variant)
internal IList<string> LoadTypes()
{
return this.sqlConnection
.CreateCommand("SELECT DISTINCT [OmniVariant] FROM [OmniTestPoints] ORDER BY 1")
.ExecuteReader(reader => reader.GetString()?.Trim())
.ToList();
}
internal IList<string> LoadSizes()
{
return this.sqlConnection
.CreateCommand("SELECT [Type] FROM [OmniTypes] ORDER BY [TypeId]")
.ExecuteReader(reader => reader.GetString()?.Trim())
.ToList();
}
public OmniAuftrag LoadAuftrag(string sizeName, string variant)
{
var auftrag = default(OmniAuftrag);
@@ -155,13 +181,13 @@
, [OTP].[Duration] -- 14
, [OTP].[MinAccuracy] -- 15
, [OTP].[MaxAccuracy] -- 16
FROM [OmniTypes] AS [OT]
JOIN [OmniTestPoints] AS [OTP]
ON [OTP].[OmniTypeId] = [OT].[TypeId]
WHERE [OT].[Size] = @{nameof(size)}
AND [OTP].[OmniVariant] = @{nameof(variant)}
ORDER BY [OTP].[GalPerMin] DESC")
.SetParameter(nameof(size), size)
FROM [OmniTypes] AS [OT]
JOIN [OmniTestPoints] AS [OTP]
ON [OTP].[OmniTypeId] = [OT].[TypeId]
WHERE LTRIM(RTRIM([OT].[Type])) = @{nameof(sizeName)}
AND LTRIM(RTRIM([OTP].[OmniVariant])) = @{nameof(variant)}
ORDER BY[OTP].[GalPerMin] DESC")
.SetParameter(nameof(sizeName), sizeName)
.SetParameter(nameof(variant), variant)
.ExecuteReader(reader =>
{
@@ -174,9 +200,9 @@
};
}
if (auftrag.TypParameter is null)
if (auftrag.TypeParameters is null)
{
auftrag.TypParameter = new OmniParameter
auftrag.TypeParameters = new OmniParameter
{
TypeId = reader.GetTinyint(0),
Type = reader.GetString(1),
@@ -208,13 +234,18 @@
});
});
if (auftrag is null)
{
auftrag = new OmniAuftrag
{
TypeParameters = new OmniParameter(),
Pruefpunkte = new List<OmniPruefpunkt>()
};
}
auftrag.GiveAllTestPointsNr();
return auftrag ?? new OmniAuftrag
{
TypParameter = new OmniParameter(),
Pruefpunkte = new List<OmniPruefpunkt>()
};
return auftrag;
}
public OmniPruefgang AddTestRun(int id, string psnr, int slotnr, string buildInfo)
@@ -307,7 +338,7 @@
public int Nennweite { get; internal set; }
public OmniParameter TypParameter { get; internal set; }
public OmniParameter TypeParameters { get; internal set; }
public ICollection<OmniPruefpunkt> Pruefpunkte { get; internal set; }
= new List<OmniPruefpunkt>();
@@ -365,6 +396,10 @@
public double MinAccuracy { get; internal set; }
public double FlowM3H => this.GalPerMin.GPM2M3H();
public int TargetDuration => this.CalculateTargetDuration();
public OmniParameter Defaults { get; internal set; }
}
public class OmniPruefgang : Dictionary<string, object>
-11
View File
@@ -1,11 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OmniPlus
{
class OmniLogger
{
}
}
+27 -177
View File
@@ -5,34 +5,29 @@
using OmniPlus.Inspection;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
public class OmniMeter
{
const string NA = "n/a";
private readonly ConcurrentQueue<object> states = new ConcurrentQueue<object>();
private readonly OmniParameter defaults;
private readonly string outputDirectory;
private readonly string outputFile;
private OmniConnection connection;
private bool factorySealed;
public OmniMeter(string psnr, int nr, string portName, string outputDirectory)
public OmniMeter(string psnr, int nr, string portName)
{
this.PSNR = psnr;
this.SlotNr = nr;
this.PortName = portName;
this.outputDirectory = outputDirectory;
this.outputFile = GetOrCreateOutputFile(nr, portName, outputDirectory);
this.defaults = OmniContext.Current.Defaults;
}
public event Action<object> StateChanged;
public string PSNR { get; }
public int SlotNr { get; }
@@ -45,13 +40,21 @@
public OmniPruefgang TestRun { get; private set; }
public Boolean IsConnected { get; set; }
public bool IsActive { get; private set; }
public void ConnectIrda()
public void Connect(int connectionType = 0)
{
if (this.connection is null)
{
this.connection = new OmniIrdaConnection(this.PortName);
if (connectionType == 1)
{
this.connection = new OmniUniProConnection(this.PortName);
}
else
{
this.connection = new OmniIrdaConnection(this.PortName);
}
this.connection.StateChenged += this.NotifyStateChanged;
}
@@ -60,28 +63,28 @@
this.connection.Close();
this.connection.Open();
}
}
public void IdentifySelf()
{
var buildInfo = this.connection.ViewBuildInformation();
if (buildInfo.Status == Status.Completed)
{
this.MeterNr = buildInfo.Value;
this.IsActive = true;
if (string.IsNullOrWhiteSpace(this.MeterNr))
{
this.MeterNr = new string('.', 12);
}
else
{
this.IsConnected = true;
this.IsActive = false;
}
}
else
{
this.MeterNr = NA;
this.IsActive = false;
}
this.WriteToLog();
}
public void Dispose()
@@ -94,13 +97,6 @@
}
this.connection = null;
this.WriteToLog();
}
public void SaveCorrection()
{
}
public void InitializeForInspection(bool keepCorrection = false)
@@ -144,126 +140,34 @@
this.TestRun.CrrfBefore = this.connection.ViewFactoryCorrection();
this.TestRun.SaveChanges();
this.WriteToLog();
}
public void LoadTestRun()
{
this.TestRun = OmniContext.Current.AddTestRun(this.PSNR, this.SlotNr, this.MeterNr);
this.WriteToLog();
}
public void SaveMeterState()
{
if (this.MeterNr == NA)
{
return;
}
if (OmniContext.Current.Exists(this.MeterNr))
{
return;
}
var commands = new List<byte[]>
{
new byte[] { 0x01 },
new byte[] { 0x03 },
new byte[] { 0x05 },
new byte[] { 0x07 },
new byte[] { 0x09 },
new byte[] { 0x0B },
new byte[] { 0x0D },
new byte[] { 0x0F },
new byte[] { 0x11 },
new byte[] { 0x13 },
new byte[] { 0x15 },
new byte[] { 0x17 },
new byte[] { 0x1F },
new byte[] { 0x21 },
new byte[] { 0x25 },
new byte[] { 0x27 },
new byte[] { 0x29 },
new byte[] { 0x2B },
new byte[] { 0xFD, 0x02 },
new byte[] { 0xFD, 0x05 },
new byte[] { 0xFD, 0x06 },
new byte[] { 0xFD, 0x08 },
new byte[] { 0xFD, 0x0A },
new byte[] { 0xFD, 0x0E },
new byte[] { 0xFD, 0x10 },
new byte[] { 0xFD, 0x12 },
new byte[] { 0xFD, 0x14 },
new byte[] { 0xFD, 0x22 },
new byte[] { 0xFD, 0x24 },
new byte[] { 0xFD, 0x26 },
new byte[] { 0xFD, 0x28 },
new byte[] { 0xFD, 0x39 },
new byte[] { 0xFD, 0x3D },
new byte[] { 0xFD, 0x55 },
new byte[] { 0xFD, 0x63 },
new byte[] { 0xFD, 0x7B },
new byte[] { 0xFD, 0x7E, 0x00 },
new byte[] { 0xFD, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
new byte[] { 0xFD, 0x8B },
new byte[] { 0xFD, 0xA9 },
new byte[] { 0xFD, 0xAA },
new byte[] { 0xFD, 0xAC },
new byte[] { 0xFD, 0xB7 },
new byte[] { 0xFD, 0xBC },
new byte[] { 0xFD, 0xC2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
new byte[] { 0xFD, 0xC3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
new byte[] { 0xFD, 0xC4, 0x00 },
new byte[] { 0xFD, 0xC6 },
new byte[] { 0xFD, 0xC7 }
};
var meterState = new StringBuilder();
foreach (var cmd in commands)
{
var response = this.connection.Send(cmd);
var entry = $"{BitConverter.ToString(cmd)}:{BitConverter.ToString(response)};";
meterState.Append(entry);
}
OmniContext.Current.Add(this.MeterNr, meterState.ToString());
this.WriteToLog();
}
public void StartCalibration(ushort rotations, ushort duration)
{
var response = connection.StartChamberCalibration(rotations, duration);
this.WriteToLog();
}
public Tuple<double, string, double> StopCalibration(OmniPruefpunkt pp, double refm3s)
{
var response = this.connection.ViewChamberCalibration();
Thread.Sleep(1000);
var rotations = response.Rotations;
var duration = response.DurationSec;
this.NotifyStateChanged(rotations);
this.NotifyStateChanged(duration);
var rs = $"{rotations}/{duration:0.0}";
var mlr = OmniPlusFormulas.MilliliterPerRotation(this.defaults.IntPart, (ushort)this.defaults.Fraction, this.defaults.Factor);
var m3s = OmniPlusFormulas.MeterFlowM3S(rotations, mlr, duration);
this.NotifyStateChanged(mlr);
this.NotifyStateChanged(m3s);
var acc = OmniPlusFormulas.AccuracyPercentage(m3s, refm3s);
this.TestRun.AddTestPoint(pp.PPNR, pp.TestPointId, pp.GalPerMin, rotations, duration, m3s, refm3s, acc);
this.WriteToLog();
return new Tuple<double, string, double>(m3s, rs, acc);
}
@@ -271,7 +175,7 @@
{
var crrf = this.TestRun
.GetAccuracies()
.GetCorrectionFactor(out bool succeeded);
.GetCalibrationFactor(out bool succeeded);
var testPoints = OmniContext
.Current
.Auftrag
@@ -290,7 +194,7 @@
}
var point = testPoints[ppnr];
var acc = test.Accuracy * (1 + crrf / 100D);
var acc = test.Accuracy + crrf;
test.Acc = acc;
test.Succeeded = point.Item1 <= acc && acc <= point.Item2;
@@ -336,13 +240,11 @@
{
this.connection.FactorySeal(true);
}
this.WriteToLog();
}
public void NotifyStateChanged(object state)
{
this.states.Enqueue(state);
this.StateChanged?.Invoke(state);
}
private static string GetOrCreateOutputFile(int slotNr, string portName, string outputDirectory)
@@ -353,57 +255,5 @@
return outputFile;
}
private void WriteToLog()
{
while (this.states.TryDequeue(out var state))
{
File.AppendAllText(this.outputFile, $"{state}{Environment.NewLine}");
}
}
}
}
/*
* SELECT [TP1].[OmniVariant] AS [Type]
* , [TR].[BuildInfo] AS [BuildNr]
* , [TP1].[GalPerMin] AS [Q1_GPM]
* , [TR].[Q1_RefM3S] AS [Q1_RefM3S]
* , [TR].[Q1_MeterM3S] AS [Q1_RegM3S]
* , ROUND([TR].[Q2_Accuracy], 1) AS [Q1_RawAcc]
* , [TP2].[GalPerMin] AS [Q2_GPM]
* , [TR].[Q2_RefM3S] AS [Q2_RefM3S]
* , [TR].[Q2_MeterM3S] AS [Q2_RegM3S]
* , ROUND([TR].[Q2_Accuracy], 1) AS [Q2_RawAcc]
* , [TP3].[GalPerMin] AS [Q3_GPM]
* , [TR].[Q3_RefM3S] AS [Q3_RefM3S]
* , [TR].[Q3_MeterM3S] AS [Q3_RegM3S]
* , ROUND([TR].[Q3_Accuracy], 1) AS [Q3_RawAcc]
* , ROUND([TR].[CrrfAfter], 1) AS [Correction]
* , ROUND([TR].[Q1_Acc], 1) AS [Q1_CrrAcc]
* , ROUND([TR].[Q2_Acc], 1) AS [Q2_CrrAcc]
* , ROUND([TR].[Q3_Acc], 1) AS [Q3_CrrAcc]
* FROM [OmniTestRuns] AS [TR]
* JOIN [OmniTestPoints] AS [TP1]
* ON [TP1].[TestPointId] = [TR].[Q1_TpId]
* JOIN [OmniTestPoints] AS [TP2]
* ON [TP2].[TestPointId] = [TR].[Q2_TpId]
* JOIN [OmniTestPoints] AS [TP3]
* ON [TP3].[TestPointId] = [TR].[Q3_TpId]
* WHERE [TR].[CrrfAfter] > 0.1
* AND [TR].[CrrfAfter] < 12.0
* AND ([TR].[BuildInfo] LIKE '%12400'
* OR [TR].[BuildInfo] LIKE '%02710'
* OR [TR].[BuildInfo] LIKE '%13747'
* OR [TR].[BuildInfo] LIKE '%11975'
* OR [TR].[BuildInfo] LIKE '%11979'
* OR [TR].[BuildInfo] LIKE '%12000'
* OR [TR].[BuildInfo] LIKE '%12804'
* OR [TR].[BuildInfo] LIKE '%12293'
* OR [TR].[BuildInfo] LIKE '%05113'
* OR [TR].[BuildInfo] LIKE '%03769')
* AND [TP1].[OmniVariant] IN ('T2', 'R2')
* ORDER BY [TP1].[OmniVariant]
* , [TR].[BuildInfo]
* , [TR].[Id]
*/
+31 -3
View File
@@ -1,5 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SSDTUnitTestPath Condition="'$(SSDTUnitTestPath)' == ''">$(VsInstallRoot)\Common7\IDE\Extensions\Microsoft\SQLDB</SSDTUnitTestPath>
</PropertyGroup>
<PropertyGroup>
<SSDTPath Condition="'$(SSDTPath)' == ''">$(VsInstallRoot)\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\130</SSDTPath>
</PropertyGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -103,16 +112,15 @@
<Compile Include="OmniConnection.cs" />
<Compile Include="OmniContext.cs" />
<Compile Include="OmniIrdaConnection.cs" />
<Compile Include="OmniLogger.cs" />
<Compile Include="OmniMeter.cs" />
<Compile Include="OmniDatabase.cs" />
<Compile Include="Inspection\OmniPlusTest.cs" />
<Compile Include="Inspection\OmniPlusTestPoint.cs" />
<Compile Include="Inspection\OmniPlusType.cs" />
<Compile Include="OmniUniProConnection.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SqlDatabaseSetup.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Prüfungstabellen.sql" />
<Content Include="OmniPlusDatabase.sql" />
</ItemGroup>
<ItemGroup>
@@ -125,5 +133,25 @@
<Name>ExchangeHub</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup Condition="$(VisualStudioVersion) == '15.0'">
<Reference Include="Microsoft.Data.Tools.Schema.Sql, Version=13.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>$(SSDTPath)\Microsoft.Data.Tools.Schema.Sql.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Tools.Schema.Sql.UnitTesting, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>$(SSDTUnitTestPath)\Microsoft.Data.Tools.Schema.Sql.UnitTesting.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Tools.Schema.Sql.UnitTestingAdapter, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>$(SSDTUnitTestPath)\Microsoft.Data.Tools.Schema.Sql.UnitTestingAdapter.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<SsdtUnitTestVersion>3.1</SsdtUnitTestVersion>
</PropertyGroup>
<Import Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="$(VisualStudioVersion) != '15.0' And '$(SQLDBExtensionsRefPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="$(VisualStudioVersion) != '15.0' And '$(SQLDBExtensionsRefPath)' == ''" />
</Project>
+68 -2
View File
@@ -29,12 +29,18 @@ CREATE TABLE [OmniTypes] (
INSERT INTO [OmniTypes]
([Type], [Size], [Range], [Direction], [IntPart], [Fraction], [CorrectionFactor], [PulsePerRotation])
VALUES ( '1½"', 0x05, 0x00, 0x00, 0x00, 34017, 100, 8)
, ( '2"', 0x06, 0x00, 0x00, 0x00, 34017, 100, 8);
, ( '2"', 0x06, 0x00, 0x00, 0x00, 34017, 100, 8)
, ( ' 3"', 0x07, 0x01, 0x00, 0x01, 50827, 100, 8)
, ( ' 4"', 0x08, 0x01, 0x00, 0x01, 50827, 100, 8)
, ( ' 6"', 0x09, 0x02, 0x00, 0x06, 16754, 100, 8)
, ( ' 8"', 0x10, 0x03, 0x01, 0x01, 36814, 1000, 8)
, ( '10"', 0x11, 0x04, 0x01, 0x02, 21667, 1000, 8);
CREATE TABLE [OmniTestPoints] (
[TestPointId] SMALLINT NOT NULL IDENTITY(1, 1),
[OmniTypeId] TINYINT NOT NULL,
[OmniVariant] CHAR(2) NULL,
[OmniVariant] VARCHAR(20) NULL,
[GalPerMin] FLOAT NOT NULL,
[Rotations] SMALLINT NOT NULL,
[Duration] SMALLINT NOT NULL,
@@ -120,3 +126,63 @@ CREATE TABLE [OmniTestRuns] (
CONSTRAINT [PK_OmniTestRuns] PRIMARY KEY ([Id], [SlotNr])
);
--SELECT [TR].[Id] AS [Test Run]
-- , [TR].[SlotNr] AS [Slot Nr]
-- , [TR].[BuildInfo] AS [Build Nr]
-- , [TR].[AddDate] AS [Add Date]
-- , [TR].[EndDate] AS [End Date]
-- , [Q1].[OmniVariant] AS [Q1 Type]
-- , STR([Q1].[GalPerMin] * 0.003785411784 * 60, 6, 3) AS [Q1 Target m³/s]
-- , [Q1].[Rotations] AS [Q1 Target R]
-- , [Q1].[Duration] AS [Q1 Target T]
-- , STR([TR].[Q1_Rotations], 5, 1) AS [Q1 Is R]
-- , STR([TR].[Q1_Duration], 5, 1) AS [Q1 Is T]
-- , STR([TR].[Q1_RefM3S], 13, 10) AS [Q1 Reference m³/s]
-- , STR([TR].[Q1_MeterM3S], 13, 10) AS [Q1 Meter m³/s]
-- , STR([TR].[Q1_Accuracy], 5, 1) AS [Q1 Raw Accuracy]
-- , STR([Q1].[MinAccuracy], 5, 1) AS [Q1 Min Accuracy]
-- , STR([TR].[Q1_Acc], 5, 1) AS [Q1 Accuracy]
-- , STR([Q1].[MaxAccuracy], 5, 1) AS [Q1 Max Accuracy]
-- , [Q2].[OmniVariant] AS [Q2 Type]
-- , STR([Q2].[GalPerMin] * 0.003785411784 * 60, 6, 3) AS [Q2 Target m³/s]
-- , [Q2].[Rotations] AS [Q2 Target R]
-- , [Q2].[Duration] AS [Q2 Target T]
-- , STR([TR].[Q2_Rotations], 5, 1) AS [Q2 Is R]
-- , STR([TR].[Q2_Duration], 5, 1) AS [Q2 Is T]
-- , STR([TR].[Q2_RefM3S], 13, 10) AS [Q2 Reference m³/s]
-- , STR([TR].[Q2_MeterM3S], 13, 10) AS [Q2 Meter m³/s]
-- , STR([TR].[Q2_Accuracy], 5, 1) AS [Q2 Raw Accuracy]
-- , STR([Q2].[MinAccuracy], 5, 1) AS [Q2 Min Accuracy]
-- , STR([TR].[Q2_Acc], 5, 1) AS [Q2 Accuracy]
-- , STR([Q2].[MaxAccuracy], 5, 1) AS [Q2 Max Accuracy]
-- , [Q3].[OmniVariant] AS [Q3 Type]
-- , STR([Q3].[GalPerMin] * 0.003785411784 * 60, 6, 3) AS [Q3 Target m³/s]
-- , [Q3].[Rotations] AS [Q3 Target R]
-- , [Q3].[Duration] AS [Q3 Target T]
-- , STR([TR].[Q3_Rotations], 5, 1) AS [Q3 Is R]
-- , STR([TR].[Q3_Duration], 5, 1) AS [Q3 Is T]
-- , STR([TR].[Q3_RefM3S], 13, 10) AS [Q3 Reference m³/s]
-- , STR([TR].[Q3_MeterM3S], 13, 10) AS [Q3 Meter m³/s]
-- , STR([TR].[Q3_Accuracy], 5, 1) AS [Q3 Raw Accuracy]
-- , STR([Q3].[MinAccuracy], 5, 1) AS [Q3 Min Accuracy]
-- , STR([TR].[Q3_Acc], 5, 1) AS [Q3 Accuracy]
-- , STR([Q3].[MaxAccuracy], 5, 1) AS [Q3 Max Accuracy]
-- , STR([TR].[CrrfAfter], 5, 1) AS [Calibration Factor]
-- FROM [OmniTestRuns] AS [TR]
-- JOIN [OmniTestPoints] AS [Q1]
-- ON [Q1].[TestPointId] = [TR].[Q1_TpId]
-- JOIN [OmniTestPoints] AS [Q2]
-- ON [Q2].[TestPointId] = [TR].[Q2_TpId]
-- JOIN [OmniTestPoints] AS [Q3]
-- ON [Q3].[TestPointId] = [TR].[Q3_TpId]
-- WHERE [Q2_Acc] <= 100
-- AND [TR].[BuildInfo] <> 'n/a'
-- AND [TR].[Q1_Rotations] <> 0
-- ORDER BY [TR].[BuildInfo]
@@ -0,0 +1,44 @@
USE [Auftrag];
IF OBJECT_ID(N'TestRuns') IS NOT NULL DROP TABLE [TestRun];
IF OBJECT_ID(N'TestPoints') IS NOT NULL DROP TABLE [TestPoint];
IF OBJECT_ID(N'TestResults') IS NOT NULL DROP TABLE [TestResult];
CREATE TABLE [TestPoints] (
[IdentNr] INT NOT NULL,
[Type] VARCHAR(50) NOT NULL,
[Variant] VARCHAR(50) NOT NULL,
[DN] INT NOT NULL,
[°C] INT NOT NULL,
[Pressure] INT NOT NULL,
[TargetQ] FLOAT NOT NULL,
[TargetT] FLOAT NOT NULL,
[TargetX] FLOAT NOT NULL,
[MinError] FLOAT NOT NULL,
[MaxError] FLOAT NOT NULL,
CONSTRAINT [PK_TestPoints] PRIMARY KEY ([IdentNr])
);
CREATE TABLE [TestRuns] (
[Nr] INT NOT NULL,
[SlotNr] INT NOT NULL,
[Ps] INT NOT NULL,
[PcbId] INT NOT NULL,
[StartDate] DATETIME NOT NULL DEFAULT(GETDATE()),
[EndDate] DATETIME NOT NULL,
CONSTRAINT [PK_TestRuns] PRIMARY KEY ([Nr], [SlotNr])
);
CREATE TABLE [TestResults] (
[Id] INT NOT NULL IDENTITY(1, 1),
[Nr] INT NOT NULL,
[SlotNr] INT NOT NULL,
[TpId] INT NOT NULL,
[AvgQ] FLOAT NOT NULL,
[TestT] FLOAT NOT NULL,
[RefM3S] FLOAT NOT NULL,
[MeterM3S] FLOAT NOT NULL,
[Error] FLOAT NOT NULL,
[Accuracy] FLOAT NOT NULL,
CONSTRAINT [PK_TestResults] PRIMARY KEY ([Id])
);
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.Common;
using Microsoft.Data.Tools.Schema.Sql.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace OmniPlus
{
[TestClass()]
public class SqlDatabaseSetup
{
[AssemblyInitialize()]
public static void InitializeAssembly(TestContext ctx)
{
// Setup the test database based on setting in the
// configuration file
SqlDatabaseTestClass.TestService.DeployDatabaseProject();
SqlDatabaseTestClass.TestService.GenerateData();
}
}
}
+8
View File
@@ -0,0 +1,8 @@
namespace Plugins.Abstraction
{
using System;
public interface IMeter : IDisposable
{
}
}
@@ -0,0 +1,8 @@
namespace Plugins.Abstraction
{
using System;
public interface IMeterBatch : IDisposable
{
}
}
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D96612D9-5B00-42CB-9779-FE5C251BB78F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Plugins.Abstraction</RootNamespace>
<AssemblyName>Plugins.Abstraction</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="IMeter.cs" />
<Compile Include="IMeterBatch.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Inspection Plugins")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Plugin system")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("d96612d9-5b00-42cb-9779-fe5c251bb78f")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+21
View File
@@ -0,0 +1,21 @@
namespace Plugins.OMNI
{
using Plugins.Abstraction;
using System.Collections.Generic;
public class OmniBatch : IMeterBatch
{
private readonly ICollection<IMeter> meters;
public OmniBatch()
{
this.meters = new List<IMeter>();
}
public void Dispose()
{
}
}
}
+12
View File
@@ -0,0 +1,12 @@
namespace Plugins.OMNI
{
using Plugins.Abstraction;
internal class OmniMeter : IMeter
{
public void Dispose()
{
}
}
}
+54
View File
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A04A3FE3-1443-45B2-9917-E90168567101}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Plugins.OMNI</RootNamespace>
<AssemblyName>Plugins.OMNI</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="OmniBatch.cs" />
<Compile Include="OmniMeter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Plugins.Abstraction\Plugins.Abstraction.csproj">
<Project>{d96612d9-5b00-42cb-9779-fe5c251bb78f}</Project>
<Name>Plugins.Abstraction</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Plugins.OMNI")]
[assembly: AssemblyDescription("Plugins.OMNI")]
[assembly: AssemblyConfiguration("Plugins.OMNI")]
[assembly: AssemblyCompany("Plugins.OMNI")]
[assembly: AssemblyProduct("Plugins.OMNI")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("Plugins.OMNI")]
[assembly: AssemblyCulture("en-US")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a04a3fe3-1443-45b2-9917-e90168567101")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -322,6 +322,39 @@ namespace Xylem.Common.Logic.SoftwareAccessHelper
}
public static IRestResponse PutAsJson(this Object json, String url, Action<RestRequestHeaders> headersHandler = null, Int32? timeoutMs = null)
{
try
{
var client = new RestClient(url);
var request = new RestRequest(Method.PUT);
var headers = new RestRequestHeaders(request)
{
ContentType = "application/json",
Accept = "application/json"
};
headersHandler?.Invoke(headers);
if (json != null)
{
request.AddJsonBody(json);
}
ServicePointManager.Expect100Continue = false;
return client.Execute(request);
}
catch (Exception error)
{
return new RestResponse
{
StatusCode = HttpStatusCode.InternalServerError,
Content = error.ToString()
};
}
}
/// <summary>
/// Web request
/// </summary>
@@ -0,0 +1,29 @@
namespace Xylem.Common.Logic.SoftwareAccessHelper
{
using RestSharp;
public class RestRequestHeaders
{
private readonly RestRequest request;
internal RestRequestHeaders(RestRequest request)
{
this.request = request;
}
public string Accept
{
set => this.request.AddHeader(nameof(Accept), value);
}
public string Authorization
{
set => this.request.AddHeader(nameof(Authorization), value);
}
public string ContentType
{
set => this.request.AddHeader("Content-Type", value);
}
}
}
@@ -88,6 +88,9 @@
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http">
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
@@ -97,6 +100,7 @@
<Compile Include="Access.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="LocalWebRequest.cs" />
<Compile Include="RestRequestHeaders.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CommonCore.Configuration\CommonCore.Configuration.csproj">
@@ -1 +1 @@
247396738e2c5d26ac00f9df05c0cc5c61d7f33a
338bdd8d71c148c9df0972f903098eb23eacf0c9
+38 -16
View File
@@ -39,6 +39,7 @@
this.submitBtn = new System.Windows.Forms.Button();
this.cancelBtn = new System.Windows.Forms.Button();
this.ChangePasswordErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
this.errorLbl = new System.Windows.Forms.Label();
this.layout.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.ChangePasswordErrorProvider)).BeginInit();
this.SuspendLayout();
@@ -47,9 +48,9 @@
//
this.layout.AutoSize = true;
this.layout.ColumnCount = 3;
this.layout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.layout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.layout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.layout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 18.75F));
this.layout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 62.5F));
this.layout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 18.75F));
this.layout.Controls.Add(this.oldPasswordLbl, 1, 1);
this.layout.Controls.Add(this.newPasswordLbl, 1, 4);
this.layout.Controls.Add(this.confirmPasswordLbl, 1, 7);
@@ -58,11 +59,12 @@
this.layout.Controls.Add(this.confirmPassword, 1, 8);
this.layout.Controls.Add(this.submitBtn, 1, 10);
this.layout.Controls.Add(this.cancelBtn, 1, 12);
this.layout.Controls.Add(this.errorLbl, 1, 13);
this.layout.Dock = System.Windows.Forms.DockStyle.Fill;
this.layout.Font = new System.Drawing.Font("Consolas", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.layout.Location = new System.Drawing.Point(0, 0);
this.layout.Name = "layout";
this.layout.RowCount = 14;
this.layout.RowCount = 15;
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle());
@@ -76,8 +78,9 @@
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 10F));
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.layout.Size = new System.Drawing.Size(517, 584);
this.layout.Size = new System.Drawing.Size(413, 584);
this.layout.TabIndex = 0;
//
// oldPasswordLbl
@@ -85,7 +88,7 @@
this.oldPasswordLbl.AutoSize = true;
this.oldPasswordLbl.Dock = System.Windows.Forms.DockStyle.Fill;
this.oldPasswordLbl.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.oldPasswordLbl.Location = new System.Drawing.Point(129, 188);
this.oldPasswordLbl.Location = new System.Drawing.Point(77, 178);
this.oldPasswordLbl.Margin = new System.Windows.Forms.Padding(0);
this.oldPasswordLbl.Name = "oldPasswordLbl";
this.oldPasswordLbl.Size = new System.Drawing.Size(258, 15);
@@ -98,7 +101,7 @@
this.newPasswordLbl.AutoSize = true;
this.newPasswordLbl.Dock = System.Windows.Forms.DockStyle.Fill;
this.newPasswordLbl.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.newPasswordLbl.Location = new System.Drawing.Point(129, 236);
this.newPasswordLbl.Location = new System.Drawing.Point(77, 226);
this.newPasswordLbl.Margin = new System.Windows.Forms.Padding(0);
this.newPasswordLbl.Name = "newPasswordLbl";
this.newPasswordLbl.Size = new System.Drawing.Size(258, 15);
@@ -111,7 +114,7 @@
this.confirmPasswordLbl.AutoSize = true;
this.confirmPasswordLbl.Dock = System.Windows.Forms.DockStyle.Fill;
this.confirmPasswordLbl.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.confirmPasswordLbl.Location = new System.Drawing.Point(129, 284);
this.confirmPasswordLbl.Location = new System.Drawing.Point(77, 274);
this.confirmPasswordLbl.Margin = new System.Windows.Forms.Padding(0);
this.confirmPasswordLbl.Name = "confirmPasswordLbl";
this.confirmPasswordLbl.Size = new System.Drawing.Size(258, 15);
@@ -123,38 +126,42 @@
//
this.oldPassword.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.oldPassword.Dock = System.Windows.Forms.DockStyle.Fill;
this.oldPassword.Location = new System.Drawing.Point(132, 203);
this.oldPassword.Location = new System.Drawing.Point(80, 193);
this.oldPassword.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.oldPassword.Name = "oldPassword";
this.oldPassword.Size = new System.Drawing.Size(255, 23);
this.oldPassword.TabIndex = 3;
this.oldPassword.UseSystemPasswordChar = true;
//
// newPassword
//
this.newPassword.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.newPassword.Dock = System.Windows.Forms.DockStyle.Fill;
this.newPassword.Location = new System.Drawing.Point(132, 251);
this.newPassword.Location = new System.Drawing.Point(80, 241);
this.newPassword.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.newPassword.Name = "newPassword";
this.newPassword.Size = new System.Drawing.Size(255, 23);
this.newPassword.TabIndex = 4;
this.newPassword.UseSystemPasswordChar = true;
//
// confirmPassword
//
this.confirmPassword.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.confirmPassword.Dock = System.Windows.Forms.DockStyle.Fill;
this.confirmPassword.Location = new System.Drawing.Point(132, 299);
this.confirmPassword.Location = new System.Drawing.Point(80, 289);
this.confirmPassword.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.confirmPassword.Name = "confirmPassword";
this.confirmPassword.Size = new System.Drawing.Size(255, 23);
this.confirmPassword.TabIndex = 5;
this.confirmPassword.UseSystemPasswordChar = true;
//
// submitBtn
//
this.submitBtn.AutoSize = true;
this.submitBtn.Cursor = System.Windows.Forms.Cursors.Hand;
this.submitBtn.Dock = System.Windows.Forms.DockStyle.Fill;
this.submitBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.submitBtn.Location = new System.Drawing.Point(132, 332);
this.submitBtn.Location = new System.Drawing.Point(80, 322);
this.submitBtn.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.submitBtn.Name = "submitBtn";
this.submitBtn.Size = new System.Drawing.Size(255, 27);
@@ -166,9 +173,10 @@
// cancelBtn
//
this.cancelBtn.AutoSize = true;
this.cancelBtn.Cursor = System.Windows.Forms.Cursors.Hand;
this.cancelBtn.Dock = System.Windows.Forms.DockStyle.Fill;
this.cancelBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.cancelBtn.Location = new System.Drawing.Point(132, 369);
this.cancelBtn.Location = new System.Drawing.Point(80, 359);
this.cancelBtn.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.cancelBtn.Name = "cancelBtn";
this.cancelBtn.Size = new System.Drawing.Size(255, 27);
@@ -180,13 +188,26 @@
//
this.ChangePasswordErrorProvider.ContainerControl = this;
//
// ResetPassword
// errorLbl
//
this.errorLbl.AutoSize = true;
this.errorLbl.Dock = System.Windows.Forms.DockStyle.Fill;
this.errorLbl.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.errorLbl.ForeColor = System.Drawing.Color.Firebrick;
this.errorLbl.Location = new System.Drawing.Point(77, 386);
this.errorLbl.Margin = new System.Windows.Forms.Padding(0);
this.errorLbl.Name = "errorLbl";
this.errorLbl.Size = new System.Drawing.Size(258, 20);
this.errorLbl.TabIndex = 8;
this.errorLbl.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
//
// ChangePassword
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.layout);
this.Name = "ResetPassword";
this.Size = new System.Drawing.Size(517, 584);
this.Name = "ChangePassword";
this.Size = new System.Drawing.Size(413, 584);
this.layout.ResumeLayout(false);
this.layout.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.ChangePasswordErrorProvider)).EndInit();
@@ -207,5 +228,6 @@
private System.Windows.Forms.Button submitBtn;
private System.Windows.Forms.Button cancelBtn;
private System.Windows.Forms.ErrorProvider ChangePasswordErrorProvider;
private System.Windows.Forms.Label errorLbl;
}
}
@@ -43,6 +43,8 @@
if (!Software.ChangePassword(this.oldPassword.Text, this.newPassword.Text, this.confirmPassword.Text, out var errors))
{
this.errorLbl.Text = "Password change failed.";
foreach (var kvp in errors)
{
if (this.fields.TryGetValue(kvp.Key, out var control))
-39
View File
@@ -1,39 +0,0 @@
namespace Xylem.Common.Ui.GenesisToolBox.Ctls
{
partial class RegisterForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "RegisterForm";
}
#endregion
}
}
@@ -1,20 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Xylem.Common.Ui.GenesisToolBox.Ctls
{
public partial class RegisterForm : Form
{
public RegisterForm()
{
InitializeComponent();
}
}
}
+41 -19
View File
@@ -48,6 +48,7 @@
this.confirmPassword = new System.Windows.Forms.TextBox();
this.submitBtn = new System.Windows.Forms.Button();
this.cancelBtn = new System.Windows.Forms.Button();
this.errorLbl = new System.Windows.Forms.Label();
this.RegisterErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
this.layout.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.RegisterErrorProvider)).BeginInit();
@@ -78,12 +79,13 @@
this.layout.Controls.Add(this.confirmPassword, 1, 23);
this.layout.Controls.Add(this.submitBtn, 1, 25);
this.layout.Controls.Add(this.cancelBtn, 1, 27);
this.layout.Controls.Add(this.errorLbl, 1, 28);
this.layout.Dock = System.Windows.Forms.DockStyle.Fill;
this.layout.Font = new System.Drawing.Font("Consolas", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.layout.Location = new System.Drawing.Point(0, 0);
this.layout.Margin = new System.Windows.Forms.Padding(0);
this.layout.Name = "layout";
this.layout.RowCount = 29;
this.layout.RowCount = 30;
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle());
@@ -112,7 +114,9 @@
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 10F));
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.layout.Size = new System.Drawing.Size(371, 545);
this.layout.TabIndex = 1;
//
@@ -121,7 +125,7 @@
this.employeeIdLbl.AutoSize = true;
this.employeeIdLbl.Dock = System.Windows.Forms.DockStyle.Fill;
this.employeeIdLbl.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.employeeIdLbl.Location = new System.Drawing.Point(68, 66);
this.employeeIdLbl.Location = new System.Drawing.Point(68, 58);
this.employeeIdLbl.Margin = new System.Windows.Forms.Padding(0);
this.employeeIdLbl.Name = "employeeIdLbl";
this.employeeIdLbl.Size = new System.Drawing.Size(233, 15);
@@ -133,7 +137,7 @@
//
this.employeeId.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.employeeId.Dock = System.Windows.Forms.DockStyle.Fill;
this.employeeId.Location = new System.Drawing.Point(71, 81);
this.employeeId.Location = new System.Drawing.Point(71, 73);
this.employeeId.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.employeeId.Name = "employeeId";
this.employeeId.ReadOnly = true;
@@ -145,7 +149,7 @@
this.firstnameLbl.AutoSize = true;
this.firstnameLbl.Dock = System.Windows.Forms.DockStyle.Fill;
this.firstnameLbl.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.firstnameLbl.Location = new System.Drawing.Point(68, 109);
this.firstnameLbl.Location = new System.Drawing.Point(68, 101);
this.firstnameLbl.Margin = new System.Windows.Forms.Padding(0);
this.firstnameLbl.Name = "firstnameLbl";
this.firstnameLbl.Size = new System.Drawing.Size(233, 15);
@@ -158,7 +162,7 @@
this.lastnameLbl.AutoSize = true;
this.lastnameLbl.Dock = System.Windows.Forms.DockStyle.Fill;
this.lastnameLbl.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.lastnameLbl.Location = new System.Drawing.Point(68, 152);
this.lastnameLbl.Location = new System.Drawing.Point(68, 144);
this.lastnameLbl.Margin = new System.Windows.Forms.Padding(0);
this.lastnameLbl.Name = "lastnameLbl";
this.lastnameLbl.Size = new System.Drawing.Size(233, 15);
@@ -171,7 +175,7 @@
this.phoneLbl.AutoSize = true;
this.phoneLbl.Dock = System.Windows.Forms.DockStyle.Fill;
this.phoneLbl.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.phoneLbl.Location = new System.Drawing.Point(68, 195);
this.phoneLbl.Location = new System.Drawing.Point(68, 187);
this.phoneLbl.Margin = new System.Windows.Forms.Padding(0);
this.phoneLbl.Name = "phoneLbl";
this.phoneLbl.Size = new System.Drawing.Size(233, 15);
@@ -184,7 +188,7 @@
this.emailLbl.AutoSize = true;
this.emailLbl.Dock = System.Windows.Forms.DockStyle.Fill;
this.emailLbl.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.emailLbl.Location = new System.Drawing.Point(68, 238);
this.emailLbl.Location = new System.Drawing.Point(68, 230);
this.emailLbl.Margin = new System.Windows.Forms.Padding(0);
this.emailLbl.Name = "emailLbl";
this.emailLbl.Size = new System.Drawing.Size(233, 15);
@@ -197,7 +201,7 @@
this.usernameLbl.AutoSize = true;
this.usernameLbl.Dock = System.Windows.Forms.DockStyle.Fill;
this.usernameLbl.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.usernameLbl.Location = new System.Drawing.Point(68, 281);
this.usernameLbl.Location = new System.Drawing.Point(68, 273);
this.usernameLbl.Margin = new System.Windows.Forms.Padding(0);
this.usernameLbl.Name = "usernameLbl";
this.usernameLbl.Size = new System.Drawing.Size(233, 15);
@@ -210,7 +214,7 @@
this.passwordLbl.AutoSize = true;
this.passwordLbl.Dock = System.Windows.Forms.DockStyle.Fill;
this.passwordLbl.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.passwordLbl.Location = new System.Drawing.Point(68, 324);
this.passwordLbl.Location = new System.Drawing.Point(68, 316);
this.passwordLbl.Margin = new System.Windows.Forms.Padding(0);
this.passwordLbl.Name = "passwordLbl";
this.passwordLbl.Size = new System.Drawing.Size(233, 15);
@@ -223,7 +227,7 @@
this.confirmPasswordLbl.AutoSize = true;
this.confirmPasswordLbl.Dock = System.Windows.Forms.DockStyle.Fill;
this.confirmPasswordLbl.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.confirmPasswordLbl.Location = new System.Drawing.Point(68, 367);
this.confirmPasswordLbl.Location = new System.Drawing.Point(68, 359);
this.confirmPasswordLbl.Margin = new System.Windows.Forms.Padding(0);
this.confirmPasswordLbl.Name = "confirmPasswordLbl";
this.confirmPasswordLbl.Size = new System.Drawing.Size(233, 15);
@@ -235,7 +239,7 @@
//
this.firstname.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.firstname.Dock = System.Windows.Forms.DockStyle.Fill;
this.firstname.Location = new System.Drawing.Point(71, 124);
this.firstname.Location = new System.Drawing.Point(71, 116);
this.firstname.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.firstname.Name = "firstname";
this.firstname.ReadOnly = true;
@@ -246,7 +250,7 @@
//
this.lastname.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lastname.Dock = System.Windows.Forms.DockStyle.Fill;
this.lastname.Location = new System.Drawing.Point(71, 167);
this.lastname.Location = new System.Drawing.Point(71, 159);
this.lastname.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.lastname.Name = "lastname";
this.lastname.ReadOnly = true;
@@ -257,7 +261,7 @@
//
this.phone.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.phone.Dock = System.Windows.Forms.DockStyle.Fill;
this.phone.Location = new System.Drawing.Point(71, 210);
this.phone.Location = new System.Drawing.Point(71, 202);
this.phone.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.phone.Name = "phone";
this.phone.ReadOnly = true;
@@ -268,7 +272,7 @@
//
this.email.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.email.Dock = System.Windows.Forms.DockStyle.Fill;
this.email.Location = new System.Drawing.Point(71, 253);
this.email.Location = new System.Drawing.Point(71, 245);
this.email.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.email.Name = "email";
this.email.ReadOnly = true;
@@ -279,7 +283,7 @@
//
this.username.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.username.Dock = System.Windows.Forms.DockStyle.Fill;
this.username.Location = new System.Drawing.Point(71, 296);
this.username.Location = new System.Drawing.Point(71, 288);
this.username.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.username.Name = "username";
this.username.Size = new System.Drawing.Size(230, 23);
@@ -289,28 +293,31 @@
//
this.password.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.password.Dock = System.Windows.Forms.DockStyle.Fill;
this.password.Location = new System.Drawing.Point(71, 339);
this.password.Location = new System.Drawing.Point(71, 331);
this.password.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.password.Name = "password";
this.password.Size = new System.Drawing.Size(230, 23);
this.password.TabIndex = 14;
this.password.UseSystemPasswordChar = true;
//
// confirmPassword
//
this.confirmPassword.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.confirmPassword.Dock = System.Windows.Forms.DockStyle.Fill;
this.confirmPassword.Location = new System.Drawing.Point(71, 382);
this.confirmPassword.Location = new System.Drawing.Point(71, 374);
this.confirmPassword.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.confirmPassword.Name = "confirmPassword";
this.confirmPassword.Size = new System.Drawing.Size(230, 23);
this.confirmPassword.TabIndex = 15;
this.confirmPassword.UseSystemPasswordChar = true;
//
// submitBtn
//
this.submitBtn.AutoSize = true;
this.submitBtn.Cursor = System.Windows.Forms.Cursors.Hand;
this.submitBtn.Dock = System.Windows.Forms.DockStyle.Fill;
this.submitBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.submitBtn.Location = new System.Drawing.Point(71, 415);
this.submitBtn.Location = new System.Drawing.Point(71, 407);
this.submitBtn.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.submitBtn.Name = "submitBtn";
this.submitBtn.Size = new System.Drawing.Size(230, 27);
@@ -322,9 +329,10 @@
// cancelBtn
//
this.cancelBtn.AutoSize = true;
this.cancelBtn.Cursor = System.Windows.Forms.Cursors.Hand;
this.cancelBtn.Dock = System.Windows.Forms.DockStyle.Fill;
this.cancelBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.cancelBtn.Location = new System.Drawing.Point(71, 452);
this.cancelBtn.Location = new System.Drawing.Point(71, 444);
this.cancelBtn.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.cancelBtn.Name = "cancelBtn";
this.cancelBtn.Size = new System.Drawing.Size(230, 27);
@@ -333,6 +341,19 @@
this.cancelBtn.UseVisualStyleBackColor = true;
this.cancelBtn.Click += new System.EventHandler(this.OnCancellationClick);
//
// errorLbl
//
this.errorLbl.AutoSize = true;
this.errorLbl.Dock = System.Windows.Forms.DockStyle.Fill;
this.errorLbl.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.errorLbl.ForeColor = System.Drawing.Color.Firebrick;
this.errorLbl.Location = new System.Drawing.Point(68, 471);
this.errorLbl.Margin = new System.Windows.Forms.Padding(0);
this.errorLbl.Name = "errorLbl";
this.errorLbl.Size = new System.Drawing.Size(233, 15);
this.errorLbl.TabIndex = 18;
this.errorLbl.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
//
// RegisterErrorProvider
//
this.RegisterErrorProvider.ContainerControl = this;
@@ -373,5 +394,6 @@
private System.Windows.Forms.Button submitBtn;
private System.Windows.Forms.ErrorProvider RegisterErrorProvider;
private System.Windows.Forms.Button cancelBtn;
private System.Windows.Forms.Label errorLbl;
}
}
@@ -54,11 +54,17 @@
var user = Software.PendingUser;
user.Username = this.username.Text;
user.Password = this.password.Text;
user.ConfirmPassword = this.confirmPassword.Text;
user.Password = this.password
.Text
.ComputeBase64Hash();
user.ConfirmPassword = this.confirmPassword
.Text
.ComputeBase64Hash();
if (!Software.Register(user, out var errors))
{
this.errorLbl.Text = "Registration failed.";
foreach (var kvp in errors)
{
if (this.fields.TryGetValue(kvp.Key, out var control))
+1 -1
View File
@@ -407,7 +407,7 @@
/// </summary>
private void SetSoftwareFunctions()
{
resetPasswordMenuItem.Tag = SoftwareFunctions.LAA_ADMIN;
// changePassword.Tag = SoftwareFunctions.LAA_ADMIN;
btnSetup.Tag = SoftwareFunctions.GENERAL_SETUP;
btnAlarm.Tag = SoftwareFunctions.GENERAL_ALARM;
@@ -449,11 +449,16 @@
<DependentUpon>FrmTempMeter.cs</DependentUpon>
</Compile>
<Compile Include="Infrastructure\Appsettings.cs" />
<Compile Include="Infrastructure\CordonelTempLut.cs" />
<Compile Include="Infrastructure\LDAPLoginModel.cs" />
<Compile Include="Infrastructure\LDAPRegisterModel.cs" />
<Compile Include="Infrastructure\LDAPUser.cs" />
<Compile Include="Infrastructure\ParseExtensions.cs" />
<Compile Include="Infrastructure\RefTempRange.cs" />
<Compile Include="Infrastructure\Software.cs" />
<Compile Include="Infrastructure\SoftwareVersion.cs" />
<Compile Include="Infrastructure\SoftwareFunctions.cs" />
<Compile Include="Infrastructure\TemperatureSource.cs" />
<Compile Include="Infrastructure\TempMeterModels.cs" />
<Compile Include="Infrastructure\UserLoginModel.cs" />
<Compile Include="ProccessConfig.cs" />
@@ -0,0 +1,31 @@
namespace Xylem.Common.Ui.GenesisToolBox.Infrastructure
{
public class LDAPRegisterModel
{
public string Assembly { get; set; }
public int MajorV { get; set; }
public int MinorV { get; set; }
public int BuildV { get; set; }
public int EmployeeId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
public string Username { get; set; }
public string DomainName { get; set; }
public string Password { get; set; }
public string ConfirmPassword { get; set; }
}
}
@@ -10,6 +10,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http.Headers;
using System.Security.Cryptography;
using System.Text;
@@ -18,30 +19,37 @@
/// </summary>
internal static class Software
{
const string Bearer = nameof(Bearer);
private static String bearer;
private static LDAPUser user;
private static IEnumerable<SoftwareFunctions> softwareFunctions = Array.Empty<SoftwareFunctions>();
public static String UserName { get; private set; }
public static Boolean IsRegistrationPending { get; set; } //=> user.Found && string.IsNullOrWhiteSpace(bearer);
public static Boolean IsRegistrationPending { get; set; }
public static LDAPUser PendingUser => user;
public static AuthenticationHeaderValue AuthorizationHeader
= new AuthenticationHeaderValue(Bearer, bearer);
public static void Initialize()
{
var version = SoftwareVersion.Current;
user = new LDAPUser();
var version = SoftwareVersion.Current;
var authenticationResponse = LocalWebRequest.PostRequestAndGetResponseAsync(
url: $"{ServiceUrls.LaaProductionAPI}/LaaProductionWeb/API/Login/AD",
json: user);
if (authenticationResponse.StatusCode == HttpStatusCode.Accepted)
var uri = $"{ServiceUrls.LaaProductionAPI}/LaaProductionWeb/API/Login/AD";
var authenticationResponse = LocalWebRequest.PostRequestAndGetResponseAsync(uri, json: new LDAPLoginModel
{
IsRegistrationPending = true;
}
else
Assembly = version.Name,
BuildV = version.BuildV,
MajorV = version.MajorV,
MinorV = version.MinorV,
EmployeeId = user.EmployeeId
});
if (authenticationResponse.StatusCode == HttpStatusCode.OK)
{
bearer = authenticationResponse
?.Content
@@ -54,6 +62,10 @@
UserName = $"{user.FirstName} {user.LastName}";
}
}
else if (authenticationResponse.StatusCode == HttpStatusCode.Accepted)
{
IsRegistrationPending = true;
}
if (string.IsNullOrWhiteSpace(UserName))
{
@@ -61,13 +73,20 @@
}
}
internal static Boolean ChangePassword(String text1, String text2, String text3, out Dictionary<String, String> errors)
internal static Boolean ChangePassword(String oldPassword, String newPassword, String confirmPassword, out Dictionary<String, String> errors)
{
errors = new Dictionary<string, string>();
var changePasswordResponse = LocalWebRequest.PostRequestAndGetResponseAsync(
url: $"{ServiceUrls.LaaProductionAPI}/LaaProductionWeb/API/Login/AD",
json: user);
var changePasswordModel = new
{
OldPassword = oldPassword.ComputeBase64Hash(),
NewPassword = newPassword.ComputeBase64Hash(),
ConfirmPassword = confirmPassword.ComputeBase64Hash()
};
var changePasswordResponse = changePasswordModel.PutAsJson($"{ServiceUrls.LaaProductionAPI}/LaaProductionWeb/API/Login", headers =>
{
headers.Authorization = $"{Bearer} {bearer}";
});
if (changePasswordResponse.StatusCode != HttpStatusCode.OK)
{
@@ -84,24 +103,46 @@
{
errors = new Dictionary<string, string>();
var registerLDAPResponse = LocalWebRequest.PostRequestAndGetResponseAsync(
url: $"{ServiceUrls.LaaProductionAPI}/LaaProductionWeb/API/Login/AD",
json: user);
if (registerLDAPResponse.StatusCode == HttpStatusCode.OK)
var version = SoftwareVersion.Current;
var registerModel = new LDAPRegisterModel
{
bearer = registerLDAPResponse
Assembly = version.Name,
BuildV = version.BuildV,
ConfirmPassword = user.ConfirmPassword,
DomainName = user.DomainName,
Email = user.Email,
EmployeeId = user.EmployeeId,
FirstName = user.FirstName,
LastName = user.LastName,
MajorV = version.MajorV,
MinorV = version.MinorV,
Password = user.Password,
Phone = user.Phone,
Username = user.Username
};
var registerResponse = registerModel.PutAsJson($"{ServiceUrls.LaaProductionAPI}/LaaProductionWeb/API/Login/AD");
if (registerResponse.StatusCode == HttpStatusCode.OK)
{
IsRegistrationPending = false;
bearer = registerResponse
?.Content
?.Trim()
?.Trim('"');
softwareFunctions = GetFunctions();
if (!string.IsNullOrWhiteSpace(bearer))
{
UserName = $"{user.FirstName} {user.LastName}";
}
}
else if (!string.IsNullOrWhiteSpace(registerLDAPResponse.Content))
else if (!string.IsNullOrWhiteSpace(registerResponse.Content))
{
errors = JsonConvert.DeserializeObject<Dictionary<string, string>>(registerLDAPResponse.Content);
errors = JsonConvert.DeserializeObject<Dictionary<string, string>>(registerResponse.Content);
}
return registerLDAPResponse.StatusCode == HttpStatusCode.OK;
return registerResponse.StatusCode == HttpStatusCode.OK;
}
/// <summary>
@@ -132,7 +173,7 @@
.GetRequest(
timeoutMs: 1200,
url: $"{ServiceUrls.LaaProductionAPI}/LaaProductionWeb/API/Personalization/Login",
header: new Dictionary<String, String> { { "Authorization", $"Bearer {bearer}" } })
header: new Dictionary<String, String> { { "Authorization", $"{Bearer} {bearer}" } })
.Trim('"');
}
@@ -156,7 +197,7 @@
var functionsResponse = LocalWebRequest.GetRequest(
timeoutMs: 1200,
url: $"{ServiceUrls.LaaProductionAPI}/LaaProductionWeb/API/Personalization/Software/Access",
header: new Dictionary<String, String> { { "Authorization", $"Bearer {bearer}" } });
header: new Dictionary<String, String> { { "Authorization", $"{Bearer} {bearer}" } });
return JsonConvert
.DeserializeObject<IEnumerable<String>>(functionsResponse)
@@ -197,3 +238,7 @@
}
}
}
/*
* 19207 Stoyan Zlatev +49 (5102) 74 3005 AD True 0 szlatev rd rd NULL 2017-07-18 00:00:00 6271 NULL 0 False Stoyan.Zlatev@xylem.com NULL NULL False False NULL NULL NULL NULL
*/
+7 -7
View File
@@ -54,7 +54,7 @@
this.optionsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.loginMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.logoutMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.resetPasswordMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.changePassword = new System.Windows.Forms.ToolStripMenuItem();
this.gpGerneral.SuspendLayout();
this.gpLAA.SuspendLayout();
this.gbDeveloper.SuspendLayout();
@@ -336,7 +336,7 @@
this.optionsMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.loginMenuItem,
this.logoutMenuItem,
this.resetPasswordMenuItem});
this.changePassword});
this.optionsMenuItem.Name = "optionsMenuItem";
this.optionsMenuItem.Size = new System.Drawing.Size(61, 20);
this.optionsMenuItem.Text = "Options";
@@ -358,10 +358,10 @@
//
// resetPasswordMenuItem
//
this.resetPasswordMenuItem.Name = "resetPasswordMenuItem";
this.resetPasswordMenuItem.Size = new System.Drawing.Size(180, 22);
this.resetPasswordMenuItem.Text = "Change Password";
this.resetPasswordMenuItem.Click += new System.EventHandler(this.OnChangePasswordClick);
this.changePassword.Name = "resetPasswordMenuItem";
this.changePassword.Size = new System.Drawing.Size(180, 22);
this.changePassword.Text = "Change Password";
this.changePassword.Click += new System.EventHandler(this.OnChangePasswordClick);
//
// FrmMainForm
//
@@ -419,7 +419,7 @@
private System.Windows.Forms.ToolStripMenuItem optionsMenuItem;
private System.Windows.Forms.ToolStripMenuItem loginMenuItem;
private System.Windows.Forms.ToolStripMenuItem logoutMenuItem;
private System.Windows.Forms.ToolStripMenuItem resetPasswordMenuItem;
private System.Windows.Forms.ToolStripMenuItem changePassword;
}
}
@@ -30,6 +30,18 @@
this.softwareRepository = LaaServiceProvider.GetService<ISoftwareRepository>();
}
public bool ChangePassword(string password, string bearer)
{
var tokenData = this.employeesRepository.GetTokenData(bearer);
if (tokenData is null)
{
return false;
}
return this.employeesRepository.SetPassword(tokenData.EmployeeId, password);
}
public IPrincipal GetClaimsPrincipal(string token)
{
var claimsIdentity = anonymous;
@@ -75,8 +87,10 @@
return new ClaimsPrincipal(claimsIdentity);
}
public string Login(LDAPLoginModel model)
public bool? Login(LDAPLoginModel model, out string bearer)
{
bearer = default(string);
var softwareId = this.GetOrCreateSoftwareId(
model.Assembly,
model.MajorV,
@@ -85,39 +99,19 @@
if (softwareId <= 0)
{
return default(string);
return false;
}
var employeeNr = this.employeesRepository.FindEmployeeNr(model.EmployeeId);
//if (employeeNr <= 0)
//{
// employeeNr = this.employeesRepository.Update(
// model.EmployeeId,
// model.FirstName,
// model.LastName,
// model.Phone,
// model.Username,
// model.Email);
// if (employeeNr <= 0)
// {
// employeeNr = this.employeesRepository.Insert(
// model.EmployeeId,
// model.FirstName,
// model.LastName,
// model.Phone,
// model.Username,
// model.Email);
// }
//}
if (employeeNr <= 0)
{
return default(string);
return null;
}
return this.GetOrCreateAuthToken(softwareId, employeeNr);
bearer = this.GetOrCreateAuthToken(softwareId, employeeNr);
return true;
}
public string Login(UserLoginModel model)
@@ -180,5 +174,48 @@
return token;
}
public bool? Register(LDAPRegisterModel model, out string bearer)
{
bearer = default(string);
var softwareId = this.GetOrCreateSoftwareId(
model.Assembly,
model.MajorV,
model.MinorV,
model.BuildV);
if (softwareId <= 0)
{
return false;
}
var employeeNr = this.employeesRepository.Update(
model.EmployeeId,
model.FirstName,
model.LastName,
model.Phone,
model.Email,
model.Username,
model.DomainName,
model.Password);
if (employeeNr <= 0)
{
employeeNr = this.employeesRepository.Insert(
model.EmployeeId,
model.FirstName,
model.LastName,
model.Phone,
model.Email,
model.Username,
model.DomainName,
model.Password);
}
bearer = this.GetOrCreateAuthToken(softwareId, employeeNr);
return true;
}
}
}
@@ -6,14 +6,18 @@
public interface IAccountManager
{
bool ChangePassword(string password, string bearer);
IPrincipal GetClaimsPrincipal(string token);
string Login(LDAPLoginModel model);
bool? Login(LDAPLoginModel model, out string bearer);
string Login(UserLoginModel model);
void ResetPassword(short employeeId);
void SetPassword(short employeeId, string password);
bool? Register(LDAPRegisterModel model, out string bearer);
}
}
@@ -163,7 +163,7 @@
.SetParameter(nameof(token), token)
.ExecuteReader(x => x.GetString());
public short Insert(int employeeId, string firstName, string lastName, string phone, string username, string email)
public short Insert(int employeeId, string firstName, string lastName, string phone, string email, string username, string domainname, string password)
=> this.sqlConnection
.CreateCommand($@"
INSERT INTO [Mitarbeiter] (
@@ -175,7 +175,8 @@
, [Benutzername]
, [AnlageDatum]
, [eMail]
, [DomainUser])
, [DomainUser]
, [PasswordHash])
OUTPUT [inserted].[MitarbeiterNr]
VALUES ((SELECT MAX([MitarbeiterNr]) + 1 FROM [Mitarbeiter])
, @{nameof(employeeId)}
@@ -185,13 +186,16 @@
, @{nameof(username)}
, GETDATE()
, @{nameof(email)}
, @{nameof(username)})")
, @{nameof(domainname)}
, @{nameof(password)})")
.SetParameter(nameof(employeeId), employeeId)
.SetParameter(nameof(firstName), firstName)
.SetParameter(nameof(lastName), lastName)
.SetParameter(nameof(phone), phone)
.SetParameter(nameof(username), username)
.SetParameter(nameof(email), email)
.SetParameter(nameof(username), username)
.SetParameter(nameof(domainname), domainname)
.SetParameter(nameof(password), password)
.ExecuteScalar(x => x.GetSmallint());
public void ResetPassword(short employeeId)
@@ -211,7 +215,7 @@
.SetParameter(nameof(employeeId), employeeId)
.ExecuteNonQuery();
public void SetPassword(short employeeId, string password)
public bool SetPassword(short employeeId, string password)
=> this.sqlConnection
.CreateCommand($@"
UPDATE [Mitarbeiter]
@@ -219,16 +223,18 @@
WHERE [MitarbeiterNr] = @{nameof(employeeId)}")
.SetParameter(nameof(employeeId), employeeId)
.SetParameter(nameof(password), password)
.ExecuteNonQuery();
.ExecuteNonQuery() == 1;
public short Update(int employeeId, string firstName, string lastName, string phone, string username, string email)
public short Update(int employeeId, string firstName, string lastName, string phone, string email, string username, string domainname, string password)
=> this.sqlConnection
.CreateCommand($@"
UPDATE [Mitarbeiter]
SET [EmployeeId] = ISNULL(@{nameof(employeeId)}, [EmployeeId])
, [eMail] = ISNULL(@{nameof(email)}, [eMail])
, [Telefon] = ISNULL(@{nameof(phone)}, [Telefon])
, [DomainUser] = ISNULL(@{nameof(username)}, [DomainUser])
SET [EmployeeId] = ISNULL(@{nameof(employeeId)} , [EmployeeId])
, [eMail] = ISNULL(@{nameof(email)} , [eMail])
, [Telefon] = ISNULL(@{nameof(phone)} , [Telefon])
, [Benutzername] = ISNULL(@{nameof(username)} , [Benutzername])
, [DomainUser] = ISNULL(@{nameof(domainname)} , [DomainUser])
, [PasswordHash] = ISNULL(@{nameof(password)} , [PasswordHash])
OUTPUT [inserted].[MitarbeiterNr]
WHERE [Vorname] = @{nameof(firstName)}
AND [Name] = @{nameof(lastName)}
@@ -237,8 +243,10 @@
.SetParameter(nameof(firstName), firstName)
.SetParameter(nameof(lastName), lastName)
.SetParameter(nameof(phone), phone)
.SetParameter(nameof(username), username)
.SetParameter(nameof(email), email)
.SetParameter(nameof(username), username)
.SetParameter(nameof(domainname), domainname)
.SetParameter(nameof(password), password)
.ExecuteScalar(x => x.GetSmallint());
}
}
@@ -24,14 +24,14 @@
IEnumerable<string> GetUserRoles(string token);
short Insert(int employeeId, string firstName, string lastName, string phone, string username, string email);
short Insert(int employeeId, string firstName, string lastName, string phone, string email, string username, string domainname, string password);
void ResetPassword(short employeeId);
void ResetTokens(short employeeId);
void SetPassword(short employeeId, string password);
bool SetPassword(short employeeId, string password);
short Update(int employeeId, string firstName, string lastName, string phone, string username, string email);
short Update(int employeeId, string firstName, string lastName, string phone, string email, string username, string domainname, string password);
}
}
@@ -13,21 +13,7 @@
public int BuildV { get; set; }
[Range(1, int.MaxValue, ErrorMessage = "EmployeeId is required.")]
public int EmployeeId { get; set; }
[Required]
public string FirstName { get; set; }
[Required]
public string LastName { get; set; }
[Required]
public string Username { get; set; }
[Required]
public string Phone { get; set; }
[Required]
public string Email { get; set; }
}
}
@@ -0,0 +1,42 @@
namespace LaaProduction.SharedModels
{
using System.ComponentModel.DataAnnotations;
public class LDAPRegisterModel
{
[Required(AllowEmptyStrings = false)]
public string Assembly { get; set; }
public int MajorV { get; set; }
public int MinorV { get; set; }
public int BuildV { get; set; }
[Range(1, int.MaxValue, ErrorMessage = "Employee id is required.")]
public int EmployeeId { get; set; }
[Required(AllowEmptyStrings = false)]
public string FirstName { get; set; }
[Required(AllowEmptyStrings = false)]
public string LastName { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
[Required(AllowEmptyStrings = false)]
public string Username { get; set; }
[Required(AllowEmptyStrings = false)]
public string DomainName { get; set; }
[Required(AllowEmptyStrings = false)]
public string Password { get; set; }
[Required(AllowEmptyStrings = false)]
[Compare(nameof(Password), ErrorMessage = "Password and password confirmation did not match.")]
public string ConfirmPassword { get; set; }
}
}
@@ -48,7 +48,9 @@
</ItemGroup>
<ItemGroup>
<Compile Include="LDAPLoginModel.cs" />
<Compile Include="LDAPRegisterModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UserChangePasswordModel.cs" />
<Compile Include="UserLoginModel.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
@@ -0,0 +1,17 @@
namespace LaaProduction.SharedModels
{
using System.ComponentModel.DataAnnotations;
public class UserChangePasswordModel
{
[Required(AllowEmptyStrings = false)]
public string OldPassword { get; set; }
[Required(AllowEmptyStrings = false)]
public string NewPassword { get; set; }
[Required(AllowEmptyStrings = false)]
[Compare(nameof(NewPassword), ErrorMessage = "Password and password confirmation did not match.")]
public string ConfirmPassword { get; set; }
}
}
@@ -1,6 +1,7 @@
namespace LaaProductionWeb.API
{
using Newtonsoft.Json;
using System.Net;
using System.Net.Http;
using System.Text;
@@ -33,10 +33,32 @@
{
return this.BadRequest();
}
else if (this.accountManager.Login(model, out var bearer) is null)
{
return this.StatusCode(HttpStatusCode.Accepted);
}
else
{
return this.Json(bearer);
}
}
var bearer = this.accountManager.Login(model);
return this.Json(bearer);
[HttpPut]
[Route(nameof(AD))]
public IHttpActionResult AD([FromBody] LDAPRegisterModel model)
{
if (!this.ModelState.IsValid)
{
return this.BadRequest();
}
else if (this.accountManager.Register(model, out var bearer) is null)
{
return this.StatusCode(HttpStatusCode.Accepted);
}
else
{
return this.Json(bearer);
}
}
[HttpPost]
@@ -52,5 +74,23 @@
return this.Json(bearer);
}
[HttpPut]
[AuthorizeBearer]
public IHttpActionResult Put([FromBody] UserChangePasswordModel model)
{
var bearer = this.User.GetNameIdentifier();
if (!this.ModelState.IsValid)
{
return this.BadRequest();
}
else if (!this.accountManager.ChangePassword(model.NewPassword, bearer))
{
this.ModelState.AddModelError(nameof(model.OldPassword), "Invalid change request!");
}
return this.Ok();
}
}
}
@@ -1,59 +0,0 @@
namespace LaaProductionWeb.API
{
using LaaProduction.Personalization.Interfaces;
using LaaProductionDI;
using System.ComponentModel.DataAnnotations;
using System.Web.Http;
[RoutePrefix("api/Register")]
public class RegisterController : ApiController
{
private readonly IAccountManager accountManager;
public RegisterController()
=> this.accountManager = LaaServiceProvider.GetService<IAccountManager>();
[HttpOptions]
public IHttpActionResult Options()
{
return this.Ok(new RegisterModel());
}
[HttpPost]
public IHttpActionResult Post(RegisterModel model)
{
if (!this.ModelState.IsValid)
{
return this.BadRequest(this.ModelState.ErrorsJson());
}
return this.Ok();
}
}
public class RegisterModel
{
[Required]
public string FirstName { get; set; }
[Required]
public string LastName { get; set; }
[Required]
public string Username { get; set; }
public string Domainuser { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
[Required]
public string Password { get; set; }
[Required]
[Compare(nameof(Password))]
public string ConfirmPassword { get; set; }
}
}
@@ -1,43 +0,0 @@
namespace LaaProductionWeb.Controllers
{
using Newtonsoft.Json;
using System.IO;
using System.Web;
using System.Web.Http;
[AllowAnonymous]
[RoutePrefix("/api/values")]
public class ValuesController : ApiController
{
// GET api/values
public object Get()
{
var filePath = HttpContext.Current.Server.MapPath("~/App_Content/json/chart.json");
var fileContent = File.ReadAllText(filePath);
return JsonConvert.DeserializeObject(fileContent);
}
// GET api/values/5
public string Get(int id)
{
return "value";
}
// POST api/values
public void Post([FromBody]string value)
{
}
// PUT api/values/5
public void Put(int id, [FromBody]string value)
{
}
// DELETE api/values/5
public void Delete(int id)
{
}
}
}
@@ -6,7 +6,6 @@
using System.Threading.Tasks;
using System.Web.Mvc;
using LaaProductionWeb.API;
[AllowAnonymous]
public class HomeController : Controller
@@ -19,13 +18,8 @@
}
[HttpGet]
public async Task<ActionResult> Index()
public ActionResult Index()
{
var response = await this.httpClient
.Post("/Register")
.WhitJsonBody(new RegisterModel())
.SendAsync<object>();
return this.View();
}
@@ -180,6 +180,7 @@
<Compile Include="API\Production\TempMeterController.cs" />
<Compile Include="API\Production\VFMController.cs" />
<Compile Include="API\Search\WildcardController.cs" />
<Compile Include="API\SendController.cs" />
<Compile Include="App_Infrastructure\AllowedRolesAttribute.cs" />
<Compile Include="App_Infrastructure\Appsettings.cs" />
<Compile Include="App_Infrastructure\AuthorizationFilter.cs" />
@@ -217,7 +218,6 @@
<Compile Include="Controllers\ReportController.cs" />
<Compile Include="Controllers\SearchController.cs" />
<Compile Include="Controllers\ShipmentsController.cs" />
<Compile Include="Controllers\ValuesController.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
@@ -225,6 +225,7 @@
<Compile Include="App_Start\StartupConfig.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="API\SendController.cs.sql" />
<Content Include="App_Content\css\bootstrap.min.css" />
<Content Include="App_Content\css\styles.css" />
<Content Include="App_Content\font\bootstrap-icons.min.css" />