aktueller stand
This commit is contained in:
@@ -3,18 +3,20 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using FasdCockpitBase.Models;
|
||||
using FasdCockpitCommunicationDemo;
|
||||
using C4IT.FASD.Base;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using FasdCockpitBase;
|
||||
using C4IT.Logging;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.Xml;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using FasdCockpitBase.Models;
|
||||
using FasdCockpitCommunicationDemo;
|
||||
using C4IT.Configuration;
|
||||
using C4IT.FASD.Base;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using FasdCockpitBase;
|
||||
using C4IT.Logging;
|
||||
|
||||
|
||||
namespace C4IT.FASD.Cockpit.Communication
|
||||
@@ -245,18 +247,19 @@ namespace C4IT.FASD.Cockpit.Communication
|
||||
scopeDictionary[scopeKey] = definitions;
|
||||
}
|
||||
|
||||
if (!definitions.Any(d => d.TicketId == record.TicketId))
|
||||
{
|
||||
definitions.Add(new TicketOverviewRelationDefinition
|
||||
{
|
||||
TicketId = record.TicketId,
|
||||
UserId = record.UserId,
|
||||
DisplayName = record.DisplayName,
|
||||
Summary = record.Summary,
|
||||
StatusId = record.StatusId,
|
||||
UserDisplayName = record.UserDisplayName,
|
||||
UserAccount = record.UserAccount,
|
||||
UserDomain = record.UserDomain
|
||||
if (!definitions.Any(d => d.TicketId == record.TicketId))
|
||||
{
|
||||
definitions.Add(new TicketOverviewRelationDefinition
|
||||
{
|
||||
TicketId = record.TicketId,
|
||||
UserId = record.UserId,
|
||||
DisplayName = record.DisplayName,
|
||||
ActivityType = record.ActivityType,
|
||||
Summary = record.Summary,
|
||||
StatusId = record.StatusId,
|
||||
UserDisplayName = record.UserDisplayName,
|
||||
UserAccount = record.UserAccount,
|
||||
UserDomain = record.UserDomain
|
||||
});
|
||||
}
|
||||
|
||||
@@ -490,6 +493,9 @@ namespace C4IT.FASD.Cockpit.Communication
|
||||
var summary = definition.Summary ?? string.Empty;
|
||||
if (detailTicket != null && !string.IsNullOrWhiteSpace(detailTicket.Summary))
|
||||
summary = detailTicket.Summary;
|
||||
var activityType = string.IsNullOrWhiteSpace(definition.ActivityType)
|
||||
? null
|
||||
: definition.ActivityType.Trim();
|
||||
|
||||
var relation = new cF4sdApiSearchResultRelation
|
||||
{
|
||||
@@ -504,12 +510,13 @@ namespace C4IT.FASD.Cockpit.Communication
|
||||
["StatusId"] = definition.StatusId ?? string.Empty,
|
||||
["UserDisplayName"] = definition.UserDisplayName ?? string.Empty,
|
||||
["UserAccount"] = definition.UserAccount ?? string.Empty,
|
||||
["UserDomain"] = definition.UserDomain ?? string.Empty
|
||||
["UserDomain"] = definition.UserDomain ?? string.Empty,
|
||||
["ActivityType"] = activityType
|
||||
},
|
||||
Identities = new cF4sdIdentityList
|
||||
{
|
||||
new cF4sdIdentityEntry { Class = enumFasdInformationClass.Ticket, Id = definition.TicketId },
|
||||
new cF4sdIdentityEntry { Class = enumFasdInformationClass.User, Id = definition.UserId }
|
||||
Identities = new cF4sdIdentityList
|
||||
{
|
||||
new cF4sdIdentityEntry { Class = enumFasdInformationClass.Ticket, Id = definition.TicketId },
|
||||
new cF4sdIdentityEntry { Class = enumFasdInformationClass.User, Id = definition.UserId }
|
||||
}
|
||||
};
|
||||
relations.Add(relation);
|
||||
@@ -555,10 +562,133 @@ namespace C4IT.FASD.Cockpit.Communication
|
||||
return fallbackData.Tickets.FirstOrDefault(ticket => ticket.Id == definition.TicketId);
|
||||
}
|
||||
|
||||
private static string ResolveTicketActivityType(string displayName, cF4SDTicket detailTicket = null)
|
||||
{
|
||||
var linkType = TryGetActivityTypeFromTicketLinks(detailTicket);
|
||||
if (!string.IsNullOrWhiteSpace(linkType))
|
||||
return linkType;
|
||||
|
||||
var ticketName = displayName ?? detailTicket?.Name;
|
||||
if (string.IsNullOrWhiteSpace(ticketName))
|
||||
return "SPSActivityTypeTicket";
|
||||
|
||||
if (ticketName.StartsWith("INC", StringComparison.OrdinalIgnoreCase))
|
||||
return "SPSActivityTypeIncident";
|
||||
|
||||
if (ticketName.StartsWith("SRQ", StringComparison.OrdinalIgnoreCase))
|
||||
return "SPSActivityTypeServiceRequest";
|
||||
|
||||
if (ticketName.StartsWith("PRB", StringComparison.OrdinalIgnoreCase))
|
||||
return "SPSActivityTypeGroupTicket";
|
||||
|
||||
if (ticketName.StartsWith("ALT", StringComparison.OrdinalIgnoreCase))
|
||||
return "SPSActivityTypeAlert";
|
||||
|
||||
if (ticketName.StartsWith("CHG", StringComparison.OrdinalIgnoreCase))
|
||||
return "SVMChangeRequestType";
|
||||
|
||||
if (ticketName.StartsWith("TSK", StringComparison.OrdinalIgnoreCase))
|
||||
return "SPSActivityTypeBase";
|
||||
|
||||
return "SPSActivityTypeTicket";
|
||||
}
|
||||
|
||||
private static string TryGetActivityTypeFromTicketLinks(cF4SDTicket ticket)
|
||||
{
|
||||
if (ticket?.DirectLinks == null || ticket.DirectLinks.Count == 0)
|
||||
return null;
|
||||
|
||||
foreach (var link in ticket.DirectLinks.Values)
|
||||
{
|
||||
var type = TryGetActivityTypeFromUrl(link);
|
||||
if (!string.IsNullOrWhiteSpace(type))
|
||||
return type;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string TryGetActivityTypeFromUrl(string url)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(url))
|
||||
return null;
|
||||
|
||||
var markerList = new[] { "preview-object/", "edit-object/", "create-object/" };
|
||||
foreach (var marker in markerList)
|
||||
{
|
||||
var markerIndex = url.IndexOf(marker, StringComparison.OrdinalIgnoreCase);
|
||||
if (markerIndex < 0)
|
||||
continue;
|
||||
|
||||
var start = markerIndex + marker.Length;
|
||||
var end = url.IndexOf('/', start);
|
||||
if (end < 0)
|
||||
end = url.IndexOf('?', start);
|
||||
if (end < 0)
|
||||
end = url.Length;
|
||||
|
||||
if (end <= start)
|
||||
continue;
|
||||
|
||||
var activityType = url.Substring(start, end - start).Trim();
|
||||
if (!string.IsNullOrWhiteSpace(activityType))
|
||||
return activityType;
|
||||
}
|
||||
|
||||
// Fallback for view-options based deeplinks.
|
||||
var decodedUrl = Uri.UnescapeDataString(url);
|
||||
const string queryTypeToken = "\"type\":\"";
|
||||
var typeStart = decodedUrl.IndexOf(queryTypeToken, StringComparison.OrdinalIgnoreCase);
|
||||
if (typeStart < 0)
|
||||
return null;
|
||||
|
||||
typeStart += queryTypeToken.Length;
|
||||
var typeEnd = decodedUrl.IndexOf('"', typeStart);
|
||||
if (typeEnd <= typeStart)
|
||||
return null;
|
||||
|
||||
var parsedType = decodedUrl.Substring(typeStart, typeEnd - typeStart).Trim();
|
||||
return string.IsNullOrWhiteSpace(parsedType) ? null : parsedType;
|
||||
}
|
||||
|
||||
private string ResolveDemoM42Server()
|
||||
{
|
||||
foreach (var sampleData in MockupData)
|
||||
{
|
||||
if (sampleData?.Tickets == null)
|
||||
continue;
|
||||
|
||||
foreach (var ticket in sampleData.Tickets)
|
||||
{
|
||||
if (ticket?.DirectLinks == null)
|
||||
continue;
|
||||
|
||||
foreach (var link in ticket.DirectLinks.Values)
|
||||
{
|
||||
if (TryExtractServerBase(link, out var serverBase))
|
||||
return serverBase;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "https://srvwsm001.imagoverum.com";
|
||||
}
|
||||
|
||||
private static bool TryExtractServerBase(string url, out string serverBase)
|
||||
{
|
||||
serverBase = null;
|
||||
|
||||
if (!Uri.TryCreate(url, UriKind.Absolute, out var uri))
|
||||
return false;
|
||||
|
||||
serverBase = uri.GetLeftPart(UriPartial.Authority);
|
||||
return !string.IsNullOrWhiteSpace(serverBase);
|
||||
}
|
||||
|
||||
private static Task SimulateTicketOverviewLatencyAsync(int count)
|
||||
{
|
||||
int baseMs = 420;
|
||||
int perItem = 100;
|
||||
int baseMs = 420;
|
||||
int perItem = 100;
|
||||
int capped = Math.Max(0, Math.Min(count, 5));
|
||||
int delay = Math.Max(240, Math.Min(baseMs + capped * perItem, 2000));
|
||||
return Task.Delay(delay);
|
||||
@@ -1126,10 +1256,10 @@ namespace C4IT.FASD.Cockpit.Communication
|
||||
|
||||
var demoTickets = await GetDemoTicketData(new cF4sdHealthCardRawDataRequest() { Identities = new cF4sdIdentityList() { new cF4sdIdentityEntry() { Class = enumFasdInformationClass.User, Id = Guid.Parse(constGuidTimoTicket) }, new cF4sdIdentityEntry() { Class = enumFasdInformationClass.Computer, Id = Guid.NewGuid() } } });
|
||||
|
||||
foreach (var demoTicket in demoTickets)
|
||||
{
|
||||
output.Add(new cF4sdApiSearchResultRelation() { id = demoTicket.Id, Name = demoTicket.Name, DisplayName = demoTicket.Name, Infos = new Dictionary<string, string>() { ["Summary"] = demoTicket.Summary, ["Status"] = demoTicket.Status.ToString(), ["StatusId"] = ((int)demoTicket.Status).ToString(), ["Asset"] = demoTicket.Asset }, Type = enumF4sdSearchResultClass.Ticket, Identities = new cF4sdIdentityList() { new cF4sdIdentityEntry() { Class = enumFasdInformationClass.User, Id = Guid.Parse(constGuidTimoTicket) }, new cF4sdIdentityEntry() { Class = enumFasdInformationClass.Ticket, Id = demoTicket.Id } } });
|
||||
}
|
||||
foreach (var demoTicket in demoTickets)
|
||||
{
|
||||
output.Add(new cF4sdApiSearchResultRelation() { id = demoTicket.Id, Name = demoTicket.Name, DisplayName = demoTicket.Name, Infos = new Dictionary<string, string>() { ["Summary"] = demoTicket.Summary, ["Status"] = demoTicket.Status.ToString(), ["StatusId"] = ((int)demoTicket.Status).ToString(), ["Asset"] = demoTicket.Asset, ["ActivityType"] = ResolveTicketActivityType(demoTicket.Name, demoTicket) }, Type = enumF4sdSearchResultClass.Ticket, Identities = new cF4sdIdentityList() { new cF4sdIdentityEntry() { Class = enumFasdInformationClass.User, Id = Guid.Parse(constGuidTimoTicket) }, new cF4sdIdentityEntry() { Class = enumFasdInformationClass.Ticket, Id = demoTicket.Id } } });
|
||||
}
|
||||
|
||||
break;
|
||||
case constGuidTimoTicketComputer:
|
||||
@@ -1187,7 +1317,8 @@ namespace C4IT.FASD.Cockpit.Communication
|
||||
["Summary"] = demoTicket.Summary ?? string.Empty,
|
||||
["Status"] = demoTicket.Status.ToString(),
|
||||
["StatusId"] = ((int)demoTicket.Status).ToString(),
|
||||
["Asset"] = demoTicket.Asset ?? string.Empty
|
||||
["Asset"] = demoTicket.Asset ?? string.Empty,
|
||||
["ActivityType"] = ResolveTicketActivityType(demoTicket.Name, demoTicket)
|
||||
},
|
||||
Identities = new cF4sdIdentityList()
|
||||
{
|
||||
@@ -2007,16 +2138,43 @@ namespace C4IT.FASD.Cockpit.Communication
|
||||
return true;
|
||||
}
|
||||
|
||||
public override async Task<bool> GetCockpitConfiguration()
|
||||
{
|
||||
cCockpitConfiguration.Instance = new cCockpitConfiguration();
|
||||
cCockpitConfiguration.Instance.agentApiConfiguration = new cAgentApiConfiguration() { ApiUrl = "", ClientId = "", ClientSecret = "", LogonUrl = "", OrganizationCode = 0 };
|
||||
cCockpitConfiguration.Instance.m42ServerConfiguration = new cM42ServerConfiguration() { Server = "" };
|
||||
await Task.CompletedTask;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override Task<bool> GetAgentOnlineStatus(int AgentDeviceId, int? AgentUserId = null) => Task.FromResult(true);
|
||||
public override async Task<bool> GetCockpitConfiguration()
|
||||
{
|
||||
cCockpitConfiguration.Instance = new cCockpitConfiguration();
|
||||
cCockpitConfiguration.Instance.agentApiConfiguration = new cAgentApiConfiguration() { ApiUrl = "", ClientId = "", ClientSecret = "", LogonUrl = "", OrganizationCode = 0 };
|
||||
cCockpitConfiguration.Instance.m42ServerConfiguration = new cM42ServerConfiguration() { Server = ResolveDemoM42Server() };
|
||||
cCockpitConfiguration.Instance.GlobalConfig = LoadDemoGlobalConfig();
|
||||
await Task.CompletedTask;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static cConfigHelperParameterList LoadDemoGlobalConfig()
|
||||
{
|
||||
try
|
||||
{
|
||||
var executingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
var filePath = Path.Combine(executingDirectory, "Config", "F4SD-Global-Configuration.xml");
|
||||
if (!File.Exists(filePath))
|
||||
return null;
|
||||
|
||||
var xmlDocument = new XmlDocument();
|
||||
xmlDocument.Load(filePath);
|
||||
|
||||
var root = xmlDocument.DocumentElement;
|
||||
if (root == null || !string.Equals(root.Name, "F4SD-Global-Configuration", StringComparison.OrdinalIgnoreCase))
|
||||
return null;
|
||||
|
||||
return cF4sdGlobalConfigParameterParser.Parse(root);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override Task<bool> GetAgentOnlineStatus(int AgentDeviceId, int? AgentUserId = null) => Task.FromResult(true);
|
||||
|
||||
public override Task<cF4sdAgentScript> GetQuickActionOfAgent(int ScriptId) => Task.FromResult(new cF4sdAgentScript() { Id = ScriptId, Name = "AgentScript", Type = enumAgentScriptType.user, UserPermissionRequired = false });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user