Changes to support barcode scanner and

new CDE5 Windows 7 machine
This commit is contained in:
2022-06-27 18:32:46 -07:00
parent 044b0e2bcd
commit 94b06b7de5
14 changed files with 433 additions and 204 deletions

View File

@ -12,7 +12,6 @@ using System.Linq;
using System.Net.Http;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
namespace Adaptation.FileHandlers.DownloadRsMFile;
@ -120,12 +119,13 @@ public class FileRead : Shared.FileRead, IFileRead
throw new Exception(string.Concat("See ", nameof(Callback)));
}
private async Task DownloadRsMFileAsync()
private void DownloadRsMFileAsync()
{
if (_HttpClient is null)
throw new Exception();
if (string.IsNullOrEmpty(_StaticFileServer))
throw new Exception();
string logUrl;
string logText;
string runJson;
string rootJson;
@ -141,6 +141,7 @@ public class FileRead : Shared.FileRead, IFileRead
string dateTimeFormat = "yy/MM/dd HH:mm:ss";
NginxFileSystem[] runNginxFileSystemCollection;
NginxFileSystem[] rootNginxFileSystemCollection;
NginxFileSystem[] innerNginxFileSystemCollection;
DateTime fileAgeThresholdDateTime = DateTime.Now;
string nginxFormat = "ddd, dd MMM yyyy HH:mm:ss zzz";
List<Tuple<DateTime, FileInfo, FileInfo, string>> possibleDownload = new();
@ -157,13 +158,30 @@ public class FileRead : Shared.FileRead, IFileRead
_ => throw new Exception(),
};
}
rootJson = await _HttpClient.GetStringAsync(string.Concat("http://", _StaticFileServer));
rootJson = _HttpClient.GetStringAsync(string.Concat("http://", _StaticFileServer)).Result;
rootNginxFileSystemCollection = JsonSerializer.Deserialize<NginxFileSystem[]>(rootJson, propertyNameCaseInsensitiveJsonSerializerOptions);
foreach (NginxFileSystem rootNginxFileSystem in rootNginxFileSystemCollection)
{
if (!(from l in _FileConnectorConfiguration.SourceFileFilters where rootNginxFileSystem.Name == l select false).Any())
continue;
logText = await _HttpClient.GetStringAsync(string.Concat("http://", _StaticFileServer, '/', rootNginxFileSystem.Name));
logUrl = string.Empty;
if (rootNginxFileSystem.Name.Contains("."))
logUrl = string.Concat("http://", _StaticFileServer, '/', rootNginxFileSystem.Name);
else
{
rootJson = _HttpClient.GetStringAsync(string.Concat("http://", _StaticFileServer, '/', rootNginxFileSystem.Name)).Result;
innerNginxFileSystemCollection = JsonSerializer.Deserialize<NginxFileSystem[]>(rootJson, propertyNameCaseInsensitiveJsonSerializerOptions);
foreach (NginxFileSystem innerNginxFileSystem in innerNginxFileSystemCollection)
{
if (!(from l in _FileConnectorConfiguration.SourceFileFilters where innerNginxFileSystem.Name == l select false).Any())
continue;
logUrl = string.Concat("http://", _StaticFileServer, '/', rootNginxFileSystem.Name, '/', innerNginxFileSystem.Name);
break;
}
}
if (string.IsNullOrEmpty(logUrl))
continue;
logText = _HttpClient.GetStringAsync(logUrl).Result;
logLines = logText.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
foreach (string logLine in logLines)
{
@ -182,7 +200,7 @@ public class FileRead : Shared.FileRead, IFileRead
runFullFileNameSegments = runFullFileName.Split('\\').ToList();
runFileName = runFullFileNameSegments[runFullFileNameSegments.Count - 1];
runFullFileNameSegments.RemoveAt(runFullFileNameSegments.Count - 1);
runJson = await _HttpClient.GetStringAsync(string.Concat("http://", _StaticFileServer, '/', string.Join("/", runFullFileNameSegments)));
runJson = _HttpClient.GetStringAsync(string.Concat("http://", _StaticFileServer, '/', string.Join("/", runFullFileNameSegments))).Result;
runFullFileNameSegments.Add(runFileName);
runNginxFileSystemCollection = JsonSerializer.Deserialize<NginxFileSystem[]>(runJson, propertyNameCaseInsensitiveJsonSerializerOptions);
foreach (NginxFileSystem matchNginxFileSystem in runNginxFileSystemCollection)
@ -222,7 +240,7 @@ public class FileRead : Shared.FileRead, IFileRead
File.Delete(alternateFileInfo.FullName);
if (targetFileInfo.Exists)
File.Delete(targetFileInfo.FullName);
targetJson = await _HttpClient.GetStringAsync(targetFileName);
targetJson = _HttpClient.GetStringAsync(targetFileName).Result;
File.WriteAllText(targetFileInfo.FullName, targetJson);
targetFileInfo.LastWriteTime = matchNginxFileSystemDateTime;
File.Copy(targetFileInfo.FullName, alternateFileInfo.FullName);
@ -234,7 +252,7 @@ public class FileRead : Shared.FileRead, IFileRead
try
{
if (_IsEAFHosted)
_ = DownloadRsMFileAsync();
DownloadRsMFileAsync();
}
catch (Exception exception)
{