This commit is contained in:
Mike Phares 2022-05-10 16:52:18 -07:00
parent 6c8ad46064
commit 0a2f97fd93
3 changed files with 73 additions and 95 deletions

View File

@ -1,20 +1 @@
[
{
"DocumentId": {
"ProjectId": {
"Id": "1c39e10e-5359-42ab-be77-db59c291586c"
},
"Id": "81852d1e-25b8-4230-9e00-0399608db1e6"
},
"FileName": "Background.cshtml.cs",
"FilePath": "G:\\Mesa_FI\\EDA-Viewer\\EDA Viewer\\Pages\\Background.cshtml.cs",
"FileChanges": [
{
"LineNumber": 1,
"CharNumber": 1,
"DiagnosticId": "IMPORTS",
"FormatDescription": "Fix imports ordering."
}
]
}
]
[]

View File

@ -112,7 +112,7 @@ public class TimedHostedService : IHostedService, IDisposable
{
try
{
if (!_BackgroundMethods.IsPrimaryInstance())
if (_BackgroundMethods.IsPrimaryInstance())
_BackgroundMethods.LogPathCleanUpByWeekCallback();
}
catch (Exception e) { _Log.Error(e, "Error: "); }
@ -132,7 +132,7 @@ public class TimedHostedService : IHostedService, IDisposable
{
try
{
if (!_BackgroundMethods.IsPrimaryInstance())
if (_BackgroundMethods.IsPrimaryInstance())
_BackgroundMethods.EDAOutputArchiveCallback();
}
catch (Exception e) { _Log.Error(e, "Error: "); }
@ -152,7 +152,7 @@ public class TimedHostedService : IHostedService, IDisposable
{
try
{
if (!_BackgroundMethods.IsPrimaryInstance())
if (_BackgroundMethods.IsPrimaryInstance())
_BackgroundMethods.EdaDataCollectionPlansCallback();
}
catch (Exception e) { _Log.Error(e, "Error: "); }

View File

@ -736,35 +736,10 @@ public class Background : Models.Properties.IBackground, IBackground, IDisposabl
configuration = ParseXML<PDSFConfiguration>(xml, throwExceptions: true);
if (configuration is null)
continue;
if (!Directory.Exists(Path.GetPathRoot(configuration.Settings.StoragePath)))
continue;
else
{
common.Update(configuration);
json = JsonSerializer.Serialize(configuration, configuration.GetType(), jsonSerializerOptions);
if (!Directory.Exists(common.StoragePath))
_ = Directory.CreateDirectory(common.StoragePath);
if (common?.UnitName is null)
continue;
if (!common.StoragePath.Contains(common.UnitName) && (common.StoragePath.Contains(@"01EquipmentIntegration") || common.StoragePath.Contains(@"02BusinessIntegration")))
{
common.StoragePath = common.StoragePath.Replace("Traces", "Empty");
if (!Directory.Exists(common.StoragePath))
_ = Directory.CreateDirectory(common.StoragePath);
if (common.UnitName != "PRF01")
{
unitDirectory = string.Concat(Path.GetDirectoryName(common.StoragePath), @"\", common.UnitName);
common.StoragePath = string.Concat(unitDirectory, @"\BadPath");
if (!Directory.Exists(common.StoragePath))
_ = Directory.CreateDirectory(common.StoragePath);
common.StoragePath = string.Concat(unitDirectory, @"\LogFile");
if (!Directory.Exists(common.StoragePath))
_ = Directory.CreateDirectory(common.StoragePath);
common.StoragePath = string.Concat(unitDirectory, @"\PollPath");
if (!Directory.Exists(common.StoragePath))
_ = Directory.CreateDirectory(common.StoragePath);
}
}
fileName = string.Concat(edaObjectFile.Replace(replace, "Partial"), ".csv");
File.WriteAllText(fileName, common.ParametersAsCsv);
try
@ -816,6 +791,28 @@ public class Background : Models.Properties.IBackground, IBackground, IDisposabl
{ File.SetCreationTime(fileName, lastModifiedDate); File.SetLastWriteTime(fileName, lastModifiedDate); }
catch (Exception) { }
}
if (string.IsNullOrEmpty(configuration.Settings.StoragePath) || !Directory.Exists(Path.GetPathRoot(configuration.Settings.StoragePath)))
continue;
if (!Directory.Exists(common.StoragePath))
_ = Directory.CreateDirectory(common.StoragePath);
if (!common.StoragePath.Contains(common.UnitName) && (common.StoragePath.Contains(@"01EquipmentIntegration") || common.StoragePath.Contains(@"02BusinessIntegration")))
{
common.StoragePath = common.StoragePath.Replace("Traces", "Empty");
if (!Directory.Exists(common.StoragePath))
_ = Directory.CreateDirectory(common.StoragePath);
if (common.UnitName != "PRF01")
{
unitDirectory = string.Concat(Path.GetDirectoryName(common.StoragePath), @"\", common.UnitName);
common.StoragePath = string.Concat(unitDirectory, @"\BadPath");
if (!Directory.Exists(common.StoragePath))
_ = Directory.CreateDirectory(common.StoragePath);
common.StoragePath = string.Concat(unitDirectory, @"\LogFile");
if (!Directory.Exists(common.StoragePath))
_ = Directory.CreateDirectory(common.StoragePath);
common.StoragePath = string.Concat(unitDirectory, @"\PollPath");
if (!Directory.Exists(common.StoragePath))
_ = Directory.CreateDirectory(common.StoragePath);
}
}
}
}