Try Catch on Serialize
Better Relation Data
This commit is contained in:
parent
3fa7998ff6
commit
0505330ac5
@ -145,9 +145,9 @@ public class ProcessData : IProcessData
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
childRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Child", nests, keepRelations); // Forward
|
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
|
relatedRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Related", nests, keepRelations); // Related
|
||||||
successorRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Successor", nests, keepRelations); // Forward
|
successorRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Successor", nests, keepRelations); // Forward
|
||||||
|
// predecessorRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Predecessor", nests, keepRelations); // Reverse
|
||||||
record = Record.Get(keyValuePair.Value, parentWorkItem, childRecords, relatedRecords, successorRecords, keepRelations);
|
record = Record.Get(keyValuePair.Value, parentWorkItem, childRecords, relatedRecords, successorRecords, keepRelations);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
@ -223,7 +223,10 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
||||||
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
||||||
try
|
try
|
||||||
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
|
{
|
||||||
|
_SMTP.SendHighPriorityEmailMessage(subject, body);
|
||||||
|
File.WriteAllText(".email", body);
|
||||||
|
}
|
||||||
catch (Exception) { }
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
@ -238,7 +241,10 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
||||||
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
||||||
try
|
try
|
||||||
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
|
{
|
||||||
|
_SMTP.SendHighPriorityEmailMessage(subject, body);
|
||||||
|
File.WriteAllText(".email", body);
|
||||||
|
}
|
||||||
catch (Exception) { }
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,10 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
||||||
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
||||||
try
|
try
|
||||||
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
|
{
|
||||||
|
_SMTP.SendHighPriorityEmailMessage(subject, body);
|
||||||
|
File.WriteAllText(".email", body);
|
||||||
|
}
|
||||||
catch (Exception) { }
|
catch (Exception) { }
|
||||||
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Critical.ToString(), exception.Message, exception.StackTrace });
|
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Critical.ToString(), exception.Message, exception.StackTrace });
|
||||||
_ = monIn.SendStatus(site, monARessource, stateName, State.Critical);
|
_ = monIn.SendStatus(site, monARessource, stateName, State.Critical);
|
||||||
@ -265,7 +268,10 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
||||||
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
||||||
try
|
try
|
||||||
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
|
{
|
||||||
|
_SMTP.SendHighPriorityEmailMessage(subject, body);
|
||||||
|
File.WriteAllText(".email", body);
|
||||||
|
}
|
||||||
catch (Exception) { }
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
@ -278,7 +284,10 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
||||||
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
||||||
try
|
try
|
||||||
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
|
{
|
||||||
|
_SMTP.SendHighPriorityEmailMessage(subject, body);
|
||||||
|
File.WriteAllText(".email", body);
|
||||||
|
}
|
||||||
catch (Exception) { }
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
@ -71,7 +72,7 @@ public class ProcessData : IProcessData
|
|||||||
_ = Directory.CreateDirectory(destinationDirectory);
|
_ = Directory.CreateDirectory(destinationDirectory);
|
||||||
ReadOnlyDictionary<int, Record> keyValuePairs = GetWorkItems(workItems, keepRelations);
|
ReadOnlyDictionary<int, Record> keyValuePairs = GetWorkItems(workItems, keepRelations);
|
||||||
ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes = new(new string[] { "Bug", "User Story", "Task" });
|
ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes = new(new string[] { "Bug", "User Story", "Task" });
|
||||||
ReadOnlyDictionary<int, string> collection = MoveCurrentAndGetExpectedDirectories(taskWorkItemType, destinationDirectory, bugUserStoryTaskWorkItemTypes, keyValuePairs);
|
ReadOnlyDictionary<int, string> collection = MoveCurrentAndGetExpectedDirectoriesAndFileCopy(taskWorkItemType, destinationDirectory, json, bugUserStoryTaskWorkItemTypes, keyValuePairs);
|
||||||
WriteFiles(fileRead, fileInfoCollection, taskWorkItemType, destinationDirectory, keyValuePairs, collection);
|
WriteFiles(fileRead, fileInfoCollection, taskWorkItemType, destinationDirectory, keyValuePairs, collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,12 +86,12 @@ public class ProcessData : IProcessData
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReadOnlyDictionary<int, string> MoveCurrentAndGetExpectedDirectories(string taskWorkItemType, string destinationDirectory, ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes, ReadOnlyDictionary<int, Record> keyValuePairs)
|
private static ReadOnlyDictionary<int, string> MoveCurrentAndGetExpectedDirectoriesAndFileCopy(string taskWorkItemType, string destinationDirectory, string json, ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes, ReadOnlyDictionary<int, Record> keyValuePairs)
|
||||||
{
|
{
|
||||||
ReadOnlyDictionary<int, string> results;
|
ReadOnlyDictionary<int, string> results;
|
||||||
string? directory;
|
string? directory;
|
||||||
ReadOnlyDictionary<int, string> collection = GetCurrentDirectories(destinationDirectory, bugUserStoryTaskWorkItemTypes);
|
ReadOnlyDictionary<int, string> collection = GetCurrentDirectories(destinationDirectory, bugUserStoryTaskWorkItemTypes);
|
||||||
results = GetExpectedDirectories(taskWorkItemType, destinationDirectory, bugUserStoryTaskWorkItemTypes, keyValuePairs);
|
results = GetExpectedDirectoriesAndFileCopy(taskWorkItemType, destinationDirectory, json, bugUserStoryTaskWorkItemTypes, keyValuePairs);
|
||||||
foreach (KeyValuePair<int, string> keyValuePair in collection)
|
foreach (KeyValuePair<int, string> keyValuePair in collection)
|
||||||
{
|
{
|
||||||
if (!results.TryGetValue(keyValuePair.Key, out directory))
|
if (!results.TryGetValue(keyValuePair.Key, out directory))
|
||||||
@ -109,12 +110,18 @@ public class ProcessData : IProcessData
|
|||||||
private static FileInfo GetFileInfoAndMaybeWriteFile(string directory, WorkItem workItem)
|
private static FileInfo GetFileInfoAndMaybeWriteFile(string directory, WorkItem workItem)
|
||||||
{
|
{
|
||||||
FileInfo result;
|
FileInfo result;
|
||||||
string json;
|
string json = JsonSerializer.Serialize(workItem, WorkItemSourceGenerationContext.Default.WorkItem);
|
||||||
json = JsonSerializer.Serialize(workItem, WorkItemSourceGenerationContext.Default.WorkItem);
|
|
||||||
string singletonDirectory = Path.Combine(directory, $"{workItem.Id}");
|
string singletonDirectory = Path.Combine(directory, $"{workItem.Id}");
|
||||||
if (!Directory.Exists(singletonDirectory))
|
if (Directory.Exists(singletonDirectory))
|
||||||
_ = Directory.CreateDirectory(singletonDirectory);
|
{
|
||||||
result = new(Path.Combine(singletonDirectory, ".json"));
|
List<string> files = Directory.GetFiles(singletonDirectory, "*", SearchOption.AllDirectories).ToList();
|
||||||
|
string checkFile = Path.Combine(singletonDirectory, ".json");
|
||||||
|
if (files.Remove(checkFile))
|
||||||
|
File.Delete(checkFile);
|
||||||
|
if (files.Count == 0)
|
||||||
|
Directory.Delete(singletonDirectory);
|
||||||
|
}
|
||||||
|
result = new(Path.Combine(directory, $"{workItem.Id}.json"));
|
||||||
string old = result.Exists ? File.ReadAllText(result.FullName) : string.Empty;
|
string old = result.Exists ? File.ReadAllText(result.FullName) : string.Empty;
|
||||||
if (old != json)
|
if (old != json)
|
||||||
File.WriteAllText(result.FullName, json);
|
File.WriteAllText(result.FullName, json);
|
||||||
@ -126,7 +133,6 @@ public class ProcessData : IProcessData
|
|||||||
string? directory;
|
string? directory;
|
||||||
FileInfo fileInfo;
|
FileInfo fileInfo;
|
||||||
WorkItem workItem;
|
WorkItem workItem;
|
||||||
Record? parent;
|
|
||||||
foreach (KeyValuePair<int, Record> keyValuePair in keyValuePairs)
|
foreach (KeyValuePair<int, Record> keyValuePair in keyValuePairs)
|
||||||
{
|
{
|
||||||
workItem = keyValuePair.Value.WorkItem;
|
workItem = keyValuePair.Value.WorkItem;
|
||||||
@ -139,8 +145,6 @@ public class ProcessData : IProcessData
|
|||||||
fileInfo = GetFileInfoAndMaybeWriteFile(directory, workItem);
|
fileInfo = GetFileInfoAndMaybeWriteFile(directory, workItem);
|
||||||
if (!fileRead.IsEAFHosted)
|
if (!fileRead.IsEAFHosted)
|
||||||
fileInfoCollection.Add(fileInfo);
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,9 +167,9 @@ public class ProcessData : IProcessData
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
childRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Child", nests, keepRelations); // Forward
|
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
|
relatedRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Related", nests, keepRelations); // Related
|
||||||
successorRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Successor", nests, keepRelations); // Forward
|
successorRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Successor", nests, keepRelations); // Forward
|
||||||
|
// predecessorRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Predecessor", nests, keepRelations); // Reverse
|
||||||
record = Record.Get(keyValuePair.Value, parentWorkItem, childRecords, relatedRecords, successorRecords, keepRelations);
|
record = Record.Get(keyValuePair.Value, parentWorkItem, childRecords, relatedRecords, successorRecords, keepRelations);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
@ -205,14 +209,32 @@ public class ProcessData : IProcessData
|
|||||||
return new(results);
|
return new(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReadOnlyDictionary<int, string> GetExpectedDirectories(string taskWorkItemType, string destinationDirectory, ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes, ReadOnlyDictionary<int, Record> keyValuePairs)
|
private static void FileCopy(string destinationDirectory, string json, List<string> distinct)
|
||||||
|
{
|
||||||
|
string old;
|
||||||
|
string checkFile;
|
||||||
|
foreach (string iterationPath in distinct)
|
||||||
|
{
|
||||||
|
checkFile = Path.Combine(destinationDirectory, iterationPath, "[].json");
|
||||||
|
old = File.Exists(checkFile) ? File.ReadAllText(checkFile) : string.Empty;
|
||||||
|
if (old != json)
|
||||||
|
File.WriteAllText(checkFile, json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ReadOnlyDictionary<int, string> GetExpectedDirectoriesAndFileCopy(string taskWorkItemType, string destinationDirectory, string json, ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes, ReadOnlyDictionary<int, Record> keyValuePairs)
|
||||||
{
|
{
|
||||||
Dictionary<int, string> results = new();
|
Dictionary<int, string> results = new();
|
||||||
string directory;
|
string directory;
|
||||||
WorkItem workItem;
|
WorkItem workItem;
|
||||||
|
string iterationPath;
|
||||||
|
List<string> distinct = new();
|
||||||
foreach (KeyValuePair<int, Record> keyValuePair in keyValuePairs)
|
foreach (KeyValuePair<int, Record> keyValuePair in keyValuePairs)
|
||||||
{
|
{
|
||||||
workItem = keyValuePair.Value.WorkItem;
|
workItem = keyValuePair.Value.WorkItem;
|
||||||
|
iterationPath = workItem.IterationPath.Replace(" ", "-");
|
||||||
|
if (!distinct.Contains(iterationPath))
|
||||||
|
distinct.Add(iterationPath);
|
||||||
if (!bugUserStoryTaskWorkItemTypes.Contains(workItem.WorkItemType))
|
if (!bugUserStoryTaskWorkItemTypes.Contains(workItem.WorkItemType))
|
||||||
continue;
|
continue;
|
||||||
if (workItem.WorkItemType == taskWorkItemType && workItem.Parent is not null)
|
if (workItem.WorkItemType == taskWorkItemType && workItem.Parent is not null)
|
||||||
@ -220,6 +242,8 @@ public class ProcessData : IProcessData
|
|||||||
directory = GetDirectory(destinationDirectory, workItem);
|
directory = GetDirectory(destinationDirectory, workItem);
|
||||||
results.Add(workItem.Id, directory);
|
results.Add(workItem.Id, directory);
|
||||||
}
|
}
|
||||||
|
if (distinct.Count > 0)
|
||||||
|
FileCopy(destinationDirectory, json, distinct);
|
||||||
return new(results);
|
return new(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ using Adaptation.Shared;
|
|||||||
using Adaptation.Shared.Duplicator;
|
using Adaptation.Shared.Duplicator;
|
||||||
using Adaptation.Shared.Methods;
|
using Adaptation.Shared.Methods;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Microsoft.VisualStudio.Services.Common;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
@ -81,15 +80,16 @@ public class ProcessData : IProcessData
|
|||||||
List<char> spaces = new();
|
List<char> spaces = new();
|
||||||
bool keepRelations = false;
|
bool keepRelations = false;
|
||||||
List<string> lines = new();
|
List<string> lines = new();
|
||||||
|
List<string> messages = new();
|
||||||
ReadOnlyCollection<Record> results;
|
ReadOnlyCollection<Record> results;
|
||||||
ReadOnlyDictionary<int, Record> keyValuePairs = GetWorkItems(workItems, keepRelations);
|
ReadOnlyDictionary<int, Record> keyValuePairs = GetWorkItems(workItems, keepRelations);
|
||||||
ReadOnlyCollection<Record> records = new(keyValuePairs.Values.ToArray());
|
ReadOnlyCollection<Record> records = new(keyValuePairs.Values.ToArray());
|
||||||
WriteFile(fileRead, destinationDirectory, fileInfoCollection, records, "records");
|
|
||||||
ReadOnlyCollection<string> bugFeatureWorkItemTypes = new(new string[] { "Bug", "Feature" });
|
ReadOnlyCollection<string> bugFeatureWorkItemTypes = new(new string[] { "Bug", "Feature" });
|
||||||
ReadOnlyCollection<string> bugUserStoryWorkItemTypes = new(new string[] { "Bug", "User Story" });
|
ReadOnlyCollection<string> bugUserStoryWorkItemTypes = new(new string[] { "Bug", "User Story" });
|
||||||
ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes = new(new string[] { "Bug", "User Story", "Task" });
|
ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes = new(new string[] { "Bug", "User Story", "Task" });
|
||||||
WriteWithPartentsFile(fileRead, destinationDirectory, fileInfoCollection, records, bugFeatureWorkItemTypes, "bugs-features-with-parents");
|
messages.AddRange(WriteFile(fileRead, destinationDirectory, fileInfoCollection, records, "records"));
|
||||||
WriteWithPartentsFile(fileRead, destinationDirectory, fileInfoCollection, records, bugUserStoryWorkItemTypes, "bugs-user-stories-with-parents");
|
messages.AddRange(WriteWithPartentsFile(fileRead, destinationDirectory, fileInfoCollection, records, bugFeatureWorkItemTypes, "bugs-features-with-parents"));
|
||||||
|
messages.AddRange(WriteWithPartentsFile(fileRead, destinationDirectory, fileInfoCollection, records, bugUserStoryWorkItemTypes, "bugs-user-stories-with-parents"));
|
||||||
foreach (string workItemType in workItemTypes)
|
foreach (string workItemType in workItemTypes)
|
||||||
{
|
{
|
||||||
lines.Clear();
|
lines.Clear();
|
||||||
@ -154,6 +154,8 @@ public class ProcessData : IProcessData
|
|||||||
WriteFiles(fileRead, destinationDirectory, fileInfoCollection, new(lines), results, "check-122517");
|
WriteFiles(fileRead, destinationDirectory, fileInfoCollection, new(lines), results, "check-122517");
|
||||||
_Details.Add(results);
|
_Details.Add(results);
|
||||||
}
|
}
|
||||||
|
if (messages.Count > 0)
|
||||||
|
throw new Exception($"{messages.Count}{Environment.NewLine}{string.Join(Environment.NewLine, messages)}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void WriteFiles(IFileRead fileRead, string destinationDirectory, List<FileInfo> fileInfoCollection, ReadOnlyCollection<string> lines, ReadOnlyCollection<Record> records, string fileName)
|
private static void WriteFiles(IFileRead fileRead, string destinationDirectory, List<FileInfo> fileInfoCollection, ReadOnlyCollection<string> lines, ReadOnlyCollection<Record> records, string fileName)
|
||||||
@ -191,19 +193,41 @@ public class ProcessData : IProcessData
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void WriteFile(IFileRead fileRead, string destinationDirectory, List<FileInfo> fileInfoCollection, ReadOnlyCollection<Record> records, string fileName)
|
private static string? GetJson(IEnumerable<Record> records, List<string> results)
|
||||||
{
|
{
|
||||||
string json = JsonSerializer.Serialize(records, new JsonSerializerOptions() { WriteIndented = true });
|
string? result;
|
||||||
|
try
|
||||||
|
{ result = JsonSerializer.Serialize(records.ToArray(), RecordCollectionSourceGenerationContext.Default.RecordArray); }
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
result = null;
|
||||||
|
foreach (Record record in records)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{ _ = JsonSerializer.Serialize(record, RecordSourceGenerationContext.Default.Record); }
|
||||||
|
catch (Exception ex)
|
||||||
|
{ results.Add($"Record {record.WorkItem.Id} is not serializable!{Environment.NewLine}{ex.Message}"); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ReadOnlyCollection<string> WriteFile(IFileRead fileRead, string destinationDirectory, List<FileInfo> fileInfoCollection, ReadOnlyCollection<Record> records, string fileName)
|
||||||
|
{
|
||||||
|
List<string> results = new();
|
||||||
|
string? json = GetJson(records, results);
|
||||||
string jsonFile = Path.Combine(destinationDirectory, $"{fileName}.json");
|
string jsonFile = Path.Combine(destinationDirectory, $"{fileName}.json");
|
||||||
string jsonOld = !File.Exists(jsonFile) ? string.Empty : File.ReadAllText(jsonFile);
|
string jsonOld = !File.Exists(jsonFile) ? string.Empty : File.ReadAllText(jsonFile);
|
||||||
if (json != jsonOld)
|
if (!string.IsNullOrEmpty(json) && json != jsonOld)
|
||||||
File.WriteAllText(jsonFile, json);
|
File.WriteAllText(jsonFile, json);
|
||||||
if (!fileRead.IsEAFHosted)
|
if (!fileRead.IsEAFHosted)
|
||||||
fileInfoCollection.Add(new(jsonFile));
|
fileInfoCollection.Add(new(jsonFile));
|
||||||
|
return new(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void WriteWithPartentsFile(IFileRead fileRead, string destinationDirectory, List<FileInfo> fileInfoCollection, ReadOnlyCollection<Record> records, ReadOnlyCollection<string> workItemTypes, string fileName)
|
private static ReadOnlyCollection<string> WriteWithPartentsFile(IFileRead fileRead, string destinationDirectory, List<FileInfo> fileInfoCollection, ReadOnlyCollection<Record> records, ReadOnlyCollection<string> workItemTypes, string fileName)
|
||||||
{
|
{
|
||||||
|
List<string> results = new();
|
||||||
List<Record> filtered = new();
|
List<Record> filtered = new();
|
||||||
Record record;
|
Record record;
|
||||||
foreach (Record r in records)
|
foreach (Record r in records)
|
||||||
@ -213,13 +237,14 @@ public class ProcessData : IProcessData
|
|||||||
record = new(r.WorkItem, r.Parent, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>());
|
record = new(r.WorkItem, r.Parent, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>());
|
||||||
filtered.Add(record);
|
filtered.Add(record);
|
||||||
}
|
}
|
||||||
string json = JsonSerializer.Serialize(filtered, new JsonSerializerOptions() { WriteIndented = true });
|
string? json = GetJson(filtered, results);
|
||||||
string jsonFile = Path.Combine(destinationDirectory, $"{fileName}.json");
|
string jsonFile = Path.Combine(destinationDirectory, $"{fileName}.json");
|
||||||
string jsonOld = !File.Exists(jsonFile) ? string.Empty : File.ReadAllText(jsonFile);
|
string jsonOld = !File.Exists(jsonFile) ? string.Empty : File.ReadAllText(jsonFile);
|
||||||
if (json != jsonOld)
|
if (!string.IsNullOrEmpty(json) && json != jsonOld)
|
||||||
File.WriteAllText(jsonFile, json);
|
File.WriteAllText(jsonFile, json);
|
||||||
if (!fileRead.IsEAFHosted)
|
if (!fileRead.IsEAFHosted)
|
||||||
fileInfoCollection.Add(new(jsonFile));
|
fileInfoCollection.Add(new(jsonFile));
|
||||||
|
return new(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AppendLines(string url, List<char> spaces, List<string> lines, ReadOnlyCollection<Record> records, string workItemType)
|
private static void AppendLines(string url, List<char> spaces, List<string> lines, ReadOnlyCollection<Record> records, string workItemType)
|
||||||
@ -304,9 +329,9 @@ public class ProcessData : IProcessData
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
childRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Child", nests, keepRelations); // Forward
|
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
|
relatedRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Related", nests, keepRelations); // Related
|
||||||
successorRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Successor", nests, keepRelations); // Forward
|
successorRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Successor", nests, keepRelations); // Forward
|
||||||
|
// predecessorRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Predecessor", nests, keepRelations); // Reverse
|
||||||
record = Record.Get(keyValuePair.Value, parentWorkItem, childRecords, relatedRecords, successorRecords, keepRelations);
|
record = Record.Get(keyValuePair.Value, parentWorkItem, childRecords, relatedRecords, successorRecords, keepRelations);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
@ -40,4 +40,10 @@ public class Aggregation
|
|||||||
[JsonSerializable(typeof(Aggregation))]
|
[JsonSerializable(typeof(Aggregation))]
|
||||||
internal partial class AggregationSourceGenerationContext : JsonSerializerContext
|
internal partial class AggregationSourceGenerationContext : JsonSerializerContext
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(Aggregation[]))]
|
||||||
|
internal partial class AggregationCollectionSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
}
|
}
|
@ -262,7 +262,10 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
||||||
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
||||||
try
|
try
|
||||||
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
|
{
|
||||||
|
_SMTP.SendHighPriorityEmailMessage(subject, body);
|
||||||
|
File.WriteAllText(".email", body);
|
||||||
|
}
|
||||||
catch (Exception) { }
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
@ -277,7 +280,10 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
||||||
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
||||||
try
|
try
|
||||||
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
|
{
|
||||||
|
_SMTP.SendHighPriorityEmailMessage(subject, body);
|
||||||
|
File.WriteAllText(".email", body);
|
||||||
|
}
|
||||||
catch (Exception) { }
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,9 @@ using System.Diagnostics;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace Adaptation.FileHandlers.json;
|
namespace Adaptation.FileHandlers.json;
|
||||||
@ -111,14 +113,54 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
|
||||||
private static ReadOnlyCollection<WorkItem> GetWorkItems(ReadOnlyCollection<Value> valueWithReqCollection)
|
private static string GetParamCase(string value)
|
||||||
{
|
{
|
||||||
List<WorkItem> results = new();
|
string result;
|
||||||
|
StringBuilder stringBuilder = new(value);
|
||||||
|
List<Match> matches = new();
|
||||||
|
MatchCollection matchCollection = Regex.Matches(value, "([A-Z]+(.))");
|
||||||
|
foreach (object? item in matchCollection)
|
||||||
|
{
|
||||||
|
if (item is not Match match)
|
||||||
|
continue;
|
||||||
|
matches.Add(match);
|
||||||
|
}
|
||||||
|
for (int i = matches.Count - 1; i > -1; i--)
|
||||||
|
_ = stringBuilder.Insert(matches[i].Index, '-');
|
||||||
|
string[] segments = Regex.Split(stringBuilder.ToString().ToLower(), "[\\s!?.,@:;|\\\\/\"'`£$%\\^&*{}[\\]()<>~#+\\-=_¬]+");
|
||||||
|
result = string.Join("-", segments).Trim('-');
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ReadOnlyDictionary<int, WorkItem> GetKeyValuePairs(ReadOnlyCollection<Value> valueWithReqCollection)
|
||||||
|
{
|
||||||
|
Dictionary<int, WorkItem> results = new();
|
||||||
Fields fields;
|
Fields fields;
|
||||||
WorkItem workItem;
|
WorkItem workItem;
|
||||||
|
Relation relation;
|
||||||
|
string[] segments;
|
||||||
|
List<Relation> relations;
|
||||||
|
WorkItems.Attribute attributes;
|
||||||
foreach (Value value in valueWithReqCollection)
|
foreach (Value value in valueWithReqCollection)
|
||||||
{
|
{
|
||||||
|
relations = new();
|
||||||
fields = value.Fields;
|
fields = value.Fields;
|
||||||
|
if (value.Relations is not null)
|
||||||
|
{
|
||||||
|
foreach (WIQL.Relation r in value.Relations)
|
||||||
|
{
|
||||||
|
segments = r?.Attributes is null ? Array.Empty<string>() : r.URL.Split('/');
|
||||||
|
if (segments.Length < 2)
|
||||||
|
continue;
|
||||||
|
if (r?.Attributes is null)
|
||||||
|
continue;
|
||||||
|
if (!int.TryParse(segments[segments.Length - 1], out int id))
|
||||||
|
continue;
|
||||||
|
attributes = new(r.Attributes.IsLocked, r.Attributes.Name, null, null, null);
|
||||||
|
relation = new(attributes, id, r.Rel);
|
||||||
|
relations.Add(relation);
|
||||||
|
}
|
||||||
|
}
|
||||||
workItem = new(fields.MicrosoftVSTSCommonActivatedDate == DateTime.MinValue ? null : fields.MicrosoftVSTSCommonActivatedDate,
|
workItem = new(fields.MicrosoftVSTSCommonActivatedDate == DateTime.MinValue ? null : fields.MicrosoftVSTSCommonActivatedDate,
|
||||||
fields.SystemAreaPath,
|
fields.SystemAreaPath,
|
||||||
fields.SystemAssignedTo?.DisplayName,
|
fields.SystemAssignedTo?.DisplayName,
|
||||||
@ -133,7 +175,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
fields.SystemIterationPath,
|
fields.SystemIterationPath,
|
||||||
fields.SystemParent == 0 ? null : fields.SystemParent,
|
fields.SystemParent == 0 ? null : fields.SystemParent,
|
||||||
fields.MicrosoftVSTSCommonPriority == 0 ? null : fields.MicrosoftVSTSCommonPriority,
|
fields.MicrosoftVSTSCommonPriority == 0 ? null : fields.MicrosoftVSTSCommonPriority,
|
||||||
value.Relations,
|
relations.ToArray(),
|
||||||
fields.CustomRequester?.DisplayName,
|
fields.CustomRequester?.DisplayName,
|
||||||
fields.MicrosoftVSTSCommonResolvedDate == DateTime.MinValue ? null : fields.MicrosoftVSTSCommonResolvedDate,
|
fields.MicrosoftVSTSCommonResolvedDate == DateTime.MinValue ? null : fields.MicrosoftVSTSCommonResolvedDate,
|
||||||
value.Rev,
|
value.Rev,
|
||||||
@ -143,10 +185,41 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
fields.SystemTags,
|
fields.SystemTags,
|
||||||
fields.MicrosoftVSTSSchedulingTargetDate == DateTime.MinValue ? null : fields.MicrosoftVSTSSchedulingTargetDate,
|
fields.MicrosoftVSTSSchedulingTargetDate == DateTime.MinValue ? null : fields.MicrosoftVSTSSchedulingTargetDate,
|
||||||
fields.MicrosoftVSTSCommonTimeCriticality is null or 0 ? null : (long)fields.MicrosoftVSTSCommonTimeCriticality,
|
fields.MicrosoftVSTSCommonTimeCriticality is null or 0 ? null : (long)fields.MicrosoftVSTSCommonTimeCriticality,
|
||||||
fields.SystemTitle,
|
fields.SystemTitle.Trim(),
|
||||||
null,
|
null,
|
||||||
fields.CustomWSJF is null or 0 ? null : (long)fields.CustomWSJF,
|
fields.CustomWSJF is null or 0 ? null : (long)fields.CustomWSJF,
|
||||||
fields.SystemWorkItemType);
|
fields.SystemWorkItemType);
|
||||||
|
results.Add(workItem.Id, workItem);
|
||||||
|
}
|
||||||
|
return new(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ReadOnlyCollection<WorkItem> GetWorkItems(ReadOnlyCollection<Value> valueWithReqCollection)
|
||||||
|
{
|
||||||
|
List<WorkItem> results = new();
|
||||||
|
WorkItem workItem;
|
||||||
|
Relation relation;
|
||||||
|
string parameterTitle;
|
||||||
|
List<Relation> relations;
|
||||||
|
WorkItem? relationWorkItem;
|
||||||
|
WorkItems.Attribute attributes;
|
||||||
|
ReadOnlyDictionary<int, WorkItem> keyValuePairs = GetKeyValuePairs(valueWithReqCollection);
|
||||||
|
foreach (KeyValuePair<int, WorkItem> keyValuePair in keyValuePairs)
|
||||||
|
{
|
||||||
|
relations = new();
|
||||||
|
if (keyValuePair.Value.Relations is not null)
|
||||||
|
{
|
||||||
|
foreach (Relation r in keyValuePair.Value.Relations)
|
||||||
|
{
|
||||||
|
if (!keyValuePairs.TryGetValue(r.Id, out relationWorkItem))
|
||||||
|
continue;
|
||||||
|
parameterTitle = GetParamCase(relationWorkItem.Title);
|
||||||
|
attributes = new(r.Attributes.IsLocked, r.Attributes.Name, parameterTitle, relationWorkItem.State, relationWorkItem.WorkItemType);
|
||||||
|
relation = new(attributes, r.Id, r.Rel);
|
||||||
|
relations.Add(relation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
workItem = WorkItem.Get(keyValuePair.Value, relations.ToArray());
|
||||||
results.Add(workItem);
|
results.Add(workItem);
|
||||||
}
|
}
|
||||||
return new(results);
|
return new(results);
|
||||||
@ -237,7 +310,10 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
||||||
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
||||||
try
|
try
|
||||||
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
|
{
|
||||||
|
_SMTP.SendHighPriorityEmailMessage(subject, body);
|
||||||
|
File.WriteAllText(".email", body);
|
||||||
|
}
|
||||||
catch (Exception) { }
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
@ -252,7 +328,10 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
||||||
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
||||||
try
|
try
|
||||||
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
|
{
|
||||||
|
_SMTP.SendHighPriorityEmailMessage(subject, body);
|
||||||
|
File.WriteAllText(".email", body);
|
||||||
|
}
|
||||||
catch (Exception) { }
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
25
Adaptation/FileHandlers/json/WIQL/Attribute.cs
Normal file
25
Adaptation/FileHandlers/json/WIQL/Attribute.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Adaptation.FileHandlers.json.WIQL;
|
||||||
|
|
||||||
|
internal class Attribute
|
||||||
|
{
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
public Attribute(bool isLocked,
|
||||||
|
string name)
|
||||||
|
{
|
||||||
|
IsLocked = isLocked;
|
||||||
|
Name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonPropertyName("isLocked")] public bool IsLocked { get; }
|
||||||
|
[JsonPropertyName("name")] public string Name { get; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(Attribute))]
|
||||||
|
internal partial class WIQLAttributeSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
35
Adaptation/FileHandlers/json/WIQL/Relation.cs
Normal file
35
Adaptation/FileHandlers/json/WIQL/Relation.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Adaptation.FileHandlers.json.WIQL;
|
||||||
|
|
||||||
|
internal class Relation
|
||||||
|
{
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
public Relation(string rel,
|
||||||
|
string url,
|
||||||
|
Attribute attributes)
|
||||||
|
{
|
||||||
|
Rel = rel;
|
||||||
|
Rel = rel;
|
||||||
|
URL = url;
|
||||||
|
Attributes = attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonPropertyName("attributes")] public Attribute Attributes { get; set; }
|
||||||
|
[JsonPropertyName("rel")] public string Rel { get; set; }
|
||||||
|
[JsonPropertyName("url")] public string URL { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(Relation))]
|
||||||
|
internal partial class WIQLRelationSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(Relation[]))]
|
||||||
|
internal partial class WIQLRelationCollectionSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
@ -5,16 +5,27 @@ namespace Adaptation.FileHandlers.json.WorkItems;
|
|||||||
internal class Attribute
|
internal class Attribute
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
[JsonConstructor]
|
[JsonConstructor]
|
||||||
public Attribute(bool isLocked,
|
public Attribute(bool isLocked,
|
||||||
string name)
|
string name,
|
||||||
|
string? parameterTitle,
|
||||||
|
string? state,
|
||||||
|
string? workItemType)
|
||||||
{
|
{
|
||||||
IsLocked = isLocked;
|
IsLocked = isLocked;
|
||||||
Name = name;
|
Name = name;
|
||||||
|
ParameterTitle = parameterTitle;
|
||||||
|
State = state;
|
||||||
|
WorkItemType = workItemType;
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonPropertyName("isLocked")] public bool IsLocked { get; }
|
[JsonPropertyName("isLocked")] public bool IsLocked { get; }
|
||||||
[JsonPropertyName("name")] public string Name { get; }
|
[JsonPropertyName("name")] public string Name { get; }
|
||||||
|
[JsonPropertyName("parameterTitle")] public string? ParameterTitle { get; set; }
|
||||||
|
[JsonPropertyName("state")] public string? State { get; set; }
|
||||||
|
[JsonPropertyName("workItemType")] public string? WorkItemType { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,30 +88,13 @@ internal class Record
|
|||||||
return result;
|
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)
|
internal static ReadOnlyCollection<Record> GetKeyValuePairs(ReadOnlyDictionary<int, WorkItem> keyValuePairs, WorkItem workItem, string relationName, List<bool> nests, bool keepRelations)
|
||||||
{
|
{
|
||||||
List<Record> results = new();
|
List<Record> results = new();
|
||||||
int? childId;
|
|
||||||
Record record;
|
Record record;
|
||||||
nests.Add(true);
|
nests.Add(true);
|
||||||
WorkItem? childWorkItem;
|
|
||||||
WorkItem? parentWorkItem;
|
WorkItem? parentWorkItem;
|
||||||
|
WorkItem? relationWorkItem;
|
||||||
List<WorkItem> collection = new();
|
List<WorkItem> collection = new();
|
||||||
ReadOnlyCollection<Record> childRecords;
|
ReadOnlyCollection<Record> childRecords;
|
||||||
ReadOnlyCollection<Record> relatedRecords;
|
ReadOnlyCollection<Record> relatedRecords;
|
||||||
@ -121,12 +104,13 @@ internal class Record
|
|||||||
collection.Clear();
|
collection.Clear();
|
||||||
foreach (Relation relation in workItem.Relations)
|
foreach (Relation relation in workItem.Relations)
|
||||||
{
|
{
|
||||||
childId = GetIdFromUrl(relationName, relation);
|
if (relation.Attributes.Name != relationName)
|
||||||
if (childId is not null && workItem.Parent is not null && relation?.URL is not null && relation.URL.Contains(workItem.Parent.Value.ToString()))
|
|
||||||
continue;
|
continue;
|
||||||
if (childId is null || !keyValuePairs.TryGetValue(childId.Value, out childWorkItem))
|
if (workItem.Parent is not null && relation.Id == workItem.Parent.Value)
|
||||||
continue;
|
continue;
|
||||||
collection.Add(childWorkItem);
|
if (!keyValuePairs.TryGetValue(relation.Id, out relationWorkItem))
|
||||||
|
continue;
|
||||||
|
collection.Add(relationWorkItem);
|
||||||
}
|
}
|
||||||
collection = (from l in collection orderby l.State != "Closed", l.Id select l).ToList();
|
collection = (from l in collection orderby l.State != "Closed", l.Id select l).ToList();
|
||||||
foreach (WorkItem w in collection)
|
foreach (WorkItem w in collection)
|
||||||
@ -138,14 +122,9 @@ internal class Record
|
|||||||
else
|
else
|
||||||
_ = keyValuePairs.TryGetValue(w.Parent.Value, out parentWorkItem);
|
_ = keyValuePairs.TryGetValue(w.Parent.Value, out parentWorkItem);
|
||||||
childRecords = GetKeyValuePairs(keyValuePairs, w, "Child", nests, keepRelations); // Forward
|
childRecords = GetKeyValuePairs(keyValuePairs, w, "Child", nests, keepRelations); // Forward
|
||||||
// records = GetKeyValuePairs(keyValuePairs, w, "Predecessor", nests); // Reverse
|
|
||||||
// successorRecords = GetKeyValuePairs(keyValuePairs, w, "Successor", nests); // Forward
|
// successorRecords = GetKeyValuePairs(keyValuePairs, w, "Successor", nests); // Forward
|
||||||
// if (successorRecords.Count > 0)
|
|
||||||
// {
|
|
||||||
// if (successorRecords.Count > 0)
|
|
||||||
// { }
|
|
||||||
// }
|
|
||||||
successorRecords = new(Array.Empty<Record>());
|
successorRecords = new(Array.Empty<Record>());
|
||||||
|
// predecessorRecords = GetKeyValuePairs(keyValuePairs, w, "Predecessor", nests); // Reverse
|
||||||
relatedRecords = GetKeyValuePairs(keyValuePairs, w, "Related", nests, keepRelations); // Related
|
relatedRecords = GetKeyValuePairs(keyValuePairs, w, "Related", nests, keepRelations); // Related
|
||||||
record = Get(w, parentWorkItem, childRecords, relatedRecords, successorRecords, keepRelations);
|
record = Get(w, parentWorkItem, childRecords, relatedRecords, successorRecords, keepRelations);
|
||||||
results.Add(record);
|
results.Add(record);
|
||||||
@ -160,4 +139,10 @@ internal class Record
|
|||||||
[JsonSerializable(typeof(Record))]
|
[JsonSerializable(typeof(Record))]
|
||||||
internal partial class RecordSourceGenerationContext : JsonSerializerContext
|
internal partial class RecordSourceGenerationContext : JsonSerializerContext
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(Record[]))]
|
||||||
|
internal partial class RecordCollectionSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
}
|
}
|
@ -6,18 +6,18 @@ internal class Relation
|
|||||||
{
|
{
|
||||||
|
|
||||||
[JsonConstructor]
|
[JsonConstructor]
|
||||||
public Relation(string rel,
|
public Relation(Attribute attributes,
|
||||||
string url,
|
int id,
|
||||||
Attribute attributes)
|
string rel)
|
||||||
{
|
{
|
||||||
Rel = rel;
|
|
||||||
URL = url;
|
|
||||||
Attributes = attributes;
|
Attributes = attributes;
|
||||||
|
Id = id;
|
||||||
|
Rel = rel;
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonPropertyName("attributes")] public Attribute Attributes { get; set; }
|
[JsonPropertyName("attributes")] public Attribute Attributes { get; set; }
|
||||||
|
[JsonPropertyName("id")] public int Id { get; set; }
|
||||||
[JsonPropertyName("rel")] public string Rel { get; set; }
|
[JsonPropertyName("rel")] public string Rel { get; set; }
|
||||||
[JsonPropertyName("url")] public string URL { get; set; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ internal class Value
|
|||||||
int id,
|
int id,
|
||||||
int rev,
|
int rev,
|
||||||
Fields fields,
|
Fields fields,
|
||||||
Relation[] relations,
|
WIQL.Relation[] relations,
|
||||||
CommentVersionRef commentVersionRef,
|
CommentVersionRef commentVersionRef,
|
||||||
string url
|
string url
|
||||||
)
|
)
|
||||||
@ -26,7 +26,7 @@ internal class Value
|
|||||||
[JsonPropertyName("commentVersionRef")] public CommentVersionRef CommentVersionRef { get; }
|
[JsonPropertyName("commentVersionRef")] public CommentVersionRef CommentVersionRef { get; }
|
||||||
[JsonPropertyName("fields")] public Fields Fields { get; }
|
[JsonPropertyName("fields")] public Fields Fields { get; }
|
||||||
[JsonPropertyName("id")] public int Id { get; }
|
[JsonPropertyName("id")] public int Id { get; }
|
||||||
[JsonPropertyName("relations")] public Relation[] Relations { get; }
|
[JsonPropertyName("relations")] public WIQL.Relation[] Relations { get; }
|
||||||
[JsonPropertyName("rev")] public int Rev { get; }
|
[JsonPropertyName("rev")] public int Rev { get; }
|
||||||
[JsonPropertyName("url")] public string Url { get; }
|
[JsonPropertyName("url")] public string Url { get; }
|
||||||
|
|
||||||
|
@ -70,6 +70,39 @@ internal class WorkItem
|
|||||||
|
|
||||||
public override string ToString() => $"{Id} - {WorkItemType} - {Title}";
|
public override string ToString() => $"{Id} - {WorkItemType} - {Title}";
|
||||||
|
|
||||||
|
public static WorkItem Get(WorkItem workItem, Relation[] relations)
|
||||||
|
{
|
||||||
|
WorkItem result = new(workItem.ActivatedDate,
|
||||||
|
workItem.AreaPath,
|
||||||
|
workItem.AssignedTo,
|
||||||
|
workItem.BusinessValue,
|
||||||
|
workItem.ChangedDate,
|
||||||
|
workItem.ClosedDate,
|
||||||
|
workItem.CommentCount,
|
||||||
|
workItem.CreatedDate,
|
||||||
|
workItem.Description,
|
||||||
|
workItem.Effort,
|
||||||
|
workItem.Id,
|
||||||
|
workItem.IterationPath,
|
||||||
|
workItem.Parent,
|
||||||
|
workItem.Priority,
|
||||||
|
relations,
|
||||||
|
workItem.Requester,
|
||||||
|
workItem.ResolvedDate,
|
||||||
|
workItem.Revision,
|
||||||
|
workItem.RiskReductionMinusOpportunityEnablement,
|
||||||
|
workItem.StartDate,
|
||||||
|
workItem.State,
|
||||||
|
workItem.Tags,
|
||||||
|
workItem.TargetDate,
|
||||||
|
workItem.TimeCriticality,
|
||||||
|
workItem.Title,
|
||||||
|
workItem.Violation,
|
||||||
|
workItem.WeightedShortestJobFirst,
|
||||||
|
workItem.WorkItemType);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static WorkItem? GetWithOutRelations(WorkItem? workItem)
|
public static WorkItem? GetWithOutRelations(WorkItem? workItem)
|
||||||
{
|
{
|
||||||
WorkItem? result = workItem is null ? null : new(workItem.ActivatedDate,
|
WorkItem? result = workItem is null ? null : new(workItem.ActivatedDate,
|
||||||
|
@ -48,8 +48,8 @@ public class BACKLOG
|
|||||||
{
|
{
|
||||||
string check = "*.json";
|
string check = "*.json";
|
||||||
bool validatePDSF = false;
|
bool validatePDSF = false;
|
||||||
MethodBase methodBase = new StackFrame().GetMethod();
|
|
||||||
_BACKLOG.Development__v2_57_0__BACKLOG__json();
|
_BACKLOG.Development__v2_57_0__BACKLOG__json();
|
||||||
|
MethodBase methodBase = new StackFrame().GetMethod();
|
||||||
Assert.IsFalse(string.IsNullOrEmpty(_BACKLOG.AdaptationTesting.TestContext.FullyQualifiedTestClassName));
|
Assert.IsFalse(string.IsNullOrEmpty(_BACKLOG.AdaptationTesting.TestContext.FullyQualifiedTestClassName));
|
||||||
string[] variables = _BACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF);
|
string[] variables = _BACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF);
|
||||||
IFileRead fileRead = _BACKLOG.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false);
|
IFileRead fileRead = _BACKLOG.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false);
|
||||||
|
@ -119,8 +119,10 @@
|
|||||||
<Compile Include="Adaptation\FileHandlers\IQSSi\FileRead.cs" />
|
<Compile Include="Adaptation\FileHandlers\IQSSi\FileRead.cs" />
|
||||||
<Compile Include="Adaptation\FileHandlers\json\FileRead.cs" />
|
<Compile Include="Adaptation\FileHandlers\json\FileRead.cs" />
|
||||||
<Compile Include="Adaptation\FileHandlers\json\ProcessData.cs" />
|
<Compile Include="Adaptation\FileHandlers\json\ProcessData.cs" />
|
||||||
|
<Compile Include="Adaptation\FileHandlers\json\WIQL\Attribute.cs" />
|
||||||
<Compile Include="Adaptation\FileHandlers\json\WIQL\Column.cs" />
|
<Compile Include="Adaptation\FileHandlers\json\WIQL\Column.cs" />
|
||||||
<Compile Include="Adaptation\FileHandlers\json\WIQL\Field.cs" />
|
<Compile Include="Adaptation\FileHandlers\json\WIQL\Field.cs" />
|
||||||
|
<Compile Include="Adaptation\FileHandlers\json\WIQL\Relation.cs" />
|
||||||
<Compile Include="Adaptation\FileHandlers\json\WIQL\Root.cs" />
|
<Compile Include="Adaptation\FileHandlers\json\WIQL\Root.cs" />
|
||||||
<Compile Include="Adaptation\FileHandlers\json\WIQL\SortColumn.cs" />
|
<Compile Include="Adaptation\FileHandlers\json\WIQL\SortColumn.cs" />
|
||||||
<Compile Include="Adaptation\FileHandlers\json\WIQL\WorkItem.cs" />
|
<Compile Include="Adaptation\FileHandlers\json\WIQL\WorkItem.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user