Save check for file already present

This commit is contained in:
Mike Phares 2023-03-08 15:31:38 -07:00
parent 445a0ac773
commit 5448546b96

View File

@ -182,6 +182,7 @@ public class FromIQS
internal static void Save(string openInsightApiECDirectory, string openInsightApiIFXDirectory, Logistics logistics, string reportFullPath, string logisticLines, Stratus.Description description, string lines, long? subGroupId, string weekOfYear)
{
string checkFile;
string fileName = Path.GetFileName(reportFullPath);
string json = GetJson(logistics, logisticLines, description);
string? ecPathRoot = Path.GetPathRoot(openInsightApiECDirectory);
@ -195,18 +196,24 @@ public class FromIQS
_ = Directory.CreateDirectory(ecDirectory);
if (ifxExists && !Directory.Exists(ifxDirectory))
_ = Directory.CreateDirectory(ifxDirectory);
if (ecExists)
File.Copy(reportFullPath, Path.Combine(ecDirectory, fileName));
if (ifxExists)
File.Copy(reportFullPath, Path.Combine(ifxDirectory, fileName));
if (ecExists)
File.WriteAllText(Path.Combine(ecDirectory, $"{logistics.DateTimeFromSequence.Ticks}.txt"), lines);
if (ifxExists)
File.WriteAllText(Path.Combine(ifxDirectory, $"{logistics.DateTimeFromSequence.Ticks}.txt"), lines);
if (ecExists)
File.WriteAllText(Path.Combine(ecDirectory, $"{logistics.DateTimeFromSequence.Ticks}.json"), json);
if (ifxExists)
File.WriteAllText(Path.Combine(ifxDirectory, $"{logistics.DateTimeFromSequence.Ticks}.json"), json);
checkFile = Path.Combine(ecDirectory, fileName);
if (ecExists && !File.Exists(checkFile))
File.Copy(reportFullPath, checkFile);
checkFile = Path.Combine(ifxDirectory, fileName);
if (ifxExists && !File.Exists(checkFile))
File.Copy(reportFullPath, checkFile);
checkFile = Path.Combine(ecDirectory, $"{logistics.DateTimeFromSequence.Ticks}.txt");
if (ecExists && !File.Exists(checkFile))
File.WriteAllText(checkFile, lines);
checkFile = Path.Combine(ifxDirectory, $"{logistics.DateTimeFromSequence.Ticks}.txt");
if (ifxExists && !File.Exists(checkFile))
File.WriteAllText(checkFile, lines);
checkFile = Path.Combine(ecDirectory, $"{logistics.DateTimeFromSequence.Ticks}.json");
if (ecExists && !File.Exists(checkFile))
File.WriteAllText(checkFile, json);
checkFile = Path.Combine(ifxDirectory, $"{logistics.DateTimeFromSequence.Ticks}.json");
if (ifxExists && !File.Exists(checkFile))
File.WriteAllText(checkFile, json);
}
#nullable disable