Add Phoenix remote desktop, action connector, documentation engine, and gamification support. Refactor support-case processing and search/action UI, and update installer assets and dependencies.
71 lines
2.5 KiB
C#
71 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
using C4IT.FASD.Base;
|
|
using C4IT.Logging;
|
|
|
|
using FasdDesktopUi.Basics;
|
|
|
|
using static C4IT.Logging.cLogManager;
|
|
|
|
namespace FasdDesktopUi.Basics.Helper
|
|
{
|
|
internal static class TicketExternalLinkHelper
|
|
{
|
|
internal static bool TryOpenTicketRelationExternally(cF4sdApiSearchResultRelation relation)
|
|
{
|
|
try
|
|
{
|
|
if (relation == null || relation.Type != enumF4sdSearchResultClass.Ticket)
|
|
return false;
|
|
|
|
// check how we should open this ticket (intern, extern or both)
|
|
var ticketType = GetTicketType(relation);
|
|
var processing = ShouldOpenExternally(ticketType);
|
|
|
|
// check if we have a valid user id in the id list => if not we could open this ticket only extern.
|
|
var hasUser = relation.Identities.Any(e => (e.Class == enumFasdInformationClass.User && e.Id != null && e.Id != Guid.Empty));
|
|
if (!hasUser)
|
|
processing = enumTicketProcessing.Extern;
|
|
|
|
if (processing == enumTicketProcessing.Intern)
|
|
return false;
|
|
|
|
if (relation?.Infos?.TryGetValue("TicketLink", out var ticketLink) == true && !string.IsNullOrWhiteSpace(ticketLink))
|
|
new cBrowsers().Start("default", ticketLink);
|
|
|
|
return processing == enumTicketProcessing.Extern;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogException(ex);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
private static enumTicketType GetTicketType(cF4sdApiSearchResultRelation relation)
|
|
{
|
|
if (relation?.Infos != null && relation.Infos.TryGetValue("TicketType", out var ticketTypeValue))
|
|
{
|
|
if (Enum.TryParse<enumTicketType>(ticketTypeValue, true, out var ticketType))
|
|
return ticketType;
|
|
}
|
|
return enumTicketType.Ticket;
|
|
}
|
|
|
|
private static enumTicketProcessing ShouldOpenExternally(enumTicketType ticketType)
|
|
{
|
|
var ticketConfig = cFasdCockpitConfig.Instance?.Global?.TicketConfiguration;
|
|
if (ticketConfig == null)
|
|
return enumTicketProcessing.Extern;
|
|
|
|
if (ticketConfig.TicketProcessing?.TryGetValue(ticketType, out var processing) == true)
|
|
return processing;
|
|
|
|
return ticketConfig.DefaultProcessing;
|
|
}
|
|
}
|
|
}
|