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 = non_public # IDE0060: Remove unused parameter
dotnet_code_quality.CAXXXX.api_surface = private, internal
dotnet_diagnostic.CA1816.severity = none # CA1816: Call GC.SuppressFinalize correctly
dotnet_diagnostic.CA1825.severity = warning # CA1823: Avoid zero-length array allocations
dotnet_diagnostic.CA1510.severity = none # CA1510: Use 'ArgumentNullException.ThrowIfNull' instead of explicitly throwing a new exception instance
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.CA1834.severity = warning # CA1834: Consider using 'StringBuilder.Append(char)' when applicable
dotnet_diagnostic.CA1846.severity = none # CA1846: Prefer AsSpan over Substring

View File

@ -49,6 +49,16 @@
],
"problemMatcher": "$msCompile"
},
{
"label": "Format-Whitespaces",
"command": "dotnet",
"type": "process",
"args": [
"format",
"whitespace"
],
"problemMatcher": "$msCompile"
},
{
"label": "Nuget Clear",
"command": "dotnet",
@ -68,7 +78,7 @@
"args": [
"/target:Build",
"/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",
"/consoleloggerparameters:PerformanceSummary;ErrorsOnly;",
"/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)
#pragma warning restore IDE0060
{
if (dateTime == DateTime.MinValue)
throw new ArgumentNullException(nameof(dateTime));
string logisticsSequence = _Logistics.Sequence.ToString();
string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
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
{
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(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),

View File

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

View File

@ -5,7 +5,6 @@ using Adaptation.Shared.Duplicator;
using Adaptation.Shared.Methods;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Text.Json;
@ -16,8 +15,6 @@ public class FileRead : Shared.FileRead, IFileRead
private long? _TickOffset;
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) :
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);
if (!_IsDuplicator)
throw new Exception(cellInstanceConnectionName);
List<string> cssLines = new();
string cellInstanceNamed = string.Concat("CellInstance.", _EquipmentType);
_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)
NestExistingFiles(_FileConnectorConfiguration);
}
@ -124,7 +109,7 @@ public class FileRead : Shared.FileRead, IFileRead
results.Item4.Add(_Logistics.FileInfo);
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)
throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks));
results = iProcessData.GetResults(this, _Logistics, results.Item4);

View File

