aktueller Stand
This commit is contained in:
@@ -56,7 +56,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
@@ -95,11 +95,12 @@
|
||||
<Compile Include="..\Shared\SharedAssemblyInfo.cs">
|
||||
<Link>Properties\SharedAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="F4sdCockpitCommunicationM42Web.cs" />
|
||||
<Compile Include="FasdCockpitCommunicationWeb.cs" />
|
||||
<Compile Include="FasdCockpitMachineConfiguration.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Compile Include="F4sdCockpitCommunicationM42Web.cs" />
|
||||
<Compile Include="FasdCockpitCommunicationWeb.cs" />
|
||||
<Compile Include="FasdCockpitMachineConfiguration.cs" />
|
||||
<Compile Include="TicketOverview\TicketOverviewCountsResponse.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\F4SD-Logging\F4SD-Logging.csproj">
|
||||
<Project>{7793f281-b226-4e20-b6f6-5d53d70f1dc1}</Project>
|
||||
@@ -115,6 +116,7 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
@@ -123,4 +125,4 @@
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
</Target>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -17,7 +17,8 @@ using C4IT.Security;
|
||||
using C4IT.FASD.Communication.Agent;
|
||||
|
||||
using FasdCockpitBase.Models;
|
||||
using FasdCockpitCommunication;
|
||||
using FasdCockpitCommunication;
|
||||
using FasdCockpitCommunication.TicketOverview;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -1095,10 +1096,119 @@ namespace C4IT.FASD.Cockpit.Communication
|
||||
|
||||
return output;
|
||||
}
|
||||
public override Task<List<cF4sdApiSearchResultRelation>> GetTicketOverviewRelations(string key, bool useRoleScope, int count)
|
||||
{
|
||||
return Task.FromResult(new List<cF4sdApiSearchResultRelation>());
|
||||
}
|
||||
public override async Task<Dictionary<string, int>> GetTicketOverviewCounts(IEnumerable<string> keys, bool useRoleScope)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
|
||||
var apiError = 0;
|
||||
var timeStart = DateTime.UtcNow;
|
||||
|
||||
try
|
||||
{
|
||||
var normalizedKeys = (keys ?? Enumerable.Empty<string>())
|
||||
.Where(k => !string.IsNullOrWhiteSpace(k))
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
|
||||
var http = GetHttpHelper(true);
|
||||
var scope = useRoleScope ? "role" : "personal";
|
||||
var urlBuilder = new StringBuilder($"api/TicketOverview/GetCounts?scope={scope}");
|
||||
|
||||
if (normalizedKeys.Count > 0)
|
||||
{
|
||||
var joinedKeys = HttpUtility.UrlEncode(string.Join(",", normalizedKeys));
|
||||
urlBuilder.Append($"&keys={joinedKeys}");
|
||||
}
|
||||
|
||||
var url = urlBuilder.ToString();
|
||||
var result = await http.GetHttpJson(url, 15000, CancellationToken.None);
|
||||
|
||||
if (!result.IsOk)
|
||||
{
|
||||
apiError = (int)result.Status;
|
||||
if (CheckConnectionStatus != null)
|
||||
await CheckConnectionStatus.Invoke();
|
||||
|
||||
LogEntry($"Error on requesting ticket overview counts ({scope}). Status: {result.Status}", LogLevels.Warning);
|
||||
return new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
if (Debug_apiValues) SaveApiResultValueJson("TicketOverview.GetCounts", result.Result, url);
|
||||
|
||||
var response = JsonConvert.DeserializeObject<TicketOverviewCountsResponse>(result.Result);
|
||||
return response?.ToDictionary(normalizedKeys) ?? new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
apiError = E.HResult;
|
||||
if (CheckConnectionStatus != null)
|
||||
await CheckConnectionStatus.Invoke();
|
||||
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (Debug_apiTiming) SaveApiTimingEntry("TicketOverview.GetCounts", timeStart, apiError);
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
|
||||
return new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public override async Task<List<cF4sdApiSearchResultRelation>> GetTicketOverviewRelations(string key, bool useRoleScope, int count)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
|
||||
var apiError = 0;
|
||||
var timeStart = DateTime.UtcNow;
|
||||
var output = new List<cF4sdApiSearchResultRelation>();
|
||||
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(key))
|
||||
return output;
|
||||
|
||||
var http = GetHttpHelper(true);
|
||||
var scope = useRoleScope ? "role" : "personal";
|
||||
var safeKey = HttpUtility.UrlEncode(key);
|
||||
var url = $"api/TicketOverview/GetRelations?key={safeKey}&scope={scope}&count={Math.Max(0, count)}";
|
||||
|
||||
var result = await http.GetHttpJson(url, 20000, CancellationToken.None);
|
||||
|
||||
if (!result.IsOk)
|
||||
{
|
||||
apiError = (int)result.Status;
|
||||
if (CheckConnectionStatus != null)
|
||||
await CheckConnectionStatus.Invoke();
|
||||
|
||||
LogEntry($"Error on requesting ticket overview relations for '{key}' ({scope}). Status: {result.Status}", LogLevels.Warning);
|
||||
return output;
|
||||
}
|
||||
|
||||
if (Debug_apiValues) SaveApiResultValueJson("TicketOverview.GetRelations", result.Result, url);
|
||||
|
||||
var relations = JsonConvert.DeserializeObject<List<cF4sdApiSearchResultRelation>>(result.Result);
|
||||
if (relations != null)
|
||||
output = relations;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
apiError = E.HResult;
|
||||
if (CheckConnectionStatus != null)
|
||||
await CheckConnectionStatus.Invoke();
|
||||
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (Debug_apiTiming) SaveApiTimingEntry("TicketOverview.GetRelations", timeStart, apiError);
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
public override async Task<cF4SDHealthCardRawData> GetHealthCardData(cF4sdHealthCardRawDataRequest requestData)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace FasdCockpitCommunication.TicketOverview
|
||||
{
|
||||
internal sealed class TicketOverviewCountsResponse
|
||||
{
|
||||
[JsonProperty("counts")]
|
||||
public Dictionary<string, int> Counts { get; set; } = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public Dictionary<string, int> ToDictionary(IEnumerable<string> expectedKeys)
|
||||
{
|
||||
var comparer = StringComparer.OrdinalIgnoreCase;
|
||||
var output = new Dictionary<string, int>(comparer);
|
||||
|
||||
if (expectedKeys != null)
|
||||
{
|
||||
foreach (var key in expectedKeys)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(key))
|
||||
continue;
|
||||
|
||||
if (Counts != null && Counts.TryGetValue(key, out var count))
|
||||
output[key] = count;
|
||||
else
|
||||
output[key] = 0;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
if (Counts != null)
|
||||
{
|
||||
foreach (var kvp in Counts)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(kvp.Key))
|
||||
continue;
|
||||
|
||||
output[kvp.Key] = kvp.Value;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
FasdCockpitCommunication/app.config
Normal file
11
FasdCockpitCommunication/app.config
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-10.0.0.2" newVersion="10.0.0.2" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="13.0.4" targetFramework="net472" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user