Creation of ADO Connection

This commit is contained in:
Mike Phares 2024-11-08 15:47:49 -07:00
parent 5d9b5a4022
commit 9c5651a862
46 changed files with 1094 additions and 561 deletions

View File

@ -92,8 +92,8 @@ csharp_using_directive_placement = outside_namespace
dotnet_code_quality_unused_parameters = all dotnet_code_quality_unused_parameters = all
dotnet_code_quality_unused_parameters = non_public # IDE0060: Remove unused parameter dotnet_code_quality_unused_parameters = non_public # IDE0060: Remove unused parameter
dotnet_code_quality.CAXXXX.api_surface = private, internal dotnet_code_quality.CAXXXX.api_surface = private, internal
dotnet_diagnostic.CA1816.severity = none # CA1816: Call GC.SuppressFinalize correctly dotnet_diagnostic.CA1510.severity = none # CA1510: Use 'ArgumentNullException.ThrowIfNull' instead of explicitly throwing a new exception instance
dotnet_diagnostic.CA1825.severity = warning # CA1823: Avoid zero-length array allocations dotnet_diagnostic.CA1816.severity = warning # CA1823: Avoid zero-length array allocations
dotnet_diagnostic.CA1829.severity = warning # CA1829: Use Length/Count property instead of Count() when available dotnet_diagnostic.CA1829.severity = warning # CA1829: Use Length/Count property instead of Count() when available
dotnet_diagnostic.CA1834.severity = warning # CA1834: Consider using 'StringBuilder.Append(char)' when applicable dotnet_diagnostic.CA1834.severity = warning # CA1834: Consider using 'StringBuilder.Append(char)' when applicable
dotnet_diagnostic.CA1846.severity = none # CA1846: Prefer AsSpan over Substring dotnet_diagnostic.CA1846.severity = none # CA1846: Prefer AsSpan over Substring

View File

@ -49,6 +49,16 @@
], ],
"problemMatcher": "$msCompile" "problemMatcher": "$msCompile"
}, },
{
"label": "Format-Whitespaces",
"command": "dotnet",
"type": "process",
"args": [
"format",
"whitespace"
],
"problemMatcher": "$msCompile"
},
{ {
"label": "Nuget Clear", "label": "Nuget Clear",
"command": "dotnet", "command": "dotnet",
@ -68,7 +78,7 @@
"args": [ "args": [
"/target:Build", "/target:Build",
"/restore:True", "/restore:True",
"/p:RestoreSources=https://artifactory.intra.infineon.com/artifactory/api/nuget/ngt-fi-package-main-vir/%3Bhttps://packagemanagement.eu.infineon.com:4430/api/v2/%3Bhttps://tfs.intra.infineon.com/tfs/ManufacturingIT/_packaging/eaf/nuget/v3/index.json%3Bhttps://tfs.intra.infineon.com/tfs/FactoryIntegration/_packaging/EAF%40Local/nuget/v3/index.json%3Bhttps://api.nuget.org/v3/index.json", "/p:RestoreSources=https://artifactory.intra.infineon.com/artifactory/api/nuget/ngt-fi-package-main-vir/%3Bhttps://packagemanagement.eu.infineon.com:4430/api/v2/%3Bhttps://tfs.intra.infineon.com/tfs/FactoryIntegration/_packaging/EAF/nuget/v3/index.json%3Bhttps://tfs.intra.infineon.com/tfs/FactoryIntegration/_packaging/EAF%40Local/nuget/v3/index.json%3Bhttps://api.nuget.org/v3/index.json",
"/detailedsummary", "/detailedsummary",
"/consoleloggerparameters:PerformanceSummary;ErrorsOnly;", "/consoleloggerparameters:PerformanceSummary;ErrorsOnly;",
"/property:Configuration=Debug;TargetFrameworkVersion=v4.8", "/property:Configuration=Debug;TargetFrameworkVersion=v4.8",

View File

@ -0,0 +1,120 @@
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
using Adaptation.Shared;
using Adaptation.Shared.Duplicator;
using Adaptation.Shared.Methods;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
namespace Adaptation.FileHandlers.ADO;
public class FileRead : Shared.FileRead, IFileRead
{
private long? _TickOffset;
private readonly string _URL;
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, Dictionary<long, List<string>> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
{
_MinFileLength = 10;
_NullData = string.Empty;
_Logistics = new(this);
if (_FileParameter is null)
throw new Exception(cellInstanceConnectionName);
if (_ModelObjectParameterDefinitions is null)
throw new Exception(cellInstanceConnectionName);
if (!_IsDuplicator)
throw new Exception(cellInstanceConnectionName);
string cellInstanceNamed = string.Concat("CellInstance.", _EquipmentType);
_URL = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, $"{cellInstanceNamed}.URL");
if (_IsEAFHosted)
NestExistingFiles(_FileConnectorConfiguration);
}
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) => Move(extractResults);
void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
string IFileRead.GetEventDescription()
{
string result = _Description.GetEventDescription();
return result;
}
List<string> IFileRead.GetHeaderNames()
{
List<string> results = _Description.GetHeaderNames();
return results;
}
string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception)
{
string[] results = Move(extractResults, to, from, resolvedFileLocation, exception);
return results;
}
JsonProperty[] IFileRead.GetDefault()
{
JsonProperty[] results = _Description.GetDefault(this, _Logistics);
return results;
}
Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement()
{
Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this);
return results;
}
List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData)
{
List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
return results;
}
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.GetExtractResult(string reportFullPath, string eventName)
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
if (string.IsNullOrEmpty(eventName))
throw new Exception();
_ReportFullPath = reportFullPath;
DateTime dateTime = DateTime.Now;
results = GetExtractResult(reportFullPath, dateTime);
if (results.Item3 is null)
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(results.Item1, Array.Empty<Test>(), JsonSerializer.Deserialize<JsonElement[]>("[]"), results.Item4);
if (results.Item3.Length > 0 && _IsEAFHosted)
WritePDSF(this, results.Item3);
UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks);
return results;
}
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.ReExtract()
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
List<string> headerNames = _Description.GetHeaderNames();
Dictionary<string, string> keyValuePairs = _Description.GetDisplayNamesJsonElement(this);
results = ReExtract(this, headerNames, keyValuePairs);
return results;
}
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>());
_TickOffset ??= 0; // new FileInfo(reportFullPath).LastWriteTime.Ticks - dateTime.Ticks;
_Logistics = new Logistics(reportFullPath, $"LOGISTICS_1{'\t'}A_JOBID={"BACKLOG"};A_MES_ENTITY={"BACKLOG"};");
SetFileParameterLotIDToLogisticsMID();
if (_Logistics.FileInfo.Length < _MinFileLength)
results.Item4.Add(_Logistics.FileInfo);
else
{
IProcessData iProcessData = new ProcessData(this, _Logistics, _FileConnectorConfiguration.TargetFileLocation, _URL, results.Item4);
if (iProcessData.Details.Count == 0)
throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks));
results = iProcessData.GetResults(this, _Logistics, results.Item4);
}
return results;
}
}

View File

@ -0,0 +1,257 @@
using Adaptation.FileHandlers.json.WorkItems;
using Adaptation.Shared;
using Adaptation.Shared.Duplicator;
using Adaptation.Shared.Methods;
using log4net;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.ADO;
public class ProcessData : IProcessData
{
private readonly List<object> _Details;
List<object> Shared.Properties.IProcessData.Details => _Details;
private readonly ILog _Log;
public ProcessData(IFileRead fileRead, Logistics logistics, string targetFileLocation, string url, List<FileInfo> fileInfoCollection)
{
if (fileRead.IsEAFHosted)
{ }
if (url is null)
throw new ArgumentNullException(nameof(url));
fileInfoCollection.Clear();
_Details = new List<object>();
_Log = LogManager.GetLogger(typeof(ProcessData));
WriteFiles(fileRead, logistics, targetFileLocation, fileInfoCollection);
}
string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) =>
throw new Exception(string.Concat("See ", nameof(WriteFiles)));
Tuple<string, Test[], JsonElement[], List<FileInfo>> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection) =>
new(logistics.Logistics1[0], Array.Empty<Test>(), Array.Empty<JsonElement>(), fileInfoCollection);
#nullable enable
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);
if (description is null)
continue;
results.Add(description);
}
return results;
}
private void WriteFiles(IFileRead fileRead, Logistics logistics, string destinationDirectory, List<FileInfo> fileInfoCollection)
{
bool keepRelations = true;
if (!Directory.Exists(destinationDirectory))
_ = Directory.CreateDirectory(destinationDirectory);
string json = File.ReadAllText(logistics.ReportFullPath);
WorkItem[]? workItems = JsonSerializer.Deserialize<WorkItem[]>(json);
if (workItems is null)
throw new Exception(nameof(workItems));
_Details.Add(workItems);
ReadOnlyDictionary<int, Record> keyValuePairs = GetWorkItems(workItems, keepRelations);
WriteFileStructure(destinationDirectory, keyValuePairs);
WriteFiles(fileRead, destinationDirectory, fileInfoCollection, keyValuePairs);
}
private static ReadOnlyDictionary<int, Record> GetWorkItems(WorkItem[] workItems, bool keepRelations)
{
ReadOnlyDictionary<int, Record> results;
Dictionary<int, WorkItem> keyValuePairs = new();
foreach (WorkItem workItem in workItems)
keyValuePairs.Add(workItem.Id, workItem);
results = GetKeyValuePairs(new(keyValuePairs), keepRelations);
return results;
}
private static void WriteFileStructure(string destinationDirectory, ReadOnlyDictionary<int, Record> keyValuePairs)
{
ReadOnlyCollection<string> collection = GetDirectories(destinationDirectory, keyValuePairs);
foreach (string directory in collection)
{
if (directory.Length > 222)
continue;
if (!Directory.Exists(directory))
_ = Directory.CreateDirectory(directory);
}
}
private static void WriteFiles(IFileRead fileRead, string destinationDirectory, List<FileInfo> fileInfoCollection, ReadOnlyDictionary<int, Record> keyValuePairs)
{
string old;
string json;
string checkFile;
WorkItem workItem;
string workItemType;
string singletonDirectory;
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileRead.ReportFullPath);
string rootDirectory = Path.Combine(destinationDirectory, fileNameWithoutExtension);
if (string.IsNullOrEmpty(rootDirectory))
throw new NullReferenceException(nameof(rootDirectory));
foreach (KeyValuePair<int, Record> keyValuePair in keyValuePairs)
{
workItem = keyValuePair.Value.WorkItem;
workItemType = workItem.WorkItemType.Replace(" ", "-");
json = JsonSerializer.Serialize(workItem, WorkItemSourceGenerationContext.Default.WorkItem);
singletonDirectory = Path.Combine(rootDirectory, workItemType, $"{workItem.Id}-{workItemType}", $"{workItem.Id}");
if (!Directory.Exists(singletonDirectory))
_ = Directory.CreateDirectory(singletonDirectory);
checkFile = Path.Combine(singletonDirectory, ".json");
old = File.Exists(checkFile) ? File.ReadAllText(checkFile) : string.Empty;
if (old == json)
continue;
File.WriteAllText(checkFile, json);
if (!fileRead.IsEAFHosted)
fileInfoCollection.Add(new(checkFile));
}
}
private static ReadOnlyDictionary<int, Record> GetKeyValuePairs(ReadOnlyDictionary<int, WorkItem> keyValuePairs, bool keepRelations)
{
Dictionary<int, Record> results = new();
Record record;
List<bool> nests = new();
WorkItem? parentWorkItem;
ReadOnlyCollection<Record> childRecords;
ReadOnlyCollection<Record> relatedRecords;
ReadOnlyCollection<Record> successorRecords;
foreach (KeyValuePair<int, WorkItem> keyValuePair in keyValuePairs)
{
nests.Clear();
if (keyValuePair.Value.Parent is null)
parentWorkItem = null;
else
_ = keyValuePairs.TryGetValue(keyValuePair.Value.Parent.Value, out parentWorkItem);
try
{
childRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Child", nests, keepRelations); // Forward
// records = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Predecessor", nests, keepRelations); // Reverse
relatedRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Related", nests, keepRelations); // Related
successorRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Successor", nests, keepRelations); // Forward
record = Record.Get(keyValuePair.Value, parentWorkItem, childRecords, relatedRecords, successorRecords, keepRelations);
}
catch (Exception)
{
record = new(keyValuePair.Value, parentWorkItem, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>());
}
results.Add(keyValuePair.Key, record);
}
return new(results);
}
private static ReadOnlyCollection<string> GetDirectories(string destinationDirectory, ReadOnlyDictionary<int, Record> keyValuePairs)
{
List<string> results = new();
Record record;
string directory;
List<bool> nests = new();
ReadOnlyCollection<string> childrenDirectories;
string dateDirectory = Path.Combine(destinationDirectory, "_", DateTime.Now.ToString("yyyy-MM-dd"));
foreach (KeyValuePair<int, Record> keyValuePair in keyValuePairs)
{
record = keyValuePair.Value;
if (record.Parent is not null && (record.WorkItem.Parent is null || record.Parent.Id != record.WorkItem.Parent.Value))
continue;
if (record.Parent is not null)
continue;
// if (record.WorkItem.Id == 110730)
// continue;
// if (record.WorkItem.Id == 110732)
// continue;
nests.Clear();
directory = Path.Combine(dateDirectory, $"{record.WorkItem.WorkItemType.Substring(0, 1)}-{record.WorkItem.Id}-{record.WorkItem.Title.Trim().Substring(0, 1)}");
childrenDirectories = GetChildrenDirectories(keyValuePairs, nests, directory, record);
results.AddRange(childrenDirectories);
}
return new(results.Distinct().ToArray());
}
private static string GetIndexLines(ReadOnlyCollection<string> frontMatterLines, Record record)
{
List<string> results = new();
results.Clear();
results.AddRange(frontMatterLines);
results.Add(string.Empty);
results.Add($"# {record.WorkItem.Id}");
results.Add(string.Empty);
results.Add("## Backlog");
results.Add(string.Empty);
results.Add("## Todo");
results.Add(string.Empty);
results.Add("## In Progress");
results.Add(string.Empty);
results.Add("## Done");
results.Add(string.Empty);
return string.Join(Environment.NewLine, results);
}
private static string GetMarkdownLines(string url, Record record, string jsonDirectory, string iterationPathDirectory)
{
List<string> results = new();
string link;
string target;
results.Add($"# {record.WorkItem.Id}");
results.Add(string.Empty);
results.Add($"## {record.WorkItem.Title}");
results.Add(string.Empty);
foreach (Record r in record.Children)
results.Add($"- [{r.WorkItem.Id}]({url}{r.WorkItem.Id})");
results.Add(string.Empty);
results.Add("```bash");
foreach (Record r in record.Children)
{
link = Path.Combine(jsonDirectory, $"{r.WorkItem.Id}-{r.WorkItem.WorkItemType}");
target = Path.Combine(iterationPathDirectory, r.WorkItem.WorkItemType, $"{r.WorkItem.Id}-{r.WorkItem.WorkItemType}", r.WorkItem.Id.ToString());
results.Add($"mklink /J \"{link}\" \"{target}\"");
}
results.Add("```");
results.Add(string.Empty);
return string.Join(Environment.NewLine, results);
}
private static ReadOnlyCollection<string> GetChildrenDirectories(ReadOnlyDictionary<int, Record> keyValuePairs, List<bool> nests, string parentDirectory, Record record)
{
List<string> results = new();
nests.Add(true);
string directory;
Record? childRecord;
ReadOnlyCollection<string> childrenDirectories;
foreach (Record r in record.Children)
{
// if (record.WorkItem.Id == 110730)
// continue;
// if (record.WorkItem.Id == 110732)
// continue;
directory = Path.Combine(parentDirectory, $"{r.WorkItem.WorkItemType.Substring(0, 1)}-{r.WorkItem.Id}-{r.WorkItem.Title.Trim().Substring(0, 1)}");
results.Add(directory);
if (!keyValuePairs.TryGetValue(r.WorkItem.Id, out childRecord))
continue;
if (nests.Count > 99)
break;
childrenDirectories = GetChildrenDirectories(keyValuePairs, nests, directory, childRecord);
results.AddRange(childrenDirectories);
}
return new(results);
}
}

