Update API
This commit is contained in:
parent
4e2cb5d696
commit
7d4b0383e9
@ -126,6 +126,58 @@ public class ProcessData : IProcessData
|
||||
private static string GetDescription(FIBacklogMesa fiBacklogMesa, DateTime dateTime) =>
|
||||
$"Req:{fiBacklogMesa.Req}; Submitted:{(dateTime == DateTime.MinValue ? fiBacklogMesa.Submitted : dateTime.ToString("d-MMM-yy"))}; Requestor:{fiBacklogMesa.Requestor}; AssignedTo:{fiBacklogMesa.AssignedTo}; SecondResource:{fiBacklogMesa.SecondResource}; Systems:{fiBacklogMesa.SystemS}; ";
|
||||
|
||||
private static void Update(HttpClient httpClient, string basePage, string api, string query, HttpContent httpContent)
|
||||
{
|
||||
Task<HttpResponseMessage> httpResponseMessageTask = httpClient.PatchAsync(string.Concat(basePage, api, query), httpContent);
|
||||
httpResponseMessageTask.Wait();
|
||||
if (!httpResponseMessageTask.Result.IsSuccessStatusCode)
|
||||
throw new Exception(httpResponseMessageTask.Result.StatusCode.ToString());
|
||||
Task<string> stringTask = httpResponseMessageTask.Result.Content.ReadAsStringAsync();
|
||||
stringTask.Wait();
|
||||
}
|
||||
|
||||
private static void UpdateIds(HttpClient httpClient, string basePage, string api, string[] checkFiles)
|
||||
{
|
||||
int? idIndex;
|
||||
string[] lines;
|
||||
string[] segments;
|
||||
string stringPayload;
|
||||
HttpContent httpContent;
|
||||
foreach (string checkFile in checkFiles)
|
||||
{
|
||||
idIndex = null;
|
||||
lines = File.ReadAllLines(checkFile);
|
||||
if (lines.Length < 1)
|
||||
continue;
|
||||
segments = lines.First().Split(',');
|
||||
for (int i = 0; i < segments.Length; i++)
|
||||
{
|
||||
if (segments[i] == "ID")
|
||||
{
|
||||
idIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (idIndex is null)
|
||||
continue;
|
||||
for (int i = 1; i < lines.Length; i++)
|
||||
{
|
||||
segments = lines[i].Split(',');
|
||||
if (segments.Length < idIndex.Value)
|
||||
continue;
|
||||
var payload = new
|
||||
{
|
||||
op = "replace",
|
||||
path = "/fields/System.IterationPath",
|
||||
value = "Mesa_FI"
|
||||
};
|
||||
stringPayload = JsonSerializer.Serialize(payload);
|
||||
httpContent = new StringContent($"[{stringPayload}]", Encoding.UTF8, "application/json-patch+json");
|
||||
Update(httpClient, basePage, api, $"/workitems/{segments[idIndex.Value].Replace("\"", string.Empty)}?api-version=1.0", httpContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, HttpClient httpClient, string basePage, string api, string query, WorkItemTrackingHttpClient workItemTrackingHttpClient, string project, string json)
|
||||
{
|
||||
if (fileRead is null)
|
||||
@ -138,37 +190,46 @@ public class ProcessData : IProcessData
|
||||
DateTime dateTime;
|
||||
string description;
|
||||
string keySection = " UAT for ";
|
||||
string ids = GetIds(httpClient, basePage, api, query);
|
||||
Value[] workItems = GetWorkItems(httpClient, basePage, api, ids);
|
||||
Task<Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models.WorkItem> workItemTask;
|
||||
Dictionary<string, FIBacklogMesa> keyToFIBacklogMesa = GetFIBacklogMesaCollection(json, keySection);
|
||||
int count = keyToFIBacklogMesa.Count;
|
||||
Value[] extra = GetExtra(keySection, workItems, keyToFIBacklogMesa);
|
||||
if (count != extra.Length)
|
||||
{ }
|
||||
if (count != keyToFIBacklogMesa.Count)
|
||||
{ }
|
||||
_Details.AddRange(workItems);
|
||||
foreach (KeyValuePair<string, FIBacklogMesa> keyValuePair in keyToFIBacklogMesa)
|
||||
string? directory = Path.GetDirectoryName(fileRead.ReportFullPath);
|
||||
if (directory is null)
|
||||
throw new Exception();
|
||||
string[] checkFiles = Directory.GetFiles(directory, "*.csv", SearchOption.TopDirectoryOnly);
|
||||
if (checkFiles.Any())
|
||||
UpdateIds(httpClient, basePage, api, checkFiles);
|
||||
else
|
||||
{
|
||||
if (counter > 5)
|
||||
break;
|
||||
JsonPatchDocument document = new();
|
||||
if (!DateTime.TryParse(keyValuePair.Value.Submitted, out dateTime))
|
||||
dateTime = DateTime.MinValue;
|
||||
AddPatch(document, "/fields/System.AreaPath", project);
|
||||
description = GetDescription(keyValuePair.Value, dateTime);
|
||||
AddPatch(document, "/fields/System.Title", keyValuePair.Key);
|
||||
AddPatch(document, "/fields/System.Description", description);
|
||||
AddPatch(document, "/fields/System.IterationPath", $"{project}\\(Default)");
|
||||
// AddPatch(document, "/fields/System.AssignedTo", "Mike.Phares@infineon.com");
|
||||
if (!fileRead.IsEAFHosted)
|
||||
continue;
|
||||
workItemTask = workItemTrackingHttpClient.CreateWorkItemAsync(document, project, "Task");
|
||||
workItemTask.Wait();
|
||||
counter++;
|
||||
if (workItemTask.Result is null)
|
||||
continue;
|
||||
string ids = GetIds(httpClient, basePage, api, query);
|
||||
Value[] workItems = GetWorkItems(httpClient, basePage, api, ids);
|
||||
Task<Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models.WorkItem> workItemTask;
|
||||
Dictionary<string, FIBacklogMesa> keyToFIBacklogMesa = GetFIBacklogMesaCollection(json, keySection);
|
||||
int count = keyToFIBacklogMesa.Count;
|
||||
Value[] extra = GetExtra(keySection, workItems, keyToFIBacklogMesa);
|
||||
if (count != extra.Length)
|
||||
{ }
|
||||
if (count != keyToFIBacklogMesa.Count)
|
||||
{ }
|
||||
_Details.AddRange(workItems);
|
||||
foreach (KeyValuePair<string, FIBacklogMesa> keyValuePair in keyToFIBacklogMesa)
|
||||
{
|
||||
if (counter > 5)
|
||||
break;
|
||||
JsonPatchDocument document = new();
|
||||
if (!DateTime.TryParse(keyValuePair.Value.Submitted, out dateTime))
|
||||
dateTime = DateTime.MinValue;
|
||||
AddPatch(document, "/fields/System.AreaPath", project);
|
||||
description = GetDescription(keyValuePair.Value, dateTime);
|
||||
AddPatch(document, "/fields/System.IterationPath", project);
|
||||
AddPatch(document, "/fields/System.Title", keyValuePair.Key);
|
||||
AddPatch(document, "/fields/System.Description", description);
|
||||
// AddPatch(document, "/fields/System.AssignedTo", "Mike.Phares@infineon.com");
|
||||
if (!fileRead.IsEAFHosted)
|
||||
continue;
|
||||
workItemTask = workItemTrackingHttpClient.CreateWorkItemAsync(document, project, "Task");
|
||||
workItemTask.Wait();
|
||||
counter++;
|
||||
if (workItemTask.Result is null)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,12 +151,13 @@ steps:
|
||||
"C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration)
|
||||
workingDirectory: Adaptation
|
||||
displayName: "Core Clean - Tests"
|
||||
enabled: false
|
||||
continueOnError: true
|
||||
|
||||
- script: |
|
||||
"C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration)
|
||||
workingDirectory: Adaptation
|
||||
displayName: "Core Clean - Adaptation"
|
||||
continueOnError: true
|
||||
|
||||
- script: 'echo $(Build.SourceVersion)-$(Build.BuildId)>bin_x_x_\$(Configuration)\$(CoreVersion)\win-x64\$(Build.Repository.Name).txt'
|
||||
displayName: "Force Fail"
|
||||
|
@ -59,4 +59,22 @@ public class MESAFIBACKLOG
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[Ignore]
|
||||
[TestMethod]
|
||||
public void Development__v2_49_0__MESAFIBACKLOG__json637961251829737449__Normal()
|
||||
{
|
||||
string check = "*.json";
|
||||
bool validatePDSF = false;
|
||||
_MESAFIBACKLOG.Development__v2_49_0__MESAFIBACKLOG__json();
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user