HttpSelfHostServer
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user