diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 9e50e35..3db76d0 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -167,6 +167,32 @@ "endsPattern": "^.*Application started.*" } } + }, + { + "label": "userSecretsInit", + "command": "dotnet", + "type": "process", + "args": [ + "user-secrets", + "-p", + "${workspaceFolder}/Server/OI.Metrology.Server.csproj", + "init" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "userSecretsSet", + "command": "dotnet", + "type": "process", + "args": [ + "user-secrets", + "-p", + "${workspaceFolder}/Server/OI.Metrology.Server.csproj", + "set", + "asdf", + "123" + ], + "problemMatcher": "$msCompile" } ] } \ No newline at end of file diff --git a/Archive/OI.Metrology.Archive.csproj b/Archive/OI.Metrology.Archive.csproj index a0d7d79..d25f0fd 100644 --- a/Archive/OI.Metrology.Archive.csproj +++ b/Archive/OI.Metrology.Archive.csproj @@ -30,7 +30,7 @@ - + diff --git a/Server/OI.Metrology.Server.csproj b/Server/OI.Metrology.Server.csproj index 332c474..b78812d 100644 --- a/Server/OI.Metrology.Server.csproj +++ b/Server/OI.Metrology.Server.csproj @@ -28,14 +28,14 @@ - + - + diff --git a/Server/Repositories/InfinityQSRepository.cs b/Server/Repositories/InfinityQSRepository.cs index 9001770..52c9bdf 100644 --- a/Server/Repositories/InfinityQSRepository.cs +++ b/Server/Repositories/InfinityQSRepository.cs @@ -177,6 +177,36 @@ public class InfinityQSRepository : IInfinityQSRepository return result; } + string IInfinityQSRepository.GetCommandText(InfinityQSBase infinityQSBase) + { + StringBuilder result = new(); + if (string.IsNullOrEmpty(infinityQSBase.PR_NAME)) + throw new ArgumentException(nameof(infinityQSBase.PR_NAME)); + if (string.IsNullOrEmpty(infinityQSBase.PD_NAME)) + throw new ArgumentException(nameof(infinityQSBase.PD_NAME)); + if (infinityQSBase.SE_SGTM is null) + throw new ArgumentException(nameof(infinityQSBase.SE_SGTM)); + _ = result + .AppendLine(" select ev.f_evnt, ") + .AppendLine(" ev.f_sgtm, ") + .AppendLine(" pr.f_name, ") + .AppendLine(" pd.f_name, ") + .AppendLine(" td.f_name, ") + .AppendLine(" ev.f_name ") + .AppendLine(" from [spcepiworld].[dbo].[evnt_inf] ev ") + .AppendLine(" join [spcepiworld].[dbo].[prcs_dat] pr ") + .AppendLine(" on ev.f_prcs = pr.f_prcs ") + .AppendLine(" join [spcepiworld].[dbo].[part_dat] pd ") + .AppendLine(" on ev.f_part = pd.f_part ") + .AppendLine(" join [spcepiworld].[dbo].[test_dat] td ") + .AppendLine(" on ev.f_test = td.f_test ") + .Append(" where pr.f_name = '").Append(infinityQSBase.PR_NAME).AppendLine("' ") + .Append(" and pd.f_name = '").Append(infinityQSBase.PD_NAME).AppendLine("' ") + .Append(" and ev.f_sgtm = ").Append(infinityQSBase.SE_SGTM).AppendLine(" ") + .AppendLine(" for json path "); + return result.ToString(); + } + Result IInfinityQSRepository.GetEvents(string subGroupId) { Result? result; @@ -196,7 +226,7 @@ public class InfinityQSRepository : IInfinityQSRepository results = Array.Empty(); else { - string commandText = $"select * from [spcepiworld].[dbo].[evnt_inf] ev where ev.f_prcs = '{infinityQSBase.PR_NAME}' and ev.f_part = '{infinityQSBase.PD_NAME}' and ev.f_sgtm = {infinityQSBase.SE_SGTM} "; + string commandText = infinityQSRepository.GetCommandText(infinityQSBase); StringBuilder stringBuilder = GetForJsonPath(_DBConnectionFactory, commandText); results = JsonSerializer.Deserialize(stringBuilder.ToString(), new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); if (results is null) diff --git a/Server/Repositories/InfinityQSV2Repository.cs b/Server/Repositories/InfinityQSV2Repository.cs index b23acc7..6934cbd 100644 --- a/Server/Repositories/InfinityQSV2Repository.cs +++ b/Server/Repositories/InfinityQSV2Repository.cs @@ -180,6 +180,36 @@ public class InfinityQSV2Repository : IInfinityQSV2Repository return result; } + string IInfinityQSV2Repository.GetCommandText(InfinityQSBaseV2 infinityQSBase) + { + StringBuilder result = new(); + if (string.IsNullOrEmpty(infinityQSBase.Process)) + throw new ArgumentException(nameof(infinityQSBase.Process)); + if (string.IsNullOrEmpty(infinityQSBase.Part)) + throw new ArgumentException(nameof(infinityQSBase.Part)); + if (infinityQSBase.SubGroupDateTime is null) + throw new ArgumentException(nameof(infinityQSBase.SubGroupDateTime)); + _ = result + .AppendLine(" select ev.f_evnt, ") + .AppendLine(" ev.f_sgtm, ") + .AppendLine(" pr.f_name, ") + .AppendLine(" pd.f_name, ") + .AppendLine(" td.f_name, ") + .AppendLine(" ev.f_name ") + .AppendLine(" from [spcepiworld].[dbo].[evnt_inf] ev ") + .AppendLine(" join [spcepiworld].[dbo].[prcs_dat] pr ") + .AppendLine(" on ev.f_prcs = pr.f_prcs ") + .AppendLine(" join [spcepiworld].[dbo].[part_dat] pd ") + .AppendLine(" on ev.f_part = pd.f_part ") + .AppendLine(" join [spcepiworld].[dbo].[test_dat] td ") + .AppendLine(" on ev.f_test = td.f_test ") + .Append(" where pr.f_name = '").Append(infinityQSBase.Process).AppendLine("' ") + .Append(" and pd.f_name = '").Append(infinityQSBase.Part).AppendLine("' ") + .Append(" and ev.f_sgtm = ").Append(infinityQSBase.SubGroupDateTime).AppendLine(" ") + .AppendLine(" for json path "); + return result.ToString(); + } + Result IInfinityQSV2Repository.GetEvents(string subGroupId) { Result? result; @@ -199,7 +229,7 @@ public class InfinityQSV2Repository : IInfinityQSV2Repository collection = Array.Empty(); else { - string commandText = $"select * from [spcepiworld].[dbo].[evnt_inf] ev where ev.f_prcs = '{infinityQSBase.Process}' and ev.f_part = '{infinityQSBase.Part}' and ev.f_sgtm = {infinityQSBase.SubGroupDateTime} "; + string commandText = infinityQSV2Repository.GetCommandText(infinityQSBase); StringBuilder stringBuilder = GetForJsonPath(_DBConnectionFactory, commandText); collection = JsonSerializer.Deserialize(stringBuilder.ToString(), new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); if (collection is null) diff --git a/Shared/Models/Stateless/IInfinityQSRepository.cs b/Shared/Models/Stateless/IInfinityQSRepository.cs index 1b35a79..3f046e0 100644 --- a/Shared/Models/Stateless/IInfinityQSRepository.cs +++ b/Shared/Models/Stateless/IInfinityQSRepository.cs @@ -6,6 +6,7 @@ public interface IInfinityQSRepository { string GetCommandText(string subGroupId); + string GetCommandText(InfinityQSBase infinityQSBase); string GetCommandText(string? subGroupId, string? process, string? job, string? part, string? lot, string? dateTime); Result GetData(string subGroupId); Result GetDescriptors(string subGroupId); diff --git a/Shared/Models/Stateless/IInfinityQSV2Repository.cs b/Shared/Models/Stateless/IInfinityQSV2Repository.cs index 566c16c..31db4b1 100644 --- a/Shared/Models/Stateless/IInfinityQSV2Repository.cs +++ b/Shared/Models/Stateless/IInfinityQSV2Repository.cs @@ -6,6 +6,7 @@ public interface IInfinityQSV2Repository { string GetCommandText(string subGroupId); + string GetCommandText(InfinityQSBaseV2 infinityQSBase); string GetCommandText(string? subGroupId, string? process, string? job, string? part, string? lot, string? dateTime); Result GetData(string subGroupId); Result GetDescriptors(string subGroupId); diff --git a/Shared/OI.Metrology.Shared.csproj b/Shared/OI.Metrology.Shared.csproj index 526a475..9301b92 100644 --- a/Shared/OI.Metrology.Shared.csproj +++ b/Shared/OI.Metrology.Shared.csproj @@ -31,7 +31,7 @@ - + \ No newline at end of file diff --git a/Tests/OI.Metrology.Tests.csproj b/Tests/OI.Metrology.Tests.csproj index 3af27c8..3a478d7 100644 --- a/Tests/OI.Metrology.Tests.csproj +++ b/Tests/OI.Metrology.Tests.csproj @@ -32,7 +32,7 @@ - + diff --git a/View/OI.Metrology.View.csproj b/View/OI.Metrology.View.csproj index 8de7e60..b5f23e3 100644 --- a/View/OI.Metrology.View.csproj +++ b/View/OI.Metrology.View.csproj @@ -9,13 +9,13 @@ - + - +