View File

@ -115,10 +115,10 @@ public class FileRead : Shared.FileRead, IFileRead
} }
} }
#pragma warning disable IDE0060
private void MoveArchive(string reportFullPath, DateTime dateTime) private void MoveArchive(string reportFullPath, DateTime dateTime)
#pragma warning restore IDE0060
{ {
if (dateTime == DateTime.MinValue)
throw new ArgumentNullException(nameof(dateTime));
string logisticsSequence = _Logistics.Sequence.ToString(); string logisticsSequence = _Logistics.Sequence.ToString();
string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00"); string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
string weekDirectory = $"{_Logistics.DateTimeFromSequence:yyyy}_Week_{weekOfYear}{@"\"}{_Logistics.DateTimeFromSequence:yyyy-MM-dd}"; string weekDirectory = $"{_Logistics.DateTimeFromSequence:yyyy}_Week_{weekOfYear}{@"\"}{_Logistics.DateTimeFromSequence:yyyy-MM-dd}";

View File

@ -13,6 +13,7 @@ public class CellInstanceConnectionName
{ {
IFileRead result = cellInstanceConnectionName switch IFileRead result = cellInstanceConnectionName switch
{ {
nameof(ADO) => new ADO.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
nameof(APC) => new APC.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), nameof(APC) => new APC.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
nameof(Archive) => new Archive.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), nameof(Archive) => new Archive.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
nameof(DownloadWorkItems) => new DownloadWorkItems.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), nameof(DownloadWorkItems) => new DownloadWorkItems.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),

View File

@ -1,4 +1,5 @@
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation; using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
using Adaptation.FileHandlers.json.WIQL;
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration; using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
using Adaptation.Shared; using Adaptation.Shared;
using Adaptation.Shared.Duplicator; using Adaptation.Shared.Duplicator;
@ -148,12 +149,11 @@ public class FileRead : Shared.FileRead, IFileRead
streamTask.Wait(); streamTask.Wait();
if (!streamTask.Result.CanRead) if (!streamTask.Result.CanRead)
throw new NullReferenceException(nameof(streamTask)); throw new NullReferenceException(nameof(streamTask));
JsonSerializerOptions jsonSerializerOptions = new() { PropertyNameCaseInsensitive = true }; Root? root = JsonSerializer.Deserialize(streamTask.Result, RootSourceGenerationContext.Default.Root);
json.WIQL.Root? root = JsonSerializer.Deserialize<json.WIQL.Root>(streamTask.Result, jsonSerializerOptions);
streamTask.Result.Dispose(); streamTask.Result.Dispose();
if (root is null || root.WorkItems is null) if (root is null || root.WorkItems is null)
throw new NullReferenceException(nameof(root)); throw new NullReferenceException(nameof(root));
foreach (json.WIQL.WorkItem workItem in root.WorkItems) foreach (WorkItem workItem in root.WorkItems)
{ {
results.Add(workItem.Id); results.Add(workItem.Id);
if (results.Count > 199) if (results.Count > 199)

View File

@ -5,7 +5,6 @@ using Adaptation.Shared.Duplicator;
using Adaptation.Shared.Methods; using Adaptation.Shared.Methods;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO; using System.IO;
using System.Text.Json; using System.Text.Json;
@ -16,8 +15,6 @@ public class FileRead : Shared.FileRead, IFileRead
private long? _TickOffset; private long? _TickOffset;
private readonly string _URL; private readonly string _URL;
private readonly ReadOnlyCollection<string> _CSSLines;
private readonly ReadOnlyCollection<string> _FrontMatterLines;
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, Dictionary<long, List<string>> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, Dictionary<long, List<string>> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
@ -31,20 +28,8 @@ public class FileRead : Shared.FileRead, IFileRead
throw new Exception(cellInstanceConnectionName); throw new Exception(cellInstanceConnectionName);
if (!_IsDuplicator) if (!_IsDuplicator)
throw new Exception(cellInstanceConnectionName); throw new Exception(cellInstanceConnectionName);
List<string> cssLines = new();
string cellInstanceNamed = string.Concat("CellInstance.", _EquipmentType); string cellInstanceNamed = string.Concat("CellInstance.", _EquipmentType);
_URL = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, $"{cellInstanceNamed}.URL"); _URL = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, $"{cellInstanceNamed}.URL");
string cssLinesName = string.Concat("CellInstance.", cellInstanceName, '.', cellInstanceConnectionName, ".CSS.Lines");
ModelObjectParameterDefinition[] cssLinesDefinitions = GetProperties(cellInstanceConnectionName, modelObjectParameters, cssLinesName);
foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in cssLinesDefinitions)
cssLines.Add(modelObjectParameterDefinition.Value);
_CSSLines = new(cssLines);
List<string> FrontMatterLines = new();
string FrontMatterLinesName = string.Concat("CellInstance.", cellInstanceName, '.', cellInstanceConnectionName, ".Front.Matter.Lines");
ModelObjectParameterDefinition[] FrontMatterLinesDefinitions = GetProperties(cellInstanceConnectionName, modelObjectParameters, FrontMatterLinesName);
foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in FrontMatterLinesDefinitions)
FrontMatterLines.Add(modelObjectParameterDefinition.Value);
_FrontMatterLines = new(FrontMatterLines);
if (_IsEAFHosted) if (_IsEAFHosted)
NestExistingFiles(_FileConnectorConfiguration); NestExistingFiles(_FileConnectorConfiguration);
} }
@ -124,7 +109,7 @@ public class FileRead : Shared.FileRead, IFileRead
results.Item4.Add(_Logistics.FileInfo); results.Item4.Add(_Logistics.FileInfo);
else else
{ {
IProcessData iProcessData = new ProcessData(this, _Logistics, _FileConnectorConfiguration.TargetFileLocation, _URL, _CSSLines, _FrontMatterLines, results.Item4); IProcessData iProcessData = new ProcessData(this, _Logistics, _FileConnectorConfiguration.TargetFileLocation, _URL, results.Item4);
if (iProcessData.Details.Count == 0) if (iProcessData.Details.Count == 0)
throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks)); throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks));
results = iProcessData.GetResults(this, _Logistics, results.Item4); results = iProcessData.GetResults(this, _Logistics, results.Item4);

View File