@ -7,7 +7,6 @@ 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;
@ -22,14 +21,16 @@ public class ProcessData : IProcessData
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 (url is null)
throw new ArgumentNullException(nameof(url));
fileInfoCollection.Clear();
_Details = new List<object>();
_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) =>
@ -57,147 +58,101 @@ public class ProcessData : IProcessData
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))
_ = Directory.CreateDirectory(destinationDirectory);
bool keepRelations = true;
const string taskWorkItemType = "Task";
string json = File.ReadAllText(logistics.ReportFullPath);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(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);
WriteFileStructure(destinationDirectory, keyValuePairs);
WriteFiles(fileRead, destinationDirectory, fileInfoCollection, fileNameWithoutExtension, keyValuePairs);
WriteKanbanFiles(fileRead, url, cssLines, frontMatterLines, fileInfoCollection, destinationDirectory, keyValuePairs);
if (!Directory.Exists(destinationDirectory))
_ = Directory.CreateDirectory(destinationDirectory);
ReadOnlyDictionary<int, Record> keyValuePairs = GetWorkItems(workItems, keepRelations);
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;
Dictionary<int, WorkItem> keyValuePairs = new();
foreach (WorkItem workItem in workItems)
keyValuePairs.Add(workItem.Id, workItem);
results = GetKeyValuePairs(new(keyValuePairs));
results = GetKeyValuePairs(new(keyValuePairs), keepRelations);
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);
foreach (string directory in collection)
ReadOnlyDictionary<int, string> results;
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)
continue;
if (!Directory.Exists(directory))
_ = Directory.CreateDirectory(directory);
if (!results.TryGetValue(keyValuePair.Key, out directory))
MoveToUnknown(destinationDirectory, keyValuePair.Key, keyValuePair.Value);
else
{
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 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;
string singletonDirectory;
JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
string rootDirectory = Path.Combine(destinationDirectory, fileNameWithoutExtension);
if (string.IsNullOrEmpty(rootDirectory))
throw new NullReferenceException(nameof(rootDirectory));
Record? parent;
foreach (KeyValuePair<int, Record> keyValuePair in keyValuePairs)
{
workItem = keyValuePair.Value.WorkItem;
json = JsonSerializer.Serialize(workItem, jsonSerializerOptions);
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))
if (!collection.TryGetValue(keyValuePair.Key, out directory))
{
old = File.ReadAllText(checkFile);
if (old == json)
if (workItem.WorkItemType != taskWorkItemType || workItem.Parent is not null)
continue;
directory = GetDirectory(destinationDirectory, workItem);
}
File.WriteAllText(checkFile, json);
fileInfo = GetFileInfoAndMaybeWriteFile(directory, workItem);
if (!fileRead.IsEAFHosted)
fileInfoCollection.Add(new(checkFile));
}
}
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));
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 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();
Record record;
List<bool> nests = new();
WorkItem? parentWorkItem;
ReadOnlyCollection<Record> records;
ReadOnlyCollection<Record> childRecords;
ReadOnlyCollection<Record> relatedRecords;
ReadOnlyCollection<Record> successorRecords;
foreach (KeyValuePair<int, WorkItem> keyValuePair in keyValuePairs)
{
nests.Clear();
@ -207,166 +162,111 @@ public class ProcessData : IProcessData
_ = keyValuePairs.TryGetValue(keyValuePair.Value.Parent.Value, out parentWorkItem);
try
{
records = GetKeyValuePairs(keyValuePairs, keyValuePair.Value, nests);
record = Record.Get(keyValuePair.Value, parentWorkItem, records);
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>());
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)
private static ReadOnlyDictionary<int, string> GetCurrentDirectories(string destinationDirectory, ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes)
{
List<string> results = new();
Record record;
Dictionary<int, string> results = new();
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;
List<bool> nests = new();
ReadOnlyCollection<string> childrenDirectories;
string dateDirectory = Path.Combine(destinationDirectory, "_", DateTime.Now.ToString("yyyy-MM-dd"));
WorkItem workItem;
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))
workItem = keyValuePair.Value.WorkItem;
if (!bugUserStoryTaskWorkItemTypes.Contains(workItem.WorkItemType))
continue;
if (record.Parent is not null)
if (workItem.WorkItemType == taskWorkItemType && workItem.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<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);
}
directory = GetDirectory(destinationDirectory, workItem);
results.Add(workItem.Id, directory);
}
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();
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);
if (string.IsNullOrEmpty(destinationDirectory))
throw new ArgumentException($"'{nameof(destinationDirectory)}' {id} 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 int? GetIdFromUrlIfChild(Relation relation)
private static void MoveToNew(string destinationDirectory, int id, string oldDirectory, string newDirectory)
{
int? result;
string[] segments = relation?.Attributes is null || relation.Attributes.Name != "Child" ? Array.Empty<string>() : relation.URL.Split('/');
if (segments.Length < 2)
result = null;
if (Directory.Exists(newDirectory))
MoveToDuplicate(destinationDirectory, id, oldDirectory);
else
{
if (!int.TryParse(segments[segments.Length - 1], out int id))
result = null;
else
result = id;
string directory = Path.GetDirectoryName(newDirectory) ?? throw new NotImplementedException();
if (!Directory.Exists(directory))
_ = Directory.CreateDirectory(directory);
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;
}
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);
}
List<char> spaces = new();
bool keepRelations = false;
List<string> lines = new();
ReadOnlyCollection<Record> results;
ReadOnlyDictionary<int, Record> keyValuePairs = GetWorkItems(workItems);
ReadOnlyDictionary<int, Record> keyValuePairs = GetWorkItems(workItems, keepRelations);
ReadOnlyCollection<Record> records = new(keyValuePairs.Values.ToArray());
WriteFile(fileRead, destinationDirectory, fileInfoCollection, records, "records");
ReadOnlyCollection<string> bugFeatureWorkItemTypes = new(new string[] { "Bug", "Feature" });
ReadOnlyCollection<string> bugUserStoryWorkItemTypes = new(new string[] { "Bug", "User Story" });
ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes = new(new string[] { "Bug", "User Story", "Task" });
@ -179,16 +181,27 @@ public class ProcessData : IProcessData
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;
Dictionary<int, WorkItem> keyValuePairs = new();
foreach (WorkItem workItem in workItems)
keyValuePairs.Add(workItem.Id, workItem);
results = GetKeyValuePairs(new(keyValuePairs));
results = GetKeyValuePairs(new(keyValuePairs), keepRelations);
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)
{
List<Record> filtered = new();
@ -197,7 +210,7 @@ public class ProcessData : IProcessData
{
if (r.WorkItem.State == "Removed" || !workItemTypes.Contains(r.WorkItem.WorkItemType))
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);
}
string json = JsonSerializer.Serialize(filtered, new JsonSerializerOptions() { WriteIndented = true });
@ -272,13 +285,15 @@ public class ProcessData : IProcessData
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();
Record record;
List<bool> nests = new();
WorkItem? parentWorkItem;
ReadOnlyCollection<Record> records;
ReadOnlyCollection<Record> childRecords;
ReadOnlyCollection<Record> relatedRecords;
ReadOnlyCollection<Record> successorRecords;
foreach (KeyValuePair<int, WorkItem> keyValuePair in keyValuePairs)
{
nests.Clear();
@ -288,12 +303,15 @@ public class ProcessData : IProcessData
_ = keyValuePairs.TryGetValue(keyValuePair.Value.Parent.Value, out parentWorkItem);
try
{
records = GetKeyValuePairs(keyValuePairs, keyValuePair.Value, nests);
record = Record.Get(keyValuePair.Value, parentWorkItem, records);
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>());
record = new(keyValuePair.Value, parentWorkItem, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>());
}
results.Add(keyValuePair.Key, record);
}
@ -310,89 +328,9 @@ public class ProcessData : IProcessData
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) =>
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)
{
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(string.Empty);
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);
}
@ -519,7 +457,7 @@ public class ProcessData : IProcessData
violations.Add($"Tag:{record.WorkItem.Tags};");
foreach (Record r in recordsNotMatching)
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);
}
@ -574,7 +512,7 @@ public class ProcessData : IProcessData
violations.Add($"Priority:{record.WorkItem.Priority};");
foreach (Record r in recordsNotMatching)
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);
}
@ -706,7 +644,7 @@ public class ProcessData : IProcessData
violations.Add($"State:{record.WorkItem.State};");
foreach (Record r in recordsNotMatching)
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);
}
@ -744,7 +682,7 @@ public class ProcessData : IProcessData
violations.Add($"State:{record.WorkItem.State};");
foreach (Record r in recordsNotMatching)
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);
}
@ -784,7 +722,7 @@ public class ProcessData : IProcessData
violations.Add($"StartDate:{record.WorkItem.StartDate};");
foreach (Record r in recordsNotMatching)
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);
}

