MET08RESIMAPCDE - v2.43.0 - Using EDA

Multiple Storage Paths and delete old way
This commit is contained in:
2022-06-07 11:10:00 -07:00
parent d6887992a0
commit 2e660ec384
81 changed files with 2028 additions and 1278 deletions

View File

@ -9,6 +9,7 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
namespace Adaptation.FileHandlers.pcl;
@ -139,7 +140,7 @@ public class ProcessData : IProcessData
private string GetToEOL(bool trim)
{
string str;
str = (!trim ? GetBefore("\n", false) : GetToEOL());
str = !trim ? GetBefore("\n", false) : GetToEOL();
return str;
}
@ -147,14 +148,14 @@ public class ProcessData : IProcessData
{
while (true)
{
if ((_I >= _Data.Length || !IsNullOrWhiteSpace(_Data.Substring(_I, 1))))
if (_I >= _Data.Length || !IsNullOrWhiteSpace(_Data.Substring(_I, 1)))
break;
_I++;
}
int num = _I;
while (true)
{
if ((num >= _Data.Length || IsNullOrWhiteSpace(_Data.Substring(num, 1))))
if (num >= _Data.Length || IsNullOrWhiteSpace(_Data.Substring(num, 1)))
break;
num++;
}
@ -172,7 +173,7 @@ public class ProcessData : IProcessData
private bool IsBlankLine()
{
int num = _Data.IndexOf("\n", _I);
return IsNullOrWhiteSpace((num > -1 ? _Data.Substring(_I, num - _I) : _Data.Substring(_I)));
return IsNullOrWhiteSpace(num > -1 ? _Data.Substring(_I, num - _I) : _Data.Substring(_I));
}
private static bool IsNullOrWhiteSpace(string text)
@ -262,7 +263,7 @@ public class ProcessData : IProcessData
log = log.Replace(" ", " ");
}
log = log.Replace(" ", "\t").Replace(": ", "\t").Replace(":\t", "\t");
IEnumerable<string> lines = (from l in log.Split('\r') select l.Trim());
IEnumerable<string> lines = from l in log.Split('\r') select l.Trim();
string logFile = Path.ChangeExtension(logistics.ReportFullPath, ".log");
File.WriteAllLines(logFile, lines);
fileInfoCollection.Add(new FileInfo(logFile));
@ -383,7 +384,6 @@ public class ProcessData : IProcessData
_Log.Debug($"****ParseData - cde.Run:'{Run}'");
if (string.IsNullOrEmpty(Run))
throw new Exception("Batch (Run) information does not exist");
//parse out batch and validate
string[] parsedBatch = Run.Split('-');
if (parsedBatch.Length >= 1)
@ -400,10 +400,8 @@ public class ProcessData : IProcessData
}
if (parsedBatch.Length >= 4)
Zone = parsedBatch[3];
//create filename / unique id
string timeFormat = "yyyyMMddHHmmss";
//fix equip
StringBuilder equipFixed = new();
foreach (char c in EquipId)
@ -415,13 +413,11 @@ public class ProcessData : IProcessData
}
EquipId = equipFixed.ToString();
_Log.Debug($"****ParseData - cde.EquipId:'{EquipId}'");
// The "cde.Run" string is used as part of the SharePoint header unique ID. The "cde.Run" ID is typed
// at the tool by the users. The characters are not controlled and the user can type any characters like
// "\", "*", ".", " ", etc. Some of these characters are not valid and thus can't be used for the
// SharePoint header unique ID. Therefore, we need to filter out invalid characters and only keep the
// important ones.
StringBuilder runFixed = new();
foreach (char c in Run)
{
@ -429,15 +425,28 @@ public class ProcessData : IProcessData
_ = runFixed.Append(c);
}
Run = runFixed.ToString();
UniqueId = string.Concat(EquipId, "_", Run, "_", logistics.DateTimeFromSequence.ToString(timeFormat));
foreach (Detail item in _Details)
foreach (Detail item in _Details.Cast<Detail>())
{
item.HeaderUniqueId = UniqueId;
item.UniqueId = string.Concat(item, item.UniqueId);
}
fileInfoCollection.Add(new FileInfo(logistics.ReportFullPath));
}
internal static List<Description> GetDescriptions(JsonElement[] jsonElements)
{
List<Description> results = new();
Description description;
JsonSerializerOptions jsonSerializerOptions = new() { NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString };
foreach (JsonElement jsonElement in jsonElements)
{
if (jsonElement.ValueKind != JsonValueKind.Object)
throw new Exception();
description = JsonSerializer.Deserialize<Description>(jsonElement.ToString(), jsonSerializerOptions);
results.Add(description);
}
return results;
}
}