@ -7,7 +7,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.IO; using System.IO;
using System.Linq;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@ -22,14 +21,16 @@ public class ProcessData : IProcessData
private readonly ILog _Log; private readonly ILog _Log;
public ProcessData(IFileRead fileRead, Logistics logistics, string targetFileLocation, string url, ReadOnlyCollection<string> cssLines, ReadOnlyCollection<string> frontMatterLines, List<FileInfo> fileInfoCollection) public ProcessData(IFileRead fileRead, Logistics logistics, string targetFileLocation, string url, List<FileInfo> fileInfoCollection)
{ {
if (fileRead.IsEAFHosted) if (fileRead.IsEAFHosted)
{ } { }
if (url is null)
throw new ArgumentNullException(nameof(url));
fileInfoCollection.Clear(); fileInfoCollection.Clear();
_Details = new List<object>(); _Details = new List<object>();
_Log = LogManager.GetLogger(typeof(ProcessData)); _Log = LogManager.GetLogger(typeof(ProcessData));
WriteFiles(fileRead, logistics, url, cssLines, frontMatterLines, targetFileLocation, fileInfoCollection); WriteFiles(fileRead, logistics, targetFileLocation, fileInfoCollection);
} }
string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) => string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) =>
@ -57,147 +58,101 @@ public class ProcessData : IProcessData
return results; return results;
} }
private void WriteFiles(IFileRead fileRead, Logistics logistics, string url, ReadOnlyCollection<string> cssLines, ReadOnlyCollection<string> frontMatterLines, string destinationDirectory, List<FileInfo> fileInfoCollection) private void WriteFiles(IFileRead fileRead, Logistics logistics, string destinationDirectory, List<FileInfo> fileInfoCollection)
{ {
if (!Directory.Exists(destinationDirectory)) bool keepRelations = true;
_ = Directory.CreateDirectory(destinationDirectory); const string taskWorkItemType = "Task";
string json = File.ReadAllText(logistics.ReportFullPath); string json = File.ReadAllText(logistics.ReportFullPath);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(logistics.ReportFullPath);
WorkItem[]? workItems = JsonSerializer.Deserialize<WorkItem[]>(json); WorkItem[]? workItems = JsonSerializer.Deserialize<WorkItem[]>(json);
if (workItems is null) if (workItems is null)
throw new Exception(nameof(workItems)); throw new Exception(nameof(workItems));
_Details.Add(workItems); _Details.Add(workItems);
ReadOnlyDictionary<int, Record> keyValuePairs = GetWorkItems(workItems); if (!Directory.Exists(destinationDirectory))
WriteFileStructure(destinationDirectory, keyValuePairs); _ = Directory.CreateDirectory(destinationDirectory);
WriteFiles(fileRead, destinationDirectory, fileInfoCollection, fileNameWithoutExtension, keyValuePairs); ReadOnlyDictionary<int, Record> keyValuePairs = GetWorkItems(workItems, keepRelations);
WriteKanbanFiles(fileRead, url, cssLines, frontMatterLines, fileInfoCollection, destinationDirectory, keyValuePairs); ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes = new(new string[] { "Bug", "User Story", "Task" });
ReadOnlyDictionary<int, string> collection = MoveCurrentAndGetExpectedDirectories(taskWorkItemType, destinationDirectory, bugUserStoryTaskWorkItemTypes, keyValuePairs);
WriteFiles(fileRead, fileInfoCollection, taskWorkItemType, destinationDirectory, keyValuePairs, collection);
} }
private static ReadOnlyDictionary<int, Record> GetWorkItems(WorkItem[] workItems) private static ReadOnlyDictionary<int, Record> GetWorkItems(WorkItem[] workItems, bool keepRelations)
{ {
ReadOnlyDictionary<int, Record> results; ReadOnlyDictionary<int, Record> results;
Dictionary<int, WorkItem> keyValuePairs = new(); Dictionary<int, WorkItem> keyValuePairs = new();
foreach (WorkItem workItem in workItems) foreach (WorkItem workItem in workItems)
keyValuePairs.Add(workItem.Id, workItem); keyValuePairs.Add(workItem.Id, workItem);
results = GetKeyValuePairs(new(keyValuePairs)); results = GetKeyValuePairs(new(keyValuePairs), keepRelations);
return results; return results;
} }
private static void WriteFileStructure(string destinationDirectory, ReadOnlyDictionary<int, Record> keyValuePairs) private static ReadOnlyDictionary<int, string> MoveCurrentAndGetExpectedDirectories(string taskWorkItemType, string destinationDirectory, ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes, ReadOnlyDictionary<int, Record> keyValuePairs)
{ {
ReadOnlyCollection<string> collection = GetDirectories(destinationDirectory, keyValuePairs); ReadOnlyDictionary<int, string> results;
foreach (string directory in collection) string? directory;
ReadOnlyDictionary<int, string> collection = GetCurrentDirectories(destinationDirectory, bugUserStoryTaskWorkItemTypes);
results = GetExpectedDirectories(taskWorkItemType, destinationDirectory, bugUserStoryTaskWorkItemTypes, keyValuePairs);
foreach (KeyValuePair<int, string> keyValuePair in collection)
{ {
if (directory.Length > 222) if (!results.TryGetValue(keyValuePair.Key, out directory))
continue; MoveToUnknown(destinationDirectory, keyValuePair.Key, keyValuePair.Value);
if (!Directory.Exists(directory)) else
_ = Directory.CreateDirectory(directory); {
if (keyValuePair.Value == directory)
continue;
else
MoveToNew(destinationDirectory, keyValuePair.Key, keyValuePair.Value, directory);
}
} }
return results;
} }
private static void WriteFiles(IFileRead fileRead, string destinationDirectory, List<FileInfo> fileInfoCollection, string fileNameWithoutExtension, ReadOnlyDictionary<int, Record> keyValuePairs) private static FileInfo GetFileInfoAndMaybeWriteFile(string directory, WorkItem workItem)
{ {
string old; FileInfo result;
string json; string json;
string checkFile; json = JsonSerializer.Serialize(workItem, WorkItemSourceGenerationContext.Default.WorkItem);
string singletonDirectory = Path.Combine(directory, $"{workItem.Id}");
if (!Directory.Exists(singletonDirectory))
_ = Directory.CreateDirectory(singletonDirectory);
result = new(Path.Combine(singletonDirectory, ".json"));
string old = result.Exists ? File.ReadAllText(result.FullName) : string.Empty;
if (old != json)
File.WriteAllText(result.FullName, json);
return result;
}
private static void WriteFiles(IFileRead fileRead, List<FileInfo> fileInfoCollection, string taskWorkItemType, string destinationDirectory, ReadOnlyDictionary<int, Record> keyValuePairs, ReadOnlyDictionary<int, string> collection)
{
string? directory;
FileInfo fileInfo;
WorkItem workItem; WorkItem workItem;
string singletonDirectory; Record? parent;
JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
string rootDirectory = Path.Combine(destinationDirectory, fileNameWithoutExtension);
if (string.IsNullOrEmpty(rootDirectory))
throw new NullReferenceException(nameof(rootDirectory));
foreach (KeyValuePair<int, Record> keyValuePair in keyValuePairs) foreach (KeyValuePair<int, Record> keyValuePair in keyValuePairs)
{ {
workItem = keyValuePair.Value.WorkItem; workItem = keyValuePair.Value.WorkItem;
json = JsonSerializer.Serialize(workItem, jsonSerializerOptions); if (!collection.TryGetValue(keyValuePair.Key, out directory))
singletonDirectory = Path.Combine(rootDirectory, workItem.WorkItemType.Replace(" ", "-"), $"{workItem.Id}-{workItem.WorkItemType.Replace(" ", "-")}");
if (!Directory.Exists(singletonDirectory))
_ = Directory.CreateDirectory(singletonDirectory);
checkFile = Path.Combine(singletonDirectory, ".json");
if (File.Exists(checkFile))
{ {
old = File.ReadAllText(checkFile); if (workItem.WorkItemType != taskWorkItemType || workItem.Parent is not null)
if (old == json)
continue; continue;
directory = GetDirectory(destinationDirectory, workItem);
} }
File.WriteAllText(checkFile, json); fileInfo = GetFileInfoAndMaybeWriteFile(directory, workItem);
if (!fileRead.IsEAFHosted) if (!fileRead.IsEAFHosted)
fileInfoCollection.Add(new(checkFile)); fileInfoCollection.Add(fileInfo);
} if (workItem.WorkItemType != taskWorkItemType && workItem.Parent is not null && keyValuePairs.TryGetValue(workItem.Parent.Value, out parent))
_ = GetFileInfoAndMaybeWriteFile(Path.Combine(directory, ".parent"), parent.WorkItem);
}
private static void WriteKanbanFiles(IFileRead fileRead, string url, ReadOnlyCollection<string> cssLines, ReadOnlyCollection<string> frontMatterLines, List<FileInfo> fileInfoCollection, string destinationDirectory, ReadOnlyDictionary<int, Record> keyValuePairs)
{
string old;
string json;
Record record;
string markdown;
string checkFile;
string jsonDirectory;
string tasksDirectory;
string kanbanDirectory;
string vscodeDirectory;
string[] iterationPaths;
string singletonDirectory;
string iterationPathDirectory;
JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
foreach (KeyValuePair<int, Record> keyValuePair in keyValuePairs)
{
record = keyValuePair.Value;
iterationPathDirectory = destinationDirectory;
iterationPaths = record.WorkItem.IterationPath.Split('\\');
json = JsonSerializer.Serialize(record, jsonSerializerOptions);
foreach (string iterationPath in iterationPaths)
{
if (iterationPath.Contains("Sprint"))
continue;
iterationPathDirectory = Path.Combine(iterationPathDirectory, iterationPath);
}
singletonDirectory = Path.Combine(iterationPathDirectory, record.WorkItem.WorkItemType.Replace(" ", "-"), $"{record.WorkItem.Id}-{record.WorkItem.WorkItemType.Replace(" ", "-")}");
kanbanDirectory = Path.Combine(singletonDirectory, ".kanbn");
if (!Directory.Exists(kanbanDirectory))
_ = Directory.CreateDirectory(kanbanDirectory);
tasksDirectory = Path.Combine(kanbanDirectory, "tasks");
if (!Directory.Exists(tasksDirectory))
_ = Directory.CreateDirectory(tasksDirectory);
vscodeDirectory = Path.Combine(singletonDirectory, ".vscode");
if (!Directory.Exists(vscodeDirectory))
_ = Directory.CreateDirectory(vscodeDirectory);
jsonDirectory = Path.Combine(singletonDirectory, record.WorkItem.Id.ToString());
if (!Directory.Exists(jsonDirectory))
_ = Directory.CreateDirectory(jsonDirectory);
checkFile = Path.Combine(vscodeDirectory, "settings.json");
if (!File.Exists(checkFile))
File.WriteAllText(checkFile, "{ \"[markdown]\": { \"editor.wordWrap\": \"off\" }, \"cSpell.words\": [ \"kanbn\" ] }");
markdown = GetIndexLines(frontMatterLines, record);
checkFile = Path.Combine(kanbanDirectory, "board.css");
if (!File.Exists(checkFile))
File.WriteAllLines(checkFile, cssLines);
checkFile = Path.Combine(kanbanDirectory, "index.md");
if (!File.Exists(checkFile))
File.WriteAllText(checkFile, markdown);
checkFile = Path.Combine(jsonDirectory, ".json");
old = File.Exists(checkFile) ? File.ReadAllText(checkFile) : string.Empty;
if (old != json)
File.WriteAllText(checkFile, json);
markdown = GetMarkdownLines(url, record, jsonDirectory, iterationPathDirectory);
checkFile = Path.Combine(vscodeDirectory, "markdown.md");
old = File.Exists(checkFile) ? File.ReadAllText(checkFile) : string.Empty;
if (old != markdown)
File.WriteAllText(checkFile, markdown);
if (!fileRead.IsEAFHosted)
fileInfoCollection.Add(new(checkFile));
} }
} }
private static ReadOnlyDictionary<int, Record> GetKeyValuePairs(ReadOnlyDictionary<int, WorkItem> keyValuePairs) private static ReadOnlyDictionary<int, Record> GetKeyValuePairs(ReadOnlyDictionary<int, WorkItem> keyValuePairs, bool keepRelations)
{ {
Dictionary<int, Record> results = new(); Dictionary<int, Record> results = new();
Record record; Record record;
List<bool> nests = new(); List<bool> nests = new();
WorkItem? parentWorkItem; WorkItem? parentWorkItem;
ReadOnlyCollection<Record> records; ReadOnlyCollection<Record> childRecords;
ReadOnlyCollection<Record> relatedRecords;
ReadOnlyCollection<Record> successorRecords;
foreach (KeyValuePair<int, WorkItem> keyValuePair in keyValuePairs) foreach (KeyValuePair<int, WorkItem> keyValuePair in keyValuePairs)
{ {
nests.Clear(); nests.Clear();
@ -207,166 +162,111 @@ public class ProcessData : IProcessData
_ = keyValuePairs.TryGetValue(keyValuePair.Value.Parent.Value, out parentWorkItem); _ = keyValuePairs.TryGetValue(keyValuePair.Value.Parent.Value, out parentWorkItem);
try try
{ {
records = GetKeyValuePairs(keyValuePairs, keyValuePair.Value, nests); childRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Child", nests, keepRelations); // Forward
record = Record.Get(keyValuePair.Value, parentWorkItem, records); // records = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Predecessor", nests, keepRelations); // Reverse
relatedRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Related", nests, keepRelations); // Related
successorRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Successor", nests, keepRelations); // Forward
record = Record.Get(keyValuePair.Value, parentWorkItem, childRecords, relatedRecords, successorRecords, keepRelations);
} }
catch (Exception) catch (Exception)
{ {
record = new(keyValuePair.Value, parentWorkItem, Array.Empty<Record>()); record = new(keyValuePair.Value, parentWorkItem, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>());
} }
results.Add(keyValuePair.Key, record); results.Add(keyValuePair.Key, record);
} }
return new(results); return new(results);
} }
private static ReadOnlyCollection<string> GetDirectories(string destinationDirectory, ReadOnlyDictionary<int, Record> keyValuePairs) private static ReadOnlyDictionary<int, string> GetCurrentDirectories(string destinationDirectory, ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes)
{ {
List<string> results = new(); Dictionary<int, string> results = new();
Record record; int id;
string idCheck;
string? fileName;
string[] directories;
string[] split = new string[] { "-" };
foreach (string w in bugUserStoryTaskWorkItemTypes)
{
directories = Directory.GetDirectories(destinationDirectory, $"*-{w.Replace(" ", "-")}", SearchOption.AllDirectories);
foreach (string directory in directories)
{
fileName = Path.GetFileName(directory);
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 ReadOnlyDictionary<int, string> GetExpectedDirectories(string taskWorkItemType, string destinationDirectory, ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes, ReadOnlyDictionary<int, Record> keyValuePairs)
{
Dictionary<int, string> results = new();
string directory; string directory;
List<bool> nests = new(); WorkItem workItem;
ReadOnlyCollection<string> childrenDirectories;
string dateDirectory = Path.Combine(destinationDirectory, "_", DateTime.Now.ToString("yyyy-MM-dd"));
foreach (KeyValuePair<int, Record> keyValuePair in keyValuePairs) foreach (KeyValuePair<int, Record> keyValuePair in keyValuePairs)
{ {
record = keyValuePair.Value; workItem = keyValuePair.Value.WorkItem;
if (record.Parent is not null && (record.WorkItem.Parent is null || record.Parent.Id != record.WorkItem.Parent.Value)) if (!bugUserStoryTaskWorkItemTypes.Contains(workItem.WorkItemType))
continue; continue;
if (record.Parent is not null) if (workItem.WorkItemType == taskWorkItemType && workItem.Parent is not null)
continue; continue;
// if (record.WorkItem.Id == 110730) directory = GetDirectory(destinationDirectory, workItem);
// continue; results.Add(workItem.Id, directory);
// if (record.WorkItem.Id == 110732)
// continue;
nests.Clear();
directory = Path.Combine(dateDirectory, $"{record.WorkItem.WorkItemType.Substring(0, 1)}-{record.WorkItem.Id}-{record.WorkItem.Title.Trim().Substring(0, 1)}");
childrenDirectories = GetChildrenDirectories(keyValuePairs, nests, directory, record);
results.AddRange(childrenDirectories);
}
return new(results.Distinct().ToArray());
}
private static string GetIndexLines(ReadOnlyCollection<string> frontMatterLines, Record record)
{
List<string> results = new();
results.Clear();
results.AddRange(frontMatterLines);
results.Add(string.Empty);
results.Add($"# {record.WorkItem.Id}");
results.Add(string.Empty);
results.Add("## Backlog");
results.Add(string.Empty);
results.Add("## Todo");
results.Add(string.Empty);
results.Add("## In Progress");
results.Add(string.Empty);
results.Add("## Done");
results.Add(string.Empty);
return string.Join(Environment.NewLine, results);
}
private static string GetMarkdownLines(string url, Record record, string jsonDirectory, string iterationPathDirectory)
{
List<string> results = new();
string link;
string target;
results.Add($"# {record.WorkItem.Id}");
results.Add(string.Empty);
results.Add($"## {record.WorkItem.Title}");
results.Add(string.Empty);
foreach (Record r in record.Children)
results.Add($"- [{r.WorkItem.Id}]({url}{r.WorkItem.Id})");
results.Add(string.Empty);
results.Add("```bash");
foreach (Record r in record.Children)
{
link = Path.Combine(jsonDirectory, $"{r.WorkItem.Id}-{r.WorkItem.WorkItemType}");
target = Path.Combine(iterationPathDirectory, r.WorkItem.WorkItemType, $"{r.WorkItem.Id}-{r.WorkItem.WorkItemType}", r.WorkItem.Id.ToString());
results.Add($"mklink /J \"{link}\" \"{target}\"");
}
results.Add("```");
results.Add(string.Empty);
return string.Join(Environment.NewLine, results);
}
private static ReadOnlyCollection<Record> GetKeyValuePairs(ReadOnlyDictionary<int, WorkItem> keyValuePairs, WorkItem workItem, List<bool> nests)
{
List<Record> results = new();
int? childId;
Record record;
nests.Add(true);
WorkItem? childWorkItem;
WorkItem? parentWorkItem;
List<WorkItem> collection = new();
ReadOnlyCollection<Record> records;
if (workItem.Relations is not null && workItem.Relations.Length > 0)
{
collection.Clear();
foreach (Relation relation in workItem.Relations)
{
childId = GetIdFromUrlIfChild(relation);
if (childId is not null && workItem.Parent is not null && relation?.URL is not null && relation.URL.Contains(workItem.Parent.Value.ToString()))
continue;
if (childId is null || !keyValuePairs.TryGetValue(childId.Value, out childWorkItem))
continue;
collection.Add(childWorkItem);
}
collection = (from l in collection orderby l.State != "Closed", l.Id select l).ToList();
foreach (WorkItem w in collection)
{
if (nests.Count > 99)
break;
if (w.Parent is null)
parentWorkItem = null;
else
_ = keyValuePairs.TryGetValue(w.Parent.Value, out parentWorkItem);
records = GetKeyValuePairs(keyValuePairs, w, nests);
record = Record.Get(w, parentWorkItem, records);
results.Add(record);
}
} }
return new(results); return new(results);
} }
private static ReadOnlyCollection<string> GetChildrenDirectories(ReadOnlyDictionary<int, Record> keyValuePairs, List<bool> nests, string parentDirectory, Record record) private static void MoveToUnknown(string destinationDirectory, int id, string directory)
{ {
List<string> results = new(); if (string.IsNullOrEmpty(destinationDirectory))
nests.Add(true); throw new ArgumentException($"'{nameof(destinationDirectory)}' {id} cannot be null or empty.", nameof(destinationDirectory));
string directory; if (string.IsNullOrEmpty(directory))
Record? childRecord; throw new ArgumentException($"'{nameof(directory)}' cannot be null or empty.", nameof(directory));
ReadOnlyCollection<string> childrenDirectories;
foreach (Record r in record.Children)
{
// if (record.WorkItem.Id == 110730)
// continue;
// if (record.WorkItem.Id == 110732)
// continue;
directory = Path.Combine(parentDirectory, $"{r.WorkItem.WorkItemType.Substring(0, 1)}-{r.WorkItem.Id}-{r.WorkItem.Title.Trim().Substring(0, 1)}");
results.Add(directory);
if (!keyValuePairs.TryGetValue(r.WorkItem.Id, out childRecord))
continue;
if (nests.Count > 99)
break;
childrenDirectories = GetChildrenDirectories(keyValuePairs, nests, directory, childRecord);
results.AddRange(childrenDirectories);
}
return new(results);
} }
private static int? GetIdFromUrlIfChild(Relation relation) private static void MoveToNew(string destinationDirectory, int id, string oldDirectory, string newDirectory)
{ {
int? result; if (Directory.Exists(newDirectory))
string[] segments = relation?.Attributes is null || relation.Attributes.Name != "Child" ? Array.Empty<string>() : relation.URL.Split('/'); MoveToDuplicate(destinationDirectory, id, oldDirectory);
if (segments.Length < 2)
result = null;
else else
{ {
if (!int.TryParse(segments[segments.Length - 1], out int id)) string directory = Path.GetDirectoryName(newDirectory) ?? throw new NotImplementedException();
result = null; if (!Directory.Exists(directory))
else _ = Directory.CreateDirectory(directory);
result = id; Directory.Move(oldDirectory, newDirectory);
} }
}
private static string GetDirectory(string destinationDirectory, WorkItem workItem)
{
string result;
string workItemType = workItem.WorkItemType.Replace(" ", "-");
string iterationPath = workItem.IterationPath.Replace(" ", "-");
result = Path.Combine(destinationDirectory, iterationPath, $"{workItem.Id}-{workItemType}");
return result; return result;
} }
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 void MoveToDuplicate(string destinationDirectory, int id, string oldDirectory)
{
if (string.IsNullOrEmpty(destinationDirectory))
throw new ArgumentException($"'{nameof(destinationDirectory)}' {id} cannot be null or empty.", nameof(destinationDirectory));
if (string.IsNullOrEmpty(oldDirectory))
throw new ArgumentException($"'{nameof(oldDirectory)}' cannot be null or empty.", nameof(oldDirectory));
}
} }

View File

@ -79,10 +79,12 @@ public class ProcessData : IProcessData
workItems.Add(workItem); workItems.Add(workItem);
} }
List<char> spaces = new(); List<char> spaces = new();
bool keepRelations = false;
List<string> lines = new(); List<string> lines = new();
ReadOnlyCollection<Record> results; ReadOnlyCollection<Record> results;
ReadOnlyDictionary<int, Record> keyValuePairs = GetWorkItems(workItems); ReadOnlyDictionary<int, Record> keyValuePairs = GetWorkItems(workItems, keepRelations);
ReadOnlyCollection<Record> records = new(keyValuePairs.Values.ToArray()); ReadOnlyCollection<Record> records = new(keyValuePairs.Values.ToArray());
WriteFile(fileRead, destinationDirectory, fileInfoCollection, records, "records");
ReadOnlyCollection<string> bugFeatureWorkItemTypes = new(new string[] { "Bug", "Feature" }); ReadOnlyCollection<string> bugFeatureWorkItemTypes = new(new string[] { "Bug", "Feature" });
ReadOnlyCollection<string> bugUserStoryWorkItemTypes = new(new string[] { "Bug", "User Story" }); ReadOnlyCollection<string> bugUserStoryWorkItemTypes = new(new string[] { "Bug", "User Story" });
ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes = new(new string[] { "Bug", "User Story", "Task" }); ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes = new(new string[] { "Bug", "User Story", "Task" });
@ -179,16 +181,27 @@ public class ProcessData : IProcessData
fileInfoCollection.Add(new(jsonFile)); fileInfoCollection.Add(new(jsonFile));
} }
private static ReadOnlyDictionary<int, Record> GetWorkItems(IEnumerable<WorkItem> workItems) private static ReadOnlyDictionary<int, Record> GetWorkItems(IEnumerable<WorkItem> workItems, bool keepRelations)
{ {
ReadOnlyDictionary<int, Record> results; ReadOnlyDictionary<int, Record> results;
Dictionary<int, WorkItem> keyValuePairs = new(); Dictionary<int, WorkItem> keyValuePairs = new();
foreach (WorkItem workItem in workItems) foreach (WorkItem workItem in workItems)
keyValuePairs.Add(workItem.Id, workItem); keyValuePairs.Add(workItem.Id, workItem);
results = GetKeyValuePairs(new(keyValuePairs)); results = GetKeyValuePairs(new(keyValuePairs), keepRelations);
return results; return results;
} }
private static void WriteFile(IFileRead fileRead, string destinationDirectory, List<FileInfo> fileInfoCollection, ReadOnlyCollection<Record> records, string fileName)
{
string json = JsonSerializer.Serialize(records, new JsonSerializerOptions() { WriteIndented = true });
string jsonFile = Path.Combine(destinationDirectory, $"{fileName}.json");
string jsonOld = !File.Exists(jsonFile) ? string.Empty : File.ReadAllText(jsonFile);
if (json != jsonOld)
File.WriteAllText(jsonFile, json);
if (!fileRead.IsEAFHosted)
fileInfoCollection.Add(new(jsonFile));
}
private static void WriteWithPartentsFile(IFileRead fileRead, string destinationDirectory, List<FileInfo> fileInfoCollection, ReadOnlyCollection<Record> records, ReadOnlyCollection<string> workItemTypes, string fileName) private static void WriteWithPartentsFile(IFileRead fileRead, string destinationDirectory, List<FileInfo> fileInfoCollection, ReadOnlyCollection<Record> records, ReadOnlyCollection<string> workItemTypes, string fileName)
{ {
List<Record> filtered = new(); List<Record> filtered = new();
@ -197,7 +210,7 @@ public class ProcessData : IProcessData
{ {
if (r.WorkItem.State == "Removed" || !workItemTypes.Contains(r.WorkItem.WorkItemType)) if (r.WorkItem.State == "Removed" || !workItemTypes.Contains(r.WorkItem.WorkItemType))
continue; continue;
record = new(r.WorkItem, r.Parent, Array.Empty<Record>()); record = new(r.WorkItem, r.Parent, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>());
filtered.Add(record); filtered.Add(record);
} }
string json = JsonSerializer.Serialize(filtered, new JsonSerializerOptions() { WriteIndented = true }); string json = JsonSerializer.Serialize(filtered, new JsonSerializerOptions() { WriteIndented = true });
@ -272,13 +285,15 @@ public class ProcessData : IProcessData
spaces.RemoveAt(0); spaces.RemoveAt(0);
} }
private static ReadOnlyDictionary<int, Record> GetKeyValuePairs(ReadOnlyDictionary<int, WorkItem> keyValuePairs) private static ReadOnlyDictionary<int, Record> GetKeyValuePairs(ReadOnlyDictionary<int, WorkItem> keyValuePairs, bool keepRelations)
{ {
Dictionary<int, Record> results = new(); Dictionary<int, Record> results = new();
Record record; Record record;
List<bool> nests = new(); List<bool> nests = new();
WorkItem? parentWorkItem; WorkItem? parentWorkItem;
ReadOnlyCollection<Record> records; ReadOnlyCollection<Record> childRecords;
ReadOnlyCollection<Record> relatedRecords;
ReadOnlyCollection<Record> successorRecords;
foreach (KeyValuePair<int, WorkItem> keyValuePair in keyValuePairs) foreach (KeyValuePair<int, WorkItem> keyValuePair in keyValuePairs)
{ {
nests.Clear(); nests.Clear();
@ -288,12 +303,15 @@ public class ProcessData : IProcessData
_ = keyValuePairs.TryGetValue(keyValuePair.Value.Parent.Value, out parentWorkItem); _ = keyValuePairs.TryGetValue(keyValuePair.Value.Parent.Value, out parentWorkItem);
try try
{ {
records = GetKeyValuePairs(keyValuePairs, keyValuePair.Value, nests); childRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Child", nests, keepRelations); // Forward
record = Record.Get(keyValuePair.Value, parentWorkItem, records); // records = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Predecessor", nests, keepRelations); // Reverse
relatedRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Related", nests, keepRelations); // Related
successorRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Successor", nests, keepRelations); // Forward
record = Record.Get(keyValuePair.Value, parentWorkItem, childRecords, relatedRecords, successorRecords, keepRelations);
} }
catch (Exception) catch (Exception)
{ {
record = new(keyValuePair.Value, parentWorkItem, Array.Empty<Record>()); record = new(keyValuePair.Value, parentWorkItem, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>());
} }
results.Add(keyValuePair.Key, record); results.Add(keyValuePair.Key, record);
} }
@ -310,89 +328,9 @@ public class ProcessData : IProcessData
return result; return result;
} }
private static ReadOnlyCollection<Record> GetKeyValuePairs(ReadOnlyDictionary<int, WorkItem> keyValuePairs, WorkItem workItem, List<bool> nests)
{
List<Record> results = new();
int? childId;
Record record;
nests.Add(true);
WorkItem? childWorkItem;
WorkItem? parentWorkItem;
List<WorkItem> collection = new();
ReadOnlyCollection<Record> records;
if (workItem.Relations is not null && workItem.Relations.Length > 0)
{
collection.Clear();
foreach (Relation relation in workItem.Relations)
{
childId = GetIdFromUrlIfChild(relation);
if (childId is not null && workItem.Parent is not null && relation?.URL is not null && relation.URL.Contains(workItem.Parent.Value.ToString()))
continue;
if (childId is null || !keyValuePairs.TryGetValue(childId.Value, out childWorkItem))
continue;
collection.Add(childWorkItem);
}
collection = (from l in collection orderby l.State != "Closed", l.Id select l).ToList();
foreach (WorkItem w in collection)
{
if (nests.Count > 99)
break;
if (w.Parent is null)
parentWorkItem = null;
else
_ = keyValuePairs.TryGetValue(w.Parent.Value, out parentWorkItem);
records = GetKeyValuePairs(keyValuePairs, w, nests);
record = Record.Get(w, parentWorkItem, records);
results.Add(record);
}
}
return new(results);
}
private static string GetClosed(WorkItem workItem) => private static string GetClosed(WorkItem workItem) =>
workItem.State != "Closed" ? "[ ]" : "[x]"; workItem.State != "Closed" ? "[ ]" : "[x]";
private static int? GetIdFromUrlIfChild(Relation relation)
{
int? result;
string[] segments = relation?.Attributes is null || relation.Attributes.Name != "Child" ? Array.Empty<string>() : relation.URL.Split('/');
if (segments.Length < 2)
result = null;
else
{
if (!int.TryParse(segments[segments.Length - 1], out int id))
result = null;
else
result = id;
}
return result;
}
private static ReadOnlyCollection<string> GetChildrenDirectories(ReadOnlyDictionary<int, Record> keyValuePairs, List<bool> nests, string parentDirectory, Record record)
{
List<string> results = new();
nests.Add(true);
string directory;
Record? childRecord;
ReadOnlyCollection<string> childrenDirectories;
foreach (Record r in record.Children)
{
// if (record.WorkItem.Id == 110730)
// continue;
// if (record.WorkItem.Id == 110732)
// continue;
directory = Path.Combine(parentDirectory, $"{r.WorkItem.WorkItemType.Substring(0, 1)}-{r.WorkItem.Id}-{r.WorkItem.Title.Trim().Substring(0, 1)}");
results.Add(directory);
if (!keyValuePairs.TryGetValue(r.WorkItem.Id, out childRecord))
continue;
if (nests.Count > 99)
break;
childrenDirectories = GetChildrenDirectories(keyValuePairs, nests, directory, childRecord);
results.AddRange(childrenDirectories);
}
return new(results);
}
private static void FilterChildren(ReadOnlyCollection<string> workItemTypes, Record record, List<Record> results) private static void FilterChildren(ReadOnlyCollection<string> workItemTypes, Record record, List<Record> results)
{ {
foreach (Record r in record.Children) foreach (Record r in record.Children)
@ -462,7 +400,7 @@ public class ProcessData : IProcessData
collection.Add($"- [ ] [{record.WorkItem.Id}]({url}{record.WorkItem.Id}) => {record.WorkItem.IterationPath} != {maxIterationPath}"); collection.Add($"- [ ] [{record.WorkItem.Id}]({url}{record.WorkItem.Id}) => {record.WorkItem.IterationPath} != {maxIterationPath}");
collection.Add(string.Empty); collection.Add(string.Empty);
lines.AddRange(collection); lines.AddRange(collection);
results.Add(WorkItem.Get(record, $"IterationPath:<a target='_blank' href='{url}{record.WorkItem.Id}'>{record.WorkItem.Id}</a>;{record.WorkItem.IterationPath} != {maxIterationPath}")); results.Add(Record.GetWithoutNesting(record, $"IterationPath:<a target='_blank' href='{url}{record.WorkItem.Id}'>{record.WorkItem.Id}</a>;{record.WorkItem.IterationPath} != {maxIterationPath}"));
} }
return new(results); return new(results);
} }
@ -519,7 +457,7 @@ public class ProcessData : IProcessData
violations.Add($"Tag:{record.WorkItem.Tags};"); violations.Add($"Tag:{record.WorkItem.Tags};");
foreach (Record r in recordsNotMatching) foreach (Record r in recordsNotMatching)
violations.Add($"<a target='_blank' href='{url}{r.WorkItem.Id}'>{r.WorkItem.Id}</a>:{r.WorkItem.Tags};"); violations.Add($"<a target='_blank' href='{url}{r.WorkItem.Id}'>{r.WorkItem.Id}</a>:{r.WorkItem.Tags};");
results.Add(WorkItem.Get(record, string.Join(" ", violations))); results.Add(Record.GetWithoutNesting(record, string.Join(" ", violations)));
} }
return new(results); return new(results);
} }
@ -574,7 +512,7 @@ public class ProcessData : IProcessData
violations.Add($"Priority:{record.WorkItem.Priority};"); violations.Add($"Priority:{record.WorkItem.Priority};");
foreach (Record r in recordsNotMatching) foreach (Record r in recordsNotMatching)
violations.Add($"<a target='_blank' href='{url}{r.WorkItem.Id}'>{r.WorkItem.Id}</a>:{r.WorkItem.Priority};"); violations.Add($"<a target='_blank' href='{url}{r.WorkItem.Id}'>{r.WorkItem.Id}</a>:{r.WorkItem.Priority};");
results.Add(WorkItem.Get(record, string.Join(" ", violations))); results.Add(Record.GetWithoutNesting(record, string.Join(" ", violations)));
} }
return new(results); return new(results);
} }
@ -706,7 +644,7 @@ public class ProcessData : IProcessData
violations.Add($"State:{record.WorkItem.State};"); violations.Add($"State:{record.WorkItem.State};");
foreach (Record r in recordsNotMatching) foreach (Record r in recordsNotMatching)
violations.Add($"<a target='_blank' href='{url}{r.WorkItem.Id}'>{r.WorkItem.Id}</a>:{r.WorkItem.State};"); violations.Add($"<a target='_blank' href='{url}{r.WorkItem.Id}'>{r.WorkItem.Id}</a>:{r.WorkItem.State};");
results.Add(WorkItem.Get(record, string.Join(" ", violations))); results.Add(Record.GetWithoutNesting(record, string.Join(" ", violations)));
} }
return new(results); return new(results);
} }
@ -744,7 +682,7 @@ public class ProcessData : IProcessData
violations.Add($"State:{record.WorkItem.State};"); violations.Add($"State:{record.WorkItem.State};");
foreach (Record r in recordsNotMatching) foreach (Record r in recordsNotMatching)
violations.Add($"<a target='_blank' href='{url}{r.WorkItem.Id}'>{r.WorkItem.Id}</a>:{r.WorkItem.State};"); violations.Add($"<a target='_blank' href='{url}{r.WorkItem.Id}'>{r.WorkItem.Id}</a>:{r.WorkItem.State};");
results.Add(WorkItem.Get(record, string.Join(" ", violations))); results.Add(Record.GetWithoutNesting(record, string.Join(" ", violations)));
} }
return new(results); return new(results);
} }
@ -784,7 +722,7 @@ public class ProcessData : IProcessData
violations.Add($"StartDate:{record.WorkItem.StartDate};"); violations.Add($"StartDate:{record.WorkItem.StartDate};");
foreach (Record r in recordsNotMatching) foreach (Record r in recordsNotMatching)
violations.Add($"<a target='_blank' href='{url}{r.WorkItem.Id}'>{r.WorkItem.Id}</a>:{r.WorkItem.ActivatedDate};"); violations.Add($"<a target='_blank' href='{url}{r.WorkItem.Id}'>{r.WorkItem.Id}</a>:{r.WorkItem.ActivatedDate};");
results.Add(WorkItem.Get(record, string.Join(" ", violations))); results.Add(Record.GetWithoutNesting(record, string.Join(" ", violations)));
} }
return new(results); return new(results);
} }