View File

@ -103,10 +103,16 @@ public class FileRead : Shared.FileRead, IFileRead
return results;
}
#pragma warning disable IDE0060
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)

View File

@ -135,16 +135,16 @@ public class FileRead : Shared.FileRead, IFileRead
return result;
}
#pragma warning disable IDE0060
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)
#pragma warning restore IDE0060
{
if (dateTime == DateTime.MinValue)
throw new ArgumentNullException(nameof(dateTime));
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
_Logistics = new Logistics(reportFullPath, pdsf.Item1);

View File

@ -34,4 +34,10 @@ public class Aggregation
[JsonPropertyName("Records")] public ReadOnlyCollection<Record> Records { 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)
#pragma warning restore IDE0060
{
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"};");
results = new(_Logistics.Logistics1[0], Array.Empty<Test>(), Array.Empty<JsonElement>(), new List<FileInfo>());
return results;

View File

@ -108,10 +108,12 @@ public class FileRead : Shared.FileRead, IFileRead
return results;
}
#pragma warning disable IDE0060
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);
_ = _Logistics.Sequence.ToString();
string jobIdDirectory = Path.Combine(_JobIdParentDirectory, _Logistics.JobID);

View File

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

View File

@ -2,8 +2,9 @@ using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WIQL;
public class Column
internal class Column
{
[JsonConstructor]
public Column(
string referenceName,
@ -16,7 +17,14 @@ public class Column
Url = url;
}
public string ReferenceName { get; set; } // { init; get; }
public string Name { get; set; } // { init; get; }
public string Url { get; set; } // { init; get; }
[JsonPropertyName("referenceName")] public string ReferenceName { get; }
[JsonPropertyName("name")] public string Name { 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;
public class Field
internal class Field
{
[JsonConstructor]
public Field(
string referenceName,
@ -16,7 +17,14 @@ public class Field
Url = url;
}
public string ReferenceName { get; set; } // { init; get; }
public string Name { get; set; } // { init; get; }
public string Url { get; set; } // { init; get; }
[JsonPropertyName("referenceName")] public string ReferenceName { get; }
[JsonPropertyName("name")] public string Name { 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;
public class Root
internal class Root
{
[JsonConstructor]
public Root(
string queryType,
@ -23,10 +24,17 @@ public class Root
WorkItems = workItems;
}
public string QueryType { get; set; } // { init; get; }
public string QueryResultType { get; set; } // { init; get; }
public DateTime AsOf { get; set; } // { init; get; }
public Column[] Columns { get; set; } // { init; get; }
public SortColumn[] SortColumns { get; set; } // { init; get; }
public WorkItem[] WorkItems { get; set; } // { init; get; }
[JsonPropertyName("queryType")] public string QueryType { get; }
[JsonPropertyName("queryResultType")] public string QueryResultType { get; }
[JsonPropertyName("asOf")] public DateTime AsOf { get; }
[JsonPropertyName("columns")] public Column[] Columns { get; }
[JsonPropertyName("sortColumns")] public SortColumn[] SortColumns { 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;
public class SortColumn
internal class SortColumn
{
[JsonConstructor]
public SortColumn(
Field field,
@ -14,6 +15,13 @@ public class SortColumn
Descending = descending;
}
public Field Field { get; set; } // { init; get; }
public bool Descending { get; set; } // { init; get; }
[JsonPropertyName("field")] public Field Field { 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;
public class WorkItem
internal class WorkItem
{
[JsonConstructor]
public WorkItem(
int id,
@ -14,6 +15,13 @@ public class WorkItem
Url = url;
}
public int Id { get; set; } // { init; get; }
public string Url { get; set; } // { init; get; }
[JsonPropertyName("id")] public int Id { 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;
public class Attribute
internal class Attribute
{
#nullable enable
[JsonConstructor]
public Attribute(bool isLocked,
string name)
@ -15,7 +13,13 @@ public class Attribute
Name = name;
}
[JsonPropertyName("isLocked")] public bool IsLocked { get; set; }
[JsonPropertyName("name")] public string Name { get; set; }
[JsonPropertyName("isLocked")] public bool IsLocked { get; }
[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;
public class Avatar
internal class Avatar
{
[JsonConstructor]
public Avatar(
string 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;
public class CommentVersionRef
internal class CommentVersionRef
{
[JsonConstructor]
public CommentVersionRef(
int commentId,
@ -16,8 +17,14 @@ public class CommentVersionRef
URL = url;
}
[JsonPropertyName("commentId")] public int CommentId { get; } // { init; get; }
[JsonPropertyName("url")] public string URL { get; } // { init; get; }
[JsonPropertyName("version")] public int Version { get; } // { init; get; }
[JsonPropertyName("commentId")] public int CommentId { get; }
[JsonPropertyName("url")] public string URL { 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;
public class CustomRequester
internal class CustomRequester
{
[JsonConstructor]
public CustomRequester(
string descriptor,
@ -31,4 +32,11 @@ public class CustomRequester
[JsonPropertyName("_links")] public Links Links { get; }
[JsonPropertyName("uniqueName")] public string UniqueName { 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;
public class Fields
internal class Fields
{
#nullable enable
@ -72,35 +72,41 @@ public class Fields
SystemWorkItemType = systemWorkItemType;
}
[JsonPropertyName("Custom.Requester")] public CustomRequester? CustomRequester { get; } // { init; get; }
[JsonPropertyName("Custom.RRminusOE")] public float? CustomRRminusOE { get; } // { init; get; }
[JsonPropertyName("Custom.WSJF")] public float? CustomWSJF { get; } // { init; get; }
[JsonPropertyName("Microsoft.VSTS.Common.ActivatedDate")] public DateTime MicrosoftVSTSCommonActivatedDate { get; } // { init; get; }
[JsonPropertyName("Microsoft.VSTS.Common.BusinessValue")] public float? MicrosoftVSTSCommonBusinessValue { get; } // { init; get; }
[JsonPropertyName("Microsoft.VSTS.Common.ClosedDate")] public DateTime MicrosoftVSTSCommonClosedDate { get; } // { init; get; }
[JsonPropertyName("Microsoft.VSTS.Common.Priority")] public int MicrosoftVSTSCommonPriority { get; } // { init; get; }
[JsonPropertyName("Microsoft.VSTS.Common.ResolvedDate")] public DateTime MicrosoftVSTSCommonResolvedDate { get; } // { init; get; }
[JsonPropertyName("Microsoft.VSTS.Common.StateChangeDate")] public DateTime MicrosoftVSTSCommonStateChangeDate { get; } // { init; get; }
[JsonPropertyName("Microsoft.VSTS.Common.TimeCriticality")] public float? MicrosoftVSTSCommonTimeCriticality { get; } // { init; get; }
[JsonPropertyName("Microsoft.VSTS.Scheduling.Effort")] public float? MicrosoftVSTSSchedulingEffort { get; } // { init; get; }
[JsonPropertyName("Microsoft.VSTS.Scheduling.StartDate")] public DateTime MicrosoftVSTSSchedulingStartDate { get; } // { init; get; }
[JsonPropertyName("Microsoft.VSTS.Scheduling.TargetDate")] public DateTime MicrosoftVSTSSchedulingTargetDate { get; } // { init; get; }
[JsonPropertyName("System.AreaPath")] public string SystemAreaPath { get; } // { init; get; }
[JsonPropertyName("System.AssignedTo")] public SystemAssignedTo? SystemAssignedTo { get; } // { init; get; }
[JsonPropertyName("System.ChangedBy")] public SystemChangedBy SystemChangedBy { get; } // { init; get; }
[JsonPropertyName("System.ChangedDate")] public DateTime SystemChangedDate { get; } // { init; get; }
[JsonPropertyName("System.CommentCount")] public int SystemCommentCount { get; } // { init; get; }
[JsonPropertyName("System.CreatedBy")] public SystemCreatedBy SystemCreatedBy { get; } // { init; get; }
[JsonPropertyName("System.CreatedDate")] public DateTime SystemCreatedDate { get; } // { init; get; }
[JsonPropertyName("System.Description")] public string SystemDescription { get; } // { init; get; }
[JsonPropertyName("System.History")] public string SystemHistory { get; } // { init; get; }
[JsonPropertyName("System.IterationPath")] public string SystemIterationPath { get; } // { init; get; }
[JsonPropertyName("System.Parent")] public int SystemParent { get; } // { init; get; }
[JsonPropertyName("System.Reason")] public string SystemReason { get; } // { init; get; }
[JsonPropertyName("System.State")] public string SystemState { get; } // { init; get; }
[JsonPropertyName("System.Tags")] public string SystemTags { get; } // { init; get; }
[JsonPropertyName("System.TeamProject")] public string SystemTeamProject { get; } // { init; get; }
[JsonPropertyName("System.Title")] public string SystemTitle { get; } // { init; get; }
[JsonPropertyName("System.WorkItemType")] public string SystemWorkItemType { get; } // { init; get; }
[JsonPropertyName("Custom.Requester")] public CustomRequester? CustomRequester { get; }
[JsonPropertyName("Custom.RRminusOE")] public float? CustomRRminusOE { get; }
[JsonPropertyName("Custom.WSJF")] public float? CustomWSJF { get; }
[JsonPropertyName("Microsoft.VSTS.Common.ActivatedDate")] public DateTime MicrosoftVSTSCommonActivatedDate { get; }
[JsonPropertyName("Microsoft.VSTS.Common.BusinessValue")] public float? MicrosoftVSTSCommonBusinessValue { get; }
[JsonPropertyName("Microsoft.VSTS.Common.ClosedDate")] public DateTime MicrosoftVSTSCommonClosedDate { get; }
[JsonPropertyName("Microsoft.VSTS.Common.Priority")] public int MicrosoftVSTSCommonPriority { get; }
[JsonPropertyName("Microsoft.VSTS.Common.ResolvedDate")] public DateTime MicrosoftVSTSCommonResolvedDate { get; }
[JsonPropertyName("Microsoft.VSTS.Common.StateChangeDate")] public DateTime MicrosoftVSTSCommonStateChangeDate { get; }
[JsonPropertyName("Microsoft.VSTS.Common.TimeCriticality")] public float? MicrosoftVSTSCommonTimeCriticality { get; }
[JsonPropertyName("Microsoft.VSTS.Scheduling.Effort")] public float? MicrosoftVSTSSchedulingEffort { get; }
[JsonPropertyName("Microsoft.VSTS.Scheduling.StartDate")] public DateTime MicrosoftVSTSSchedulingStartDate { get; }
[JsonPropertyName("Microsoft.VSTS.Scheduling.TargetDate")] public DateTime MicrosoftVSTSSchedulingTargetDate { get; }
[JsonPropertyName("System.AreaPath")] public string SystemAreaPath { get; }
[JsonPropertyName("System.AssignedTo")] public SystemAssignedTo? SystemAssignedTo { get; }
[JsonPropertyName("System.ChangedBy")] public SystemChangedBy SystemChangedBy { get; }
[JsonPropertyName("System.ChangedDate")] public DateTime SystemChangedDate { get; }
[JsonPropertyName("System.CommentCount")] public int SystemCommentCount { get; }
[JsonPropertyName("System.CreatedBy")] public SystemCreatedBy SystemCreatedBy { get; }
[JsonPropertyName("System.CreatedDate")] public DateTime SystemCreatedDate { get; }
[JsonPropertyName("System.Description")] public string SystemDescription { get; }
[JsonPropertyName("System.History")] public string SystemHistory { get; }
[JsonPropertyName("System.IterationPath")] public string SystemIterationPath { get; }
[JsonPropertyName("System.Parent")] public int SystemParent { get; }
[JsonPropertyName("System.Reason")] public string SystemReason { get; }
[JsonPropertyName("System.State")] public string SystemState { get; }
[JsonPropertyName("System.Tags")] public string SystemTags { get; }
[JsonPropertyName("System.TeamProject")] public string SystemTeamProject { get; }
[JsonPropertyName("System.Title")] public string SystemTitle { 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;
public class Html
internal class Html
{
[JsonConstructor]
public Html(
string 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;
public class Links
internal class Links
{
[JsonConstructor]
public Links(
Avatar avatar
) => Avatar = avatar;
[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.Linq;
using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WorkItems;
public class Record
internal class Record
{
#nullable enable
[JsonConstructor]
public Record(WorkItem workItem, WorkItem? parent, Record[] children)
public Record(WorkItem workItem, WorkItem? parent, Record[] children, Record[] related, Record[] successors)
{
WorkItem = workItem;
Parent = parent;
Children = children;
Related = related;
Successors = successors;
}
public WorkItem WorkItem { get; set; }
public WorkItem? Parent { get; set; }
public Record[] Children { get; set; }
[JsonPropertyName("WorkItem")] public WorkItem WorkItem { get; set; }
[JsonPropertyName("Parent")] public WorkItem? Parent { 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) =>
new(workItem, parent, children.ToArray());
internal static Record GetWithoutNesting(Record record, string? violation)
{
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;
public class Relation
internal class Relation
{
#nullable enable
[JsonConstructor]
public Relation(string rel,
string url,
@ -21,4 +19,16 @@ public class Relation
[JsonPropertyName("rel")] public string Rel { 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;
public class SystemAssignedTo
internal class SystemAssignedTo
{
[JsonConstructor]
public SystemAssignedTo(
string displayName,
@ -32,4 +33,10 @@ public class SystemAssignedTo
[JsonPropertyName("uniqueName")] public string UniqueName { 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;
public class SystemChangedBy
internal class SystemChangedBy
{
[JsonConstructor]
public SystemChangedBy(
string displayName,
@ -32,4 +33,10 @@ public class SystemChangedBy
[JsonPropertyName("uniqueName")] public string UniqueName { 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;
public class SystemCreatedBy
internal class SystemCreatedBy
{
[JsonConstructor]
public SystemCreatedBy(
string displayName,
@ -32,4 +33,10 @@ public class SystemCreatedBy
[JsonPropertyName("uniqueName")] public string UniqueName { 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;
public class Value
internal class Value
{
[JsonConstructor]
public Value(
int id,
@ -28,4 +29,11 @@ public class Value
[JsonPropertyName("relations")] public Relation[] Relations { get; }
[JsonPropertyName("rev")] public int Rev { 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;
public class WorkItem
internal class WorkItem
{
#nullable enable
@ -70,68 +70,78 @@ public class WorkItem
public override string ToString() => $"{Id} - {WorkItemType} - {Title}";
public static Record Get(Record record, string? violation)
public static WorkItem? GetWithOutRelations(WorkItem? workItem)
{
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>());
WorkItem? result = workItem is null ? null : new(workItem.ActivatedDate,
workItem.AreaPath,
workItem.AssignedTo,
workItem.BusinessValue,
workItem.ChangedDate,
workItem.ClosedDate,
workItem.CommentCount,
workItem.CreatedDate,
workItem.Description,
workItem.Effort,
workItem.Id,
workItem.IterationPath,
workItem.Parent,
workItem.Priority,
Array.Empty<Relation>(),
workItem.Requester,
workItem.ResolvedDate,
workItem.Revision,
workItem.RiskReductionMinusOpportunityEnablement,
workItem.StartDate,
workItem.State,
workItem.Tags,
workItem.TargetDate,
workItem.TimeCriticality,
workItem.Title,
workItem.Violation,
workItem.WeightedShortestJobFirst,
workItem.WorkItemType);
return result;
}
public DateTime? ActivatedDate { get; set; }
public string AreaPath { get; set; }
public string? AssignedTo { get; set; }
public long? BusinessValue { get; set; }
public DateTime ChangedDate { get; set; }
public DateTime? ClosedDate { get; set; }
public int CommentCount { get; set; }
public DateTime CreatedDate { get; set; }
public string Description { get; set; }
public long? Effort { get; set; }
public int Id { get; set; }
public string IterationPath { get; set; }
public int? Parent { get; set; }
public int? Priority { get; set; }
public Relation[]? Relations { get; set; }
public string? Requester { get; set; }
public DateTime? ResolvedDate { get; set; }
public int Revision { get; set; }
public long? RiskReductionMinusOpportunityEnablement { get; set; }
public DateTime? StartDate { get; set; }
public string State { get; set; }
public string Tags { get; set; }
public DateTime? TargetDate { get; set; }
public long? TimeCriticality { get; set; }
public string Title { get; set; }
public string? Violation { get; set; }
public string WorkItemType { get; set; }
public long? WeightedShortestJobFirst { get; set; }
[JsonPropertyName("ActivatedDate")] public DateTime? ActivatedDate { get; }
[JsonPropertyName("AreaPath")] public string AreaPath { get; }
[JsonPropertyName("AssignedTo")] public string? AssignedTo { get; }
[JsonPropertyName("BusinessValue")] public long? BusinessValue { get; }
[JsonPropertyName("ChangedDate")] public DateTime ChangedDate { get; }
[JsonPropertyName("ClosedDate")] public DateTime? ClosedDate { get; }
[JsonPropertyName("CommentCount")] public int CommentCount { get; }
[JsonPropertyName("CreatedDate")] public DateTime CreatedDate { get; }
[JsonPropertyName("Description")] public string Description { get; }
[JsonPropertyName("Effort")] public long? Effort { get; }
[JsonPropertyName("Id")] public int Id { get; }
[JsonPropertyName("IterationPath")] public string IterationPath { get; }
[JsonPropertyName("Parent")] public int? Parent { get; }
[JsonPropertyName("Priority")] public int? Priority { get; }
[JsonPropertyName("Relations")] public Relation[]? Relations { get; }
[JsonPropertyName("Requester")] public string? Requester { get; }
[JsonPropertyName("ResolvedDate")] public DateTime? ResolvedDate { get; }
[JsonPropertyName("Revision")] public int Revision { get; }
[JsonPropertyName("RiskReductionMinusOpportunityEnablement")] public long? RiskReductionMinusOpportunityEnablement { get; }
[JsonPropertyName("StartDate")] public DateTime? StartDate { get; }
[JsonPropertyName("State")] public string State { get; }
[JsonPropertyName("Tags")] public string Tags { get; }
[JsonPropertyName("TargetDate")] public DateTime? TargetDate { get; }
[JsonPropertyName("TimeCriticality")] public long? TimeCriticality { get; }
[JsonPropertyName("Title")] public string Title { get; }
[JsonPropertyName("Violation")] public string? Violation { get; }
[JsonPropertyName("WeightedShortestJobFirst")] public long? WeightedShortestJobFirst { get; }
[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.Reflection;
namespace Adaptation._Tests.CreateSelfDescription.Production.v2_57_0;
namespace Adaptation._Tests.CreateSelfDescription.Development.v2_57_0;
[TestClass]
public class ALIGNMENT_EQPT : EAFLoggingUnitTesting
@ -52,7 +52,7 @@ public class ALIGNMENT_EQPT : EAFLoggingUnitTesting
[Ignore]
#endif
[TestMethod]
public void Production__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile()
public void Development__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile()
{
string check = ".xlsx";
MethodBase methodBase = new StackFrame().GetMethod();

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@ using System.Diagnostics;
using System.IO;
using System.Reflection;
namespace Adaptation._Tests.CreateSelfDescription.Production.v2_57_0;
namespace Adaptation._Tests.CreateSelfDescription.Development.v2_57_0;
[TestClass]
public class MESAFIBACKLOG : EAFLoggingUnitTesting
@ -52,7 +52,7 @@ public class MESAFIBACKLOG : EAFLoggingUnitTesting
[Ignore]
#endif
[TestMethod]
public void Production__v2_57_0__MESAFIBACKLOG__Kanban()
public void Development__v2_57_0__MESAFIBACKLOG__Kanban()
{
string check = "*.json";
MethodBase methodBase = new StackFrame().GetMethod();
@ -65,7 +65,20 @@ public class MESAFIBACKLOG : EAFLoggingUnitTesting
[Ignore]
#endif
[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";
MethodBase methodBase = new StackFrame().GetMethod();

View File

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

View File

@ -9,7 +9,7 @@ using System.IO;
using System.Reflection;
using System.Text.Json;
namespace Adaptation._Tests.Extract.Production.v2_57_0;
namespace Adaptation._Tests.Extract.Development.v2_57_0;
[TestClass]
public class ALIGNMENT
@ -18,13 +18,13 @@ public class ALIGNMENT
#pragma warning disable CA2254
#pragma warning disable IDE0060
private static CreateSelfDescription.Production.v2_57_0.ALIGNMENT _ALIGNMENT;
private static CreateSelfDescription.Development.v2_57_0.ALIGNMENT _ALIGNMENT;
[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
CreateSelfDescription.Production.v2_57_0.ALIGNMENT.ClassInitialize(testContext);
_ALIGNMENT = CreateSelfDescription.Production.v2_57_0.ALIGNMENT.EAFLoggingUnitTesting;
CreateSelfDescription.Development.v2_57_0.ALIGNMENT.ClassInitialize(testContext);
_ALIGNMENT = CreateSelfDescription.Development.v2_57_0.ALIGNMENT.EAFLoggingUnitTesting;
}
private static void NonThrowTryCatch()
@ -38,18 +38,18 @@ public class ALIGNMENT
[Ignore]
#endif
[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
[Ignore]
#endif
[TestMethod]
public void Production__v2_57_0__ALIGNMENT__ConvertExcelToJson638353030755467303__Normal()
public void Development__v2_57_0__ALIGNMENT__ConvertExcelToJson638353030755467303__Normal()
{
string check = "*.xlsx";
bool validatePDSF = false;
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));
string[] variables = _ALIGNMENT.AdaptationTesting.GetVariables(methodBase, check, validatePDSF);
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.Threading;
namespace Adaptation._Tests.Extract.Production.v2_57_0;
namespace Adaptation._Tests.Extract.Development.v2_57_0;
[TestClass]
public class BACKLOG_EQPT
@ -14,13 +14,13 @@ public class BACKLOG_EQPT
#pragma warning disable CA2254
#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]
public static void ClassInitialize(TestContext testContext)
{
CreateSelfDescription.Production.v2_57_0.BACKLOG_EQPT.ClassInitialize(testContext);
_BACKLOG_EQPT = CreateSelfDescription.Production.v2_57_0.BACKLOG_EQPT.EAFLoggingUnitTesting;
CreateSelfDescription.Development.v2_57_0.BACKLOG_EQPT.ClassInitialize(testContext);
_BACKLOG_EQPT = CreateSelfDescription.Development.v2_57_0.BACKLOG_EQPT.EAFLoggingUnitTesting;
}
private static void NonThrowTryCatch()
@ -32,16 +32,16 @@ public class BACKLOG_EQPT
[Ignore]
[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]
[TestMethod]
public void Production__v2_57_0__BACKLOG_EQPT__DownloadWorkItems638612245609095845__Normal()
public void Development__v2_57_0__BACKLOG_EQPT__DownloadWorkItems638612245609095845__Normal()
{
string check = ".json";
bool validatePDSF = false;
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);
for (int i = 0; i < int.MinValue; i++)
Thread.Sleep(500);

View File

@ -9,7 +9,7 @@ using System.IO;
using System.Reflection;
using System.Text.Json;
namespace Adaptation._Tests.Extract.Production.v2_57_0;
namespace Adaptation._Tests.Extract.Development.v2_57_0;
[TestClass]
public class BACKLOG
@ -18,13 +18,13 @@ public class BACKLOG
#pragma warning disable CA2254
#pragma warning disable IDE0060
private static CreateSelfDescription.Production.v2_57_0.BACKLOG _BACKLOG;
private static CreateSelfDescription.Development.v2_57_0.BACKLOG _BACKLOG;
[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
CreateSelfDescription.Production.v2_57_0.BACKLOG.ClassInitialize(testContext);
_BACKLOG = CreateSelfDescription.Production.v2_57_0.BACKLOG.EAFLoggingUnitTesting;
CreateSelfDescription.Development.v2_57_0.BACKLOG.ClassInitialize(testContext);
_BACKLOG = CreateSelfDescription.Development.v2_57_0.BACKLOG.EAFLoggingUnitTesting;
}
private static void NonThrowTryCatch()
@ -38,18 +38,18 @@ public class BACKLOG
[Ignore]
#endif
[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
[Ignore]
#endif
[TestMethod]
public void Production__v2_57_0__BACKLOG__json638612245609095846__Normal()
public void Development__v2_57_0__BACKLOG__json638612245609095846__Normal()
{
string check = "*.json";
bool validatePDSF = false;
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));
string[] variables = _BACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF);
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.Text.Json;
namespace Adaptation._Tests.Extract.Production.v2_57_0;
namespace Adaptation._Tests.Extract.Development.v2_57_0;
[TestClass]
public class MESAFIBACKLOG
@ -20,13 +20,13 @@ public class MESAFIBACKLOG
#pragma warning disable CA2254
#pragma warning disable IDE0060
private static CreateSelfDescription.Production.v2_57_0.MESAFIBACKLOG _MESAFIBACKLOG;
private static CreateSelfDescription.Development.v2_57_0.MESAFIBACKLOG _MESAFIBACKLOG;
[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
CreateSelfDescription.Production.v2_57_0.MESAFIBACKLOG.ClassInitialize(testContext);
_MESAFIBACKLOG = CreateSelfDescription.Production.v2_57_0.MESAFIBACKLOG.EAFLoggingUnitTesting;
CreateSelfDescription.Development.v2_57_0.MESAFIBACKLOG.ClassInitialize(testContext);
_MESAFIBACKLOG = CreateSelfDescription.Development.v2_57_0.MESAFIBACKLOG.EAFLoggingUnitTesting;
}
private static void NonThrowTryCatch()
@ -40,17 +40,17 @@ public class MESAFIBACKLOG
[Ignore]
#endif
[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
[Ignore]
#endif
[TestMethod]
public void Production__v2_57_0__MESAFIBACKLOG__Kanban638323658386612552__Normal()
public void Development__v2_57_0__MESAFIBACKLOG__Kanban638323658386612552__Normal()
{
string check = "*.json";
bool validatePDSF = false;
_MESAFIBACKLOG.Production__v2_57_0__MESAFIBACKLOG__Kanban();
_MESAFIBACKLOG.Development__v2_57_0__MESAFIBACKLOG__Kanban();
MethodBase methodBase = new StackFrame().GetMethod();
Assert.IsFalse(string.IsNullOrEmpty(_MESAFIBACKLOG.AdaptationTesting.TestContext.FullyQualifiedTestClassName));
string[] variables = _MESAFIBACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF);
@ -66,7 +66,7 @@ public class MESAFIBACKLOG
[Ignore]
#endif
[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)
{
@ -136,11 +136,11 @@ public class MESAFIBACKLOG
[Ignore]
#endif
[TestMethod]
public void Production__v2_57_0__MESAFIBACKLOG__Markdown638323658386612552__Normal()
public void Development__v2_57_0__MESAFIBACKLOG__Markdown638323658386612552__Normal()
{
string check = "*.json";
bool validatePDSF = false;
_MESAFIBACKLOG.Production__v2_57_0__MESAFIBACKLOG__Markdown();
_MESAFIBACKLOG.Development__v2_57_0__MESAFIBACKLOG__Markdown();
MethodBase methodBase = new StackFrame().GetMethod();
Assert.IsFalse(string.IsNullOrEmpty(_MESAFIBACKLOG.AdaptationTesting.TestContext.FullyQualifiedTestClassName));
string[] variables = _MESAFIBACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF);
@ -165,5 +165,25 @@ public class MESAFIBACKLOG
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

View File

@ -104,6 +104,8 @@
<Compile Include="Adaptation\Eaf\Management\ConfigurationData\CellAutomation\ModelObjectParameterDefinition.cs" />
<Compile Include="Adaptation\Eaf\Management\ConfigurationData\CellAutomation\ModelObjectParameterType.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\Archive\FileRead.cs" />
<Compile Include="Adaptation\FileHandlers\CellInstanceConnectionName.cs" />