HttpSelfHostServer

This commit is contained in:
2023-06-09 15:27:24 -07:00
parent afd4cf8efe
commit fb3c3ce699
31 changed files with 393 additions and 48 deletions

View File

@ -10,11 +10,10 @@ public class FIBacklogMesa
string requestor,
string assignedTo,
string secondResource,
string title,
string subject,
string epiLine,
string area,
string systemS,
string priSort,
string priority,
string status,
string definition,
@ -23,7 +22,7 @@ public class FIBacklogMesa
string commitDate,
string reCommitDate,
string uATAsOf,
string cMPDate,
string cmpDate,
string f20,
string f21,
string f22,
@ -44,11 +43,10 @@ public class FIBacklogMesa
Requestor = requestor;
AssignedTo = assignedTo;
SecondResource = secondResource;
Title = title;
Subject = subject;
EpiLine = epiLine;
Area = area;
SystemS = systemS;
PriSort = priSort;
Priority = priority;
Status = status;
Definition = definition;
@ -57,7 +55,7 @@ public class FIBacklogMesa
CommitDate = commitDate;
ReCommitDate = reCommitDate;
UATAsOf = uATAsOf;
CMPDate = cMPDate;
CMPDate = cmpDate;
F20 = f20;
F21 = f21;
F22 = f22;
@ -74,17 +72,18 @@ public class FIBacklogMesa
F33 = f33;
}
[JsonPropertyName("Req ")]
public string Req { get; set; } // { init; get; }
public string Submitted { get; set; } // { init; get; }
public string Requestor { get; set; } // { init; get; }
[JsonPropertyName("Assigned To ")]
[JsonPropertyName("Assigned To")]
public string AssignedTo { get; set; } // { init; get; }
[JsonPropertyName("Second Resource")]
public string SecondResource { get; set; } // { init; get; }
public string Title { get; set; } // { init; get; }
[JsonPropertyName("Subject - from Requestor")]
public string Subject { get; set; } // { init; get; }
[JsonPropertyName("Epi Line")]
public string EpiLine { get; set; } // { init; get; }
@ -93,24 +92,26 @@ public class FIBacklogMesa
[JsonPropertyName("System(s)")]
public string SystemS { get; set; } // { init; get; }
[JsonPropertyName("Pri Sort")]
public string PriSort { get; set; } // { init; get; }
public string Priority { get; set; } // { init; get; }
public string Status { get; set; } // { init; get; }
[JsonPropertyName("Definition - from FI")]
public string Definition { get; set; } // { init; get; }
public string Updates { get; set; } // { init; get; }
[JsonPropertyName("Est Effort _(days)")]
public string EstEffortDays { get; set; } // { init; get; }
[JsonPropertyName("Commit Date ")]
[JsonPropertyName("Commit Date")]
public string CommitDate { get; set; } // { init; get; }
[JsonPropertyName("Re-Commit Date ")]
[JsonPropertyName("Re-Commit Date")]
public string ReCommitDate { get; set; } // { init; get; }
[JsonPropertyName("UAT as of ")]
[JsonPropertyName("UAT as of")]
public string UATAsOf { get; set; } // { init; get; }
[JsonPropertyName("CMP _Date")]
public string CMPDate { get; set; } // { init; get; }
public string F20 { get; set; } // { init; get; }
public string F21 { get; set; } // { init; get; }

View File

@ -99,9 +99,7 @@ public class ProcessData : IProcessData
value = value.Replace("\"", "\\\"");
if (value.Contains("\n"))
value = value.Replace("\n", "<br />");
name = table.Columns[j].ColumnName.ToString();
if (name == ",")
name = "Title";
name = table.Columns[j].ColumnName.ToString().Trim();
if (name.Contains("\""))
name = name.Replace("\"", "\\\"");
if (name.Contains("\n"))
@ -134,7 +132,7 @@ public class ProcessData : IProcessData
FIBacklogMesa[]? fIBacklogMesaCollection = JsonSerializer.Deserialize<FIBacklogMesa[]>(json, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true });
if (fIBacklogMesaCollection is null || !fIBacklogMesaCollection.Any())
throw new NullReferenceException();
json = JsonSerializer.Serialize(fIBacklogMesaCollection.OrderBy(l => l.Req), new JsonSerializerOptions() { WriteIndented = true });
json = JsonSerializer.Serialize(from l in fIBacklogMesaCollection orderby l.Req.Length, l.Req select l, new JsonSerializerOptions() { WriteIndented = true });
_Details.Add(json);
}

