diff --git a/.kanbn/board.css b/.kanbn/board.css new file mode 100644 index 0000000..427c0bd --- /dev/null +++ b/.kanbn/board.css @@ -0,0 +1,28 @@ +.kanbn-column-wip .kanbn-column-task-list { + border-color: #6929c4; +} +.kanbn-column-next .kanbn-column-task-list { + border-color: #1192e8; +} +.kanbn-column-wait .kanbn-column-task-list { + border-color: #005d5d; +} +.kanbn-column-later .kanbn-column-task-list { + border-color: #9f1853; +} +.kanbn-column-maybe .kanbn-column-task-list { + border-color: #fa4d56; +} +.kanbn-column-friday .kanbn-column-task-list { + border-color: #570408; +} +.kanbn-column-done .kanbn-column-task-list { + border-color: #198038; +} +.kanbn-task-data-workload { + display: none; +} +.kanbn-task-data-relation { + display: block; + color: #198038; +} diff --git a/.kanbn/index.md b/.kanbn/index.md index 4b72297..3de6f96 100644 --- a/.kanbn/index.md +++ b/.kanbn/index.md @@ -1,33 +1,42 @@ --- startedColumns: - - 'In Progress' + - "In Progress" completedColumns: - Done +dateFormat: mm/dd --- # Barcode-Host ## Backlog -- [update-os](tasks/update-os.md) - [apt-get-install](tasks/apt-get-install.md) -- [configure-ufw](tasks/configure-ufw.md) -- [install-ubuntu-frame](tasks/install-ubuntu-frame.md) - [netplan](tasks/netplan.md) -- [install-net-7-0](tasks/install-net-7-0.md) -- [pull-repo](tasks/pull-repo.md) -- [run-secrets-task](tasks/run-secrets-task.md) -- [install-vscode-extensions](tasks/install-vscode-extensions.md) -- [run-test-ports](tasks/run-test-ports.md) -- [signalr](tasks/signalr.md) -- [publish](tasks/publish.md) -- [create-as-service](tasks/create-as-service.md) -- [setup-nginx](tasks/setup-nginx.md) -- [self-signed-certificate](tasks/self-signed-certificate.md) -- [roll-out](tasks/roll-out.md) ## Todo +- [epi-pro-scan](tasks/epi-pro-scan.md) + ## In Progress +- [post-only-once](tasks/post-only-once.md) +- [publish](tasks/publish.md) +- [roll-out](tasks/roll-out.md) +- [self-signed-certificate](tasks/self-signed-certificate.md) +- [update-os](tasks/update-os.md) + ## Done + +- [configure-ufw](tasks/configure-ufw.md) +- [create-as-service](tasks/create-as-service.md) +- [install-net-7-0](tasks/install-net-7-0.md) +- [install-ubuntu-frame](tasks/install-ubuntu-frame.md) +- [install-vscode-extensions](tasks/install-vscode-extensions.md) +- [pull-repo](tasks/pull-repo.md) +- [run-secrets-task](tasks/run-secrets-task.md) +- [run-test-ports](tasks/run-test-ports.md) +- [setup-nginx](tasks/setup-nginx.md) + +## Archive + +- [signalr](tasks/signalr.md) diff --git a/.kanbn/tasks/configure-ufw.md b/.kanbn/tasks/configure-ufw.md index b0e93d2..5d66850 100644 --- a/.kanbn/tasks/configure-ufw.md +++ b/.kanbn/tasks/configure-ufw.md @@ -34,6 +34,7 @@ ufw allow from 192.168.0.0/24 to any port 8011 comment "22) syncthing" ufw allow from 0.0.0.0/0 to any port 5201 comment "23) iperf3" ufw enable ufw status numbered +ufw disable ``` ```conf Status: active diff --git a/.kanbn/tasks/epi-pro-scan.md b/.kanbn/tasks/epi-pro-scan.md new file mode 100644 index 0000000..2941d95 --- /dev/null +++ b/.kanbn/tasks/epi-pro-scan.md @@ -0,0 +1,13 @@ +--- +--- + +# epi-pro-scan + +```bash +``` + +## Sub-tasks + +- [ ] phares3757 +- [x] unity4 +- [x] unity5 diff --git a/.kanbn/tasks/post-only-once.md b/.kanbn/tasks/post-only-once.md new file mode 100644 index 0000000..b5a3f7e --- /dev/null +++ b/.kanbn/tasks/post-only-once.md @@ -0,0 +1,12 @@ +--- +--- + +# post-only-once + +- Change to keep track but only post on a timmer + +## Sub-tasks + +- [ ] phares3757 +- [x] unity4 +- [x] unity5 diff --git a/.kanbn/tasks/publish.md b/.kanbn/tasks/publish.md index 1ac49dc..2bd2d29 100644 --- a/.kanbn/tasks/publish.md +++ b/.kanbn/tasks/publish.md @@ -11,17 +11,16 @@ mkdir /var/www mkdir /var/www/Barcode-Host mkdir /var/www/Barcode-Host/Server cd /home/unity4/Barcode-Host/Server -dotnet user-secrets init -dotnet user-secrets set "SerialPortName" "" -dotnet user-secrets set "RootPassword" "asdf" -dotnet user-secrets set "EquipmentName" "BIORAD4" -dotnet user-secrets set "FileShare" "\\\mestsa003.infineon.com\\EC_Metrology_Si\\BarcodeHost\\API" dotnet user-secrets list -dotnet publish --configuration Release --output /var/www/Barcode-Host/Server +dotnet nuget list source +dotnet nuget remove source nuget.org +dotnet build --source https://api.nuget.org/v3/index.json +dotnet publish --configuration Release --output /var/www/Barcode-Host/Server --source https://api.nuget.org/v3/index.json cd /var/www/Barcode-Host/Server dotnet /var/www/Barcode-Host/Server/Barcode.Host.Server.dll systemctl start barcode-host.service ``` + ```bash nano /etc/fstab 10.95.176.46:EC_Metrology_Si /var/locally-mounted/eaf-dev.mes.infineon.com nfs defaults 0 0 @@ -36,6 +35,7 @@ smbclient --list=10.95.128.34 --no-pass apt install smbclient ecmesEAF-10.95.128.34-mestsa07ec(A-Both) ``` + ```conf 2023-06-03 16:02:25.011 -07:00 [Information] (Barcode.Host.Server.Program.) () () Starting Web Application 2023-06-03 16:02:25.062 -07:00 [Information] (Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager.) () () User profile is available. Using '"/root/.aspnet/DataProtection-Keys"' as key repository; keys will not be encrypted at rest. @@ -45,6 +45,7 @@ ecmesEAF-10.95.128.34-mestsa07ec(A-Both) 2023-06-03 16:02:25.176 -07:00 [Information] (Microsoft.Hosting.Lifetime.) () () Hosting environment: "Production" 2023-06-03 16:02:25.176 -07:00 [Information] (Microsoft.Hosting.Lifetime.) () () Content root path: "/var/www/Barcode-Host/Server" ``` + ```bash links http://localhost:5003/api/lastScan ``` diff --git a/.kanbn/tasks/run-secrets-task.md b/.kanbn/tasks/run-secrets-task.md index 4ae7dde..7411052 100644 --- a/.kanbn/tasks/run-secrets-task.md +++ b/.kanbn/tasks/run-secrets-task.md @@ -4,8 +4,12 @@ # run-secrets-task ```bash -cd Server -dotnet user-secrets set RootPassword 4hink +cd Barcode-Host/Server +dotnet user-secrets init +dotnet user-secrets set "SerialPortName" "" +dotnet user-secrets set "RootPassword" "asdf" +dotnet user-secrets set "PostTo" "http://eaf-staging.mes.infineon.com:8080/api/Barcode/asdf" +dotnet user-secrets list ``` ## Sub-tasks diff --git a/.kanbn/tasks/self-signed-certificate.md b/.kanbn/tasks/self-signed-certificate.md index 5a9c425..93e07d0 100644 --- a/.kanbn/tasks/self-signed-certificate.md +++ b/.kanbn/tasks/self-signed-certificate.md @@ -5,16 +5,50 @@ ```bash sudo -i -nano /etc/hosts/ +echo >/etc/hosts && nano /etc/hosts +``` +```conf +127.0.0.1 localhost +127.0.1.1 unity4 +10.95.154.18 unity5 +#; 10.95.154.54 unity4 +192.168.0.40 DESKTOP-H6JG91B +192.168.0.118 ISCN5CG1325C0X +10.95.176.46 eaf-dev.mes.infineon.com +10.95.128.35 eaf-prod.mes.infineon.com +10.95.128.34 eaf-staging.mes.infineon.com +10.95.176.124 eaf-dev-reporting.mes.infineon.com +10.95.128.37 oi-metrology-viewer-prod.mes.infineon.com +# The following lines are desirable for IPv6 capable hosts +::1 ip6-localhost ip6-loopback +fe00::0 ip6-localnet +ff00::0 ip6-mcastprefix +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters +``` +```bash +sudo -i apt-get install -y ca-certificates +cd /home/unity4/Barcode-Host openssl s_client -showcerts -connect DESKTOP-H6JG91B:443 /dev/null|openssl x509 -outform PEM >DESKTOP-H6JG91B.crt -cp /home/unity5/Barcode-Host/DESKTOP-H6JG91B.crt /usr/local/share/ca-certificates/DESKTOP-H6JG91B.crt +cp /home/unity4/Barcode-Host/DESKTOP-H6JG91B.crt /usr/local/share/ca-certificates/DESKTOP-H6JG91B.crt update-ca-certificates +openssl s_client -showcerts -connect unity4:443 /dev/null|openssl x509 -outform PEM >unity4.crt +cp /home/unity4/Barcode-Host/unity4.crt /usr/local/share/ca-certificates/unity4.crt +update-ca-certificates +openssl s_client -showcerts -connect unity5:443 /dev/null|openssl x509 -outform PEM >unity5.crt +cp /home/unity5/Barcode-Host/unity5.crt /usr/local/share/ca-certificates/unity5.crt +update-ca-certificates +cd /home/unity4/Barcode-Host +openssl s_client -showcerts -connect eaf-prod.mes.infineon.com:443 /dev/null|openssl x509 -outform PEM >eaf-prod.mes.infineon.com.crt +cp /home/unity4/Barcode-Host/eaf-prod.mes.infineon.com.crt /usr/local/share/ca-certificates/eaf-prod.mes.infineon.com.crt +update-ca-certificates +links https://eaf-prod.mes.infineon.com/v3/index.json exit ``` ## Sub-tasks - [ ] phares3757 -- [ ] unity4 +- [x] unity4 - [x] unity5 diff --git a/.kanbn/tasks/update-os.md b/.kanbn/tasks/update-os.md index 090415d..5418067 100644 --- a/.kanbn/tasks/update-os.md +++ b/.kanbn/tasks/update-os.md @@ -4,6 +4,7 @@ # update-os ```bash +lsb_release -a apt update apt upgrade -y apt install update-manager-core diff --git a/Server/HostedService/TimedHostedService.cs b/Server/HostedService/TimedHostedService.cs index 02dc087..b0397ab 100644 --- a/Server/HostedService/TimedHostedService.cs +++ b/Server/HostedService/TimedHostedService.cs @@ -22,11 +22,12 @@ public class TimedHostedService : IHostedService, IAggregateInputReader, IDispos private readonly IPostService _PostService; private readonly ISerialService _SerialService; private readonly ILastScanService _LastScanService; + private readonly List _Notifications; private readonly ILogger _Logger; private readonly IHttpClientFactory _HttpClientFactory; private readonly ILinuxGroupManager _LinuxGroupManager; - private readonly IHubContext _HubContext; private readonly Dictionary _Readers; + private readonly IHubContext _HubContext; private readonly Dictionary _CharToEventCodes; private readonly List<(string MethodName, Timer Timer)> _Timers; @@ -36,6 +37,7 @@ public class TimedHostedService : IHostedService, IAggregateInputReader, IDispos _Logger = logger; _Readers = new(); _ExecutionCount = 0; + _Notifications = new(); _HubContext = hubContext; _CharToEventCodes = new(); _AppSettings = appSettings; @@ -47,9 +49,15 @@ public class TimedHostedService : IHostedService, IAggregateInputReader, IDispos _LinuxGroupManager = linuxGroupManager; _Calendar = new CultureInfo("en-US").Calendar; Timer writeTimer = new(Write, null, Timeout.Infinite, Timeout.Infinite); + Timer postToTimer = new(PostTo, null, Timeout.Infinite, Timeout.Infinite); + Timer shareToTimer = new(ShareTo, null, Timeout.Infinite, Timeout.Infinite); Timer scanForNewInputsTimer = new(ScanForNewInputs, null, Timeout.Infinite, Timeout.Infinite); if (!string.IsNullOrEmpty(_AppSettings.SerialPortName)) _Timers.Add((nameof(Write), writeTimer)); + if (!string.IsNullOrEmpty(_AppSettings.PostTo)) + _Timers.Add((nameof(PostTo), postToTimer)); + if (!string.IsNullOrEmpty(_AppSettings.FileShare)) + _Timers.Add((nameof(ShareTo), shareToTimer)); #if Linux _Timers.Add((nameof(ScanForNewInputs), scanForNewInputsTimer)); #endif @@ -129,15 +137,9 @@ public class TimedHostedService : IHostedService, IAggregateInputReader, IDispos Result result = _LastScanService.GetScan(); if (!string.IsNullOrEmpty(result.Results)) { - Notification notification = new(e, result.Results); + Notification notification = new(e, result.Results, null); + _Notifications.Add(notification); _ = _HubContext.Clients.All.SendAsync(nameof(NotificationHub.NotifyAll), notification); - if (!string.IsNullOrEmpty(_AppSettings.FileShare)) - _FileService.Write(_AppSettings.EquipmentName, _AppSettings.FileShare, _Calendar, notification); - if (!string.IsNullOrEmpty(_AppSettings.PostTo)) - { - HttpClient httpClient = _HttpClientFactory.CreateClient(nameof(TimedHostedService)); - _ = _PostService.PostAsync(_AppSettings.PostTo, httpClient, notification); - } } } } @@ -225,4 +227,82 @@ public class TimedHostedService : IHostedService, IAggregateInputReader, IDispos catch (Exception ex) { _Logger.LogError(ex, $"{nameof(Write)}-{nameof(Timer)}.{nameof(Timer.Change)}"); } } + private void PostTo() + { + if (!string.IsNullOrEmpty(_AppSettings.PostTo)) + { + Task? httpResponseMessage; + lock (_Notifications) + { + if (!_Notifications.Any()) + httpResponseMessage = null; + else + { + HttpClient httpClient = _HttpClientFactory.CreateClient(nameof(TimedHostedService)); + httpResponseMessage = _PostService.PostAsync(_AppSettings.PostTo, httpClient, _Notifications.Last()); + _Notifications.Clear(); + } + } + if (httpResponseMessage is not null) + { + httpResponseMessage.Wait(); + if (httpResponseMessage.Result.StatusCode != System.Net.HttpStatusCode.OK) + throw new Exception(httpResponseMessage.Result.StatusCode.ToString()); + Task content = httpResponseMessage.Result.Content.ReadAsStringAsync(); + content.Wait(); + Notification notification = new(null, null, content.Result); + _ = _HubContext.Clients.All.SendAsync(nameof(NotificationHub.NotifyAll), notification); + } + } + } + + private void PostTo(object? sender) + { + try + { PostTo(); } + catch (Exception ex) { _Logger.LogError(ex, nameof(PostTo)); } + try + { + Timer? timer = GetTimer(nameof(PostTo)); + if (timer is not null) + { + TimeSpan timeSpan = new(DateTime.Now.AddMilliseconds(_AppSettings.PostToEvery).Ticks - DateTime.Now.Ticks); + _ = timer.Change((int)timeSpan.TotalMilliseconds, Timeout.Infinite); + } + } + catch (Exception ex) { _Logger.LogError(ex, $"{nameof(PostTo)}-{nameof(Timer)}.{nameof(Timer.Change)}"); } + } + + private void ShareTo() + { + if (!string.IsNullOrEmpty(_AppSettings.FileShare)) + { + lock (_Notifications) + { + if (_Notifications.Any()) + { + _FileService.Write(_AppSettings.EquipmentName, _AppSettings.FileShare, _Calendar, _Notifications.Last()); + _Notifications.Clear(); + } + } + } + } + + private void ShareTo(object? sender) + { + try + { ShareTo(); } + catch (Exception ex) { _Logger.LogError(ex, nameof(ShareTo)); } + try + { + Timer? timer = GetTimer(nameof(ShareTo)); + if (timer is not null) + { + TimeSpan timeSpan = new(DateTime.Now.AddMilliseconds(_AppSettings.ShareToEvery).Ticks - DateTime.Now.Ticks); + _ = timer.Change((int)timeSpan.TotalMilliseconds, Timeout.Infinite); + } + } + catch (Exception ex) { _Logger.LogError(ex, $"{nameof(ShareTo)}-{nameof(Timer)}.{nameof(Timer.Change)}"); } + } + } \ No newline at end of file diff --git a/Server/Models/AppSettings.cs b/Server/Models/AppSettings.cs index 582022a..94ee40a 100644 --- a/Server/Models/AppSettings.cs +++ b/Server/Models/AppSettings.cs @@ -3,24 +3,26 @@ using System.Text.Json; namespace Barcode.Host.Server.Models; public record AppSettings(string BuildNumber, - string Company, int ClearLastScanServiceAfter, + string Company, string DeviceNameEndsWith, string EquipmentName, int ExpectedScanLengthA, int ExpectedScanLengthB, string FileShare, string GitCommitSeven, - string LinuxDevicePath, bool IsDevelopment, bool IsStaging, - int NotifyMinimum, + string LinuxDevicePath, string MockRoot, string MonAResource, string MonASite, + int NotifyMinimum, string PostTo, + int PostToEvery, string RootPassword, string SerialPortName, + int ShareToEvery, string URLs, string WorkingDirectoryName, int WriteToSerialEvery) diff --git a/Server/Models/Binder/AppSettings.cs b/Server/Models/Binder/AppSettings.cs index 8cee8d5..3e29a00 100644 --- a/Server/Models/Binder/AppSettings.cs +++ b/Server/Models/Binder/AppSettings.cs @@ -9,24 +9,26 @@ public class AppSettings #nullable disable [Display(Name = "Build Number"), Required] public string BuildNumber { get; set; } - [Display(Name = "Company"), Required] public string Company { get; set; } [Display(Name = "Last Scan Service Clear After"), Required] public int? ClearLastScanServiceAfter { get; set; } + [Display(Name = "Company"), Required] public string Company { get; set; } [Display(Name = "Device Name Ends With"), Required] public string DeviceNameEndsWith { get; set; } [Display(Name = "Equipment Name"), Required] public string EquipmentName { get; set; } [Display(Name = "ExpectedScanLengthA"), Required] public int? ExpectedScanLengthA { get; set; } [Display(Name = "ExpectedScanLengthB"), Required] public int? ExpectedScanLengthB { get; set; } [Display(Name = "File Share"), Required] public string FileShare { get; set; } [Display(Name = "Git Commit Seven"), Required] public string GitCommitSeven { get; set; } - [Display(Name = "Linux Device Path"), Required] public string LinuxDevicePath { get; set; } [Display(Name = "Is Development"), Required] public bool? IsDevelopment { get; set; } [Display(Name = "Is Staging"), Required] public bool? IsStaging { get; set; } - [Display(Name = "Notify Minimum"), Required] public int? NotifyMinimum { get; set; } + [Display(Name = "Linux Device Path"), Required] public string LinuxDevicePath { get; set; } [Display(Name = "Mock Root"), Required] public string MockRoot { get; set; } [Display(Name = "MonA Resource"), Required] public string MonAResource { get; set; } [Display(Name = "MonA Site"), Required] public string MonASite { get; set; } + [Display(Name = "Notify Minimum"), Required] public int? NotifyMinimum { get; set; } [Display(Name = "PostTo"), Required] public string PostTo { get; set; } + [Display(Name = "Post to Every"), Required] public int? PostToEvery { get; set; } [Display(Name = "RootPassword"), Required] public string RootPassword { get; set; } [Display(Name = "Serial Port Name"), Required] public string SerialPortName { get; set; } + [Display(Name = "Share to Every"), Required] public int? ShareToEvery { get; set; } [Display(Name = "URLs"), Required] public string URLs { get; set; } [Display(Name = "Working Directory Name"), Required] public string WorkingDirectoryName { get; set; } [Display(Name = "WriteToSerialEvery"), Required] public int? WriteToSerialEvery { get; set; } @@ -46,10 +48,10 @@ public class AppSettings throw new NullReferenceException(nameof(appSettings)); if (appSettings.BuildNumber is null) throw new NullReferenceException(nameof(BuildNumber)); - if (appSettings.Company is null) - throw new NullReferenceException(nameof(Company)); if (appSettings.ClearLastScanServiceAfter is null) throw new NullReferenceException(nameof(ClearLastScanServiceAfter)); + if (appSettings.Company is null) + throw new NullReferenceException(nameof(Company)); if (appSettings.DeviceNameEndsWith is null) throw new NullReferenceException(nameof(DeviceNameEndsWith)); if (appSettings.EquipmentName is null) @@ -62,26 +64,30 @@ public class AppSettings throw new NullReferenceException(nameof(FileShare)); if (appSettings.GitCommitSeven is null) throw new NullReferenceException(nameof(GitCommitSeven)); - if (appSettings.LinuxDevicePath is null) - throw new NullReferenceException(nameof(LinuxDevicePath)); if (appSettings.IsDevelopment is null) throw new NullReferenceException(nameof(IsDevelopment)); if (appSettings.IsStaging is null) throw new NullReferenceException(nameof(IsStaging)); - if (appSettings.NotifyMinimum is null) - throw new NullReferenceException(nameof(NotifyMinimum)); + if (appSettings.LinuxDevicePath is null) + throw new NullReferenceException(nameof(LinuxDevicePath)); if (appSettings.MockRoot is null) 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.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.URLs is null) throw new NullReferenceException(nameof(URLs)); if (appSettings.WorkingDirectoryName is null) @@ -90,24 +96,26 @@ public class AppSettings throw new NullReferenceException(nameof(WriteToSerialEvery)); result = new( appSettings.BuildNumber, - appSettings.Company, appSettings.ClearLastScanServiceAfter.Value, + appSettings.Company, appSettings.DeviceNameEndsWith, appSettings.EquipmentName, appSettings.ExpectedScanLengthA.Value, appSettings.ExpectedScanLengthB.Value, appSettings.FileShare, appSettings.GitCommitSeven, - appSettings.LinuxDevicePath, appSettings.IsDevelopment.Value, appSettings.IsStaging.Value, - appSettings.NotifyMinimum.Value, + appSettings.LinuxDevicePath, appSettings.MockRoot, appSettings.MonAResource, appSettings.MonASite, + appSettings.NotifyMinimum.Value, appSettings.PostTo, + appSettings.PostToEvery.Value, appSettings.RootPassword, appSettings.SerialPortName, + appSettings.ShareToEvery.Value, appSettings.URLs, appSettings.WorkingDirectoryName, appSettings.WriteToSerialEvery.Value); diff --git a/Server/Pages/Notification.cshtml b/Server/Pages/Notification.cshtml index 3fd208f..e17d036 100644 --- a/Server/Pages/Notification.cshtml +++ b/Server/Pages/Notification.cshtml @@ -7,7 +7,12 @@
-

+

+
+
+
+
+

diff --git a/Server/appsettings.json b/Server/appsettings.json index 908cf1a..1e8b44e 100644 --- a/Server/appsettings.json +++ b/Server/appsettings.json @@ -1,5 +1,5 @@ { - "BuildNumber": "1", + "BuildNumber": "1", "Company": "Infineon Technologies Americas Corp.", "ClearLastScanServiceAfter": 250, "DeviceNameEndsWith": "Symbol Bar Code Scanner", @@ -25,6 +25,7 @@ "MonAResource": "OI_Metrology_Viewer_EC", "MonASite": "auc", "PostTo": "", + "PostToEvery": 1000, "SerialPortName": "/dev/ttyUSB0", "Serilog": { "Using": [ @@ -63,6 +64,7 @@ "Application": "Sample" } }, + "ShareToEvery": 1000, "RootPassword": "", "URLs": "http://localhost:5003;", "WorkingDirectoryName": "IFXApps", diff --git a/Server/wwwroot/js/notification.js b/Server/wwwroot/js/notification.js index 313a5a1..6ed5b43 100644 --- a/Server/wwwroot/js/notification.js +++ b/Server/wwwroot/js/notification.js @@ -3,8 +3,14 @@ var connection = new signalR.HubConnectionBuilder().withUrl("/NotificationHub").build(); connection.on("NotifyAll", function (data) { - var message = `${data.keyPressEvent.dateTime} - [${data.lastScanServiceResultValue}]`; - document.getElementById("data").innerText = message; + if (data.keyPressEvent && data.lastScanServiceResultValue) { + var innerText = `${data.keyPressEvent.dateTime} - [${data.lastScanServiceResultValue}]`; + document.getElementById("lastScanServiceResultValue").innerText = innerText; + } + else if (data.httpContentBody) { + var innerText = `${data.httpContentBody}]`; //JSON.parse() // JSON.stringify() + document.getElementById("httpContentBody").innerText = innerText; + } }); connection.start().then(function () { diff --git a/Shared/Models/Notification.cs b/Shared/Models/Notification.cs index cedb9f0..0360949 100644 --- a/Shared/Models/Notification.cs +++ b/Shared/Models/Notification.cs @@ -2,4 +2,4 @@ using Barcode.Host.Shared.KeyboardMouse; namespace Barcode.Host.Shared.Models; -public record Notification(KeyPressEvent? KeyPressEvent, string LastScanServiceResultValue); \ No newline at end of file +public record Notification(KeyPressEvent? KeyPressEvent, string? LastScanServiceResultValue, string? HttpContentBody); \ No newline at end of file