remove appsettings
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -347,3 +347,5 @@ Server/wwwroot/js/chat.js
|
|||||||
Server/Hubs/ChatHub.cs
|
Server/Hubs/ChatHub.cs
|
||||||
Server/Pages/Chat.cshtml
|
Server/Pages/Chat.cshtml
|
||||||
Server/Pages/Chat.cshtml.cs
|
Server/Pages/Chat.cshtml.cs
|
||||||
|
|
||||||
|
.kanbn
|
@ -4,6 +4,9 @@ startedColumns:
|
|||||||
completedColumns:
|
completedColumns:
|
||||||
- Done
|
- Done
|
||||||
dateFormat: mm/dd
|
dateFormat: mm/dd
|
||||||
|
created: "2023-10-20T05:13:53.975Z"
|
||||||
|
updated: "2023-10-20T05:13:53.975Z"
|
||||||
|
type: "note"
|
||||||
---
|
---
|
||||||
|
|
||||||
# Barcode-Host
|
# Barcode-Host
|
||||||
@ -25,6 +28,7 @@ dateFormat: mm/dd
|
|||||||
- [roll-out](tasks/roll-out.md)
|
- [roll-out](tasks/roll-out.md)
|
||||||
- [publish](tasks/publish.md)
|
- [publish](tasks/publish.md)
|
||||||
- [post-only-once](tasks/post-only-once.md)
|
- [post-only-once](tasks/post-only-once.md)
|
||||||
|
- [convert-to-net-7](tasks/convert-to-net-7.md)
|
||||||
|
|
||||||
## Done
|
## Done
|
||||||
|
|
||||||
|
31
.vscode/settings.json
vendored
31
.vscode/settings.json
vendored
@ -1,19 +1,16 @@
|
|||||||
{
|
{
|
||||||
"files.eol": "\n",
|
"[markdown]": {
|
||||||
"[markdown]": {
|
"editor.wordWrap": "off"
|
||||||
"editor.wordWrap": "off"
|
},
|
||||||
},
|
"coverage-gutters.coverageBaseDir": "../.vscode/TestResults/*",
|
||||||
"cSpell.enabled": false,
|
"cSpell.enabled": false,
|
||||||
"thunder-client.saveToWorkspace": true,
|
"files.eol": "\n",
|
||||||
"thunder-client.workspaceRelativePath": ".vscode",
|
"files.exclude": {
|
||||||
"coverage-gutters.coverageBaseDir": "../.vscode/TestResults/*",
|
"**/node_modules": true
|
||||||
"[markdown]": {
|
},
|
||||||
"editor.wordWrap": "off"
|
"files.watcherExclude": {
|
||||||
},
|
"**/node_modules": true
|
||||||
"files.exclude": {
|
},
|
||||||
"**/node_modules": true
|
"thunder-client.saveToWorkspace": true,
|
||||||
},
|
"thunder-client.workspaceRelativePath": ".vscode"
|
||||||
"files.watcherExclude": {
|
|
||||||
"**/node_modules": true
|
|
||||||
}
|
|
||||||
}
|
}
|
142
.vscode/tasks.json
vendored
142
.vscode/tasks.json
vendored
@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
"version": "2.0.0",
|
|
||||||
"options": {
|
"options": {
|
||||||
"env": {
|
"env": {
|
||||||
"serverUserSecretsId": "02dce973-df1d-4325-962a-ed549af8d4c5"
|
"serverUserSecretsId": "02dce973-df1d-4325-962a-ed549af8d4c5"
|
||||||
@ -7,21 +6,18 @@
|
|||||||
},
|
},
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"label": "userSecretsInit",
|
|
||||||
"command": "dotnet",
|
|
||||||
"type": "process",
|
|
||||||
"args": [
|
"args": [
|
||||||
"user-secrets",
|
"user-secrets",
|
||||||
"-p",
|
"-p",
|
||||||
"${workspaceFolder}/Server/Barcode.Host.Server.csproj",
|
"${workspaceFolder}/Server/Barcode.Host.Server.csproj",
|
||||||
"init"
|
"init"
|
||||||
],
|
],
|
||||||
"problemMatcher": "$msCompile"
|
"command": "dotnet",
|
||||||
|
"label": "userSecretsInit",
|
||||||
|
"problemMatcher": "$msCompile",
|
||||||
|
"type": "process"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "userSecretsSet",
|
|
||||||
"command": "dotnet",
|
|
||||||
"type": "process",
|
|
||||||
"args": [
|
"args": [
|
||||||
"user-secrets",
|
"user-secrets",
|
||||||
"-p",
|
"-p",
|
||||||
@ -30,12 +26,12 @@
|
|||||||
"asdf",
|
"asdf",
|
||||||
"123"
|
"123"
|
||||||
],
|
],
|
||||||
"problemMatcher": "$msCompile"
|
"command": "dotnet",
|
||||||
|
"label": "userSecretsSet",
|
||||||
|
"problemMatcher": "$msCompile",
|
||||||
|
"type": "process"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "userSecretsMkLink",
|
|
||||||
"command": "cmd",
|
|
||||||
"type": "shell",
|
|
||||||
"args": [
|
"args": [
|
||||||
"/c",
|
"/c",
|
||||||
"mklink",
|
"mklink",
|
||||||
@ -43,47 +39,47 @@
|
|||||||
".vscode\\UserSecrets",
|
".vscode\\UserSecrets",
|
||||||
"${userHome}\\AppData\\Roaming\\Microsoft\\UserSecrets\\$env:serverUserSecretsId"
|
"${userHome}\\AppData\\Roaming\\Microsoft\\UserSecrets\\$env:serverUserSecretsId"
|
||||||
],
|
],
|
||||||
"problemMatcher": "$msCompile"
|
"command": "cmd",
|
||||||
|
"label": "userSecretsMkLink",
|
||||||
|
"problemMatcher": "$msCompile",
|
||||||
|
"type": "shell"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "buildServer",
|
|
||||||
"command": "dotnet",
|
|
||||||
"type": "process",
|
|
||||||
"args": [
|
"args": [
|
||||||
"build",
|
"build",
|
||||||
"${workspaceFolder}/Server/Barcode.Host.Server.csproj",
|
"${workspaceFolder}/Server/Barcode.Host.Server.csproj",
|
||||||
"/property:GenerateFullPaths=true",
|
"/property:GenerateFullPaths=true",
|
||||||
"/consoleloggerparameters:NoSummary"
|
"/consoleloggerparameters:NoSummary"
|
||||||
],
|
],
|
||||||
"problemMatcher": "$msCompile"
|
"command": "dotnet",
|
||||||
|
"label": "buildServer",
|
||||||
|
"problemMatcher": "$msCompile",
|
||||||
|
"type": "process"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "publishServer",
|
|
||||||
"command": "dotnet",
|
|
||||||
"type": "process",
|
|
||||||
"args": [
|
"args": [
|
||||||
"publish",
|
"publish",
|
||||||
"${workspaceFolder}/Server/Barcode.Host.Server.csproj",
|
"${workspaceFolder}/Server/Barcode.Host.Server.csproj",
|
||||||
"/property:GenerateFullPaths=true",
|
"/property:GenerateFullPaths=true",
|
||||||
"/consoleloggerparameters:NoSummary"
|
"/consoleloggerparameters:NoSummary"
|
||||||
],
|
],
|
||||||
"problemMatcher": "$msCompile"
|
"command": "dotnet",
|
||||||
|
"label": "publishServer",
|
||||||
|
"problemMatcher": "$msCompile",
|
||||||
|
"type": "process"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "testDebug",
|
|
||||||
"command": "dotnet",
|
|
||||||
"type": "process",
|
|
||||||
"args": [
|
"args": [
|
||||||
"test",
|
"test",
|
||||||
"/property:GenerateFullPaths=true",
|
"/property:GenerateFullPaths=true",
|
||||||
"/consoleloggerparameters:NoSummary"
|
"/consoleloggerparameters:NoSummary"
|
||||||
],
|
],
|
||||||
"problemMatcher": "$msCompile"
|
"command": "dotnet",
|
||||||
|
"label": "testDebug",
|
||||||
|
"problemMatcher": "$msCompile",
|
||||||
|
"type": "process"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "testRelease",
|
|
||||||
"command": "dotnet",
|
|
||||||
"type": "process",
|
|
||||||
"args": [
|
"args": [
|
||||||
"test",
|
"test",
|
||||||
"/property:GenerateFullPaths=true",
|
"/property:GenerateFullPaths=true",
|
||||||
@ -91,12 +87,12 @@
|
|||||||
"-c",
|
"-c",
|
||||||
"Release"
|
"Release"
|
||||||
],
|
],
|
||||||
"problemMatcher": "$msCompile"
|
"command": "dotnet",
|
||||||
|
"label": "testRelease",
|
||||||
|
"problemMatcher": "$msCompile",
|
||||||
|
"type": "process"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "format",
|
|
||||||
"command": "dotnet",
|
|
||||||
"type": "process",
|
|
||||||
"args": [
|
"args": [
|
||||||
"format",
|
"format",
|
||||||
"--report",
|
"--report",
|
||||||
@ -106,24 +102,24 @@
|
|||||||
"--severity",
|
"--severity",
|
||||||
"warn"
|
"warn"
|
||||||
],
|
],
|
||||||
"problemMatcher": "$msCompile"
|
"command": "dotnet",
|
||||||
|
"label": "format",
|
||||||
|
"problemMatcher": "$msCompile",
|
||||||
|
"type": "process"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "old-watch",
|
|
||||||
"command": "dotnet",
|
|
||||||
"type": "process",
|
|
||||||
"args": [
|
"args": [
|
||||||
"watch",
|
"watch",
|
||||||
"run",
|
"run",
|
||||||
"--project",
|
"--project",
|
||||||
"${workspaceFolder}/Server/Barcode.Host.Server.csproj"
|
"${workspaceFolder}/Server/Barcode.Host.Server.csproj"
|
||||||
],
|
],
|
||||||
"problemMatcher": "$msCompile"
|
"command": "dotnet",
|
||||||
|
"label": "old-watch",
|
||||||
|
"problemMatcher": "$msCompile",
|
||||||
|
"type": "process"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "watchServer",
|
|
||||||
"command": "dotnet",
|
|
||||||
"type": "process",
|
|
||||||
"args": [
|
"args": [
|
||||||
"watch",
|
"watch",
|
||||||
"--launch-profile",
|
"--launch-profile",
|
||||||
@ -133,68 +129,72 @@
|
|||||||
"${workspaceFolder}/Server/Barcode.Host.Server.csproj",
|
"${workspaceFolder}/Server/Barcode.Host.Server.csproj",
|
||||||
"--verbose"
|
"--verbose"
|
||||||
],
|
],
|
||||||
"isBackground": true,
|
"command": "dotnet",
|
||||||
"dependsOn": [
|
"dependsOn": [
|
||||||
"build"
|
"build"
|
||||||
],
|
],
|
||||||
|
"isBackground": true,
|
||||||
|
"label": "watchServer",
|
||||||
"problemMatcher": {
|
"problemMatcher": {
|
||||||
"fileLocation": "relative",
|
|
||||||
"pattern": {
|
|
||||||
"regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$",
|
|
||||||
"file": 1,
|
|
||||||
"location": 2,
|
|
||||||
"severity": 3,
|
|
||||||
"code": 4,
|
|
||||||
"message": 5
|
|
||||||
},
|
|
||||||
"background": {
|
"background": {
|
||||||
"activeOnStart": true,
|
"activeOnStart": true,
|
||||||
"beginsPattern": "^.*Shutdown requested.*",
|
"beginsPattern": "^.*Shutdown requested.*",
|
||||||
"endsPattern": "^.*Application started.*"
|
"endsPattern": "^.*Application started.*"
|
||||||
|
},
|
||||||
|
"fileLocation": "relative",
|
||||||
|
"pattern": {
|
||||||
|
"code": 4,
|
||||||
|
"file": 1,
|
||||||
|
"location": 2,
|
||||||
|
"message": 5,
|
||||||
|
"regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$",
|
||||||
|
"severity": 3
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"type": "process"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "PowerShell Force Clean",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "& Get-ChildItem . -include bin,obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }",
|
"command": "& Get-ChildItem . -include bin,obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }",
|
||||||
"problemMatcher": []
|
"label": "PowerShell Force Clean",
|
||||||
|
"problemMatcher": [],
|
||||||
|
"type": "shell"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "PowerShell Clean TestResults",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "& Get-ChildItem . -include TestResults -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }",
|
"command": "& Get-ChildItem . -include TestResults -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }",
|
||||||
"problemMatcher": []
|
"label": "PowerShell Clean TestResults",
|
||||||
|
"problemMatcher": [],
|
||||||
|
"type": "shell"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "File-Folder-Helper AOT s Set metadata",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "& L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net7.0/win-x64/publish/File-Folder-Helper.exe .kanbn",
|
"command": "& L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net7.0/win-x64/publish/File-Folder-Helper.exe .kanbn",
|
||||||
"problemMatcher": []
|
"label": "File-Folder-Helper AOT s Set metadata",
|
||||||
|
"problemMatcher": [],
|
||||||
|
"type": "shell"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "File-Folder-Helper AOT s M tasks",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "& L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net7.0/win-x64/publish/File-Folder-Helper.exe s M .kanbn/tasks",
|
"command": "& L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net7.0/win-x64/publish/File-Folder-Helper.exe s M .kanbn/tasks",
|
||||||
"problemMatcher": []
|
"label": "File-Folder-Helper AOT s M tasks",
|
||||||
|
"problemMatcher": [],
|
||||||
|
"type": "shell"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Kanbn Console",
|
"label": "Kanbn Console",
|
||||||
"type": "npm",
|
"problemMatcher": [],
|
||||||
"script": "kanbn.board",
|
"script": "kanbn.board",
|
||||||
"problemMatcher": []
|
"type": "npm"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Kanbn Write Boad",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "& kanbn board -j | L:/Git/kanbn2md/kanbn2md.exe >.kanbn/board.md",
|
"command": "& kanbn board -j | L:/Git/kanbn2md/kanbn2md.exe >.kanbn/board.md",
|
||||||
"problemMatcher": []
|
"label": "Kanbn Write Boad",
|
||||||
|
"problemMatcher": [],
|
||||||
|
"type": "shell"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Kanbn Write json",
|
"label": "Kanbn Write json",
|
||||||
"type": "npm",
|
"problemMatcher": [],
|
||||||
"script": "kanbn.board.json",
|
"script": "kanbn.board.json",
|
||||||
"problemMatcher": []
|
"type": "npm"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"version": "2.0.0"
|
||||||
}
|
}
|
@ -4,6 +4,7 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<UserSecretsId>02dce973-df1d-4325-962a-ed549af8d4c5</UserSecretsId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VSTestLogger>trx</VSTestLogger>
|
<VSTestLogger>trx</VSTestLogger>
|
||||||
@ -30,25 +31,13 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.5" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.11" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.1" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
|
||||||
<PackageReference Include="MSTest.TestAdapter" Version="3.0.4" />
|
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
|
||||||
<PackageReference Include="MSTest.TestFramework" Version="3.0.4" />
|
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
|
||||||
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
|
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
|
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
|
||||||
<PackageReference Include="Serilog" Version="2.12.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Shared\Barcode.Host.Shared.csproj" />
|
<ProjectReference Include="..\Shared\Barcode.Host.Shared.csproj" />
|
||||||
<ProjectReference Include="..\Server\Barcode.Host.Server.csproj" />
|
<ProjectReference Include="..\Server\Barcode.Host.Server.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Include="..\Server\appsettings.json">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Include="..\Server\appsettings.Development.json">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
@ -2,7 +2,7 @@ using Barcode.Host.Shared.Models;
|
|||||||
using Barcode.Host.Shared.Models.Stateless;
|
using Barcode.Host.Shared.Models.Stateless;
|
||||||
using Microsoft.AspNetCore.Mvc.Testing;
|
using Microsoft.AspNetCore.Mvc.Testing;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Serilog;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Barcode.Host.Tests;
|
namespace Barcode.Host.Tests;
|
||||||
|
|
||||||
@ -10,20 +10,17 @@ namespace Barcode.Host.Tests;
|
|||||||
public class UnitTestFileService
|
public class UnitTestFileService
|
||||||
{
|
{
|
||||||
|
|
||||||
#pragma warning disable CS8618
|
private static ILogger? _Logger;
|
||||||
|
private static TestContext? _TestContext;
|
||||||
private static ILogger _Logger;
|
private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
|
||||||
private static TestContext _TestContext;
|
|
||||||
private static WebApplicationFactory<Server.Program> _WebApplicationFactory;
|
|
||||||
|
|
||||||
#pragma warning restore
|
|
||||||
|
|
||||||
[ClassInitialize]
|
[ClassInitialize]
|
||||||
public static void ClassInitAsync(TestContext testContext)
|
public static void ClassInitAsync(TestContext testContext)
|
||||||
{
|
{
|
||||||
_TestContext = testContext;
|
_TestContext = testContext;
|
||||||
_Logger = Log.ForContext<UnitTestFileService>();
|
|
||||||
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
|
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
|
||||||
|
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
|
||||||
|
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void NonThrowTryCatch()
|
private static void NonThrowTryCatch()
|
||||||
@ -39,13 +36,15 @@ public class UnitTestFileService
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void GetWrite()
|
public void GetWrite()
|
||||||
{
|
{
|
||||||
_Logger.Information("Starting Web Application");
|
_Logger?.LogInformation("Starting Web Application");
|
||||||
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
|
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
|
||||||
Server.Models.AppSettings appSettings = serviceProvider.GetRequiredService<Server.Models.AppSettings>();
|
Server.Models.AppSettings? appSettings = serviceProvider?.GetRequiredService<Server.Models.AppSettings>();
|
||||||
IFileService fileService = serviceProvider.GetRequiredService<IFileService>();
|
IFileService? fileService = serviceProvider?.GetRequiredService<IFileService>();
|
||||||
Notification notification = new(KeyPressEvent: null, "Test", appSettings.ToolClass, null);
|
Assert.IsNotNull(appSettings);
|
||||||
|
Assert.IsNotNull(fileService);
|
||||||
|
Notification? notification = new(KeyPressEvent: null, "Test", appSettings.ToolClass, null);
|
||||||
fileService.Write(appSettings.EquipmentName, appSettings.FileShare, calendar: null, notification);
|
fileService.Write(appSettings.EquipmentName, appSettings.FileShare, calendar: null, notification);
|
||||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
_Logger?.LogInformation("{testName} completed", _TestContext?.TestName);
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ using Barcode.Host.Shared.DataModels;
|
|||||||
using Barcode.Host.Shared.Models.Stateless;
|
using Barcode.Host.Shared.Models.Stateless;
|
||||||
using Microsoft.AspNetCore.Mvc.Testing;
|
using Microsoft.AspNetCore.Mvc.Testing;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Serilog;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Barcode.Host.Tests;
|
namespace Barcode.Host.Tests;
|
||||||
|
|
||||||
@ -10,21 +10,18 @@ namespace Barcode.Host.Tests;
|
|||||||
public class UnitTestLastScanController
|
public class UnitTestLastScanController
|
||||||
{
|
{
|
||||||
|
|
||||||
#pragma warning disable CS8618
|
private static ILogger? _Logger;
|
||||||
|
private static string? _ControllerName;
|
||||||
private static ILogger _Logger;
|
private static TestContext? _TestContext;
|
||||||
private static string _ControllerName;
|
private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
|
||||||
private static TestContext _TestContext;
|
|
||||||
private static WebApplicationFactory<Server.Program> _WebApplicationFactory;
|
|
||||||
|
|
||||||
#pragma warning restore
|
|
||||||
|
|
||||||
[ClassInitialize]
|
[ClassInitialize]
|
||||||
public static void ClassInitAsync(TestContext testContext)
|
public static void ClassInitAsync(TestContext testContext)
|
||||||
{
|
{
|
||||||
_TestContext = testContext;
|
_TestContext = testContext;
|
||||||
_Logger = Log.ForContext<UnitTestLastScanController>();
|
|
||||||
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
|
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
|
||||||
|
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
|
||||||
|
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
|
||||||
_ControllerName = nameof(Server.ApiControllers.LastScanController)[..^10];
|
_ControllerName = nameof(Server.ApiControllers.LastScanController)[..^10];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,9 +35,9 @@ public class UnitTestLastScanController
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestControllerName()
|
public void TestControllerName()
|
||||||
{
|
{
|
||||||
_Logger.Information("Starting Web Application");
|
_Logger?.LogInformation("Starting Web Application");
|
||||||
Assert.AreEqual(ILastScanController<string>.GetRouteName(), _ControllerName);
|
Assert.AreEqual(ILastScanController<string>.GetRouteName(), _ControllerName);
|
||||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
_Logger?.LogInformation("{testName} completed", _TestContext?.TestName);
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,12 +47,13 @@ public class UnitTestLastScanController
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void GetScan()
|
public void GetScan()
|
||||||
{
|
{
|
||||||
_Logger.Information("Starting Web Application");
|
_Logger?.LogInformation("Starting Web Application");
|
||||||
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
|
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
|
||||||
ILastScanService lastScanService = serviceProvider.GetRequiredService<ILastScanService>();
|
ILastScanService? lastScanService = serviceProvider?.GetRequiredService<ILastScanService>();
|
||||||
|
Assert.IsNotNull(lastScanService);
|
||||||
Result<string> result = lastScanService.GetScan();
|
Result<string> result = lastScanService.GetScan();
|
||||||
Assert.IsNotNull(result?.Results);
|
Assert.IsNotNull(result?.Results);
|
||||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
_Logger?.LogInformation("{testName} completed", _TestContext?.TestName);
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,13 +63,14 @@ public class UnitTestLastScanController
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task GetScanApi()
|
public async Task GetScanApi()
|
||||||
{
|
{
|
||||||
HttpClient httpClient = _WebApplicationFactory.CreateClient();
|
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
|
||||||
_Logger.Information("Starting Web Application");
|
_Logger?.LogInformation("Starting Web Application");
|
||||||
|
Assert.IsNotNull(httpClient);
|
||||||
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/O171927.1.37/");
|
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/O171927.1.37/");
|
||||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetScan)}.json"), json);
|
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetScan)}.json"), json);
|
||||||
Result<string>? result = System.Text.Json.JsonSerializer.Deserialize<Result<string>>(json);
|
Result<string>? result = System.Text.Json.JsonSerializer.Deserialize<Result<string>>(json);
|
||||||
Assert.IsNotNull(result?.Results);
|
Assert.IsNotNull(result?.Results);
|
||||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
_Logger?.LogInformation("{testName} completed", _TestContext?.TestName);
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ using Barcode.Host.Shared.Models;
|
|||||||
using Barcode.Host.Shared.Models.Stateless;
|
using Barcode.Host.Shared.Models.Stateless;
|
||||||
using Microsoft.AspNetCore.Mvc.Testing;
|
using Microsoft.AspNetCore.Mvc.Testing;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Serilog;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Barcode.Host.Tests;
|
namespace Barcode.Host.Tests;
|
||||||
|
|
||||||
@ -10,20 +10,17 @@ namespace Barcode.Host.Tests;
|
|||||||
public class UnitTestPostService
|
public class UnitTestPostService
|
||||||
{
|
{
|
||||||
|
|
||||||
#pragma warning disable CS8618
|
private static ILogger? _Logger;
|
||||||
|
private static TestContext? _TestContext;
|
||||||
private static ILogger _Logger;
|
private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
|
||||||
private static TestContext _TestContext;
|
|
||||||
private static WebApplicationFactory<Server.Program> _WebApplicationFactory;
|
|
||||||
|
|
||||||
#pragma warning restore
|
|
||||||
|
|
||||||
[ClassInitialize]
|
[ClassInitialize]
|
||||||
public static void ClassInitAsync(TestContext testContext)
|
public static void ClassInitAsync(TestContext testContext)
|
||||||
{
|
{
|
||||||
_TestContext = testContext;
|
_TestContext = testContext;
|
||||||
_Logger = Log.ForContext<UnitTestPostService>();
|
|
||||||
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
|
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
|
||||||
|
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
|
||||||
|
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void NonThrowTryCatch()
|
private static void NonThrowTryCatch()
|
||||||
@ -39,14 +36,18 @@ public class UnitTestPostService
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void GetPostTo()
|
public void GetPostTo()
|
||||||
{
|
{
|
||||||
_Logger.Information("Starting Web Application");
|
_Logger?.LogInformation("Starting Web Application");
|
||||||
HttpClient httpClient = _WebApplicationFactory.CreateClient();
|
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
|
||||||
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
|
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
|
||||||
Server.Models.AppSettings appSettings = serviceProvider.GetRequiredService<Server.Models.AppSettings>();
|
Server.Models.AppSettings? appSettings = serviceProvider?.GetRequiredService<Server.Models.AppSettings>();
|
||||||
IPostService postService = serviceProvider.GetRequiredService<IPostService>();
|
IPostService? postService = serviceProvider?.GetRequiredService<IPostService>();
|
||||||
Notification notification = new(KeyPressEvent: null, "Test", appSettings.ToolClass, null);
|
Assert.IsNotNull(httpClient);
|
||||||
|
Assert.IsNotNull(appSettings);
|
||||||
|
Assert.IsNotNull(postService);
|
||||||
|
Notification? notification = new(KeyPressEvent: null, "Test", appSettings.ToolClass, null);
|
||||||
|
Assert.IsNotNull(notification);
|
||||||
_ = postService.Post(appSettings.PostTo, httpClient, notification);
|
_ = postService.Post(appSettings.PostTo, httpClient, notification);
|
||||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
_Logger?.LogInformation("{testName} completed", _TestContext?.TestName);
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,27 +22,17 @@
|
|||||||
<DefineConstants>Linux</DefineConstants>
|
<DefineConstants>Linux</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CliWrap" Version="3.6.3" />
|
<PackageReference Include="CliWrap" Version="3.6.4" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="7.0.5" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="7.0.11" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
|
||||||
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="7.0.0" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
|
|
||||||
<PackageReference Include="Serilog" Version="2.12.0" />
|
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||||
<PackageReference Include="System.IO.Ports" Version="7.0.0" />
|
<PackageReference Include="System.IO.Ports" Version="7.0.0" />
|
||||||
<PackageReference Include="System.Text.Json" Version="7.0.2" />
|
<PackageReference Include="System.Text.Json" Version="7.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Shared\Barcode.Host.Shared.csproj" />
|
<ProjectReference Include="..\Shared\Barcode.Host.Shared.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Include="appsettings.json">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Include="appsettings.Development.json">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
@ -5,7 +5,6 @@ using Barcode.Host.Shared.KeyboardMouse;
|
|||||||
using Barcode.Host.Shared.Models;
|
using Barcode.Host.Shared.Models;
|
||||||
using Barcode.Host.Shared.Models.Stateless;
|
using Barcode.Host.Shared.Models.Stateless;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using Serilog.Context;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
|
||||||
namespace Barcode.Host.Server.HostedService;
|
namespace Barcode.Host.Server.HostedService;
|
||||||
@ -65,12 +64,9 @@ public class TimedHostedService : IHostedService, IAggregateInputReader, IDispos
|
|||||||
|
|
||||||
public Task StartAsync(CancellationToken stoppingToken)
|
public Task StartAsync(CancellationToken stoppingToken)
|
||||||
{
|
{
|
||||||
string? methodName = IMethodName.GetActualAsyncMethodName();
|
_Logger.LogInformation("Timed Hosted Service: {BuildSourceVersion}:{ProcessId} running.", _AppSettings.BuildSourceVersion, Environment.ProcessId);
|
||||||
using (LogContext.PushProperty("MethodName", methodName))
|
if (!string.IsNullOrEmpty(_AppSettings.SerialPortName))
|
||||||
{
|
_SerialService.Open();
|
||||||
_Logger.LogInformation($"Timed Hosted Service: {_AppSettings.BuildSourceVersion}:{Environment.ProcessId} running.");
|
|
||||||
if (!string.IsNullOrEmpty(_AppSettings.SerialPortName))
|
|
||||||
_SerialService.Open();
|
|
||||||
#if Linux
|
#if Linux
|
||||||
if (!_LinuxGroupManager.IsInInputGroup().WaitAsync(stoppingToken).Result)
|
if (!_LinuxGroupManager.IsInInputGroup().WaitAsync(stoppingToken).Result)
|
||||||
{
|
{
|
||||||
@ -80,32 +76,29 @@ public class TimedHostedService : IHostedService, IAggregateInputReader, IDispos
|
|||||||
_ = _LinuxGroupManager.RebootSystem(_AppSettings.RootPassword);
|
_ = _LinuxGroupManager.RebootSystem(_AppSettings.RootPassword);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
List<(EventCode, char)> collection = _LastScanService.IncludeEventCodes();
|
List<(EventCode, char)> collection = _LastScanService.IncludeEventCodes();
|
||||||
foreach ((EventCode eventCode, char @char) in collection)
|
foreach ((EventCode eventCode, char @char) in collection)
|
||||||
_CharToEventCodes.Add(eventCode, @char);
|
_CharToEventCodes.Add(eventCode, @char);
|
||||||
int dueTime = 0;
|
int dueTime = 0;
|
||||||
foreach ((string _, Timer timer) in _Timers)
|
foreach ((string _, Timer timer) in _Timers)
|
||||||
{
|
{
|
||||||
dueTime += 300;
|
dueTime += 300;
|
||||||
_ = timer.Change(dueTime, Timeout.Infinite);
|
_ = timer.Change(dueTime, Timeout.Infinite);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task StopAsync(CancellationToken stoppingToken)
|
public Task StopAsync(CancellationToken stoppingToken)
|
||||||
{
|
{
|
||||||
string? methodName = IMethodName.GetActualAsyncMethodName();
|
_Logger.LogInformation("Timed Hosted Service: {BuildSourceVersion}:{ProcessId} is stopping.", _AppSettings.BuildSourceVersion, Environment.ProcessId);
|
||||||
using (LogContext.PushProperty("MethodName", methodName))
|
for (short i = 0; i < short.MaxValue; i++)
|
||||||
{
|
{
|
||||||
_Logger.LogInformation($"Timed Hosted Service: {_AppSettings.BuildSourceVersion}:{Environment.ProcessId} is stopping.");
|
Thread.Sleep(500);
|
||||||
for (short i = 0; i < short.MaxValue; i++)
|
if (_ExecutionCount == 0)
|
||||||
{
|
break;
|
||||||
Thread.Sleep(500);
|
|
||||||
if (_ExecutionCount == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Barcode.Host.Server.Models;
|
namespace Barcode.Host.Server.Models;
|
||||||
|
|
||||||
@ -32,8 +33,14 @@ public record AppSettings(string BuildNumber,
|
|||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
string result = JsonSerializer.Serialize(this, AppSettingsSourceGenerationContext.Default.AppSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(AppSettings))]
|
||||||
|
internal partial class AppSettingsSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
2
Server/Models/Binder/.editorconfig
Normal file
2
Server/Models/Binder/.editorconfig
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[*.cs]
|
||||||
|
csharp_preserve_single_line_statements = true
|
@ -1,4 +1,3 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace Barcode.Host.Server.Models.Binder;
|
namespace Barcode.Host.Server.Models.Binder;
|
||||||
@ -6,34 +5,32 @@ namespace Barcode.Host.Server.Models.Binder;
|
|||||||
public class AppSettings
|
public class AppSettings
|
||||||
{
|
{
|
||||||
|
|
||||||
[Display(Name = "Build Number"), Required] public string? BuildNumber { get; set; }
|
public string? BuildNumber { get; set; }
|
||||||
[Display(Name = "Build Source Version"), Required] public string? BuildSourceVersion { get; set; }
|
public string? BuildSourceVersion { get; set; }
|
||||||
[Display(Name = "Last Scan Service Clear After"), Required] public int? ClearLastScanServiceAfter { get; set; }
|
public int? ClearLastScanServiceAfter { get; set; }
|
||||||
[Display(Name = "Company"), Required] public string? Company { get; set; }
|
public string? Company { get; set; }
|
||||||
[Display(Name = "Device Name Ends With"), Required] public string? DeviceNameEndsWith { get; set; }
|
public string? DeviceNameEndsWith { get; set; }
|
||||||
[Display(Name = "Equipment Name"), Required] public string? EquipmentName { get; set; }
|
public string? EquipmentName { get; set; }
|
||||||
[Display(Name = "ExpectedScanLengthA"), Required] public int? ExpectedScanLengthA { get; set; }
|
public int? ExpectedScanLengthA { get; set; }
|
||||||
[Display(Name = "ExpectedScanLengthB"), Required] public int? ExpectedScanLengthB { get; set; }
|
public int? ExpectedScanLengthB { get; set; }
|
||||||
[Display(Name = "File Share"), Required] public string? FileShare { get; set; }
|
public string? FileShare { get; set; }
|
||||||
[Display(Name = "Is Development"), Required] public bool? IsDevelopment { get; set; }
|
public bool? IsDevelopment { get; set; }
|
||||||
[Display(Name = "Is Staging"), Required] public bool? IsStaging { get; set; }
|
public bool? IsStaging { get; set; }
|
||||||
[Display(Name = "Linux Device Path"), Required] public string? LinuxDevicePath { get; set; }
|
public string? LinuxDevicePath { get; set; }
|
||||||
[Display(Name = "Mock Root"), Required] public string? MockRoot { get; set; }
|
public string? MockRoot { get; set; }
|
||||||
[Display(Name = "MonA Resource"), Required] public string? MonAResource { get; set; }
|
public string? MonAResource { get; set; }
|
||||||
[Display(Name = "MonA Site"), Required] public string? MonASite { get; set; }
|
public string? MonASite { get; set; }
|
||||||
[Display(Name = "Notify Minimum"), Required] public int? NotifyMinimum { get; set; }
|
public int? NotifyMinimum { get; set; }
|
||||||
[Display(Name = "OpenInsight Application Programming Interface"), Required] public string? OpenInsightApplicationProgrammingInterface { get; set; }
|
public string? OpenInsightApplicationProgrammingInterface { get; set; }
|
||||||
[Display(Name = "PostTo"), Required] public string? PostTo { get; set; }
|
public string? PostTo { get; set; }
|
||||||
[Display(Name = "Post to Every"), Required] public int? PostToEvery { get; set; }
|
public int? PostToEvery { get; set; }
|
||||||
[Display(Name = "RootPassword"), Required] public string? RootPassword { get; set; }
|
public string? RootPassword { get; set; }
|
||||||
[Display(Name = "Serial Port Name"), Required] public string? SerialPortName { get; set; }
|
public string? SerialPortName { get; set; }
|
||||||
[Display(Name = "Share to Every"), Required] public int? ShareToEvery { get; set; }
|
public int? ShareToEvery { get; set; }
|
||||||
[Display(Name = "ToolClass"), Required] public string? ToolClass { get; set; }
|
public string? ToolClass { get; set; }
|
||||||
[Display(Name = "URLs"), Required] public string? URLs { get; set; }
|
public string? URLs { get; set; }
|
||||||
[Display(Name = "Working Directory Name"), Required] public string? WorkingDirectoryName { get; set; }
|
public string? WorkingDirectoryName { get; set; }
|
||||||
[Display(Name = "WriteToSerialEvery"), Required] public int? WriteToSerialEvery { get; set; }
|
public int? WriteToSerialEvery { get; set; }
|
||||||
|
|
||||||
#nullable restore
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
@ -44,60 +41,33 @@ public class AppSettings
|
|||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
if (appSettings is null)
|
if (appSettings is null) throw new NullReferenceException(nameof(appSettings));
|
||||||
throw new NullReferenceException(nameof(appSettings));
|
if (appSettings.BuildNumber is null) throw new NullReferenceException(nameof(BuildNumber));
|
||||||
if (appSettings.BuildNumber is null)
|
if (appSettings.BuildSourceVersion is null) throw new NullReferenceException(nameof(BuildSourceVersion));
|
||||||
throw new NullReferenceException(nameof(BuildNumber));
|
if (appSettings.ClearLastScanServiceAfter is null) throw new NullReferenceException(nameof(ClearLastScanServiceAfter));
|
||||||
if (appSettings.BuildSourceVersion is null)
|
if (appSettings.Company is null) throw new NullReferenceException(nameof(Company));
|
||||||
throw new NullReferenceException(nameof(BuildSourceVersion));
|
if (appSettings.DeviceNameEndsWith is null) throw new NullReferenceException(nameof(DeviceNameEndsWith));
|
||||||
if (appSettings.ClearLastScanServiceAfter is null)
|
if (appSettings.EquipmentName is null) throw new NullReferenceException(nameof(EquipmentName));
|
||||||
throw new NullReferenceException(nameof(ClearLastScanServiceAfter));
|
if (appSettings.ExpectedScanLengthA is null) throw new NullReferenceException(nameof(ExpectedScanLengthA));
|
||||||
if (appSettings.Company is null)
|
if (appSettings.ExpectedScanLengthB is null) throw new NullReferenceException(nameof(ExpectedScanLengthB));
|
||||||
throw new NullReferenceException(nameof(Company));
|
if (appSettings.FileShare is null) throw new NullReferenceException(nameof(FileShare));
|
||||||
if (appSettings.DeviceNameEndsWith is null)
|
if (appSettings.IsDevelopment is null) throw new NullReferenceException(nameof(IsDevelopment));
|
||||||
throw new NullReferenceException(nameof(DeviceNameEndsWith));
|
if (appSettings.IsStaging is null) throw new NullReferenceException(nameof(IsStaging));
|
||||||
if (appSettings.EquipmentName is null)
|
if (appSettings.LinuxDevicePath is null) throw new NullReferenceException(nameof(LinuxDevicePath));
|
||||||
throw new NullReferenceException(nameof(EquipmentName));
|
if (appSettings.MockRoot is null) throw new NullReferenceException(nameof(MockRoot));
|
||||||
if (appSettings.ExpectedScanLengthA is null)
|
if (appSettings.MonAResource is null) throw new NullReferenceException(nameof(MonAResource));
|
||||||
throw new NullReferenceException(nameof(ExpectedScanLengthA));
|
if (appSettings.MonASite is null) throw new NullReferenceException(nameof(MonASite));
|
||||||
if (appSettings.ExpectedScanLengthB is null)
|
if (appSettings.NotifyMinimum is null) throw new NullReferenceException(nameof(NotifyMinimum));
|
||||||
throw new NullReferenceException(nameof(ExpectedScanLengthB));
|
if (appSettings.OpenInsightApplicationProgrammingInterface is null) throw new NullReferenceException(nameof(OpenInsightApplicationProgrammingInterface));
|
||||||
if (appSettings.FileShare is null)
|
if (appSettings.PostTo is null) throw new NullReferenceException(nameof(PostTo));
|
||||||
throw new NullReferenceException(nameof(FileShare));
|
if (appSettings.PostToEvery is null) throw new NullReferenceException(nameof(PostToEvery));
|
||||||
if (appSettings.IsDevelopment is null)
|
if (appSettings.RootPassword is null) throw new NullReferenceException(nameof(RootPassword));
|
||||||
throw new NullReferenceException(nameof(IsDevelopment));
|
if (appSettings.SerialPortName is null) throw new NullReferenceException(nameof(SerialPortName));
|
||||||
if (appSettings.IsStaging is null)
|
if (appSettings.ShareToEvery is null) throw new NullReferenceException(nameof(ShareToEvery));
|
||||||
throw new NullReferenceException(nameof(IsStaging));
|
if (appSettings.ToolClass is null) throw new NullReferenceException(nameof(ToolClass));
|
||||||
if (appSettings.LinuxDevicePath is null)
|
if (appSettings.URLs is null) throw new NullReferenceException(nameof(URLs));
|
||||||
throw new NullReferenceException(nameof(LinuxDevicePath));
|
if (appSettings.WorkingDirectoryName is null) throw new NullReferenceException(nameof(WorkingDirectoryName));
|
||||||
if (appSettings.MockRoot is null)
|
if (appSettings.WriteToSerialEvery is null) throw new NullReferenceException(nameof(WriteToSerialEvery));
|
||||||
throw new NullReferenceException(nameof(MockRoot));
|
|
||||||
if (appSettings.MonAResource is null)
|
|
||||||
throw new NullReferenceException(nameof(MonAResource));
|
|
||||||
if (appSettings.MonASite is null)
|
|
||||||
throw new NullReferenceException(nameof(MonASite));
|
|
||||||
if (appSettings.NotifyMinimum is null)
|
|
||||||
throw new NullReferenceException(nameof(NotifyMinimum));
|
|
||||||
if (appSettings.OpenInsightApplicationProgrammingInterface is null)
|
|
||||||
throw new NullReferenceException(nameof(OpenInsightApplicationProgrammingInterface));
|
|
||||||
if (appSettings.PostTo is null)
|
|
||||||
throw new NullReferenceException(nameof(PostTo));
|
|
||||||
if (appSettings.PostToEvery is null)
|
|
||||||
throw new NullReferenceException(nameof(PostToEvery));
|
|
||||||
if (appSettings.RootPassword is null)
|
|
||||||
throw new NullReferenceException(nameof(RootPassword));
|
|
||||||
if (appSettings.SerialPortName is null)
|
|
||||||
throw new NullReferenceException(nameof(SerialPortName));
|
|
||||||
if (appSettings.ShareToEvery is null)
|
|
||||||
throw new NullReferenceException(nameof(ShareToEvery));
|
|
||||||
if (appSettings.ToolClass is null)
|
|
||||||
throw new NullReferenceException(nameof(ToolClass));
|
|
||||||
if (appSettings.URLs is null)
|
|
||||||
throw new NullReferenceException(nameof(URLs));
|
|
||||||
if (appSettings.WorkingDirectoryName is null)
|
|
||||||
throw new NullReferenceException(nameof(WorkingDirectoryName));
|
|
||||||
if (appSettings.WriteToSerialEvery is null)
|
|
||||||
throw new NullReferenceException(nameof(WriteToSerialEvery));
|
|
||||||
result = new(
|
result = new(
|
||||||
appSettings.BuildNumber,
|
appSettings.BuildNumber,
|
||||||
appSettings.BuildSourceVersion,
|
appSettings.BuildSourceVersion,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Diagnostics;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Barcode.Host.Server.Pages;
|
namespace Barcode.Host.Server.Pages;
|
||||||
|
|
||||||
@ -20,4 +20,3 @@ public class ErrorModel : PageModel
|
|||||||
public void OnGet() =>
|
public void OnGet() =>
|
||||||
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
|
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,50 +2,21 @@
|
|||||||
using Barcode.Host.Server.Hubs;
|
using Barcode.Host.Server.Hubs;
|
||||||
using Barcode.Host.Server.Models;
|
using Barcode.Host.Server.Models;
|
||||||
using Barcode.Host.Server.Services;
|
using Barcode.Host.Server.Services;
|
||||||
using Barcode.Host.Shared.Models;
|
|
||||||
using Barcode.Host.Shared.Models.Stateless;
|
using Barcode.Host.Shared.Models.Stateless;
|
||||||
using Serilog;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace Barcode.Host.Server;
|
namespace Barcode.Host.Server;
|
||||||
|
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
|
|
||||||
private static (string, WebApplicationOptions) Get(string[] args)
|
|
||||||
{
|
|
||||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
|
||||||
string? assemblyName = assembly.GetName()?.Name;
|
|
||||||
if (string.IsNullOrEmpty(assemblyName))
|
|
||||||
throw new Exception();
|
|
||||||
string baseAssemblyName = assemblyName.Split('.')[0];
|
|
||||||
string webRootPath = Path.Combine(AppContext.BaseDirectory.Split(baseAssemblyName)[0], baseAssemblyName, "wwwroot");
|
|
||||||
if (!Directory.Exists(webRootPath))
|
|
||||||
webRootPath = string.Empty;
|
|
||||||
WebApplicationOptions webApplicationOptions = new()
|
|
||||||
{
|
|
||||||
Args = args,
|
|
||||||
ContentRootPath = AppContext.BaseDirectory,
|
|
||||||
WebRootPath = webRootPath
|
|
||||||
};
|
|
||||||
return new(assemblyName, webApplicationOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int Main(string[] args)
|
public static int Main(string[] args)
|
||||||
{
|
{
|
||||||
LoggerConfiguration loggerConfiguration = new();
|
ILogger<Program>? logger = null;
|
||||||
(string assemblyName, _) = Get(args);
|
|
||||||
WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder(args);
|
WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder(args);
|
||||||
_ = webApplicationBuilder.Configuration.AddUserSecrets<Program>();
|
_ = webApplicationBuilder.Configuration.AddUserSecrets<Program>();
|
||||||
AppSettings appSettings = Models.Binder.AppSettings.Get(webApplicationBuilder.Configuration);
|
AppSettings appSettings = Models.Binder.AppSettings.Get(webApplicationBuilder.Configuration);
|
||||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
if (string.IsNullOrEmpty(appSettings.Company))
|
||||||
throw new Exception("Working directory name must have a value!");
|
throw new Exception("Company name must have a value!");
|
||||||
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assemblyName, appSettings.WorkingDirectoryName);
|
|
||||||
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
|
|
||||||
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, webApplicationBuilder.Configuration);
|
|
||||||
_ = SerilogHostBuilderExtensions.UseSerilog(webApplicationBuilder.Host);
|
|
||||||
Log.Logger = loggerConfiguration.CreateLogger();
|
|
||||||
Serilog.ILogger log = Log.ForContext<Program>();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (appSettings.IsStaging && appSettings.IsDevelopment)
|
if (appSettings.IsStaging && appSettings.IsDevelopment)
|
||||||
@ -68,6 +39,7 @@ public class Program
|
|||||||
_ = webApplicationBuilder.Services.AddHostedService<TimedHostedService>();
|
_ = webApplicationBuilder.Services.AddHostedService<TimedHostedService>();
|
||||||
_ = webApplicationBuilder.Services.AddSwaggerGen();
|
_ = webApplicationBuilder.Services.AddSwaggerGen();
|
||||||
WebApplication webApplication = webApplicationBuilder.Build();
|
WebApplication webApplication = webApplicationBuilder.Build();
|
||||||
|
logger = webApplication.Services.GetRequiredService<ILogger<Program>>();
|
||||||
if (appSettings.IsDevelopment)
|
if (appSettings.IsDevelopment)
|
||||||
{
|
{
|
||||||
_ = webApplication.UseSwagger();
|
_ = webApplication.UseSwagger();
|
||||||
@ -79,25 +51,23 @@ public class Program
|
|||||||
_ = webApplication.UseExceptionHandler("/Error");
|
_ = webApplication.UseExceptionHandler("/Error");
|
||||||
_ = webApplication.UseHsts();
|
_ = webApplication.UseHsts();
|
||||||
}
|
}
|
||||||
_ = webApplication.Lifetime.ApplicationStopped.Register(Log.CloseAndFlush);
|
|
||||||
_ = webApplication.UseStaticFiles();
|
_ = webApplication.UseStaticFiles();
|
||||||
_ = webApplication.UseRouting();
|
_ = webApplication.UseRouting();
|
||||||
_ = webApplication.UseAuthorization();
|
_ = webApplication.UseAuthorization();
|
||||||
_ = webApplication.MapControllers();
|
_ = webApplication.MapControllers();
|
||||||
_ = webApplication.MapRazorPages();
|
_ = webApplication.MapRazorPages();
|
||||||
_ = webApplication.MapHub<NotificationHub>($"/{nameof(NotificationHub)}");
|
_ = webApplication.MapHub<NotificationHub>($"/{nameof(NotificationHub)}");
|
||||||
log.Information("Starting Web Application");
|
logger.LogInformation("Starting Web Application");
|
||||||
|
logger.LogCritical("{Company}", appSettings.Company);
|
||||||
webApplication.Run();
|
webApplication.Run();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
log.Fatal(ex, "Host terminated unexpectedly");
|
try
|
||||||
return 1;
|
{ logger?.LogCritical(ex, "Host terminated unexpectedly"); }
|
||||||
}
|
catch (Exception) { }
|
||||||
finally
|
throw;
|
||||||
{
|
|
||||||
Log.CloseAndFlush();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"ExpectedScanLengthA": 6,
|
|
||||||
"ExpectedScanLengthB": 9,
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Log4netProvider": "Debug"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"IsDevelopment": true,
|
|
||||||
"Serilog": {
|
|
||||||
"MinimumLevel": "Debug"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
{
|
|
||||||
"BuildNumber": "1",
|
|
||||||
"BuildSourceVersion": "1234567",
|
|
||||||
"Company": "Infineon Technologies Americas Corp.",
|
|
||||||
"ClearLastScanServiceAfter": 250,
|
|
||||||
"DeviceNameEndsWith": "Symbol Bar Code Scanner",
|
|
||||||
"EquipmentName": "",
|
|
||||||
"ExpectedScanLengthA": 8,
|
|
||||||
"ExpectedScanLengthB": 14,
|
|
||||||
"ExpectedScanLengthBExample": "1TO172125.1.11",
|
|
||||||
"FileShare": "",
|
|
||||||
"LinuxDevicePath": "/proc/bus/input/devices",
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft": "Warning",
|
|
||||||
"Log4netProvider": "Information",
|
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"IsDevelopment": false,
|
|
||||||
"IsStaging": false,
|
|
||||||
"NotifyMinimum": 3,
|
|
||||||
"MockRoot": "",
|
|
||||||
"MonAResource": "OI_Metrology_Viewer_EC",
|
|
||||||
"MonASite": "auc",
|
|
||||||
"OpenInsightApplicationProgrammingInterface": "https://oi-prod-ec-api.mes.infineon.com/api/oiWizard",
|
|
||||||
"PostTo": "",
|
|
||||||
"PostToEvery": 1000,
|
|
||||||
"SerialPortName": "/dev/ttyUSB0",
|
|
||||||
"Serilog": {
|
|
||||||
"Using": [
|
|
||||||
"Serilog.Sinks.Console",
|
|
||||||
"Serilog.Sinks.File"
|
|
||||||
],
|
|
||||||
"MinimumLevel": "Information",
|
|
||||||
"WriteTo": [
|
|
||||||
{
|
|
||||||
"Name": "Debug",
|
|
||||||
"Args": {
|
|
||||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "Console",
|
|
||||||
"Args": {
|
|
||||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "File",
|
|
||||||
"Args": {
|
|
||||||
"path": "%workingDirectory% - Log/log-.txt",
|
|
||||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}",
|
|
||||||
"rollingInterval": "Hour"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"Enrich": [
|
|
||||||
"FromLogContext",
|
|
||||||
"WithMachineName",
|
|
||||||
"WithThreadId"
|
|
||||||
],
|
|
||||||
"Properties": {
|
|
||||||
"Application": "Sample"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ShareToEvery": 1000,
|
|
||||||
"RootPassword": "",
|
|
||||||
"ToolClass": "FTIR",
|
|
||||||
"URLs": "http://localhost:5003;",
|
|
||||||
"WorkingDirectoryName": "IFXApps",
|
|
||||||
"WriteToSerialEvery": 750
|
|
||||||
}
|
|
@ -20,7 +20,7 @@
|
|||||||
<DefineConstants>Linux</DefineConstants>
|
<DefineConstants>Linux</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="System.Text.Json" Version="7.0.2" />
|
<PackageReference Include="System.Text.Json" Version="7.0.3" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
|
||||||
|
Reference in New Issue
Block a user