View File

@ -103,10 +103,16 @@ public class FileRead : Shared.FileRead, IFileRead
return results; return results;
} }
#pragma warning disable IDE0060
private static void SaveOpenInsightFile(string reportFullPath, DateTime dateTime, List<Description> descriptions, Test[] tests) private static void SaveOpenInsightFile(string reportFullPath, DateTime dateTime, List<Description> descriptions, Test[] tests)
#pragma warning restore IDE0060
{ {
if (string.IsNullOrEmpty(reportFullPath))
throw new ArgumentException($"'{nameof(reportFullPath)}' cannot be null or empty.", nameof(reportFullPath));
if (dateTime == DateTime.MinValue)
throw new ArgumentNullException(nameof(dateTime));
if (descriptions is null)
throw new ArgumentNullException(nameof(descriptions));
if (tests is null)
throw new ArgumentNullException(nameof(tests));
} }
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime) private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)

View File

@ -135,16 +135,16 @@ public class FileRead : Shared.FileRead, IFileRead
return result; return result;
} }
#pragma warning disable IDE0060
private static void PostOpenInsightMetrologyViewerAttachments(List<Description> descriptions) private static void PostOpenInsightMetrologyViewerAttachments(List<Description> descriptions)
#pragma warning restore IDE0060
{ {
if (descriptions is null)
throw new ArgumentNullException(nameof(descriptions));
} }
#pragma warning disable IDE0060
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime) private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
#pragma warning restore IDE0060
{ {
if (dateTime == DateTime.MinValue)
throw new ArgumentNullException(nameof(dateTime));
Tuple<string, Test[], JsonElement[], List<FileInfo>> results; Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath); Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
_Logistics = new Logistics(reportFullPath, pdsf.Item1); _Logistics = new Logistics(reportFullPath, pdsf.Item1);

View File

@ -35,3 +35,9 @@ public class Aggregation
[JsonPropertyName("Sum")] public int Sum { get; } [JsonPropertyName("Sum")] public int Sum { get; }
} }
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Aggregation))]
internal partial class AggregationSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -282,11 +282,11 @@ public class FileRead : Shared.FileRead, IFileRead
} }
} }
#pragma warning disable IDE0060
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime) private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
#pragma warning restore IDE0060
{ {
Tuple<string, Test[], JsonElement[], List<FileInfo>> results; Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
if (dateTime == DateTime.MinValue)
throw new ArgumentNullException(nameof(dateTime));
_Logistics = new Logistics(reportFullPath, $"LOGISTICS_1{'\t'}A_JOBID={"BACKLOG"};A_MES_ENTITY={"BACKLOG"};"); _Logistics = new Logistics(reportFullPath, $"LOGISTICS_1{'\t'}A_JOBID={"BACKLOG"};A_MES_ENTITY={"BACKLOG"};");
results = new(_Logistics.Logistics1[0], Array.Empty<Test>(), Array.Empty<JsonElement>(), new List<FileInfo>()); results = new(_Logistics.Logistics1[0], Array.Empty<Test>(), Array.Empty<JsonElement>(), new List<FileInfo>());
return results; return results;

View File

@ -108,10 +108,12 @@ public class FileRead : Shared.FileRead, IFileRead
return results; return results;
} }
#pragma warning disable IDE0060
private void DirectoryMove(string reportFullPath, DateTime dateTime, List<Description> descriptions) private void DirectoryMove(string reportFullPath, DateTime dateTime, List<Description> descriptions)
#pragma warning restore IDE0060
{ {
if (dateTime == DateTime.MinValue)
throw new ArgumentNullException(nameof(dateTime));
if (descriptions is null)
throw new ArgumentNullException(nameof(descriptions));
FileInfo fileInfo = new(reportFullPath); FileInfo fileInfo = new(reportFullPath);
_ = _Logistics.Sequence.ToString(); _ = _Logistics.Sequence.ToString();
string jobIdDirectory = Path.Combine(_JobIdParentDirectory, _Logistics.JobID); string jobIdDirectory = Path.Combine(_JobIdParentDirectory, _Logistics.JobID);

View File

@ -173,8 +173,7 @@ public class FileRead : Shared.FileRead, IFileRead
string old; string old;
string checkFile; string checkFile;
string? pathRoot; string? pathRoot;
JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true }; string json = JsonSerializer.Serialize(workItems.ToArray(), WorkItemCollectionSourceGenerationContext.Default.WorkItemArray);
string json = JsonSerializer.Serialize(workItems, jsonSerializerOptions);
foreach (string alternateTargetFolder in alternateTargetFolders) foreach (string alternateTargetFolder in alternateTargetFolders)
{ {
if (alternateTargetFolder == fileConnectorConfiguration.TargetFileLocation) if (alternateTargetFolder == fileConnectorConfiguration.TargetFileLocation)
@ -258,10 +257,10 @@ public class FileRead : Shared.FileRead, IFileRead
} }
} }
#pragma warning disable IDE0060
private void MoveJson(string reportFullPath, DateTime dateTime) private void MoveJson(string reportFullPath, DateTime dateTime)
#pragma warning restore IDE0060
{ {
if (dateTime == DateTime.MinValue)
throw new ArgumentNullException(nameof(dateTime));
string json = File.ReadAllText(reportFullPath); string json = File.ReadAllText(reportFullPath);
Value? value = JsonSerializer.Deserialize<Value>(json); Value? value = JsonSerializer.Deserialize<Value>(json);
if (value is null) if (value is null)

View File

@ -2,8 +2,9 @@ using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WIQL; namespace Adaptation.FileHandlers.json.WIQL;
public class Column internal class Column
{ {
[JsonConstructor] [JsonConstructor]
public Column( public Column(
string referenceName, string referenceName,
@ -16,7 +17,14 @@ public class Column
Url = url; Url = url;
} }
public string ReferenceName { get; set; } // { init; get; } [JsonPropertyName("referenceName")] public string ReferenceName { get; }
public string Name { get; set; } // { init; get; } [JsonPropertyName("name")] public string Name { get; }
public string Url { get; set; } // { init; get; } [JsonPropertyName("url")] public string Url { get; }
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Column))]
internal partial class ColumnSourceGenerationContext : JsonSerializerContext
{
} }