View File

@ -0,0 +1,29 @@
using Adaptation.FileHandlers.ConvertExcelToJson;
using System.Linq;
using System.Net;
using System.Web.Http;
namespace Adaptation.FileHandlers.json;
public class BacklogController : ApiController
{
#pragma warning disable CA1822
public FIBacklogMesa[] GetAllRecords()
#pragma warning restore CA1822
{
FIBacklogMesa[] results = Helper.GetFIBacklogMesaRecords(FileRead.Json);
return results;
}
#pragma warning disable CA1822
public FIBacklogMesa GetRecordById(string id)
#pragma warning restore CA1822
{
FIBacklogMesa[] fIBacklogMesaRecords = Helper.GetFIBacklogMesaRecords(FileRead.Json);
FIBacklogMesa product = fIBacklogMesaRecords.FirstOrDefault(l => l.Req == id) ??
throw new HttpResponseException(HttpStatusCode.NotFound);
return product;
}
}

View File

@ -14,25 +14,29 @@ using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Web.Http;
using System.Web.Http.SelfHost;
namespace Adaptation.FileHandlers.json;
public class FileRead : Shared.FileRead, IFileRead
{
private string _Json;
internal static string Json { get; private set; }
private readonly string _API;
private readonly string _Query;
private readonly string _Project;
private readonly string _BasePage;
private readonly HttpClient _HttpClient;
private readonly HttpSelfHostServer _HttpSelfHostServer;
private readonly WorkItemTrackingHttpClient _WorkItemTrackingHttpClient;
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;
_Json = string.Empty;
Json = string.Empty;
_NullData = string.Empty;
_Logistics = new(this);
if (_FileParameter is null)
@ -58,6 +62,11 @@ public class FileRead : Shared.FileRead, IFileRead
VssConnection connection = new(new(string.Concat(baseAddress, basePage)), credential);
_WorkItemTrackingHttpClient = connection.GetClient<WorkItemTrackingHttpClient>();
_BasePage = basePage;
string httpSelfHostConfigurationBaseAddress = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, string.Concat("CellInstance.", cellInstanceName, ".HttpSelfHostConfiguration.BaseAddress"));
HttpSelfHostConfiguration config = new(httpSelfHostConfigurationBaseAddress);
_ = config.Routes.MapHttpRoute("API Default", "api/{controller}/{id}", new { id = RouteParameter.Optional });
_HttpSelfHostServer = new(config);
_HttpSelfHostServer.OpenAsync().Wait();
}
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) => Move(extractResults);
@ -130,7 +139,7 @@ public class FileRead : Shared.FileRead, IFileRead
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>());
_Logistics = new Logistics(reportFullPath, $"LOGISTICS_1{'\t'}A_JOBID={"BACKLOG"};A_MES_ENTITY={"BACKLOG"};");
string json = File.ReadAllText(reportFullPath);
if (_Json == json)
if (Json == json)
results.Item4.Add(_Logistics.FileInfo);
else
{
@ -140,7 +149,7 @@ public class FileRead : Shared.FileRead, IFileRead
if (!iProcessData.Details.Any())
throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks));
results = iProcessData.GetResults(this, _Logistics, results.Item4);
_Json = json;
Json = json;
}
return results;
}

View File

@ -0,0 +1,21 @@
using Adaptation.FileHandlers.ConvertExcelToJson;
using System;
using System.Text.Json;
namespace Adaptation.FileHandlers.json;
public class Helper
{
#nullable enable
internal static FIBacklogMesa[] GetFIBacklogMesaRecords(string json)
{
FIBacklogMesa[]? results;
results = JsonSerializer.Deserialize<FIBacklogMesa[]>(json, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true });
if (results is null)
throw new NullReferenceException();
return results;
}
}

