Sync to Distinct Max Iteration Path
This commit is contained in:
parent
37edec4195
commit
4a15e8dd51
@ -292,29 +292,42 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
private static void AppendLines(List<char> spaces, List<string> lines, ReadOnlyDictionary<int, Record> workItemAndChildren, string workItemType)
|
||||
{
|
||||
WorkItem workItem;
|
||||
string? maxIterationPath;
|
||||
List<string> distinct = new();
|
||||
foreach (KeyValuePair<int, Record> keyValuePair in workItemAndChildren)
|
||||
{
|
||||
workItem = keyValuePair.Value.WorkItem;
|
||||
// if (keyValuePair.Key != 109724)
|
||||
// continue;
|
||||
if (workItem.WorkItemType != workItemType)
|
||||
continue;
|
||||
lines.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}");
|
||||
lines.Add(string.Empty);
|
||||
lines.Add($"- [{workItem.Id}](https://tfs.intra.infineon.com/tfs/FactoryIntegration/ART%20SPS/_workitems/edit/{workItem.Id})");
|
||||
lines.Add(string.Empty);
|
||||
if (keyValuePair.Value.Children.Count > 0)
|
||||
if (keyValuePair.Value.Children.Count == 0)
|
||||
lines.Add(string.Empty);
|
||||
else
|
||||
{
|
||||
AppendLines(spaces, lines, keyValuePair.Value, condensed: true, sprintOnly: false);
|
||||
lines.Add(string.Empty);
|
||||
distinct.Clear();
|
||||
lines.Add($"## Distinct Iteration Path(s) - {workItem.WorkItemType} - {workItem.AssignedTo} - {workItem.Id} - {workItem.Title} - {workItem.IterationPath}");
|
||||
lines.Add(string.Empty);
|
||||
lines.Add($"- [{workItem.Id}](https://tfs.intra.infineon.com/tfs/FactoryIntegration/ART%20SPS/_workitems/edit/{workItem.Id})");
|
||||
lines.Add(string.Empty);
|
||||
AppendLines(spaces, distinct, keyValuePair.Value, condensed: false, sprintOnly: true);
|
||||
distinct.Sort();
|
||||
lines.AddRange(distinct.Distinct());
|
||||
lines.Add(string.Empty);
|
||||
if (distinct.Count > 1)
|
||||
{
|
||||
lines.Add($"## Distinct Iteration Path(s) - {workItem.WorkItemType} - {workItem.AssignedTo} - {workItem.Id} - {workItem.Title} - {workItem.IterationPath}");
|
||||
lines.Add(string.Empty);
|
||||
lines.Add($"- [{workItem.Id}](https://tfs.intra.infineon.com/tfs/FactoryIntegration/ART%20SPS/_workitems/edit/{workItem.Id})");
|
||||
distinct.Sort();
|
||||
distinct = (from l in distinct select l.Trim()).Distinct().ToList();
|
||||
lines.AddRange(distinct);
|
||||
lines.Add(string.Empty);
|
||||
maxIterationPath = distinct.Max();
|
||||
if (!string.IsNullOrEmpty(maxIterationPath) && maxIterationPath.Contains("] ") && maxIterationPath.Split(']')[1].Trim() != workItem.IterationPath)
|
||||
{
|
||||
lines.Add($"### Sync to Distinct Max Iteration Path => {maxIterationPath} - {workItem.Id} - {workItem.Title}");
|
||||
lines.Add(string.Empty);
|
||||
}
|
||||
}
|
||||
lines.Add($"## Extended - {workItem.Id} - {workItem.Title}");
|
||||
lines.Add(string.Empty);
|
||||
AppendLines(spaces, lines, keyValuePair.Value, condensed: false, sprintOnly: false);
|
||||
@ -333,7 +346,6 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
string? pathRoot;
|
||||
List<char> spaces = new();
|
||||
List<string> lines = new();
|
||||
lines.Add("# WorkItems");
|
||||
ReadOnlyDictionary<int, WorkItem> keyValuePairs = GetWorkItems(workItems);
|
||||
ReadOnlyDictionary<int, Record> workItemAndChildren = GetWorkItemAndChildren(keyValuePairs);
|
||||
foreach (string alternateTargetFolder in alternateTargetFolders)
|
||||
@ -359,6 +371,9 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
}
|
||||
foreach (string workItemType in workItemTypes)
|
||||
{
|
||||
lines.Clear();
|
||||
lines.Add("# WorkItems");
|
||||
lines.Add(string.Empty);
|
||||
AppendLines(spaces, lines, workItemAndChildren, workItemType);
|
||||
checkFile = Path.Combine(alternateTargetFolder, $"{workItemType}.md");
|
||||
text = string.Join(Environment.NewLine, lines);
|
||||
|
@ -489,6 +489,43 @@ public class FileRead : Properties.IFileRead
|
||||
}
|
||||
}
|
||||
|
||||
protected static void NestExistingFiles(FileConnectorConfiguration fileConnectorConfiguration)
|
||||
{
|
||||
if (!fileConnectorConfiguration.IncludeSubDirectories.Value)
|
||||
{
|
||||
string[] matches = GetMatches(fileConnectorConfiguration);
|
||||
if (matches is not null && matches.Length > 0)
|
||||
{
|
||||
string fileName;
|
||||
string nestedDirectory = Path.Combine(fileConnectorConfiguration.SourceFileLocation, DateTime.Now.Ticks.ToString());
|
||||
if (!Directory.Exists(nestedDirectory))
|
||||
_ = Directory.CreateDirectory(nestedDirectory);
|
||||
foreach (string match in matches)
|
||||
{
|
||||
fileName = Path.GetFileName(match);
|
||||
File.Move(match, Path.Combine(fileConnectorConfiguration.SourceFileLocation, fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static string[] GetMatches(FileConnectorConfiguration fileConnectorConfiguration)
|
||||
{
|
||||
string[] segments;
|
||||
string[] results = null;
|
||||
foreach (string subSourceFileFilter in fileConnectorConfiguration.SourceFileFilters)
|
||||
{
|
||||
segments = subSourceFileFilter.Split('\\');
|
||||
if (fileConnectorConfiguration.IncludeSubDirectories.Value)
|
||||
results = Directory.GetFiles(fileConnectorConfiguration.SourceFileLocation, segments.Last(), SearchOption.AllDirectories);
|
||||
else
|
||||
results = Directory.GetFiles(fileConnectorConfiguration.SourceFileLocation, segments.Last(), SearchOption.TopDirectoryOnly);
|
||||
if (results.Length != 0)
|
||||
break;
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
protected Tuple<string, Test[], JsonElement[], List<FileInfo>> ReExtract(IFileRead fileRead, List<string> headerNames, Dictionary<string, string> keyValuePairs)
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
@ -496,18 +533,7 @@ public class FileRead : Properties.IFileRead
|
||||
results = null;
|
||||
else
|
||||
{
|
||||
string[] segments;
|
||||
string[] matches = null;
|
||||
foreach (string subSourceFileFilter in _FileConnectorConfiguration.SourceFileFilters)
|
||||
{
|
||||
segments = subSourceFileFilter.Split('\\');
|
||||
if (_FileConnectorConfiguration.IncludeSubDirectories.Value)
|
||||
matches = Directory.GetFiles(_FileConnectorConfiguration.SourceFileLocation, segments.Last(), SearchOption.AllDirectories);
|
||||
else
|
||||
matches = Directory.GetFiles(_FileConnectorConfiguration.SourceFileLocation, segments.Last(), SearchOption.TopDirectoryOnly);
|
||||
if (matches.Length != 0)
|
||||
break;
|
||||
}
|
||||
string[] matches = GetMatches(_FileConnectorConfiguration);
|
||||
if (matches is null || matches.Length == 0)
|
||||
results = null;
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user