View File

@ -2,8 +2,9 @@ using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WIQL; namespace Adaptation.FileHandlers.json.WIQL;
public class Field internal class Field
{ {
[JsonConstructor] [JsonConstructor]
public Field( public Field(
string referenceName, string referenceName,
@ -16,7 +17,14 @@ public class Field
Url = url; Url = url;
} }
public string ReferenceName { get; set; } // { init; get; } [JsonPropertyName("referenceName")] public string ReferenceName { get; }
public string Name { get; set; } // { init; get; } [JsonPropertyName("name")] public string Name { get; }
public string Url { get; set; } // { init; get; } [JsonPropertyName("url")] public string Url { get; }
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Field))]
internal partial class FieldSourceGenerationContext : JsonSerializerContext
{
} }

View File

@ -3,8 +3,9 @@ using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WIQL; namespace Adaptation.FileHandlers.json.WIQL;
public class Root internal class Root
{ {
[JsonConstructor] [JsonConstructor]
public Root( public Root(
string queryType, string queryType,
@ -23,10 +24,17 @@ public class Root
WorkItems = workItems; WorkItems = workItems;
} }
public string QueryType { get; set; } // { init; get; } [JsonPropertyName("queryType")] public string QueryType { get; }
public string QueryResultType { get; set; } // { init; get; } [JsonPropertyName("queryResultType")] public string QueryResultType { get; }
public DateTime AsOf { get; set; } // { init; get; } [JsonPropertyName("asOf")] public DateTime AsOf { get; }
public Column[] Columns { get; set; } // { init; get; } [JsonPropertyName("columns")] public Column[] Columns { get; }
public SortColumn[] SortColumns { get; set; } // { init; get; } [JsonPropertyName("sortColumns")] public SortColumn[] SortColumns { get; }
public WorkItem[] WorkItems { get; set; } // { init; get; } [JsonPropertyName("workItems")] public WorkItem[] WorkItems { get; }
}
[JsonSourceGenerationOptions(WriteIndented = true)] // PropertyNameCaseInsensitive = true
[JsonSerializable(typeof(Root))]
internal partial class RootSourceGenerationContext : JsonSerializerContext
{
} }

View File

@ -2,8 +2,9 @@ using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WIQL; namespace Adaptation.FileHandlers.json.WIQL;
public class SortColumn internal class SortColumn
{ {
[JsonConstructor] [JsonConstructor]
public SortColumn( public SortColumn(
Field field, Field field,
@ -14,6 +15,13 @@ public class SortColumn
Descending = descending; Descending = descending;
} }
public Field Field { get; set; } // { init; get; } [JsonPropertyName("field")] public Field Field { get; }
public bool Descending { get; set; } // { init; get; } [JsonPropertyName("descending")] public bool Descending { get; }
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(SortColumn))]
internal partial class SortColumnSourceGenerationContext : JsonSerializerContext
{
} }

View File

@ -2,8 +2,9 @@ using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WIQL; namespace Adaptation.FileHandlers.json.WIQL;
public class WorkItem internal class WorkItem
{ {
[JsonConstructor] [JsonConstructor]
public WorkItem( public WorkItem(
int id, int id,
@ -14,6 +15,13 @@ public class WorkItem
Url = url; Url = url;
} }
public int Id { get; set; } // { init; get; } [JsonPropertyName("id")] public int Id { get; }
public string Url { get; set; } // { init; get; } [JsonPropertyName("url")] public string Url { get; }
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(WorkItem))]
internal partial class WIQLWorkItemSourceGenerationContext : JsonSerializerContext
{
} }

View File

@ -2,11 +2,9 @@ using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WorkItems; namespace Adaptation.FileHandlers.json.WorkItems;
public class Attribute internal class Attribute
{ {
#nullable enable
[JsonConstructor] [JsonConstructor]
public Attribute(bool isLocked, public Attribute(bool isLocked,
string name) string name)
@ -15,7 +13,13 @@ public class Attribute
Name = name; Name = name;
} }
[JsonPropertyName("isLocked")] public bool IsLocked { get; set; } [JsonPropertyName("isLocked")] public bool IsLocked { get; }
[JsonPropertyName("name")] public string Name { get; set; } [JsonPropertyName("name")] public string Name { get; }
} }
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Attribute))]
internal partial class AttributeSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -2,12 +2,20 @@ using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WorkItems; namespace Adaptation.FileHandlers.json.WorkItems;
public class Avatar internal class Avatar
{ {
[JsonConstructor] [JsonConstructor]
public Avatar( public Avatar(
string href string href
) => Href = href; ) => Href = href;
public string Href { get; } // { init; get; } [JsonPropertyName("href")] public string Href { get; }
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Avatar))]
internal partial class AvatarSourceGenerationContext : JsonSerializerContext
{
} }

View File