View File

@ -237,7 +237,7 @@ public class ProcessData : IProcessData
document = new();
AddPatch(document, "/fields/System.AreaPath", project);
AddPatch(document, "/fields/System.IterationPath", project);
AddPatch(document, "/fields/System.Title", keyValuePair.Value.Title);
AddPatch(document, "/fields/System.Title", keyValuePair.Value.Subject);
AddPatch(document, "/fields/System.Description", $"{description}<br />{keyValuePair.Value.Definition}");
// AddPatch(document, "/fields/System.AssignedTo", "Mike.Phares@infineon.com");
workItemTask = workItemTrackingHttpClient.CreateWorkItemAsync(document, project, "Bug");

View File

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>FI Backlog Mesa</title>
<link href="/igniteui/css/themes/bootstrap3/default/infragistics.theme.css?v=2023-06-09-15-01" rel="stylesheet" />
<link href="/igniteui/css/structure/infragistics.css?v=2023-06-09-15-01" rel="stylesheet" />
<script src="/js/jquery-3.6.0.min.js?v=2023-06-09-15-01" type="text/javascript"></script>
<script src="/js/jquery-ui.min.js?v=2023-06-09-15-01" type="text/javascript"></script>
<script src="/js/site.js?v=2023-06-09-15-01" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.core.js?v=2023-06-09-15-01" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.lob.js?v=2023-06-09-15-01" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.dv.js?v=2023-06-09-15-01" type="text/javascript"></script>
</head>
<body>
<h2>FI Backlog Mesa</h2>
<div style="height: 550px;" id="HeaderGridDiv">
<table id="HeaderGrid"></table>
</div>
<script>
$(document).ready(function () {
initIndex("/json/data.json");
});
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,36 @@
function compareFunction(a, b) {
return a['Priority'][0] - b['Priority'][0] || a['Req '].length - b['Req '].length || a['Req '] - b['Req '];
}
function initIndex(url) {
$.getJSON(url, function (data) {
for (var i = data.length - 1; i > -1; i--) {
if (data[i].Submitted !== '')
continue;
data.splice(i, 1);
}
data.sort(compareFunction);
$("#HeaderGrid").igGrid({
autoGenerateColumns: false,
dataSource: data,
height: "100%",
width: "100%",
columns: [
{ key: "Req", dataType: "number" },
{ key: "Submitted", dataType: "date", format: "date" },
{ key: "Requestor", dataType: "string" },
{ key: "Assigned To", dataType: "string" },
{ key: "Second Resource", dataType: "string" },
{ key: "Subject - from Requestor", dataType: "string" },
{ key: "System(s)", dataType: "string" },
{ key: "Priority", dataType: "string" },
],
features: [
{ name: "Paging", type: "local", recordCountKey: "TotalRows", pageSize: 25, pageSizeUrlKey: "pageSize", "pageIndexUrlKey": "page", showPageSizeDropDown: false },
{ name: "Selection", mode: "row", multipleSelection: false },
{ name: "Filtering", type: "local" },
{ name: "Sorting", type: "local" },
],
});
});
}

View File

@ -0,0 +1,36 @@
[
{
"Req": "",
"Submitted": "",
"Requestor": "",
"Assigned To": "",
"Second Resource": "",
"Subject - from Requestor": null,
"Epi Line": null,
"Area": null,
"System(s)": "",
"Priority": "",
"Status": "",
"Definition": null,
"Updates": "",
"Est Effort _(days)": "",
"Commit Date": "",
"Re-Commit Date": "",
"UAT as of": "",
"CMP Date": null,
"F20": "",
"F21": "",
"F22": "",
"F23": "",
"F24": "",
"F25": "",
"F26": "",
"F27": "",
"F28": "",
"F29": "",
"F30": "",
"F31": "",
"F32": "",
"F33": ""
}
]