Separate configuration settings
Added EAFLog Testing Stratus file
This commit is contained in:
37
Worker.cs
37
Worker.cs
@ -26,40 +26,15 @@ public partial class Worker : BackgroundService
|
||||
_Logger.LogInformation("A) Next execute will be at {date}", DateTime.Now.AddMilliseconds(_AppSettings.MillisecondsDelay).ToString("yyyy-MM-dd hh:mm:ss.fff tt"));
|
||||
if (!Directory.Exists(_AppSettings.WatchDirectory))
|
||||
_ = Directory.CreateDirectory(_AppSettings.WatchDirectory);
|
||||
if (!Directory.Exists(Path.GetPathRoot(_AppSettings.Destination)) || !Directory.Exists(_AppSettings.Destination))
|
||||
_Logger.LogCritical("<{Destination}> Doesn't exist!", _AppSettings.Destination);
|
||||
else
|
||||
{
|
||||
string[] files;
|
||||
string checkFile;
|
||||
FileInfo fileInfo;
|
||||
string checkDirectory;
|
||||
string[] directories = Directory.GetDirectories(_AppSettings.WatchDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
foreach (string directory in directories)
|
||||
_ = _AppSettings.Helper switch
|
||||
{
|
||||
checkDirectory = !_AppSettings.MatchPath ? _AppSettings.Destination : Path.Combine(_AppSettings.Destination, Path.GetFileName(directory));
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
_ = Directory.CreateDirectory(checkDirectory);
|
||||
files = Directory.GetFiles(directory, "*", SearchOption.TopDirectoryOnly);
|
||||
foreach (string file in files)
|
||||
{
|
||||
fileInfo = new(file);
|
||||
if (new TimeSpan(DateTime.Now.Ticks - fileInfo.LastWriteTime.Ticks).TotalMilliseconds < _AppSettings.MillisecondsDelay)
|
||||
continue;
|
||||
checkFile = Path.Combine(checkDirectory, Path.GetFileName(file));
|
||||
if (File.Exists(checkFile))
|
||||
continue;
|
||||
try
|
||||
{ File.Move(file, checkFile); }
|
||||
catch (Exception ex)
|
||||
{ _Logger.LogError(ex, "Inner loop error!"); }
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{ _Logger.LogError(ex, "Loop error!"); }
|
||||
}
|
||||
nameof(Helpers.HelperEAFLog) => Helpers.HelperEAFLog.DeleteFiles(_AppSettings, _Logger),
|
||||
nameof(Helpers.HelperStratus) => Helpers.HelperStratus.MoveFile(_AppSettings, _Logger),
|
||||
nameof(Helpers.HelperWaferCounter) => Helpers.HelperWaferCounter.MoveFile(_AppSettings, _Logger),
|
||||
_ => throw new NotSupportedException()
|
||||
};
|
||||
}
|
||||
_Logger.LogInformation("B) Next execute will be at {date}", DateTime.Now.AddMilliseconds(_AppSettings.MillisecondsDelay).ToString("yyyy-MM-dd hh:mm:ss.fff tt"));
|
||||
}
|
||||
|
Reference in New Issue
Block a user