This commit is contained in:
Mike Phares 2024-09-09 10:26:12 -07:00
parent 2301a9a9ee
commit 7ab4b756d1
2 changed files with 6 additions and 9 deletions

View File

@ -205,6 +205,7 @@ public class FileRead : Shared.FileRead, IFileRead
{ {
long tick = DateTime.Now.Ticks; long tick = DateTime.Now.Ticks;
string ids = GetIds(httpClient, basePage, api, query); string ids = GetIds(httpClient, basePage, api, query);
if (!string.IsNullOrEmpty(ids))
DownloadWorkItemsAsync(httpClient, basePage, api, targetFileLocation, ids, tick); DownloadWorkItemsAsync(httpClient, basePage, api, targetFileLocation, ids, tick);
} }

View File

@ -110,14 +110,12 @@ public class FileRead : Shared.FileRead, IFileRead
private static void ParseWorkItemsAsync(FileConnectorConfiguration fileConnectorConfiguration, string[] alternateTargetFolders, ReadOnlyCollection<WorkItem> workItems) private static void ParseWorkItemsAsync(FileConnectorConfiguration fileConnectorConfiguration, string[] alternateTargetFolders, ReadOnlyCollection<WorkItem> workItems)
{ {
bool writeFile;
string checkFile; string checkFile;
string? pathRoot; string? pathRoot;
JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true }; JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
string json = JsonSerializer.Serialize(workItems, jsonSerializerOptions); string json = JsonSerializer.Serialize(workItems, jsonSerializerOptions);
foreach (string alternateTargetFolder in alternateTargetFolders) foreach (string alternateTargetFolder in alternateTargetFolders)
{ {
writeFile = true;
if (alternateTargetFolder == fileConnectorConfiguration.TargetFileLocation) if (alternateTargetFolder == fileConnectorConfiguration.TargetFileLocation)
continue; continue;
pathRoot = Path.GetPathRoot(alternateTargetFolder); pathRoot = Path.GetPathRoot(alternateTargetFolder);
@ -135,9 +133,8 @@ public class FileRead : Shared.FileRead, IFileRead
{ {
string old = File.ReadAllText(checkFile); string old = File.ReadAllText(checkFile);
if (old == json) if (old == json)
writeFile = false; continue;
} }
if (writeFile)
File.WriteAllText(checkFile, json); File.WriteAllText(checkFile, json);
} }
} }
@ -259,10 +256,9 @@ public class FileRead : Shared.FileRead, IFileRead
{ {
string old = File.ReadAllText(checkFile); string old = File.ReadAllText(checkFile);
if (json == old) if (json == old)
{
moveFile = false; moveFile = false;
File.Delete(reportFullPath); else
} File.Delete(checkFile);
} }
if (moveFile) if (moveFile)
File.Move(reportFullPath, checkFile); File.Move(reportFullPath, checkFile);