@ -2,8 +2,9 @@ using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WorkItems; namespace Adaptation.FileHandlers.json.WorkItems;
public class CommentVersionRef internal class CommentVersionRef
{ {
[JsonConstructor] [JsonConstructor]
public CommentVersionRef( public CommentVersionRef(
int commentId, int commentId,
@ -16,8 +17,14 @@ public class CommentVersionRef
URL = url; URL = url;
} }
[JsonPropertyName("commentId")] public int CommentId { get; } // { init; get; } [JsonPropertyName("commentId")] public int CommentId { get; }
[JsonPropertyName("url")] public string URL { get; } // { init; get; } [JsonPropertyName("url")] public string URL { get; }
[JsonPropertyName("version")] public int Version { get; } // { init; get; } [JsonPropertyName("version")] public int Version { get; }
} }
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(CommentVersionRef))]
internal partial class CommentVersionRefSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -2,8 +2,9 @@ using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WorkItems; namespace Adaptation.FileHandlers.json.WorkItems;
public class CustomRequester internal class CustomRequester
{ {
[JsonConstructor] [JsonConstructor]
public CustomRequester( public CustomRequester(
string descriptor, string descriptor,
@ -31,4 +32,11 @@ public class CustomRequester
[JsonPropertyName("_links")] public Links Links { get; } [JsonPropertyName("_links")] public Links Links { get; }
[JsonPropertyName("uniqueName")] public string UniqueName { get; } [JsonPropertyName("uniqueName")] public string UniqueName { get; }
[JsonPropertyName("url")] public string Url { get; } [JsonPropertyName("url")] public string Url { get; }
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(CustomRequester))]
internal partial class CustomRequesterSourceGenerationContext : JsonSerializerContext
{
} }

View File

@ -3,7 +3,7 @@ using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WorkItems; namespace Adaptation.FileHandlers.json.WorkItems;
public class Fields internal class Fields
{ {
#nullable enable #nullable enable
@ -72,35 +72,41 @@ public class Fields
SystemWorkItemType = systemWorkItemType; SystemWorkItemType = systemWorkItemType;
} }
[JsonPropertyName("Custom.Requester")] public CustomRequester? CustomRequester { get; } // { init; get; } [JsonPropertyName("Custom.Requester")] public CustomRequester? CustomRequester { get; }
[JsonPropertyName("Custom.RRminusOE")] public float? CustomRRminusOE { get; } // { init; get; } [JsonPropertyName("Custom.RRminusOE")] public float? CustomRRminusOE { get; }
[JsonPropertyName("Custom.WSJF")] public float? CustomWSJF { get; } // { init; get; } [JsonPropertyName("Custom.WSJF")] public float? CustomWSJF { get; }
[JsonPropertyName("Microsoft.VSTS.Common.ActivatedDate")] public DateTime MicrosoftVSTSCommonActivatedDate { get; } // { init; get; } [JsonPropertyName("Microsoft.VSTS.Common.ActivatedDate")] public DateTime MicrosoftVSTSCommonActivatedDate { get; }
[JsonPropertyName("Microsoft.VSTS.Common.BusinessValue")] public float? MicrosoftVSTSCommonBusinessValue { get; } // { init; get; } [JsonPropertyName("Microsoft.VSTS.Common.BusinessValue")] public float? MicrosoftVSTSCommonBusinessValue { get; }
[JsonPropertyName("Microsoft.VSTS.Common.ClosedDate")] public DateTime MicrosoftVSTSCommonClosedDate { get; } // { init; get; } [JsonPropertyName("Microsoft.VSTS.Common.ClosedDate")] public DateTime MicrosoftVSTSCommonClosedDate { get; }
[JsonPropertyName("Microsoft.VSTS.Common.Priority")] public int MicrosoftVSTSCommonPriority { get; } // { init; get; } [JsonPropertyName("Microsoft.VSTS.Common.Priority")] public int MicrosoftVSTSCommonPriority { get; }
[JsonPropertyName("Microsoft.VSTS.Common.ResolvedDate")] public DateTime MicrosoftVSTSCommonResolvedDate { get; } // { init; get; } [JsonPropertyName("Microsoft.VSTS.Common.ResolvedDate")] public DateTime MicrosoftVSTSCommonResolvedDate { get; }
[JsonPropertyName("Microsoft.VSTS.Common.StateChangeDate")] public DateTime MicrosoftVSTSCommonStateChangeDate { get; } // { init; get; } [JsonPropertyName("Microsoft.VSTS.Common.StateChangeDate")] public DateTime MicrosoftVSTSCommonStateChangeDate { get; }
[JsonPropertyName("Microsoft.VSTS.Common.TimeCriticality")] public float? MicrosoftVSTSCommonTimeCriticality { get; } // { init; get; } [JsonPropertyName("Microsoft.VSTS.Common.TimeCriticality")] public float? MicrosoftVSTSCommonTimeCriticality { get; }
[JsonPropertyName("Microsoft.VSTS.Scheduling.Effort")] public float? MicrosoftVSTSSchedulingEffort { get; } // { init; get; } [JsonPropertyName("Microsoft.VSTS.Scheduling.Effort")] public float? MicrosoftVSTSSchedulingEffort { get; }
[JsonPropertyName("Microsoft.VSTS.Scheduling.StartDate")] public DateTime MicrosoftVSTSSchedulingStartDate { get; } // { init; get; } [JsonPropertyName("Microsoft.VSTS.Scheduling.StartDate")] public DateTime MicrosoftVSTSSchedulingStartDate { get; }
[JsonPropertyName("Microsoft.VSTS.Scheduling.TargetDate")] public DateTime MicrosoftVSTSSchedulingTargetDate { get; } // { init; get; } [JsonPropertyName("Microsoft.VSTS.Scheduling.TargetDate")] public DateTime MicrosoftVSTSSchedulingTargetDate { get; }
[JsonPropertyName("System.AreaPath")] public string SystemAreaPath { get; } // { init; get; } [JsonPropertyName("System.AreaPath")] public string SystemAreaPath { get; }
[JsonPropertyName("System.AssignedTo")] public SystemAssignedTo? SystemAssignedTo { get; } // { init; get; } [JsonPropertyName("System.AssignedTo")] public SystemAssignedTo? SystemAssignedTo { get; }
[JsonPropertyName("System.ChangedBy")] public SystemChangedBy SystemChangedBy { get; } // { init; get; } [JsonPropertyName("System.ChangedBy")] public SystemChangedBy SystemChangedBy { get; }
[JsonPropertyName("System.ChangedDate")] public DateTime SystemChangedDate { get; } // { init; get; } [JsonPropertyName("System.ChangedDate")] public DateTime SystemChangedDate { get; }
[JsonPropertyName("System.CommentCount")] public int SystemCommentCount { get; } // { init; get; } [JsonPropertyName("System.CommentCount")] public int SystemCommentCount { get; }
[JsonPropertyName("System.CreatedBy")] public SystemCreatedBy SystemCreatedBy { get; } // { init; get; } [JsonPropertyName("System.CreatedBy")] public SystemCreatedBy SystemCreatedBy { get; }
[JsonPropertyName("System.CreatedDate")] public DateTime SystemCreatedDate { get; } // { init; get; } [JsonPropertyName("System.CreatedDate")] public DateTime SystemCreatedDate { get; }
[JsonPropertyName("System.Description")] public string SystemDescription { get; } // { init; get; } [JsonPropertyName("System.Description")] public string SystemDescription { get; }
[JsonPropertyName("System.History")] public string SystemHistory { get; } // { init; get; } [JsonPropertyName("System.History")] public string SystemHistory { get; }
[JsonPropertyName("System.IterationPath")] public string SystemIterationPath { get; } // { init; get; } [JsonPropertyName("System.IterationPath")] public string SystemIterationPath { get; }
[JsonPropertyName("System.Parent")] public int SystemParent { get; } // { init; get; } [JsonPropertyName("System.Parent")] public int SystemParent { get; }
[JsonPropertyName("System.Reason")] public string SystemReason { get; } // { init; get; } [JsonPropertyName("System.Reason")] public string SystemReason { get; }
[JsonPropertyName("System.State")] public string SystemState { get; } // { init; get; } [JsonPropertyName("System.State")] public string SystemState { get; }
[JsonPropertyName("System.Tags")] public string SystemTags { get; } // { init; get; } [JsonPropertyName("System.Tags")] public string SystemTags { get; }
[JsonPropertyName("System.TeamProject")] public string SystemTeamProject { get; } // { init; get; } [JsonPropertyName("System.TeamProject")] public string SystemTeamProject { get; }
[JsonPropertyName("System.Title")] public string SystemTitle { get; } // { init; get; } [JsonPropertyName("System.Title")] public string SystemTitle { get; }
[JsonPropertyName("System.WorkItemType")] public string SystemWorkItemType { get; } // { init; get; } [JsonPropertyName("System.WorkItemType")] public string SystemWorkItemType { get; }
} }
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Fields))]
internal partial class FieldsSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -2,12 +2,20 @@ using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WorkItems; namespace Adaptation.FileHandlers.json.WorkItems;
public class Html internal class Html
{ {
[JsonConstructor] [JsonConstructor]
public Html( public Html(
string href string href
) => Href = href; ) => Href = href;
public string Href { get; } // { init; get; } [JsonPropertyName("href")] public string Href { get; }
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Html))]
internal partial class HtmlSourceGenerationContext : JsonSerializerContext
{
} }

View File

@ -2,12 +2,20 @@ using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WorkItems; namespace Adaptation.FileHandlers.json.WorkItems;
public class Links internal class Links
{ {
[JsonConstructor] [JsonConstructor]
public Links( public Links(
Avatar avatar Avatar avatar
) => Avatar = avatar; ) => Avatar = avatar;
[JsonPropertyName("avatar")] public Avatar Avatar { get; } [JsonPropertyName("avatar")] public Avatar Avatar { get; }
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Links))]
internal partial class LinksSourceGenerationContext : JsonSerializerContext
{
} }

View File

@ -1,27 +1,163 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WorkItems; namespace Adaptation.FileHandlers.json.WorkItems;
public class Record internal class Record
{ {
#nullable enable #nullable enable
[JsonConstructor] [JsonConstructor]
public Record(WorkItem workItem, WorkItem? parent, Record[] children) public Record(WorkItem workItem, WorkItem? parent, Record[] children, Record[] related, Record[] successors)
{ {
WorkItem = workItem; WorkItem = workItem;
Parent = parent; Parent = parent;
Children = children; Children = children;
Related = related;
Successors = successors;
} }
public WorkItem WorkItem { get; set; } [JsonPropertyName("WorkItem")] public WorkItem WorkItem { get; set; }
public WorkItem? Parent { get; set; } [JsonPropertyName("Parent")] public WorkItem? Parent { get; set; }
public Record[] Children { get; set; } [JsonPropertyName("Children")] public Record[] Children { get; set; }
[JsonPropertyName("Related")] public Record[] Related { get; set; }
[JsonPropertyName("Successors")] public Record[] Successors { get; set; }
public static Record Get(WorkItem workItem, WorkItem? parent, ReadOnlyCollection<Record> children) => internal static Record GetWithoutNesting(Record record, string? violation)
new(workItem, parent, children.ToArray()); {
Record result;
WorkItem workItem = new(record.WorkItem.ActivatedDate,
record.WorkItem.AreaPath,
record.WorkItem.AssignedTo,
record.WorkItem.BusinessValue,
record.WorkItem.ChangedDate,
record.WorkItem.ClosedDate,
record.WorkItem.CommentCount,
record.WorkItem.CreatedDate,
record.WorkItem.Description,
record.WorkItem.Effort,
record.WorkItem.Id,
record.WorkItem.IterationPath,
record.WorkItem.Parent,
record.WorkItem.Priority,
record.WorkItem.Relations,
record.WorkItem.Requester,
record.WorkItem.ResolvedDate,
record.WorkItem.Revision,
record.WorkItem.RiskReductionMinusOpportunityEnablement,
record.WorkItem.StartDate,
record.WorkItem.State,
record.WorkItem.Tags,
record.WorkItem.TargetDate,
record.WorkItem.TimeCriticality,
record.WorkItem.Title,
record.WorkItem.Violation is null ? violation : record.WorkItem.Violation,
record.WorkItem.WeightedShortestJobFirst,
record.WorkItem.WorkItemType);
result = new(workItem, record.Parent, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>());
return result;
}
private static Record Get(Record record, bool keepRelations)
{
Record result;
WorkItem? parentWorkItem = keepRelations ? record.Parent : WorkItem.GetWithOutRelations(record.Parent);
WorkItem? workItem = keepRelations ? record.WorkItem : WorkItem.GetWithOutRelations(record.WorkItem) ?? throw new Exception();
List<Record> childRecords = new();
List<Record> relatedRecords = new();
List<Record> successorRecords = new();
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 ? Array.Empty<string>() : relation.URL.Split('/');
if (segments.Length < 2)
result = null;
else
{
if (!int.TryParse(segments[segments.Length - 1], out int id))
result = null;
else
result = id;
}
return result;
}
internal static ReadOnlyCollection<Record> GetKeyValuePairs(ReadOnlyDictionary<int, WorkItem> keyValuePairs, WorkItem workItem, string relationName, List<bool> nests, bool keepRelations)
{
List<Record> results = new();
int? childId;
Record record;
nests.Add(true);
WorkItem? childWorkItem;
WorkItem? parentWorkItem;
List<WorkItem> collection = new();
ReadOnlyCollection<Record> childRecords;
ReadOnlyCollection<Record> relatedRecords;
ReadOnlyCollection<Record> successorRecords;
if (workItem.Relations is not null && workItem.Relations.Length > 0)
{
collection.Clear();
foreach (Relation relation in workItem.Relations)
{
childId = GetIdFromUrl(relationName, relation);
if (childId is not null && workItem.Parent is not null && relation?.URL is not null && relation.URL.Contains(workItem.Parent.Value.ToString()))
continue;
if (childId is null || !keyValuePairs.TryGetValue(childId.Value, out childWorkItem))
continue;
collection.Add(childWorkItem);
}
collection = (from l in collection orderby l.State != "Closed", l.Id select l).ToList();
foreach (WorkItem w in collection)
{
if (nests.Count > 99)
break;
if (w.Parent is null)
parentWorkItem = null;
else
_ = keyValuePairs.TryGetValue(w.Parent.Value, out parentWorkItem);
childRecords = GetKeyValuePairs(keyValuePairs, w, "Child", nests, keepRelations); // Forward
// records = GetKeyValuePairs(keyValuePairs, w, "Predecessor", nests); // Reverse
// successorRecords = GetKeyValuePairs(keyValuePairs, w, "Successor", nests); // Forward
// if (successorRecords.Count > 0)
// {
// if (successorRecords.Count > 0)
// { }
// }
successorRecords = new(Array.Empty<Record>());
relatedRecords = GetKeyValuePairs(keyValuePairs, w, "Related", nests, keepRelations); // Related
record = Get(w, parentWorkItem, childRecords, relatedRecords, successorRecords, keepRelations);
results.Add(record);
}
}
return new(results);
}
} }
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Record))]
internal partial class RecordSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -2,11 +2,9 @@ using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WorkItems; namespace Adaptation.FileHandlers.json.WorkItems;
public class Relation internal class Relation
{ {
#nullable enable
[JsonConstructor] [JsonConstructor]
public Relation(string rel, public Relation(string rel,
string url, string url,
@ -22,3 +20,15 @@ public class Relation
[JsonPropertyName("url")] public string URL { get; set; } [JsonPropertyName("url")] public string URL { get; set; }
} }
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Relation))]
internal partial class RelationSourceGenerationContext : JsonSerializerContext
{
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Relation[]))]
internal partial class RelationCollectionSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -2,8 +2,9 @@ using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WorkItems; namespace Adaptation.FileHandlers.json.WorkItems;
public class SystemAssignedTo internal class SystemAssignedTo
{ {
[JsonConstructor] [JsonConstructor]
public SystemAssignedTo( public SystemAssignedTo(
string displayName, string displayName,
@ -33,3 +34,9 @@ public class SystemAssignedTo
[JsonPropertyName("url")] public string Url { get; } [JsonPropertyName("url")] public string Url { get; }
} }
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(SystemAssignedTo))]
internal partial class SystemAssignedToSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -2,8 +2,9 @@ using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WorkItems; namespace Adaptation.FileHandlers.json.WorkItems;
public class SystemChangedBy internal class SystemChangedBy
{ {
[JsonConstructor] [JsonConstructor]
public SystemChangedBy( public SystemChangedBy(
string displayName, string displayName,
@ -33,3 +34,9 @@ public class SystemChangedBy
[JsonPropertyName("url")] public string Url { get; } [JsonPropertyName("url")] public string Url { get; }
} }
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(SystemChangedBy))]
internal partial class SystemChangedBySourceGenerationContext : JsonSerializerContext
{
}

View File

@ -2,8 +2,9 @@ using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WorkItems; namespace Adaptation.FileHandlers.json.WorkItems;
public class SystemCreatedBy internal class SystemCreatedBy
{ {
[JsonConstructor] [JsonConstructor]
public SystemCreatedBy( public SystemCreatedBy(
string displayName, string displayName,
@ -33,3 +34,9 @@ public class SystemCreatedBy
[JsonPropertyName("url")] public string Url { get; } [JsonPropertyName("url")] public string Url { get; }
} }
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(SystemCreatedBy))]
internal partial class SystemCreatedBySourceGenerationContext : JsonSerializerContext
{
}

View File

@ -2,8 +2,9 @@ using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WorkItems; namespace Adaptation.FileHandlers.json.WorkItems;
public class Value internal class Value
{ {
[JsonConstructor] [JsonConstructor]
public Value( public Value(
int id, int id,
@ -28,4 +29,11 @@ public class Value
[JsonPropertyName("relations")] public Relation[] Relations { get; } [JsonPropertyName("relations")] public Relation[] Relations { get; }
[JsonPropertyName("rev")] public int Rev { get; } [JsonPropertyName("rev")] public int Rev { get; }
[JsonPropertyName("url")] public string Url { get; } [JsonPropertyName("url")] public string Url { get; }
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Value))]
internal partial class ValueSourceGenerationContext : JsonSerializerContext
{
} }

