PostService with job reply
This commit is contained in:
parent
98c6262a4d
commit
0111a25e69
28
.kanbn/board.css
Normal file
28
.kanbn/board.css
Normal file
@ -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;
|
||||||
|
}
|
@ -1,33 +1,42 @@
|
|||||||
---
|
---
|
||||||
startedColumns:
|
startedColumns:
|
||||||
- 'In Progress'
|
- "In Progress"
|
||||||
completedColumns:
|
completedColumns:
|
||||||
- Done
|
- Done
|
||||||
|
dateFormat: mm/dd
|
||||||
---
|
---
|
||||||
|
|
||||||
# Barcode-Host
|
# Barcode-Host
|
||||||
|
|
||||||
## Backlog
|
## Backlog
|
||||||
|
|
||||||
- [update-os](tasks/update-os.md)
|
|
||||||
- [apt-get-install](tasks/apt-get-install.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)
|
- [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
|
## Todo
|
||||||
|
|
||||||
|
- [epi-pro-scan](tasks/epi-pro-scan.md)
|
||||||
|
|
||||||
## In Progress
|
## 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
|
## 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)
|
||||||
|
@ -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 allow from 0.0.0.0/0 to any port 5201 comment "23) iperf3"
|
||||||
ufw enable
|
ufw enable
|
||||||
ufw status numbered
|
ufw status numbered
|
||||||
|
ufw disable
|
||||||
```
|
```
|
||||||
```conf
|
```conf
|
||||||
Status: active
|
Status: active
|
||||||
|
13
.kanbn/tasks/epi-pro-scan.md
Normal file
13
.kanbn/tasks/epi-pro-scan.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
---
|
||||||
|
|
||||||
|
# epi-pro-scan
|
||||||
|
|
||||||
|
```bash
|
||||||
|
```
|
||||||
|
|
||||||
|
## Sub-tasks
|
||||||
|
|
||||||
|
- [ ] phares3757
|
||||||
|
- [x] unity4
|
||||||
|
- [x] unity5
|
12
.kanbn/tasks/post-only-once.md
Normal file
12
.kanbn/tasks/post-only-once.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
---
|
||||||
|
|
||||||
|
# post-only-once
|
||||||
|
|
||||||
|
- Change to keep track but only post on a timmer
|
||||||
|
|
||||||
|
## Sub-tasks
|
||||||
|
|
||||||
|
- [ ] phares3757
|
||||||
|
- [x] unity4
|
||||||
|
- [x] unity5
|
@ -11,17 +11,16 @@ mkdir /var/www
|
|||||||
mkdir /var/www/Barcode-Host
|
mkdir /var/www/Barcode-Host
|
||||||
mkdir /var/www/Barcode-Host/Server
|
mkdir /var/www/Barcode-Host/Server
|
||||||
cd /home/unity4/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 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
|
cd /var/www/Barcode-Host/Server
|
||||||
dotnet /var/www/Barcode-Host/Server/Barcode.Host.Server.dll
|
dotnet /var/www/Barcode-Host/Server/Barcode.Host.Server.dll
|
||||||
systemctl start barcode-host.service
|
systemctl start barcode-host.service
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
nano /etc/fstab
|
nano /etc/fstab
|
||||||
10.95.176.46:EC_Metrology_Si /var/locally-mounted/eaf-dev.mes.infineon.com nfs defaults 0 0
|
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
|
apt install smbclient
|
||||||
ecmesEAF-10.95.128.34-mestsa07ec(A-Both)
|
ecmesEAF-10.95.128.34-mestsa07ec(A-Both)
|
||||||
```
|
```
|
||||||
|
|
||||||
```conf
|
```conf
|
||||||
2023-06-03 16:02:25.011 -07:00 [Information] (Barcode.Host.Server.Program.) () () Starting Web Application
|
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.
|
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.) () () Hosting environment: "Production"
|
||||||
2023-06-03 16:02:25.176 -07:00 [Information] (Microsoft.Hosting.Lifetime.) () () Content root path: "/var/www/Barcode-Host/Server"
|
2023-06-03 16:02:25.176 -07:00 [Information] (Microsoft.Hosting.Lifetime.) () () Content root path: "/var/www/Barcode-Host/Server"
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
links http://localhost:5003/api/lastScan
|
links http://localhost:5003/api/lastScan
|
||||||
```
|
```
|
||||||
|
@ -4,8 +4,12 @@
|
|||||||
# run-secrets-task
|
# run-secrets-task
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd Server
|
cd Barcode-Host/Server
|
||||||
dotnet user-secrets set RootPassword 4hink
|
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
|
## Sub-tasks
|
||||||
|
@ -5,16 +5,50 @@
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo -i
|
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
|
apt-get install -y ca-certificates
|
||||||
|
cd /home/unity4/Barcode-Host
|
||||||
openssl s_client -showcerts -connect DESKTOP-H6JG91B:443 </dev/null 2>/dev/null|openssl x509 -outform PEM >DESKTOP-H6JG91B.crt
|
openssl s_client -showcerts -connect DESKTOP-H6JG91B:443 </dev/null 2>/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
|
update-ca-certificates
|
||||||
|
openssl s_client -showcerts -connect unity4:443 </dev/null 2>/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 2>/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 2>/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
|
exit
|
||||||
```
|
```
|
||||||
|
|
||||||
## Sub-tasks
|
## Sub-tasks
|
||||||
|
|
||||||
- [ ] phares3757
|
- [ ] phares3757
|
||||||
- [ ] unity4
|
- [x] unity4
|
||||||
- [x] unity5
|
- [x] unity5
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
# update-os
|
# update-os
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
lsb_release -a
|
||||||
apt update
|
apt update
|
||||||
apt upgrade -y
|
apt upgrade -y
|
||||||
apt install update-manager-core
|
apt install update-manager-core
|
||||||
|
@ -22,11 +22,12 @@ public class TimedHostedService : IHostedService, IAggregateInputReader, IDispos
|
|||||||
private readonly IPostService _PostService;
|
private readonly IPostService _PostService;
|
||||||
private readonly ISerialService _SerialService;
|
private readonly ISerialService _SerialService;
|
||||||
private readonly ILastScanService _LastScanService;
|
private readonly ILastScanService _LastScanService;
|
||||||
|
private readonly List<Notification> _Notifications;
|
||||||
private readonly ILogger<TimedHostedService> _Logger;
|
private readonly ILogger<TimedHostedService> _Logger;
|
||||||
private readonly IHttpClientFactory _HttpClientFactory;
|
private readonly IHttpClientFactory _HttpClientFactory;
|
||||||
private readonly ILinuxGroupManager _LinuxGroupManager;
|
private readonly ILinuxGroupManager _LinuxGroupManager;
|
||||||
private readonly IHubContext<NotificationHub> _HubContext;
|
|
||||||
private readonly Dictionary<string, InputReader> _Readers;
|
private readonly Dictionary<string, InputReader> _Readers;
|
||||||
|
private readonly IHubContext<NotificationHub> _HubContext;
|
||||||
private readonly Dictionary<EventCode, char> _CharToEventCodes;
|
private readonly Dictionary<EventCode, char> _CharToEventCodes;
|
||||||
private readonly List<(string MethodName, Timer Timer)> _Timers;
|
private readonly List<(string MethodName, Timer Timer)> _Timers;
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ public class TimedHostedService : IHostedService, IAggregateInputReader, IDispos
|
|||||||
_Logger = logger;
|
_Logger = logger;
|
||||||
_Readers = new();
|
_Readers = new();
|
||||||
_ExecutionCount = 0;
|
_ExecutionCount = 0;
|
||||||
|
_Notifications = new();
|
||||||
_HubContext = hubContext;
|
_HubContext = hubContext;
|
||||||
_CharToEventCodes = new();
|
_CharToEventCodes = new();
|
||||||
_AppSettings = appSettings;
|
_AppSettings = appSettings;
|
||||||
@ -47,9 +49,15 @@ public class TimedHostedService : IHostedService, IAggregateInputReader, IDispos
|
|||||||
_LinuxGroupManager = linuxGroupManager;
|
_LinuxGroupManager = linuxGroupManager;
|
||||||
_Calendar = new CultureInfo("en-US").Calendar;
|
_Calendar = new CultureInfo("en-US").Calendar;
|
||||||
Timer writeTimer = new(Write, null, Timeout.Infinite, Timeout.Infinite);
|
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);
|
Timer scanForNewInputsTimer = new(ScanForNewInputs, null, Timeout.Infinite, Timeout.Infinite);
|
||||||
if (!string.IsNullOrEmpty(_AppSettings.SerialPortName))
|
if (!string.IsNullOrEmpty(_AppSettings.SerialPortName))
|
||||||
_Timers.Add((nameof(Write), writeTimer));
|
_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
|
#if Linux
|
||||||
_Timers.Add((nameof(ScanForNewInputs), scanForNewInputsTimer));
|
_Timers.Add((nameof(ScanForNewInputs), scanForNewInputsTimer));
|
||||||
#endif
|
#endif
|
||||||
@ -129,15 +137,9 @@ public class TimedHostedService : IHostedService, IAggregateInputReader, IDispos
|
|||||||
Result<string> result = _LastScanService.GetScan();
|
Result<string> result = _LastScanService.GetScan();
|
||||||
if (!string.IsNullOrEmpty(result.Results))
|
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);
|
_ = _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)}"); }
|
catch (Exception ex) { _Logger.LogError(ex, $"{nameof(Write)}-{nameof(Timer)}.{nameof(Timer.Change)}"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void PostTo()
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(_AppSettings.PostTo))
|
||||||
|
{
|
||||||
|
Task<HttpResponseMessage>? 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<string> 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)}"); }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -3,24 +3,26 @@ using System.Text.Json;
|
|||||||
namespace Barcode.Host.Server.Models;
|
namespace Barcode.Host.Server.Models;
|
||||||
|
|
||||||
public record AppSettings(string BuildNumber,
|
public record AppSettings(string BuildNumber,
|
||||||
string Company,
|
|
||||||
int ClearLastScanServiceAfter,
|
int ClearLastScanServiceAfter,
|
||||||
|
string Company,
|
||||||
string DeviceNameEndsWith,
|
string DeviceNameEndsWith,
|
||||||
string EquipmentName,
|
string EquipmentName,
|
||||||
int ExpectedScanLengthA,
|
int ExpectedScanLengthA,
|
||||||
int ExpectedScanLengthB,
|
int ExpectedScanLengthB,
|
||||||
string FileShare,
|
string FileShare,
|
||||||
string GitCommitSeven,
|
string GitCommitSeven,
|
||||||
string LinuxDevicePath,
|
|
||||||
bool IsDevelopment,
|
bool IsDevelopment,
|
||||||
bool IsStaging,
|
bool IsStaging,
|
||||||
int NotifyMinimum,
|
string LinuxDevicePath,
|
||||||
string MockRoot,
|
string MockRoot,
|
||||||
string MonAResource,
|
string MonAResource,
|
||||||
string MonASite,
|
string MonASite,
|
||||||
|
int NotifyMinimum,
|
||||||
string PostTo,
|
string PostTo,
|
||||||
|
int PostToEvery,
|
||||||
string RootPassword,
|
string RootPassword,
|
||||||
string SerialPortName,
|
string SerialPortName,
|
||||||
|
int ShareToEvery,
|
||||||
string URLs,
|
string URLs,
|
||||||
string WorkingDirectoryName,
|
string WorkingDirectoryName,
|
||||||
int WriteToSerialEvery)
|
int WriteToSerialEvery)
|
||||||
|
@ -9,24 +9,26 @@ public class AppSettings
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
[Display(Name = "Build Number"), Required] public string BuildNumber { get; set; }
|
[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 = "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 = "Device Name Ends With"), Required] public string DeviceNameEndsWith { get; set; }
|
||||||
[Display(Name = "Equipment Name"), Required] public string EquipmentName { get; set; }
|
[Display(Name = "Equipment Name"), Required] public string EquipmentName { get; set; }
|
||||||
[Display(Name = "ExpectedScanLengthA"), Required] public int? ExpectedScanLengthA { get; set; }
|
[Display(Name = "ExpectedScanLengthA"), Required] public int? ExpectedScanLengthA { get; set; }
|
||||||
[Display(Name = "ExpectedScanLengthB"), Required] public int? ExpectedScanLengthB { get; set; }
|
[Display(Name = "ExpectedScanLengthB"), Required] public int? ExpectedScanLengthB { get; set; }
|
||||||
[Display(Name = "File Share"), Required] public string FileShare { 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 = "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 Development"), Required] public bool? IsDevelopment { get; set; }
|
||||||
[Display(Name = "Is Staging"), Required] public bool? IsStaging { 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 = "Mock Root"), Required] public string MockRoot { get; set; }
|
||||||
[Display(Name = "MonA Resource"), Required] public string MonAResource { get; set; }
|
[Display(Name = "MonA Resource"), Required] public string MonAResource { get; set; }
|
||||||
[Display(Name = "MonA Site"), Required] public string MonASite { 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 = "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 = "RootPassword"), Required] public string RootPassword { get; set; }
|
||||||
[Display(Name = "Serial Port Name"), Required] public string SerialPortName { 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 = "URLs"), Required] public string URLs { get; set; }
|
||||||
[Display(Name = "Working Directory Name"), Required] public string WorkingDirectoryName { get; set; }
|
[Display(Name = "Working Directory Name"), Required] public string WorkingDirectoryName { get; set; }
|
||||||
[Display(Name = "WriteToSerialEvery"), Required] public int? WriteToSerialEvery { get; set; }
|
[Display(Name = "WriteToSerialEvery"), Required] public int? WriteToSerialEvery { get; set; }
|
||||||
@ -46,10 +48,10 @@ public class AppSettings
|
|||||||
throw new NullReferenceException(nameof(appSettings));
|
throw new NullReferenceException(nameof(appSettings));
|
||||||
if (appSettings.BuildNumber is null)
|
if (appSettings.BuildNumber is null)
|
||||||
throw new NullReferenceException(nameof(BuildNumber));
|
throw new NullReferenceException(nameof(BuildNumber));
|
||||||
if (appSettings.Company is null)
|
|
||||||
throw new NullReferenceException(nameof(Company));
|
|
||||||
if (appSettings.ClearLastScanServiceAfter is null)
|
if (appSettings.ClearLastScanServiceAfter is null)
|
||||||
throw new NullReferenceException(nameof(ClearLastScanServiceAfter));
|
throw new NullReferenceException(nameof(ClearLastScanServiceAfter));
|
||||||
|
if (appSettings.Company is null)
|
||||||
|
throw new NullReferenceException(nameof(Company));
|
||||||
if (appSettings.DeviceNameEndsWith is null)
|
if (appSettings.DeviceNameEndsWith is null)
|
||||||
throw new NullReferenceException(nameof(DeviceNameEndsWith));
|
throw new NullReferenceException(nameof(DeviceNameEndsWith));
|
||||||
if (appSettings.EquipmentName is null)
|
if (appSettings.EquipmentName is null)
|
||||||
@ -62,26 +64,30 @@ public class AppSettings
|
|||||||
throw new NullReferenceException(nameof(FileShare));
|
throw new NullReferenceException(nameof(FileShare));
|
||||||
if (appSettings.GitCommitSeven is null)
|
if (appSettings.GitCommitSeven is null)
|
||||||
throw new NullReferenceException(nameof(GitCommitSeven));
|
throw new NullReferenceException(nameof(GitCommitSeven));
|
||||||
if (appSettings.LinuxDevicePath is null)
|
|
||||||
throw new NullReferenceException(nameof(LinuxDevicePath));
|
|
||||||
if (appSettings.IsDevelopment is null)
|
if (appSettings.IsDevelopment is null)
|
||||||
throw new NullReferenceException(nameof(IsDevelopment));
|
throw new NullReferenceException(nameof(IsDevelopment));
|
||||||
if (appSettings.IsStaging is null)
|
if (appSettings.IsStaging is null)
|
||||||
throw new NullReferenceException(nameof(IsStaging));
|
throw new NullReferenceException(nameof(IsStaging));
|
||||||
if (appSettings.NotifyMinimum is null)
|
if (appSettings.LinuxDevicePath is null)
|
||||||
throw new NullReferenceException(nameof(NotifyMinimum));
|
throw new NullReferenceException(nameof(LinuxDevicePath));
|
||||||
if (appSettings.MockRoot is null)
|
if (appSettings.MockRoot is null)
|
||||||
throw new NullReferenceException(nameof(MockRoot));
|
throw new NullReferenceException(nameof(MockRoot));
|
||||||
if (appSettings.MonAResource is null)
|
if (appSettings.MonAResource is null)
|
||||||
throw new NullReferenceException(nameof(MonAResource));
|
throw new NullReferenceException(nameof(MonAResource));
|
||||||
if (appSettings.MonASite is null)
|
if (appSettings.MonASite is null)
|
||||||
throw new NullReferenceException(nameof(MonASite));
|
throw new NullReferenceException(nameof(MonASite));
|
||||||
|
if (appSettings.NotifyMinimum is null)
|
||||||
|
throw new NullReferenceException(nameof(NotifyMinimum));
|
||||||
if (appSettings.PostTo is null)
|
if (appSettings.PostTo is null)
|
||||||
throw new NullReferenceException(nameof(PostTo));
|
throw new NullReferenceException(nameof(PostTo));
|
||||||
|
if (appSettings.PostToEvery is null)
|
||||||
|
throw new NullReferenceException(nameof(PostToEvery));
|
||||||
if (appSettings.RootPassword is null)
|
if (appSettings.RootPassword is null)
|
||||||
throw new NullReferenceException(nameof(RootPassword));
|
throw new NullReferenceException(nameof(RootPassword));
|
||||||
if (appSettings.SerialPortName is null)
|
if (appSettings.SerialPortName is null)
|
||||||
throw new NullReferenceException(nameof(SerialPortName));
|
throw new NullReferenceException(nameof(SerialPortName));
|
||||||
|
if (appSettings.ShareToEvery is null)
|
||||||
|
throw new NullReferenceException(nameof(ShareToEvery));
|
||||||
if (appSettings.URLs is null)
|
if (appSettings.URLs is null)
|
||||||
throw new NullReferenceException(nameof(URLs));
|
throw new NullReferenceException(nameof(URLs));
|
||||||
if (appSettings.WorkingDirectoryName is null)
|
if (appSettings.WorkingDirectoryName is null)
|
||||||
@ -90,24 +96,26 @@ public class AppSettings
|
|||||||
throw new NullReferenceException(nameof(WriteToSerialEvery));
|
throw new NullReferenceException(nameof(WriteToSerialEvery));
|
||||||
result = new(
|
result = new(
|
||||||
appSettings.BuildNumber,
|
appSettings.BuildNumber,
|
||||||
appSettings.Company,
|
|
||||||
appSettings.ClearLastScanServiceAfter.Value,
|
appSettings.ClearLastScanServiceAfter.Value,
|
||||||
|
appSettings.Company,
|
||||||
appSettings.DeviceNameEndsWith,
|
appSettings.DeviceNameEndsWith,
|
||||||
appSettings.EquipmentName,
|
appSettings.EquipmentName,
|
||||||
appSettings.ExpectedScanLengthA.Value,
|
appSettings.ExpectedScanLengthA.Value,
|
||||||
appSettings.ExpectedScanLengthB.Value,
|
appSettings.ExpectedScanLengthB.Value,
|
||||||
appSettings.FileShare,
|
appSettings.FileShare,
|
||||||
appSettings.GitCommitSeven,
|
appSettings.GitCommitSeven,
|
||||||
appSettings.LinuxDevicePath,
|
|
||||||
appSettings.IsDevelopment.Value,
|
appSettings.IsDevelopment.Value,
|
||||||
appSettings.IsStaging.Value,
|
appSettings.IsStaging.Value,
|
||||||
appSettings.NotifyMinimum.Value,
|
appSettings.LinuxDevicePath,
|
||||||
appSettings.MockRoot,
|
appSettings.MockRoot,
|
||||||
appSettings.MonAResource,
|
appSettings.MonAResource,
|
||||||
appSettings.MonASite,
|
appSettings.MonASite,
|
||||||
|
appSettings.NotifyMinimum.Value,
|
||||||
appSettings.PostTo,
|
appSettings.PostTo,
|
||||||
|
appSettings.PostToEvery.Value,
|
||||||
appSettings.RootPassword,
|
appSettings.RootPassword,
|
||||||
appSettings.SerialPortName,
|
appSettings.SerialPortName,
|
||||||
|
appSettings.ShareToEvery.Value,
|
||||||
appSettings.URLs,
|
appSettings.URLs,
|
||||||
appSettings.WorkingDirectoryName,
|
appSettings.WorkingDirectoryName,
|
||||||
appSettings.WriteToSerialEvery.Value);
|
appSettings.WriteToSerialEvery.Value);
|
||||||
|
@ -7,7 +7,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row p-1">
|
<div class="row p-1">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<h1 id="data" style="text-align:center"></h1>
|
<h1 id="lastScanServiceResultValue" style="text-align:center"></h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row p-1">
|
||||||
|
<div class="col-6">
|
||||||
|
<h1 id="httpContentBody" style="text-align:center"></h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
"MonAResource": "OI_Metrology_Viewer_EC",
|
"MonAResource": "OI_Metrology_Viewer_EC",
|
||||||
"MonASite": "auc",
|
"MonASite": "auc",
|
||||||
"PostTo": "",
|
"PostTo": "",
|
||||||
|
"PostToEvery": 1000,
|
||||||
"SerialPortName": "/dev/ttyUSB0",
|
"SerialPortName": "/dev/ttyUSB0",
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
"Using": [
|
"Using": [
|
||||||
@ -63,6 +64,7 @@
|
|||||||
"Application": "Sample"
|
"Application": "Sample"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"ShareToEvery": 1000,
|
||||||
"RootPassword": "",
|
"RootPassword": "",
|
||||||
"URLs": "http://localhost:5003;",
|
"URLs": "http://localhost:5003;",
|
||||||
"WorkingDirectoryName": "IFXApps",
|
"WorkingDirectoryName": "IFXApps",
|
||||||
|
@ -3,8 +3,14 @@
|
|||||||
var connection = new signalR.HubConnectionBuilder().withUrl("/NotificationHub").build();
|
var connection = new signalR.HubConnectionBuilder().withUrl("/NotificationHub").build();
|
||||||
|
|
||||||
connection.on("NotifyAll", function (data) {
|
connection.on("NotifyAll", function (data) {
|
||||||
var message = `${data.keyPressEvent.dateTime} - [${data.lastScanServiceResultValue}]`;
|
if (data.keyPressEvent && data.lastScanServiceResultValue) {
|
||||||
document.getElementById("data").innerText = message;
|
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 () {
|
connection.start().then(function () {
|
||||||
|
@ -2,4 +2,4 @@ using Barcode.Host.Shared.KeyboardMouse;
|
|||||||
|
|
||||||
namespace Barcode.Host.Shared.Models;
|
namespace Barcode.Host.Shared.Models;
|
||||||
|
|
||||||
public record Notification(KeyPressEvent? KeyPressEvent, string LastScanServiceResultValue);
|
public record Notification(KeyPressEvent? KeyPressEvent, string? LastScanServiceResultValue, string? HttpContentBody);
|
Loading…
x
Reference in New Issue
Block a user