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

View File

@ -736,85 +736,82 @@ public class Background : Models.Properties.IBackground, IBackground, IDisposabl
configuration = ParseXML<PDSFConfiguration>(xml, throwExceptions: true); configuration = ParseXML<PDSFConfiguration>(xml, throwExceptions: true);
if (configuration is null) if (configuration is null)
continue; continue;
if (!Directory.Exists(Path.GetPathRoot(configuration.Settings.StoragePath))) common.Update(configuration);
json = JsonSerializer.Serialize(configuration, configuration.GetType(), jsonSerializerOptions);
if (common?.UnitName is null)
continue; continue;
else fileName = string.Concat(edaObjectFile.Replace(replace, "Partial"), ".csv");
File.WriteAllText(fileName, common.ParametersAsCsv);
try
{ File.SetCreationTime(fileName, lastModifiedDate); File.SetLastWriteTime(fileName, lastModifiedDate); }
catch (Exception) { }
fileName = string.Concat(edaObjectFile.Replace(replace, "Partial"), ".json");
File.WriteAllText(fileName, json);
text = Helper.Background.EdaDCP.GetText(edaObjectFile, common, json);
fileName = string.Concat(edaObjectFile.Replace(replace, "Partial"), ".txt");
File.WriteAllText(fileName, text);
try
{ File.SetCreationTime(fileName, lastModifiedDate); File.SetLastWriteTime(fileName, lastModifiedDate); }
catch (Exception) { }
html = Helper.Background.EdaDCP.GetEdaObjectToHtml(edaObjectFile, common);
fileName = string.Concat(edaObjectFile.Replace(replace, "Partial"), ".html");
File.WriteAllText(fileName, html);
try
{ File.SetCreationTime(fileName, lastModifiedDate); File.SetLastWriteTime(fileName, lastModifiedDate); }
catch (Exception) { }
xml = Helper.Background.EdaDCP.GetEdaObjectToDMSGridFormat(edaObjectFile, common, useAlias: false);
fileName = string.Concat(edaObjectFile.Replace(replace, "DMSGridFormat"), ".xml");
File.WriteAllText(fileName, xml);
try
{ File.SetCreationTime(fileName, lastModifiedDate); File.SetLastWriteTime(fileName, lastModifiedDate); }
catch (Exception) { }
xml = Helper.Background.EdaDCP.GetEdaObjectToDMSGridFormat(edaObjectFile, common, useAlias: true);
fileName = string.Concat(edaObjectFile.Replace(replace, "DMSGridFormat - Alias"), ".xml");
File.WriteAllText(fileName, xml);
try
{ File.SetCreationTime(fileName, lastModifiedDate); File.SetLastWriteTime(fileName, lastModifiedDate); }
catch (Exception) { }
csv = Helper.Background.EdaDCP.GetEdaObjectToAPCParameter(edaObjectFile, common);
fileName = string.Concat(edaObjectFile.Replace(replace, "APCParameter"), ".csv");
File.WriteAllText(fileName, csv);
try
{ File.SetCreationTime(fileName, lastModifiedDate); File.SetLastWriteTime(fileName, lastModifiedDate); }
catch (Exception) { }
csv = Helper.Background.EdaDCP.GetEdaObjectToAPCRunKeyNumber(edaObjectFile, common);
fileName = string.Concat(edaObjectFile.Replace(replace, "APCRunKeyNumber"), ".csv");
File.WriteAllText(fileName, csv);
try
{ File.SetCreationTime(fileName, lastModifiedDate); File.SetLastWriteTime(fileName, lastModifiedDate); }
catch (Exception) { }
fileName = string.Concat(edaObjectFile.Replace(replace, "APC"), ".xlsx");
if (File.Exists(emptyAPC) && !File.Exists(fileName))
{ {
common.Update(configuration); File.Copy(emptyAPC, fileName);
json = JsonSerializer.Serialize(configuration, configuration.GetType(), jsonSerializerOptions); try
{ 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)) if (!Directory.Exists(common.StoragePath))
_ = Directory.CreateDirectory(common.StoragePath); _ = Directory.CreateDirectory(common.StoragePath);
if (common?.UnitName is null) if (common.UnitName != "PRF01")
continue;
if (!common.StoragePath.Contains(common.UnitName) && (common.StoragePath.Contains(@"01EquipmentIntegration") || common.StoragePath.Contains(@"02BusinessIntegration")))
{ {
common.StoragePath = common.StoragePath.Replace("Traces", "Empty"); 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)) if (!Directory.Exists(common.StoragePath))
_ = Directory.CreateDirectory(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
{ File.SetCreationTime(fileName, lastModifiedDate); File.SetLastWriteTime(fileName, lastModifiedDate); }
catch (Exception) { }
fileName = string.Concat(edaObjectFile.Replace(replace, "Partial"), ".json");
File.WriteAllText(fileName, json);
text = Helper.Background.EdaDCP.GetText(edaObjectFile, common, json);
fileName = string.Concat(edaObjectFile.Replace(replace, "Partial"), ".txt");
File.WriteAllText(fileName, text);
try
{ File.SetCreationTime(fileName, lastModifiedDate); File.SetLastWriteTime(fileName, lastModifiedDate); }
catch (Exception) { }
html = Helper.Background.EdaDCP.GetEdaObjectToHtml(edaObjectFile, common);
fileName = string.Concat(edaObjectFile.Replace(replace, "Partial"), ".html");
File.WriteAllText(fileName, html);
try
{ File.SetCreationTime(fileName, lastModifiedDate); File.SetLastWriteTime(fileName, lastModifiedDate); }
catch (Exception) { }
xml = Helper.Background.EdaDCP.GetEdaObjectToDMSGridFormat(edaObjectFile, common, useAlias: false);
fileName = string.Concat(edaObjectFile.Replace(replace, "DMSGridFormat"), ".xml");
File.WriteAllText(fileName, xml);
try
{ File.SetCreationTime(fileName, lastModifiedDate); File.SetLastWriteTime(fileName, lastModifiedDate); }
catch (Exception) { }
xml = Helper.Background.EdaDCP.GetEdaObjectToDMSGridFormat(edaObjectFile, common, useAlias: true);
fileName = string.Concat(edaObjectFile.Replace(replace, "DMSGridFormat - Alias"), ".xml");
File.WriteAllText(fileName, xml);
try
{ File.SetCreationTime(fileName, lastModifiedDate); File.SetLastWriteTime(fileName, lastModifiedDate); }
catch (Exception) { }
csv = Helper.Background.EdaDCP.GetEdaObjectToAPCParameter(edaObjectFile, common);
fileName = string.Concat(edaObjectFile.Replace(replace, "APCParameter"), ".csv");
File.WriteAllText(fileName, csv);
try
{ File.SetCreationTime(fileName, lastModifiedDate); File.SetLastWriteTime(fileName, lastModifiedDate); }
catch (Exception) { }
csv = Helper.Background.EdaDCP.GetEdaObjectToAPCRunKeyNumber(edaObjectFile, common);
fileName = string.Concat(edaObjectFile.Replace(replace, "APCRunKeyNumber"), ".csv");
File.WriteAllText(fileName, csv);
try
{ File.SetCreationTime(fileName, lastModifiedDate); File.SetLastWriteTime(fileName, lastModifiedDate); }
catch (Exception) { }
fileName = string.Concat(edaObjectFile.Replace(replace, "APC"), ".xlsx");
if (File.Exists(emptyAPC) && !File.Exists(fileName))
{
File.Copy(emptyAPC, fileName);
try
{ File.SetCreationTime(fileName, lastModifiedDate); File.SetLastWriteTime(fileName, lastModifiedDate); }
catch (Exception) { }
} }
} }
} }