aktueller Stand
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user