Changed to long types
122517
This commit is contained in:
@ -3,6 +3,7 @@ using Adaptation.Shared;
|
||||
using Adaptation.Shared.Duplicator;
|
||||
using Adaptation.Shared.Methods;
|
||||
using log4net;
|
||||
using Microsoft.VisualStudio.Services.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@ -62,9 +63,21 @@ public class ProcessData : IProcessData
|
||||
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));
|
||||
// WorkItem[]? workItems = JsonSerializer.Deserialize<WorkItem[]>(json);
|
||||
// if (workItems is null)
|
||||
// throw new Exception(nameof(workItems));
|
||||
JsonElement[]? jsonElements = JsonSerializer.Deserialize<JsonElement[]>(json);
|
||||
if (jsonElements is null)
|
||||
throw new Exception(nameof(jsonElements));
|
||||
WorkItem? workItem;
|
||||
List<WorkItem> workItems = new();
|
||||
foreach (JsonElement jsonElement in jsonElements)
|
||||
{
|
||||
workItem = JsonSerializer.Deserialize<WorkItem>(jsonElement.ToString());
|
||||
if (workItem is null)
|
||||
continue;
|
||||
workItems.Add(workItem);
|
||||
}
|
||||
List<char> spaces = new();
|
||||
List<string> lines = new();
|
||||
ReadOnlyCollection<WorkItem> results;
|
||||
@ -72,7 +85,7 @@ public class ProcessData : IProcessData
|
||||
ReadOnlyCollection<Record> records = new(keyValuePairs.Values.ToArray());
|
||||
ReadOnlyCollection<string> bugUserStoryWorkItemTypes = new(new string[] { "Bug", "User Story" });
|
||||
ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes = new(new string[] { "Bug", "User Story", "Task" });
|
||||
WriteFiles(fileRead, destinationDirectory, fileInfoCollection, records, "with-parents");
|
||||
WriteWithPartentsFile(fileRead, destinationDirectory, fileInfoCollection, records, "with-parents");
|
||||
foreach (string workItemType in workItemTypes)
|
||||
{
|
||||
lines.Clear();
|
||||
@ -128,6 +141,15 @@ public class ProcessData : IProcessData
|
||||
WriteFiles(fileRead, destinationDirectory, fileInfoCollection, new(lines), results, "check-123067");
|
||||
_Details.Add(results);
|
||||
}
|
||||
{
|
||||
lines.Clear();
|
||||
string workItemType = "Feature";
|
||||
lines.Add($"# {nameof(FeatureCheckStart122517)}");
|
||||
lines.Add(string.Empty);
|
||||
results = FeatureCheckStart122517(url, lines, bugUserStoryTaskWorkItemTypes, records, workItemType);
|
||||
WriteFiles(fileRead, destinationDirectory, fileInfoCollection, new(lines), results, "check-122517");
|
||||
_Details.Add(results);
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteFiles(IFileRead fileRead, string destinationDirectory, List<FileInfo> fileInfoCollection, ReadOnlyCollection<string> lines, ReadOnlyCollection<WorkItem> workItems, string fileName)
|
||||
@ -155,7 +177,7 @@ public class ProcessData : IProcessData
|
||||
fileInfoCollection.Add(new(jsonFile));
|
||||
}
|
||||
|
||||
private static ReadOnlyDictionary<int, Record> GetWorkItems(WorkItem[] workItems)
|
||||
private static ReadOnlyDictionary<int, Record> GetWorkItems(IEnumerable<WorkItem> workItems)
|
||||
{
|
||||
ReadOnlyDictionary<int, Record> results;
|
||||
Dictionary<int, WorkItem> keyValuePairs = new();
|
||||
@ -165,9 +187,10 @@ public class ProcessData : IProcessData
|
||||
return results;
|
||||
}
|
||||
|
||||
private static void WriteFiles(IFileRead fileRead, string destinationDirectory, List<FileInfo> fileInfoCollection, ReadOnlyCollection<Record> records, string fileName)
|
||||
private static void WriteWithPartentsFile(IFileRead fileRead, string destinationDirectory, List<FileInfo> fileInfoCollection, ReadOnlyCollection<Record> records, string fileName)
|
||||
{
|
||||
string json = JsonSerializer.Serialize(records, new JsonSerializerOptions() { WriteIndented = true });
|
||||
Record[] features = (from l in records where l.WorkItem.WorkItemType == "Feature" select l).ToArray();
|
||||
string json = JsonSerializer.Serialize(features, new JsonSerializerOptions() { WriteIndented = true });
|
||||
string jsonFile = Path.Combine(destinationDirectory, $"{fileName}.json");
|
||||
string jsonOld = !File.Exists(jsonFile) ? string.Empty : File.ReadAllText(jsonFile);
|
||||
if (json != jsonOld)
|
||||
@ -612,6 +635,28 @@ public class ProcessData : IProcessData
|
||||
return new(results);
|
||||
}
|
||||
|
||||
private static ReadOnlyCollection<WorkItem> GetWorkItemsNotMatching122517(Record record, ReadOnlyCollection<WorkItem> workItems)
|
||||
{
|
||||
List<WorkItem> results = new();
|
||||
if (record.WorkItem.StartDate is null)
|
||||
throw new Exception();
|
||||
DateTime dateTime = record.WorkItem.StartDate.Value;
|
||||
List<KeyValuePair<long, WorkItem>> collection = new();
|
||||
foreach (WorkItem workItem in workItems)
|
||||
{
|
||||
if (workItem.State is "Removed")
|
||||
continue;
|
||||
if (workItem.ActivatedDate is null)
|
||||
continue;
|
||||
if (dateTime >= workItem.ActivatedDate.Value)
|
||||
continue;
|
||||
collection.Add(new(workItem.ActivatedDate.Value.Ticks, workItem));
|
||||
}
|
||||
foreach (KeyValuePair<long, WorkItem> keyValuePair in collection.OrderByDescending(l => l.Key))
|
||||
results.Add(keyValuePair.Value);
|
||||
return new(results);
|
||||
}
|
||||
|
||||
private static ReadOnlyCollection<WorkItem> FeatureCheckState123066(string url, List<string> lines, ReadOnlyCollection<string> workItemTypes, ReadOnlyCollection<Record> records, string workItemType)
|
||||
{
|
||||
List<WorkItem> results = new();
|
||||
@ -684,4 +729,42 @@ public class ProcessData : IProcessData
|
||||
return new(results);
|
||||
}
|
||||
|
||||
private static ReadOnlyCollection<WorkItem> FeatureCheckStart122517(string url, List<string> lines, ReadOnlyCollection<string> workItemTypes, ReadOnlyCollection<Record> records, string workItemType)
|
||||
{
|
||||
List<WorkItem> results = new();
|
||||
List<string> collection = new();
|
||||
List<string> violations = new();
|
||||
ReadOnlyCollection<WorkItem> childrenWorkItems;
|
||||
ReadOnlyCollection<WorkItem> workItemsNotMatching;
|
||||
foreach (Record record in records)
|
||||
{
|
||||
if (record.WorkItem.State is "Removed")
|
||||
continue;
|
||||
if (record.WorkItem.WorkItemType != workItemType)
|
||||
continue;
|
||||
collection.Clear();
|
||||
violations.Clear();
|
||||
if (record.Children.Count == 0)
|
||||
continue;
|
||||
if (record.WorkItem.StartDate is null)
|
||||
continue;
|
||||
childrenWorkItems = FilterChildren(workItemTypes, record);
|
||||
workItemsNotMatching = GetWorkItemsNotMatching122517(record, childrenWorkItems);
|
||||
if (workItemsNotMatching.Count == 0)
|
||||
continue;
|
||||
collection.Add($"## {record.WorkItem.AssignedTo} - {record.WorkItem.Id} - {record.WorkItem.Title}");
|
||||
collection.Add(string.Empty);
|
||||
collection.Add($"- [{record.WorkItem.Id}]({url}{record.WorkItem.Id})");
|
||||
foreach (WorkItem workItem in workItemsNotMatching)
|
||||
collection.Add($"- [ ] [{workItem.Id}]({url}{workItem.Id}) {nameof(record.WorkItem.ActivatedDate)} != {record.WorkItem.ActivatedDate}");
|
||||
collection.Add(string.Empty);
|
||||
lines.AddRange(collection);
|
||||
violations.Add($"StartDate:{record.WorkItem.StartDate};");
|
||||
foreach (WorkItem workItem in workItemsNotMatching)
|
||||
violations.Add($"<a target='_blank' href='{url}{workItem.Id}'>{workItem.Id}</a>:{workItem.ActivatedDate};");
|
||||
results.Add(WorkItem.Get(record.WorkItem, string.Join(" ", violations)));
|
||||
}
|
||||
return new(results);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user