View File

@ -3,7 +3,7 @@ using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WorkItems; namespace Adaptation.FileHandlers.json.WorkItems;
public class WorkItem internal class WorkItem
{ {
#nullable enable #nullable enable
@ -70,68 +70,78 @@ public class WorkItem
public override string ToString() => $"{Id} - {WorkItemType} - {Title}"; public override string ToString() => $"{Id} - {WorkItemType} - {Title}";
public static Record Get(Record record, string? violation) public static WorkItem? GetWithOutRelations(WorkItem? workItem)
{ {
Record result; WorkItem? result = workItem is null ? null : new(workItem.ActivatedDate,
WorkItem workItem = new(record.WorkItem.ActivatedDate, workItem.AreaPath,
record.WorkItem.AreaPath, workItem.AssignedTo,
record.WorkItem.AssignedTo, workItem.BusinessValue,
record.WorkItem.BusinessValue, workItem.ChangedDate,
record.WorkItem.ChangedDate, workItem.ClosedDate,
record.WorkItem.ClosedDate, workItem.CommentCount,
record.WorkItem.CommentCount, workItem.CreatedDate,
record.WorkItem.CreatedDate, workItem.Description,
record.WorkItem.Description, workItem.Effort,
record.WorkItem.Effort, workItem.Id,
record.WorkItem.Id, workItem.IterationPath,
record.WorkItem.IterationPath, workItem.Parent,
record.WorkItem.Parent, workItem.Priority,
record.WorkItem.Priority, Array.Empty<Relation>(),
record.WorkItem.Relations, workItem.Requester,
record.WorkItem.Requester, workItem.ResolvedDate,
record.WorkItem.ResolvedDate, workItem.Revision,
record.WorkItem.Revision, workItem.RiskReductionMinusOpportunityEnablement,
record.WorkItem.RiskReductionMinusOpportunityEnablement, workItem.StartDate,
record.WorkItem.StartDate, workItem.State,
record.WorkItem.State, workItem.Tags,
record.WorkItem.Tags, workItem.TargetDate,
record.WorkItem.TargetDate, workItem.TimeCriticality,
record.WorkItem.TimeCriticality, workItem.Title,
record.WorkItem.Title, workItem.Violation,
record.WorkItem.Violation is null ? violation : record.WorkItem.Violation, workItem.WeightedShortestJobFirst,
record.WorkItem.WeightedShortestJobFirst, workItem.WorkItemType);
record.WorkItem.WorkItemType);
result = new(workItem, record.Parent, Array.Empty<Record>());
return result; return result;
} }
public DateTime? ActivatedDate { get; set; } [JsonPropertyName("ActivatedDate")] public DateTime? ActivatedDate { get; }
public string AreaPath { get; set; } [JsonPropertyName("AreaPath")] public string AreaPath { get; }
public string? AssignedTo { get; set; } [JsonPropertyName("AssignedTo")] public string? AssignedTo { get; }
public long? BusinessValue { get; set; } [JsonPropertyName("BusinessValue")] public long? BusinessValue { get; }
public DateTime ChangedDate { get; set; } [JsonPropertyName("ChangedDate")] public DateTime ChangedDate { get; }
public DateTime? ClosedDate { get; set; } [JsonPropertyName("ClosedDate")] public DateTime? ClosedDate { get; }
public int CommentCount { get; set; } [JsonPropertyName("CommentCount")] public int CommentCount { get; }
public DateTime CreatedDate { get; set; } [JsonPropertyName("CreatedDate")] public DateTime CreatedDate { get; }
public string Description { get; set; } [JsonPropertyName("Description")] public string Description { get; }
public long? Effort { get; set; } [JsonPropertyName("Effort")] public long? Effort { get; }
public int Id { get; set; } [JsonPropertyName("Id")] public int Id { get; }
public string IterationPath { get; set; } [JsonPropertyName("IterationPath")] public string IterationPath { get; }
public int? Parent { get; set; } [JsonPropertyName("Parent")] public int? Parent { get; }
public int? Priority { get; set; } [JsonPropertyName("Priority")] public int? Priority { get; }
public Relation[]? Relations { get; set; } [JsonPropertyName("Relations")] public Relation[]? Relations { get; }
public string? Requester { get; set; } [JsonPropertyName("Requester")] public string? Requester { get; }
public DateTime? ResolvedDate { get; set; } [JsonPropertyName("ResolvedDate")] public DateTime? ResolvedDate { get; }
public int Revision { get; set; } [JsonPropertyName("Revision")] public int Revision { get; }
public long? RiskReductionMinusOpportunityEnablement { get; set; } [JsonPropertyName("RiskReductionMinusOpportunityEnablement")] public long? RiskReductionMinusOpportunityEnablement { get; }
public DateTime? StartDate { get; set; } [JsonPropertyName("StartDate")] public DateTime? StartDate { get; }
public string State { get; set; } [JsonPropertyName("State")] public string State { get; }
public string Tags { get; set; } [JsonPropertyName("Tags")] public string Tags { get; }
public DateTime? TargetDate { get; set; } [JsonPropertyName("TargetDate")] public DateTime? TargetDate { get; }
public long? TimeCriticality { get; set; } [JsonPropertyName("TimeCriticality")] public long? TimeCriticality { get; }
public string Title { get; set; } [JsonPropertyName("Title")] public string Title { get; }
public string? Violation { get; set; } [JsonPropertyName("Violation")] public string? Violation { get; }
public string WorkItemType { get; set; } [JsonPropertyName("WeightedShortestJobFirst")] public long? WeightedShortestJobFirst { get; }
public long? WeightedShortestJobFirst { get; set; } [JsonPropertyName("WorkItemType")] public string WorkItemType { get; }
} }
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(WorkItem))]
internal partial class WorkItemSourceGenerationContext : JsonSerializerContext
{
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(WorkItem[]))]
internal partial class WorkItemCollectionSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -7,7 +7,7 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
namespace Adaptation._Tests.CreateSelfDescription.Production.v2_57_0; namespace Adaptation._Tests.CreateSelfDescription.Development.v2_57_0;
[TestClass] [TestClass]
public class ALIGNMENT_EQPT : EAFLoggingUnitTesting public class ALIGNMENT_EQPT : EAFLoggingUnitTesting
@ -52,7 +52,7 @@ public class ALIGNMENT_EQPT : EAFLoggingUnitTesting
[Ignore] [Ignore]
#endif #endif
[TestMethod] [TestMethod]
public void Production__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile() public void Development__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile()
{ {
string check = ".xlsx"; string check = ".xlsx";
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();

View File

@ -7,7 +7,7 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
namespace Adaptation._Tests.CreateSelfDescription.Production.v2_57_0; namespace Adaptation._Tests.CreateSelfDescription.Development.v2_57_0;
[TestClass] [TestClass]
public class ALIGNMENT : EAFLoggingUnitTesting public class ALIGNMENT : EAFLoggingUnitTesting
@ -52,7 +52,7 @@ public class ALIGNMENT : EAFLoggingUnitTesting
[Ignore] [Ignore]
#endif #endif
[TestMethod] [TestMethod]
public void Production__v2_57_0__ALIGNMENT__ConvertExcelToJson() public void Development__v2_57_0__ALIGNMENT__ConvertExcelToJson()
{ {
string check = "*.xlsx"; string check = "*.xlsx";
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();

View File

@ -7,7 +7,7 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
namespace Adaptation._Tests.CreateSelfDescription.Production.v2_57_0; namespace Adaptation._Tests.CreateSelfDescription.Development.v2_57_0;
[TestClass] [TestClass]
public class BACKLOG_EQPT : EAFLoggingUnitTesting public class BACKLOG_EQPT : EAFLoggingUnitTesting
@ -52,7 +52,7 @@ public class BACKLOG_EQPT : EAFLoggingUnitTesting
[Ignore] [Ignore]
#endif #endif
[TestMethod] [TestMethod]
public void Production__v2_57_0__BACKLOG_EQPT__DownloadWorkItems() public void Development__v2_57_0__BACKLOG_EQPT__DownloadWorkItems()
{ {
string check = ".xlsx"; string check = ".xlsx";
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();

View File

@ -7,7 +7,7 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
namespace Adaptation._Tests.CreateSelfDescription.Production.v2_57_0; namespace Adaptation._Tests.CreateSelfDescription.Development.v2_57_0;
[TestClass] [TestClass]
public class BACKLOG : EAFLoggingUnitTesting public class BACKLOG : EAFLoggingUnitTesting
@ -52,7 +52,7 @@ public class BACKLOG : EAFLoggingUnitTesting
[Ignore] [Ignore]
#endif #endif
[TestMethod] [TestMethod]
public void Production__v2_57_0__BACKLOG__json() public void Development__v2_57_0__BACKLOG__json()
{ {
string check = "*.json"; string check = "*.json";
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();

View File

@ -7,7 +7,7 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
namespace Adaptation._Tests.CreateSelfDescription.Production.v2_57_0; namespace Adaptation._Tests.CreateSelfDescription.Development.v2_57_0;
[TestClass] [TestClass]
public class MESAFIBACKLOG : EAFLoggingUnitTesting public class MESAFIBACKLOG : EAFLoggingUnitTesting
@ -52,7 +52,7 @@ public class MESAFIBACKLOG : EAFLoggingUnitTesting
[Ignore] [Ignore]
#endif #endif
[TestMethod] [TestMethod]
public void Production__v2_57_0__MESAFIBACKLOG__Kanban() public void Development__v2_57_0__MESAFIBACKLOG__Kanban()
{ {
string check = "*.json"; string check = "*.json";
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();
@ -65,7 +65,20 @@ public class MESAFIBACKLOG : EAFLoggingUnitTesting
[Ignore] [Ignore]
#endif #endif
[TestMethod] [TestMethod]
public void Production__v2_57_0__MESAFIBACKLOG__Markdown() public void Development__v2_57_0__MESAFIBACKLOG__Markdown()
{
string check = "*.json";
MethodBase methodBase = new StackFrame().GetMethod();
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
_ = AdaptationTesting.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting);
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
}
#if DEBUG
[Ignore]
#endif
[TestMethod]
public void Development__v2_57_0__MESAFIBACKLOG__ADO()
{ {
string check = "*.json"; string check = "*.json";
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();

View File

@ -5,7 +5,7 @@ using System.Diagnostics;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
namespace Adaptation._Tests.Extract.Production.v2_57_0; namespace Adaptation._Tests.Extract.Development.v2_57_0;
[TestClass] [TestClass]
public class ALIGNMENT_EQPT public class ALIGNMENT_EQPT
@ -14,13 +14,13 @@ public class ALIGNMENT_EQPT
#pragma warning disable CA2254 #pragma warning disable CA2254
#pragma warning disable IDE0060 #pragma warning disable IDE0060
private static CreateSelfDescription.Production.v2_57_0.ALIGNMENT_EQPT _ALIGNMENT_EQPT; private static CreateSelfDescription.Development.v2_57_0.ALIGNMENT_EQPT _ALIGNMENT_EQPT;
[ClassInitialize] [ClassInitialize]
public static void ClassInitialize(TestContext testContext) public static void ClassInitialize(TestContext testContext)
{ {
CreateSelfDescription.Production.v2_57_0.ALIGNMENT_EQPT.ClassInitialize(testContext); CreateSelfDescription.Development.v2_57_0.ALIGNMENT_EQPT.ClassInitialize(testContext);
_ALIGNMENT_EQPT = CreateSelfDescription.Production.v2_57_0.ALIGNMENT_EQPT.EAFLoggingUnitTesting; _ALIGNMENT_EQPT = CreateSelfDescription.Development.v2_57_0.ALIGNMENT_EQPT.EAFLoggingUnitTesting;
} }
private static void NonThrowTryCatch() private static void NonThrowTryCatch()
@ -32,16 +32,16 @@ public class ALIGNMENT_EQPT
[Ignore] [Ignore]
[TestMethod] [TestMethod]
public void Production__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile() => _ALIGNMENT_EQPT.Production__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile(); public void Development__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile() => _ALIGNMENT_EQPT.Development__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile();
[Ignore] [Ignore]
[TestMethod] [TestMethod]
public void Production__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile637961178824025822__Normal() public void Development__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile637961178824025822__Normal()
{ {
string check = ".xlsx"; string check = ".xlsx";
bool validatePDSF = false; bool validatePDSF = false;
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();
_ALIGNMENT_EQPT.Production__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile(); _ALIGNMENT_EQPT.Development__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile();
_ = _ALIGNMENT_EQPT.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); _ = _ALIGNMENT_EQPT.AdaptationTesting.GetVariables(methodBase, check, validatePDSF);
for (int i = 0; i < int.MinValue; i++) for (int i = 0; i < int.MinValue; i++)
Thread.Sleep(500); Thread.Sleep(500);

View File

@ -9,7 +9,7 @@ using System.IO;
using System.Reflection; using System.Reflection;
using System.Text.Json; using System.Text.Json;
namespace Adaptation._Tests.Extract.Production.v2_57_0; namespace Adaptation._Tests.Extract.Development.v2_57_0;
[TestClass] [TestClass]
public class ALIGNMENT public class ALIGNMENT
@ -18,13 +18,13 @@ public class ALIGNMENT
#pragma warning disable CA2254 #pragma warning disable CA2254
#pragma warning disable IDE0060 #pragma warning disable IDE0060
private static CreateSelfDescription.Production.v2_57_0.ALIGNMENT _ALIGNMENT; private static CreateSelfDescription.Development.v2_57_0.ALIGNMENT _ALIGNMENT;
[ClassInitialize] [ClassInitialize]
public static void ClassInitialize(TestContext testContext) public static void ClassInitialize(TestContext testContext)
{ {
CreateSelfDescription.Production.v2_57_0.ALIGNMENT.ClassInitialize(testContext); CreateSelfDescription.Development.v2_57_0.ALIGNMENT.ClassInitialize(testContext);
_ALIGNMENT = CreateSelfDescription.Production.v2_57_0.ALIGNMENT.EAFLoggingUnitTesting; _ALIGNMENT = CreateSelfDescription.Development.v2_57_0.ALIGNMENT.EAFLoggingUnitTesting;
} }
private static void NonThrowTryCatch() private static void NonThrowTryCatch()
@ -38,18 +38,18 @@ public class ALIGNMENT
[Ignore] [Ignore]
#endif #endif
[TestMethod] [TestMethod]
public void Production__v2_57_0__ALIGNMENT__ConvertExcelToJson() => _ALIGNMENT.Production__v2_57_0__ALIGNMENT__ConvertExcelToJson(); public void Development__v2_57_0__ALIGNMENT__ConvertExcelToJson() => _ALIGNMENT.Development__v2_57_0__ALIGNMENT__ConvertExcelToJson();
#if DEBUG #if DEBUG
[Ignore] [Ignore]
#endif #endif
[TestMethod] [TestMethod]
public void Production__v2_57_0__ALIGNMENT__ConvertExcelToJson638353030755467303__Normal() public void Development__v2_57_0__ALIGNMENT__ConvertExcelToJson638353030755467303__Normal()
{ {
string check = "*.xlsx"; string check = "*.xlsx";
bool validatePDSF = false; bool validatePDSF = false;
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();
_ALIGNMENT.Production__v2_57_0__ALIGNMENT__ConvertExcelToJson(); _ALIGNMENT.Development__v2_57_0__ALIGNMENT__ConvertExcelToJson();
Assert.IsFalse(string.IsNullOrEmpty(_ALIGNMENT.AdaptationTesting.TestContext.FullyQualifiedTestClassName)); Assert.IsFalse(string.IsNullOrEmpty(_ALIGNMENT.AdaptationTesting.TestContext.FullyQualifiedTestClassName));
string[] variables = _ALIGNMENT.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); string[] variables = _ALIGNMENT.AdaptationTesting.GetVariables(methodBase, check, validatePDSF);
IFileRead fileRead = _ALIGNMENT.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false); IFileRead fileRead = _ALIGNMENT.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false);

View File

@ -5,7 +5,7 @@ using System.Diagnostics;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
namespace Adaptation._Tests.Extract.Production.v2_57_0; namespace Adaptation._Tests.Extract.Development.v2_57_0;
[TestClass] [TestClass]
public class BACKLOG_EQPT public class BACKLOG_EQPT
@ -14,13 +14,13 @@ public class BACKLOG_EQPT
#pragma warning disable CA2254 #pragma warning disable CA2254
#pragma warning disable IDE0060 #pragma warning disable IDE0060
private static CreateSelfDescription.Production.v2_57_0.BACKLOG_EQPT _BACKLOG_EQPT; private static CreateSelfDescription.Development.v2_57_0.BACKLOG_EQPT _BACKLOG_EQPT;
[ClassInitialize] [ClassInitialize]
public static void ClassInitialize(TestContext testContext) public static void ClassInitialize(TestContext testContext)
{ {
CreateSelfDescription.Production.v2_57_0.BACKLOG_EQPT.ClassInitialize(testContext); CreateSelfDescription.Development.v2_57_0.BACKLOG_EQPT.ClassInitialize(testContext);
_BACKLOG_EQPT = CreateSelfDescription.Production.v2_57_0.BACKLOG_EQPT.EAFLoggingUnitTesting; _BACKLOG_EQPT = CreateSelfDescription.Development.v2_57_0.BACKLOG_EQPT.EAFLoggingUnitTesting;
} }
private static void NonThrowTryCatch() private static void NonThrowTryCatch()
@ -32,16 +32,16 @@ public class BACKLOG_EQPT
[Ignore] [Ignore]
[TestMethod] [TestMethod]
public void Production__v2_57_0__BACKLOG_EQPT__DownloadWorkItems() => _BACKLOG_EQPT.Production__v2_57_0__BACKLOG_EQPT__DownloadWorkItems(); public void Development__v2_57_0__BACKLOG_EQPT__DownloadWorkItems() => _BACKLOG_EQPT.Development__v2_57_0__BACKLOG_EQPT__DownloadWorkItems();
[Ignore] [Ignore]
[TestMethod] [TestMethod]
public void Production__v2_57_0__BACKLOG_EQPT__DownloadWorkItems638612245609095845__Normal() public void Development__v2_57_0__BACKLOG_EQPT__DownloadWorkItems638612245609095845__Normal()
{ {
string check = ".json"; string check = ".json";
bool validatePDSF = false; bool validatePDSF = false;
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();
_BACKLOG_EQPT.Production__v2_57_0__BACKLOG_EQPT__DownloadWorkItems(); _BACKLOG_EQPT.Development__v2_57_0__BACKLOG_EQPT__DownloadWorkItems();
_ = _BACKLOG_EQPT.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); _ = _BACKLOG_EQPT.AdaptationTesting.GetVariables(methodBase, check, validatePDSF);
for (int i = 0; i < int.MinValue; i++) for (int i = 0; i < int.MinValue; i++)
Thread.Sleep(500); Thread.Sleep(500);

View File

@ -9,7 +9,7 @@ using System.IO;
using System.Reflection; using System.Reflection;
using System.Text.Json; using System.Text.Json;
namespace Adaptation._Tests.Extract.Production.v2_57_0; namespace Adaptation._Tests.Extract.Development.v2_57_0;
[TestClass] [TestClass]
public class BACKLOG public class BACKLOG
@ -18,13 +18,13 @@ public class BACKLOG
#pragma warning disable CA2254 #pragma warning disable CA2254
#pragma warning disable IDE0060 #pragma warning disable IDE0060
private static CreateSelfDescription.Production.v2_57_0.BACKLOG _BACKLOG; private static CreateSelfDescription.Development.v2_57_0.BACKLOG _BACKLOG;
[ClassInitialize] [ClassInitialize]
public static void ClassInitialize(TestContext testContext) public static void ClassInitialize(TestContext testContext)
{ {
CreateSelfDescription.Production.v2_57_0.BACKLOG.ClassInitialize(testContext); CreateSelfDescription.Development.v2_57_0.BACKLOG.ClassInitialize(testContext);
_BACKLOG = CreateSelfDescription.Production.v2_57_0.BACKLOG.EAFLoggingUnitTesting; _BACKLOG = CreateSelfDescription.Development.v2_57_0.BACKLOG.EAFLoggingUnitTesting;
} }
private static void NonThrowTryCatch() private static void NonThrowTryCatch()
@ -38,18 +38,18 @@ public class BACKLOG
[Ignore] [Ignore]
#endif #endif
[TestMethod] [TestMethod]
public void Production__v2_57_0__BACKLOG__json() => _BACKLOG.Production__v2_57_0__BACKLOG__json(); public void Development__v2_57_0__BACKLOG__json() => _BACKLOG.Development__v2_57_0__BACKLOG__json();
#if DEBUG #if DEBUG
[Ignore] [Ignore]
#endif #endif
[TestMethod] [TestMethod]
public void Production__v2_57_0__BACKLOG__json638612245609095846__Normal() public void Development__v2_57_0__BACKLOG__json638612245609095846__Normal()
{ {
string check = "*.json"; string check = "*.json";
bool validatePDSF = false; bool validatePDSF = false;
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();
_BACKLOG.Production__v2_57_0__BACKLOG__json(); _BACKLOG.Development__v2_57_0__BACKLOG__json();
Assert.IsFalse(string.IsNullOrEmpty(_BACKLOG.AdaptationTesting.TestContext.FullyQualifiedTestClassName)); Assert.IsFalse(string.IsNullOrEmpty(_BACKLOG.AdaptationTesting.TestContext.FullyQualifiedTestClassName));
string[] variables = _BACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); string[] variables = _BACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF);
IFileRead fileRead = _BACKLOG.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false); IFileRead fileRead = _BACKLOG.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false);

View File

@ -11,7 +11,7 @@ using System.IO;
using System.Reflection; using System.Reflection;
using System.Text.Json; using System.Text.Json;
namespace Adaptation._Tests.Extract.Production.v2_57_0; namespace Adaptation._Tests.Extract.Development.v2_57_0;
[TestClass] [TestClass]
public class MESAFIBACKLOG public class MESAFIBACKLOG
@ -20,13 +20,13 @@ public class MESAFIBACKLOG
#pragma warning disable CA2254 #pragma warning disable CA2254
#pragma warning disable IDE0060 #pragma warning disable IDE0060
private static CreateSelfDescription.Production.v2_57_0.MESAFIBACKLOG _MESAFIBACKLOG; private static CreateSelfDescription.Development.v2_57_0.MESAFIBACKLOG _MESAFIBACKLOG;
[ClassInitialize] [ClassInitialize]
public static void ClassInitialize(TestContext testContext) public static void ClassInitialize(TestContext testContext)
{ {
CreateSelfDescription.Production.v2_57_0.MESAFIBACKLOG.ClassInitialize(testContext); CreateSelfDescription.Development.v2_57_0.MESAFIBACKLOG.ClassInitialize(testContext);
_MESAFIBACKLOG = CreateSelfDescription.Production.v2_57_0.MESAFIBACKLOG.EAFLoggingUnitTesting; _MESAFIBACKLOG = CreateSelfDescription.Development.v2_57_0.MESAFIBACKLOG.EAFLoggingUnitTesting;
} }
private static void NonThrowTryCatch() private static void NonThrowTryCatch()
@ -40,17 +40,17 @@ public class MESAFIBACKLOG
[Ignore] [Ignore]
#endif #endif
[TestMethod] [TestMethod]
public void Production__v2_57_0__MESAFIBACKLOG__Kanban() => _MESAFIBACKLOG.Production__v2_57_0__MESAFIBACKLOG__Kanban(); public void Development__v2_57_0__MESAFIBACKLOG__Kanban() => _MESAFIBACKLOG.Development__v2_57_0__MESAFIBACKLOG__Kanban();
#if DEBUG #if DEBUG
[Ignore] [Ignore]
#endif #endif
[TestMethod] [TestMethod]
public void Production__v2_57_0__MESAFIBACKLOG__Kanban638323658386612552__Normal() public void Development__v2_57_0__MESAFIBACKLOG__Kanban638323658386612552__Normal()
{ {
string check = "*.json"; string check = "*.json";
bool validatePDSF = false; bool validatePDSF = false;
_MESAFIBACKLOG.Production__v2_57_0__MESAFIBACKLOG__Kanban(); _MESAFIBACKLOG.Development__v2_57_0__MESAFIBACKLOG__Kanban();
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();
Assert.IsFalse(string.IsNullOrEmpty(_MESAFIBACKLOG.AdaptationTesting.TestContext.FullyQualifiedTestClassName)); Assert.IsFalse(string.IsNullOrEmpty(_MESAFIBACKLOG.AdaptationTesting.TestContext.FullyQualifiedTestClassName));
string[] variables = _MESAFIBACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); string[] variables = _MESAFIBACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF);
@ -66,7 +66,7 @@ public class MESAFIBACKLOG
[Ignore] [Ignore]
#endif #endif
[TestMethod] [TestMethod]
public void Production__v2_57_0__MESAFIBACKLOG__Markdown() => _MESAFIBACKLOG.Production__v2_57_0__MESAFIBACKLOG__Markdown(); public void Development__v2_57_0__MESAFIBACKLOG__Markdown() => _MESAFIBACKLOG.Development__v2_57_0__MESAFIBACKLOG__Markdown();
private static ReadOnlyDictionary<string, FileInfo> GetKeyValuePairs(List<FileInfo> collection) private static ReadOnlyDictionary<string, FileInfo> GetKeyValuePairs(List<FileInfo> collection)
{ {
@ -136,11 +136,11 @@ public class MESAFIBACKLOG
[Ignore] [Ignore]
#endif #endif
[TestMethod] [TestMethod]
public void Production__v2_57_0__MESAFIBACKLOG__Markdown638323658386612552__Normal() public void Development__v2_57_0__MESAFIBACKLOG__Markdown638323658386612552__Normal()
{ {
string check = "*.json"; string check = "*.json";
bool validatePDSF = false; bool validatePDSF = false;
_MESAFIBACKLOG.Production__v2_57_0__MESAFIBACKLOG__Markdown(); _MESAFIBACKLOG.Development__v2_57_0__MESAFIBACKLOG__Markdown();
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();
Assert.IsFalse(string.IsNullOrEmpty(_MESAFIBACKLOG.AdaptationTesting.TestContext.FullyQualifiedTestClassName)); Assert.IsFalse(string.IsNullOrEmpty(_MESAFIBACKLOG.AdaptationTesting.TestContext.FullyQualifiedTestClassName));
string[] variables = _MESAFIBACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); string[] variables = _MESAFIBACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF);
@ -165,5 +165,25 @@ public class MESAFIBACKLOG
NonThrowTryCatch(); NonThrowTryCatch();
} }
#if DEBUG
[Ignore]
#endif
[TestMethod]
public void Development__v2_57_0__MESAFIBACKLOG__ADO638323658386612552__Normal()
{
string check = "*.json";
bool validatePDSF = false;
_MESAFIBACKLOG.Development__v2_57_0__MESAFIBACKLOG__ADO();
MethodBase methodBase = new StackFrame().GetMethod();
Assert.IsFalse(string.IsNullOrEmpty(_MESAFIBACKLOG.AdaptationTesting.TestContext.FullyQualifiedTestClassName));
string[] variables = _MESAFIBACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF);
IFileRead fileRead = _MESAFIBACKLOG.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false);
Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResult = fileRead.ReExtract();
Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1));
Assert.IsNotNull(extractResult.Item3);
Assert.IsNotNull(extractResult.Item4);
NonThrowTryCatch();
}
} }
#endif #endif

View File

@ -104,6 +104,8 @@
<Compile Include="Adaptation\Eaf\Management\ConfigurationData\CellAutomation\ModelObjectParameterDefinition.cs" /> <Compile Include="Adaptation\Eaf\Management\ConfigurationData\CellAutomation\ModelObjectParameterDefinition.cs" />
<Compile Include="Adaptation\Eaf\Management\ConfigurationData\CellAutomation\ModelObjectParameterType.cs" /> <Compile Include="Adaptation\Eaf\Management\ConfigurationData\CellAutomation\ModelObjectParameterType.cs" />
<Compile Include="Adaptation\Eaf\Management\ConfigurationData\Semiconductor\CellInstances\SecsConnectionConfiguration.cs" /> <Compile Include="Adaptation\Eaf\Management\ConfigurationData\Semiconductor\CellInstances\SecsConnectionConfiguration.cs" />
<Compile Include="Adaptation\FileHandlers\ADO\FileRead.cs" />
<Compile Include="Adaptation\FileHandlers\ADO\ProcessData.cs" />
<Compile Include="Adaptation\FileHandlers\APC\FileRead.cs" /> <Compile Include="Adaptation\FileHandlers\APC\FileRead.cs" />
<Compile Include="Adaptation\FileHandlers\Archive\FileRead.cs" /> <Compile Include="Adaptation\FileHandlers\Archive\FileRead.cs" />
<Compile Include="Adaptation\FileHandlers\CellInstanceConnectionName.cs" /> <Compile Include="Adaptation\FileHandlers\CellInstanceConnectionName.cs" />