Not Tested
This commit is contained in:
parent
3812a46667
commit
446b5587be
19
.vscode/launch.json
vendored
19
.vscode/launch.json
vendored
@ -11,12 +11,27 @@
|
|||||||
"preLaunchTask": "build",
|
"preLaunchTask": "build",
|
||||||
"program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/File-Folder-Helper.dll",
|
"program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/File-Folder-Helper.dll",
|
||||||
"args": [
|
"args": [
|
||||||
|
"s",
|
||||||
|
"X",
|
||||||
|
"D:/5-Other-Small/Kanban-mestsa003/ART-SPS/2024/PI4/Sprint-4.1/126448-User-Story/.files/638675719896500885",
|
||||||
|
"Day-Helper-2024-11-15",
|
||||||
|
"*.txt",
|
||||||
|
"s",
|
||||||
|
"X",
|
||||||
|
"D:/5-Other-Small/Kanban-mestsa003/ART-SPS/2024/PI4/Sprint-4.1/126448-User-Story/.files/Production__v2_57_0__BIORAD4__Stratus__1TRDS",
|
||||||
|
"Day-Helper-2024-11-15",
|
||||||
|
"*.txt",
|
||||||
|
"s",
|
||||||
|
"X",
|
||||||
|
"D:/5-Other-Small/Kanban-mestsa003/ART-SPS/2024/PI4/Sprint-4.1/126448-User-Story/.files/Production__v2_57_0__BIORAD2__QS408M__FourteenPoint",
|
||||||
|
"Day-Helper-2024-11-15",
|
||||||
|
"*.txt",
|
||||||
"s",
|
"s",
|
||||||
"X",
|
"X",
|
||||||
"D:/5-Other-Small/Kanban-mestsa003/ART-SPS/2024/PI4/Sprint-4.1/126996-User-Story",
|
"D:/5-Other-Small/Kanban-mestsa003/ART-SPS/2024/PI4/Sprint-4.1/126996-User-Story",
|
||||||
"Day-Helper-2024-11-08",
|
"Day-Helper-2024-11-08",
|
||||||
"Bug|User Story",
|
"[].json",
|
||||||
"D:/5-Other-Small/Kanban-mestsa003/ART-SPS",
|
"333",
|
||||||
"444",
|
"444",
|
||||||
"555",
|
"555",
|
||||||
"666",
|
"666",
|
||||||
|
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -11,6 +11,7 @@
|
|||||||
},
|
},
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"ASPNETCORE",
|
"ASPNETCORE",
|
||||||
|
"BIORAD",
|
||||||
"BIRT",
|
"BIRT",
|
||||||
"CHIL",
|
"CHIL",
|
||||||
"DEAT",
|
"DEAT",
|
||||||
|
@ -100,8 +100,8 @@ internal static partial class Helper20240427
|
|||||||
private static void MoveAssets(ILogger<Worker> logger, string var, string home, string pictures, List<Asset> assets)
|
private static void MoveAssets(ILogger<Worker> logger, string var, string home, string pictures, List<Asset> assets)
|
||||||
{
|
{
|
||||||
string? checkFile;
|
string? checkFile;
|
||||||
ReadOnlyCollection<string> varDirectoryNames = HelperDirectory.GetDirectoryNames(home);
|
ReadOnlyCollection<string> directoryNames = HelperDirectory.GetDirectoryNames(home);
|
||||||
string lastVarDirectoryName = varDirectoryNames[^1];
|
string lastDirectoryName = directoryNames[^1];
|
||||||
foreach (Asset asset in assets)
|
foreach (Asset asset in assets)
|
||||||
{
|
{
|
||||||
if (asset.OriginalFileName is null)
|
if (asset.OriginalFileName is null)
|
||||||
@ -114,10 +114,10 @@ internal static partial class Helper20240427
|
|||||||
continue;
|
continue;
|
||||||
if (asset.OriginalPath is null || !asset.OriginalPath.StartsWith(pictures))
|
if (asset.OriginalPath is null || !asset.OriginalPath.StartsWith(pictures))
|
||||||
continue;
|
continue;
|
||||||
checkFile = MoveAsset(home, asset.OriginalFileName, lastVarDirectoryName, asset.PreviewPath);
|
checkFile = MoveAsset(home, asset.OriginalFileName, lastDirectoryName, asset.PreviewPath);
|
||||||
if (checkFile is null)
|
if (checkFile is null)
|
||||||
continue;
|
continue;
|
||||||
checkFile = MoveAsset(home, asset.OriginalFileName, lastVarDirectoryName, asset.ThumbnailPath);
|
checkFile = MoveAsset(home, asset.OriginalFileName, lastDirectoryName, asset.ThumbnailPath);
|
||||||
if (checkFile is null)
|
if (checkFile is null)
|
||||||
continue;
|
continue;
|
||||||
logger.LogDebug("<{OriginalFileName}> moved.", asset.OriginalFileName);
|
logger.LogDebug("<{OriginalFileName}> moved.", asset.OriginalFileName);
|
||||||
|
@ -1,12 +1,17 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
#if CommonMark
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace File_Folder_Helper.ADO2024.PI3;
|
namespace File_Folder_Helper.ADO2024.PI3;
|
||||||
|
|
||||||
internal static partial class Helper20240911
|
internal static partial class Helper20240911
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if CommonMark
|
||||||
|
|
||||||
private record Attribute([property: JsonPropertyName("isLocked")] bool IsLocked,
|
private record Attribute([property: JsonPropertyName("isLocked")] bool IsLocked,
|
||||||
[property: JsonPropertyName("name")] string Name);
|
[property: JsonPropertyName("name")] string Name);
|
||||||
|
|
||||||
@ -758,4 +763,14 @@ internal static partial class Helper20240911
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
internal static void WriteMarkdown(ILogger<Worker> logger, List<string> args)
|
||||||
|
{
|
||||||
|
logger.LogError("WriteMarkdown is not available in CommonMark {args[0]}", args[0]);
|
||||||
|
logger.LogError("WriteMarkdown is not available in CommonMark {args[1]}", args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
@ -9,11 +9,14 @@ internal static partial class Helper20241108
|
|||||||
{
|
{
|
||||||
|
|
||||||
private record Attribute([property: JsonPropertyName("isLocked")] bool IsLocked,
|
private record Attribute([property: JsonPropertyName("isLocked")] bool IsLocked,
|
||||||
[property: JsonPropertyName("name")] string Name);
|
[property: JsonPropertyName("name")] string Name,
|
||||||
|
[property: JsonPropertyName("parameterTitle")] string? ParameterTitle,
|
||||||
|
[property: JsonPropertyName("state")] string? State,
|
||||||
|
[property: JsonPropertyName("workItemType")] string? WorkItemType);
|
||||||
|
|
||||||
private record Relation([property: JsonPropertyName("rel")] string Type,
|
private record Relation([property: JsonPropertyName("attributes")] Attribute Attributes,
|
||||||
[property: JsonPropertyName("url")] string URL,
|
[property: JsonPropertyName("id")] int Id,
|
||||||
[property: JsonPropertyName("attributes")] Attribute Attributes);
|
[property: JsonPropertyName("rel")] string Rel);
|
||||||
|
|
||||||
private record WorkItem(DateTime? ActivatedDate,
|
private record WorkItem(DateTime? ActivatedDate,
|
||||||
string AreaPath,
|
string AreaPath,
|
||||||
@ -47,6 +50,39 @@ internal static partial class Helper20241108
|
|||||||
|
|
||||||
public override string ToString() => $"{Id} - {WorkItemType} - {Title}";
|
public override string ToString() => $"{Id} - {WorkItemType} - {Title}";
|
||||||
|
|
||||||
|
public static WorkItem Get(WorkItem workItem, Relation[] relations)
|
||||||
|
{
|
||||||
|
WorkItem result = new(workItem.ActivatedDate,
|
||||||
|
workItem.AreaPath,
|
||||||
|
workItem.AssignedTo,
|
||||||
|
workItem.BusinessValue,
|
||||||
|
workItem.ChangedDate,
|
||||||
|
workItem.ClosedDate,
|
||||||
|
workItem.CommentCount,
|
||||||
|
workItem.CreatedDate,
|
||||||
|
workItem.Description,
|
||||||
|
workItem.Effort,
|
||||||
|
workItem.Id,
|
||||||
|
workItem.IterationPath,
|
||||||
|
workItem.Parent,
|
||||||
|
workItem.Priority,
|
||||||
|
relations,
|
||||||
|
workItem.Requester,
|
||||||
|
workItem.ResolvedDate,
|
||||||
|
workItem.Revision,
|
||||||
|
workItem.RiskReductionMinusOpportunityEnablement,
|
||||||
|
workItem.StartDate,
|
||||||
|
workItem.State,
|
||||||
|
workItem.Tags,
|
||||||
|
workItem.TargetDate,
|
||||||
|
workItem.TimeCriticality,
|
||||||
|
workItem.Title,
|
||||||
|
workItem.Violation,
|
||||||
|
workItem.WeightedShortestJobFirst,
|
||||||
|
workItem.WorkItemType);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static WorkItem? GetWithOutRelations(WorkItem? workItem)
|
public static WorkItem? GetWithOutRelations(WorkItem? workItem)
|
||||||
{
|
{
|
||||||
WorkItem? result = workItem is null ? null : new(workItem.ActivatedDate,
|
WorkItem? result = workItem is null ? null : new(workItem.ActivatedDate,
|
||||||
@ -88,7 +124,7 @@ internal static partial class Helper20241108
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private record Record(WorkItem WorkItem, WorkItem? Parent, Record[] Children, Record[] Related, Record[] Successors)
|
private record Record(WorkItem WorkItem, WorkItem? Parent, Record[]? Children, Record[]? Related, Record[]? Successors)
|
||||||
{
|
{
|
||||||
|
|
||||||
internal static Record GetWithoutNesting(Record record, string? violation)
|
internal static Record GetWithoutNesting(Record record, string? violation)
|
||||||
@ -122,95 +158,95 @@ internal static partial class Helper20241108
|
|||||||
record.WorkItem.Violation is null ? violation : record.WorkItem.Violation,
|
record.WorkItem.Violation is null ? violation : record.WorkItem.Violation,
|
||||||
record.WorkItem.WeightedShortestJobFirst,
|
record.WorkItem.WeightedShortestJobFirst,
|
||||||
record.WorkItem.WorkItemType);
|
record.WorkItem.WorkItemType);
|
||||||
result = new(workItem, record.Parent, [], [], []);
|
result = new(workItem, record.Parent, null, null, null);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Record Get(Record record, bool keepRelations)
|
private static Record Get(Record record, bool keepRelations)
|
||||||
{
|
{
|
||||||
Record result;
|
Record result;
|
||||||
|
Record[]? childRecords;
|
||||||
|
Record[]? relatedRecords;
|
||||||
|
Record[]? successorRecords;
|
||||||
|
List<Record> relationRecords;
|
||||||
WorkItem? parentWorkItem = keepRelations ? record.Parent : WorkItem.GetWithOutRelations(record.Parent);
|
WorkItem? parentWorkItem = keepRelations ? record.Parent : WorkItem.GetWithOutRelations(record.Parent);
|
||||||
WorkItem? workItem = keepRelations ? record.WorkItem : WorkItem.GetWithOutRelations(record.WorkItem) ?? throw new Exception();
|
WorkItem? workItem = keepRelations ? record.WorkItem : WorkItem.GetWithOutRelations(record.WorkItem) ?? throw new Exception();
|
||||||
List<Record> childRecords = [];
|
if (record.Children is null)
|
||||||
List<Record> relatedRecords = [];
|
childRecords = null;
|
||||||
List<Record> successorRecords = [];
|
|
||||||
foreach (Record r in record.Children)
|
|
||||||
childRecords.Add(Get(r, keepRelations));
|
|
||||||
foreach (Record r in record.Related)
|
|
||||||
relatedRecords.Add(Get(r, keepRelations));
|
|
||||||
foreach (Record r in record.Successors)
|
|
||||||
successorRecords.Add(Get(r, keepRelations));
|
|
||||||
result = new(workItem, parentWorkItem, childRecords.ToArray(), relatedRecords.ToArray(), successorRecords.ToArray());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static Record Get(WorkItem workItem, WorkItem? parent, ReadOnlyCollection<Record> children, ReadOnlyCollection<Record> related, ReadOnlyCollection<Record> successors, bool keepRelations)
|
|
||||||
{
|
|
||||||
Record result;
|
|
||||||
Record record = new(workItem, parent, children.ToArray(), related.ToArray(), successors.ToArray());
|
|
||||||
result = Get(record, keepRelations);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int? GetIdFromUrl(string relationName, Relation relation)
|
|
||||||
{
|
|
||||||
int? result;
|
|
||||||
string[] segments = relation?.Attributes is null || relation.Attributes.Name != relationName ? [] : relation.URL.Split('/');
|
|
||||||
if (segments.Length < 2)
|
|
||||||
result = null;
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!int.TryParse(segments[^1], out int id))
|
relationRecords = [];
|
||||||
result = null;
|
foreach (Record r in record.Children)
|
||||||
else
|
relationRecords.Add(Get(r, keepRelations));
|
||||||
result = id;
|
childRecords = relationRecords.ToArray();
|
||||||
}
|
}
|
||||||
|
if (record.Related is null)
|
||||||
|
relatedRecords = null;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
relationRecords = [];
|
||||||
|
foreach (Record r in record.Related)
|
||||||
|
relationRecords.Add(Get(r, keepRelations));
|
||||||
|
relatedRecords = relationRecords.ToArray();
|
||||||
|
}
|
||||||
|
if (record.Successors is null)
|
||||||
|
successorRecords = null;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
relationRecords = [];
|
||||||
|
foreach (Record r in record.Successors)
|
||||||
|
relationRecords.Add(Get(r, keepRelations));
|
||||||
|
successorRecords = relationRecords.ToArray();
|
||||||
|
}
|
||||||
|
result = new(workItem, parentWorkItem, childRecords, relatedRecords, successorRecords);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static Record Get(WorkItem workItem, WorkItem? parent, ReadOnlyCollection<Record>? children, ReadOnlyCollection<Record>? related, ReadOnlyCollection<Record>? successors, bool keepRelations)
|
||||||
|
{
|
||||||
|
Record result;
|
||||||
|
Record record = new(workItem, parent, children?.ToArray(), related?.ToArray(), successors?.ToArray());
|
||||||
|
result = Get(record, keepRelations);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static ReadOnlyCollection<Record> GetKeyValuePairs(ReadOnlyDictionary<int, WorkItem> keyValuePairs, WorkItem workItem, string relationName, List<bool> nests, bool keepRelations)
|
internal static ReadOnlyCollection<Record> GetKeyValuePairs(ReadOnlyDictionary<int, WorkItem> keyValuePairs, WorkItem workItem, string relationName, List<bool> nests, bool keepRelations)
|
||||||
{
|
{
|
||||||
List<Record> results = [];
|
List<Record> results = [];
|
||||||
int? childId;
|
|
||||||
Record record;
|
Record record;
|
||||||
nests.Add(true);
|
nests.Add(true);
|
||||||
WorkItem? childWorkItem;
|
|
||||||
WorkItem? parentWorkItem;
|
WorkItem? parentWorkItem;
|
||||||
|
WorkItem? relationWorkItem;
|
||||||
List<WorkItem> collection = [];
|
List<WorkItem> collection = [];
|
||||||
ReadOnlyCollection<Record> childRecords;
|
ReadOnlyCollection<Record>? childRecords;
|
||||||
ReadOnlyCollection<Record> relatedRecords;
|
ReadOnlyCollection<Record>? relatedRecords;
|
||||||
ReadOnlyCollection<Record> successorRecords;
|
ReadOnlyCollection<Record>? successorRecords;
|
||||||
if (workItem.Relations is not null && workItem.Relations.Length > 0)
|
if (workItem.Relations is not null && workItem.Relations.Length > 0)
|
||||||
{
|
{
|
||||||
collection.Clear();
|
collection.Clear();
|
||||||
foreach (Relation relation in workItem.Relations)
|
foreach (Relation relation in workItem.Relations)
|
||||||
{
|
{
|
||||||
childId = GetIdFromUrl(relationName, relation);
|
if (relation.Attributes.Name != relationName)
|
||||||
if (childId is not null && workItem.Parent is not null && relation?.URL is not null && relation.URL.Contains(workItem.Parent.Value.ToString()))
|
|
||||||
continue;
|
continue;
|
||||||
if (childId is null || !keyValuePairs.TryGetValue(childId.Value, out childWorkItem))
|
if (workItem.Parent is not null && relation.Id == workItem.Parent.Value)
|
||||||
continue;
|
continue;
|
||||||
collection.Add(childWorkItem);
|
if (!keyValuePairs.TryGetValue(relation.Id, out relationWorkItem))
|
||||||
|
continue;
|
||||||
|
collection.Add(relationWorkItem);
|
||||||
}
|
}
|
||||||
collection = (from l in collection orderby l.State != "Closed", l.Id select l).ToList();
|
collection = (from l in collection orderby l.State != "Closed", l.Id select l).ToList();
|
||||||
foreach (WorkItem w in collection)
|
foreach (WorkItem w in collection)
|
||||||
{
|
{
|
||||||
if (nests.Count > 99)
|
if (nests.Count > 500)
|
||||||
break;
|
break;
|
||||||
if (w.Parent is null)
|
if (w.Parent is null)
|
||||||
parentWorkItem = null;
|
parentWorkItem = null;
|
||||||
else
|
else
|
||||||
_ = keyValuePairs.TryGetValue(w.Parent.Value, out parentWorkItem);
|
_ = keyValuePairs.TryGetValue(w.Parent.Value, out parentWorkItem);
|
||||||
childRecords = GetKeyValuePairs(keyValuePairs, w, "Child", nests, keepRelations); // Forward
|
childRecords = GetKeyValuePairs(keyValuePairs, w, "Child", nests, keepRelations); // Forward
|
||||||
// records = GetKeyValuePairs(keyValuePairs, w, "Predecessor", nests); // Reverse
|
relatedRecords = null; // GetKeyValuePairs(keyValuePairs, w, "Related", nests, keepRelations); // Related
|
||||||
// successorRecords = GetKeyValuePairs(keyValuePairs, w, "Successor", nests); // Forward
|
successorRecords = null; // GetKeyValuePairs(keyValuePairs, w, "Successor", nests, keepRelations); // Forward
|
||||||
// if (successorRecords.Count > 0)
|
// predecessorRecords = GetKeyValuePairs(keyValuePairs, w, "Predecessor", nests, keepRelations); // Reverse
|
||||||
// {
|
|
||||||
// if (successorRecords.Count > 0)
|
|
||||||
// { }
|
|
||||||
// }
|
|
||||||
successorRecords = new([]);
|
|
||||||
relatedRecords = GetKeyValuePairs(keyValuePairs, w, "Related", nests, keepRelations); // Related
|
|
||||||
record = Get(w, parentWorkItem, childRecords, relatedRecords, successorRecords, keepRelations);
|
record = Get(w, parentWorkItem, childRecords, relatedRecords, successorRecords, keepRelations);
|
||||||
results.Add(record);
|
results.Add(record);
|
||||||
}
|
}
|
||||||
@ -269,125 +305,60 @@ internal static partial class Helper20241108
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReadOnlyDictionary<int, string> GetCurrentDirectories(string destinationDirectory, ReadOnlyCollection<string> bugUserStoryWorkItemTypes)
|
private static ReadOnlyCollection<WorkItem>? GetWorkItems(string fileName, string sourceDirectory)
|
||||||
{
|
{
|
||||||
Dictionary<int, string> results = [];
|
WorkItem[]? results;
|
||||||
int id;
|
string? checkFile = null;
|
||||||
string idCheck;
|
string? checkDirectory = sourceDirectory;
|
||||||
string? fileName;
|
string? pathRoot = Path.GetPathRoot(sourceDirectory);
|
||||||
string[] directories;
|
for (int i = 0; i < int.MaxValue; i++)
|
||||||
string[] split = ["-"];
|
|
||||||
foreach (string w in bugUserStoryWorkItemTypes)
|
|
||||||
{
|
{
|
||||||
directories = Directory.GetDirectories(destinationDirectory, $"*-{w.Replace(" ", "-")}", SearchOption.AllDirectories);
|
checkDirectory = Path.GetDirectoryName(checkDirectory);
|
||||||
foreach (string directory in directories)
|
if (string.IsNullOrEmpty(checkDirectory) || checkDirectory == pathRoot)
|
||||||
{
|
break;
|
||||||
fileName = Path.GetFileName(directory);
|
checkFile = Path.Combine(checkDirectory, fileName);
|
||||||
if (string.IsNullOrEmpty(fileName))
|
|
||||||
continue;
|
|
||||||
idCheck = fileName.Split(split, StringSplitOptions.None)[0];
|
|
||||||
if (!int.TryParse(idCheck, out id))
|
|
||||||
continue;
|
|
||||||
if (!results.ContainsKey(id))
|
|
||||||
results.Add(id, directory);
|
|
||||||
else
|
|
||||||
MoveToDuplicate(destinationDirectory, directory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new(results);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void MoveToDuplicate(string destinationDirectory, string directory)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(destinationDirectory))
|
|
||||||
throw new ArgumentException($"'{nameof(destinationDirectory)}' cannot be null or empty.", nameof(destinationDirectory));
|
|
||||||
if (string.IsNullOrEmpty(directory))
|
|
||||||
throw new ArgumentException($"'{nameof(directory)}' cannot be null or empty.", nameof(directory));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ReadOnlyCollection<WorkItem> GetWorkItems(string sourceDirectory, ReadOnlyCollection<string> bugUserStoryWorkItemTypes)
|
|
||||||
{
|
|
||||||
List<WorkItem> results = [];
|
|
||||||
string json;
|
|
||||||
string checkFile;
|
|
||||||
WorkItem? workItem;
|
|
||||||
string directoryName;
|
|
||||||
string? checkDirectory = null;
|
|
||||||
foreach (string w in bugUserStoryWorkItemTypes)
|
|
||||||
{
|
|
||||||
directoryName = Path.GetFileName(sourceDirectory);
|
|
||||||
if (!directoryName.EndsWith(w.Replace(" ", "-")))
|
|
||||||
continue;
|
|
||||||
checkDirectory = Path.Combine(sourceDirectory, directoryName.Split('-')[0]);
|
|
||||||
if (!Directory.Exists(checkDirectory))
|
|
||||||
{
|
|
||||||
checkDirectory = null;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrEmpty(checkDirectory))
|
|
||||||
{
|
|
||||||
checkFile = Path.Combine(checkDirectory, ".json");
|
|
||||||
if (File.Exists(checkFile))
|
if (File.Exists(checkFile))
|
||||||
{
|
break;
|
||||||
json = File.ReadAllText(checkFile);
|
checkFile = null;
|
||||||
workItem = JsonSerializer.Deserialize(json, WorkItemSourceGenerationContext.Default.WorkItem);
|
|
||||||
if (workItem is not null)
|
|
||||||
results.Add(workItem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return new(results);
|
if (checkFile is null)
|
||||||
}
|
results = null;
|
||||||
|
|
||||||
private static ReadOnlyCollection<WorkItem> GetWorkItems(ReadOnlyDictionary<int, string> collection)
|
|
||||||
{
|
|
||||||
List<WorkItem> results = [];
|
|
||||||
string json;
|
|
||||||
string checkFile;
|
|
||||||
string? directory;
|
|
||||||
WorkItem? workItem;
|
|
||||||
string? checkDirectory;
|
|
||||||
foreach (KeyValuePair<int, string> keyValuePair in collection)
|
|
||||||
{
|
|
||||||
if (!collection.TryGetValue(keyValuePair.Key, out directory) || string.IsNullOrEmpty(directory))
|
|
||||||
continue;
|
|
||||||
checkDirectory = Path.Combine(directory, $"{keyValuePair.Key}");
|
|
||||||
if (!Directory.Exists(checkDirectory))
|
|
||||||
continue;
|
|
||||||
checkFile = Path.Combine(checkDirectory, ".json");
|
|
||||||
if (!File.Exists(checkFile))
|
|
||||||
continue;
|
|
||||||
json = File.ReadAllText(checkFile);
|
|
||||||
workItem = JsonSerializer.Deserialize(json, WorkItemSourceGenerationContext.Default.WorkItem);
|
|
||||||
if (workItem is null)
|
|
||||||
continue;
|
|
||||||
results.Add(workItem);
|
|
||||||
}
|
|
||||||
return new(results);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ReadOnlyCollection<WorkItem> GetWorkItems(string sourceDirectory, ReadOnlyCollection<string> bugUserStoryWorkItemTypes, ReadOnlyDictionary<int, string> collection)
|
|
||||||
{
|
|
||||||
ReadOnlyCollection<WorkItem> results;
|
|
||||||
if (collection.Count > 0)
|
|
||||||
results = GetWorkItems(collection);
|
|
||||||
else
|
else
|
||||||
results = GetWorkItems(sourceDirectory, bugUserStoryWorkItemTypes);
|
{
|
||||||
return results;
|
string json = File.ReadAllText(checkFile);
|
||||||
|
results = JsonSerializer.Deserialize<WorkItem[]>(json);
|
||||||
|
}
|
||||||
|
return results is null ? null : new(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void WriteMarkdown(ILogger<Worker> logger, List<string> args)
|
internal static void WriteMarkdown(ILogger<Worker> logger, List<string> args)
|
||||||
{
|
{
|
||||||
// string url = args[5];
|
// string url = args[5];
|
||||||
bool keepRelations = true;
|
bool keepRelations = true;
|
||||||
|
string fileName = args[2];
|
||||||
string sourceDirectory = Path.GetFullPath(args[0]);
|
string sourceDirectory = Path.GetFullPath(args[0]);
|
||||||
ReadOnlyCollection<string> bugUserStoryWorkItemTypes = args[2].Split('|').ToArray().AsReadOnly();
|
string sourceDirectoryName = Path.GetFileName(sourceDirectory);
|
||||||
// ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes = new(new string[] { "Bug", "User Story", "Task" });
|
string idCheck = sourceDirectoryName.Split('-', StringSplitOptions.None)[0];
|
||||||
ReadOnlyDictionary<int, string> collection = GetCurrentDirectories(sourceDirectory, bugUserStoryWorkItemTypes);
|
if (!int.TryParse(idCheck, out int id))
|
||||||
ReadOnlyCollection<WorkItem> workItems = GetWorkItems(sourceDirectory, bugUserStoryWorkItemTypes, collection);
|
logger.LogInformation("Not valid directory!");
|
||||||
ReadOnlyDictionary<int, Record> keyValuePairs = GetWorkItems(workItems, keepRelations);
|
else
|
||||||
logger.LogInformation("Found {keyValuePairs}", keyValuePairs.Count);
|
{
|
||||||
|
ReadOnlyCollection<WorkItem>? workItems = GetWorkItems(fileName, sourceDirectory);
|
||||||
|
if (workItems is null)
|
||||||
|
logger.LogInformation("No file found!");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Record? record;
|
||||||
|
ReadOnlyDictionary<int, Record> keyValuePairs = GetWorkItems(workItems, keepRelations);
|
||||||
|
logger.LogInformation("Found {keyValuePairs}", keyValuePairs.Count);
|
||||||
|
if (!keyValuePairs.TryGetValue(id, out record))
|
||||||
|
logger.LogInformation($"Id {id} not found!");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.LogInformation($"Id {id} found with title {record.WorkItem.Title}!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
62
ADO2024/PI4/Helper-2024-11-15.cs
Normal file
62
ADO2024/PI4/Helper-2024-11-15.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace File_Folder_Helper.ADO2024.PI4;
|
||||||
|
|
||||||
|
internal static partial class Helper20241115
|
||||||
|
{
|
||||||
|
|
||||||
|
#if !BIORAD
|
||||||
|
|
||||||
|
internal static void ScanPast(string text, int[] i, string search)
|
||||||
|
{
|
||||||
|
int num = text.IndexOf(search, i[0]);
|
||||||
|
if (num > -1)
|
||||||
|
i[0] = num + search.Length;
|
||||||
|
else
|
||||||
|
i[0] = text.Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void GetComplete(ILogger<Worker> logger, List<string> args)
|
||||||
|
{
|
||||||
|
string searchPattern = args[2];
|
||||||
|
string sourceDirectory = Path.GetFullPath(args[0]);
|
||||||
|
string[] files = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.TopDirectoryOnly);
|
||||||
|
if (files.Length != 1)
|
||||||
|
logger.LogError("No files found in {sourceDirectory} with search pattern {searchPattern}", sourceDirectory, searchPattern);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
List<string> group = [];
|
||||||
|
string text = File.ReadAllText(files[0]);
|
||||||
|
int[] i = [0];
|
||||||
|
ScanPast(text, i, "Recipe ID:");
|
||||||
|
ScanPast(text, i, "*");
|
||||||
|
#pragma warning disable IDE0057
|
||||||
|
string[] segments = text.Substring(i[0]).Split('*');
|
||||||
|
string[] segmentsB;
|
||||||
|
string[] segmentsC;
|
||||||
|
foreach (string segment in segments)
|
||||||
|
{
|
||||||
|
segmentsB = segment.Split(Environment.NewLine);
|
||||||
|
segmentsC = segmentsB[0].Split(' ');
|
||||||
|
if (segment.Contains("Group"))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
internal static void GetComplete(ILogger<Worker> logger, List<string> args)
|
||||||
|
{
|
||||||
|
string searchPattern = args[2];
|
||||||
|
string sourceDirectory = Path.GetFullPath(args[0]);
|
||||||
|
string[] files = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.TopDirectoryOnly);
|
||||||
|
if (files.Length != 1)
|
||||||
|
logger.LogError("No files found in {sourceDirectory} with search pattern {searchPattern}", sourceDirectory, searchPattern);
|
||||||
|
logger.LogError("GetComplete is not available in CDE {args[1]}", args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
@ -117,6 +117,8 @@ internal static class HelperDay
|
|||||||
ADO2024.PI3.Helper20241031.GetComplete(logger, args);
|
ADO2024.PI3.Helper20241031.GetComplete(logger, args);
|
||||||
else if (args[1] == "Day-Helper-2024-11-08")
|
else if (args[1] == "Day-Helper-2024-11-08")
|
||||||
ADO2024.PI4.Helper20241108.WriteMarkdown(logger, args);
|
ADO2024.PI4.Helper20241108.WriteMarkdown(logger, args);
|
||||||
|
else if (args[1] == "Day-Helper-2024-11-15")
|
||||||
|
ADO2024.PI4.Helper20241115.GetComplete(logger, args);
|
||||||
else
|
else
|
||||||
throw new Exception(appSettings.Company);
|
throw new Exception(appSettings.Company);
|
||||||
}
|
}
|
||||||
|
@ -13,16 +13,14 @@
|
|||||||
<RuntimeHostConfigurationOption Include="AssemblyName" Value="File-Folder-Helper" />
|
<RuntimeHostConfigurationOption Include="AssemblyName" Value="File-Folder-Helper" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CommonMark.NET" Version="0.15.1" />
|
|
||||||
<PackageReference Include="DiscUtils.Iso9660" Version="0.16.13" />
|
<PackageReference Include="DiscUtils.Iso9660" Version="0.16.13" />
|
||||||
<PackageReference Include="MetadataExtractor" Version="2.8.1" />
|
<PackageReference Include="MetadataExtractor" Version="2.8.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
|
||||||
<PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="19.225.1" />
|
|
||||||
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="8.0.10" />
|
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="8.0.10" />
|
||||||
<PackageReference Include="System.Text.Json" Version="8.0.5" />
|
<PackageReference Include="System.Text.Json" Version="8.0.5" />
|
||||||
<PackageReference Include="TextCopy" Version="6.2.1" />
|
<PackageReference Include="TextCopy" Version="6.2.1" />
|
||||||
<PackageReference Include="WindowsShortcutFactory" Version="1.2.0" />
|
<PackageReference Include="WindowsShortcutFactory" Version="1.2.0" />
|
||||||
<PackageReference Include="YamlDotNet" Version="16.1.3" />
|
<PackageReference Include="YamlDotNet" Version="16.2.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -12,7 +12,7 @@ internal class Program
|
|||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
#pragma warning disable IL3050
|
#pragma warning disable IL3050
|
||||||
HostApplicationBuilder builder = Microsoft.Extensions.Hosting.Host.CreateApplicationBuilder(args);
|
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
|
||||||
#pragma warning restore IL3050
|
#pragma warning restore IL3050
|
||||||
_ = builder.Configuration.AddEnvironmentVariables();
|
_ = builder.Configuration.AddEnvironmentVariables();
|
||||||
_ = builder.Configuration.AddUserSecrets<Program>();
|
_ = builder.Configuration.AddUserSecrets<Program>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user