aktueller Stand
This commit is contained in:
85
FasdDesktopUi/Basics/Helper/TicketDeepLinkHelper.cs
Normal file
85
FasdDesktopUi/Basics/Helper/TicketDeepLinkHelper.cs
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
using System;
|
||||||
|
using C4IT.FASD.Base;
|
||||||
|
using C4IT.Logging;
|
||||||
|
using FasdDesktopUi.Basics;
|
||||||
|
using static C4IT.Logging.cLogManager;
|
||||||
|
|
||||||
|
namespace FasdDesktopUi.Basics.Helper
|
||||||
|
{
|
||||||
|
internal static class TicketDeepLinkHelper
|
||||||
|
{
|
||||||
|
internal static bool TryOpenTicketRelationExternally(cF4sdApiSearchResultRelation relation)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (relation == null || relation.Type != enumF4sdSearchResultClass.Ticket)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var ticketConfig = cFasdCockpitConfig.Instance?.Global?.TicketConfiguration;
|
||||||
|
if (ticketConfig == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var isIncident = IsIncidentRelation(relation, out var activityType);
|
||||||
|
var openExternally = isIncident
|
||||||
|
? ticketConfig.OpenIncidentsExternally
|
||||||
|
: ticketConfig.OpenTicketsExternally;
|
||||||
|
|
||||||
|
if (!openExternally)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var url = BuildTicketDeepLink(relation.id, activityType);
|
||||||
|
if (string.IsNullOrWhiteSpace(url))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
new cBrowsers().Start("default", url);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static bool IsIncidentRelation(cF4sdApiSearchResultRelation relation, out string activityType)
|
||||||
|
{
|
||||||
|
activityType = null;
|
||||||
|
|
||||||
|
if (relation?.Infos != null && relation.Infos.TryGetValue("ActivityType", out var activityTypeValue))
|
||||||
|
activityType = activityTypeValue;
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(activityType))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return activityType.IndexOf("Incident", StringComparison.OrdinalIgnoreCase) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static string BuildTicketDeepLink(Guid ticketId, string activityType)
|
||||||
|
{
|
||||||
|
if (ticketId == Guid.Empty)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var server = cCockpitConfiguration.Instance?.m42ServerConfiguration?.Server;
|
||||||
|
if (string.IsNullOrWhiteSpace(server))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var baseUrl = server.TrimEnd('/');
|
||||||
|
if (!baseUrl.StartsWith("http://", StringComparison.OrdinalIgnoreCase) &&
|
||||||
|
!baseUrl.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
baseUrl = "https://" + baseUrl;
|
||||||
|
}
|
||||||
|
if (!baseUrl.EndsWith("/wm", StringComparison.OrdinalIgnoreCase))
|
||||||
|
baseUrl += "/wm";
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(activityType))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var viewOptionsJson = $"{{\"embedded\":false,\"objectId\":\"{ticketId}\",\"type\":\"{activityType}\",\"viewType\":\"preview\",\"archived\":0}}";
|
||||||
|
var viewOptionsEncoded = Uri.EscapeDataString(viewOptionsJson);
|
||||||
|
|
||||||
|
return $"{baseUrl}/app-ServiceDesk/?view-options={viewOptionsEncoded}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using C4IT.FASD.Base;
|
using C4IT.FASD.Base;
|
||||||
using C4IT.Logging;
|
using C4IT.Logging;
|
||||||
using C4IT.MultiLanguage;
|
using C4IT.MultiLanguage;
|
||||||
|
using FasdDesktopUi.Basics.Helper;
|
||||||
using FasdDesktopUi.Basics.Services.RelationService;
|
using FasdDesktopUi.Basics.Services.RelationService;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -67,6 +68,9 @@ namespace FasdDesktopUi.Basics.UiActions
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TicketDeepLinkHelper.TryOpenTicketRelationExternally(_selectedRelation))
|
||||||
|
return false;
|
||||||
|
|
||||||
// check, if have an active support case
|
// check, if have an active support case
|
||||||
var supportCaseActive = dataProvider?.IsActive ?? false;
|
var supportCaseActive = dataProvider?.IsActive ?? false;
|
||||||
|
|
||||||
|
|||||||
@@ -219,6 +219,7 @@
|
|||||||
<Compile Include="Basics\Enums\enumActionDisplayType.cs" />
|
<Compile Include="Basics\Enums\enumActionDisplayType.cs" />
|
||||||
<Compile Include="Basics\Helper\DirectConnectionHelper.cs" />
|
<Compile Include="Basics\Helper\DirectConnectionHelper.cs" />
|
||||||
<Compile Include="Basics\Helper\HealthCardDataHelper.cs" />
|
<Compile Include="Basics\Helper\HealthCardDataHelper.cs" />
|
||||||
|
<Compile Include="Basics\Helper\TicketDeepLinkHelper.cs" />
|
||||||
<Compile Include="Basics\Helper\QuickActionProtocollHelper.cs" />
|
<Compile Include="Basics\Helper\QuickActionProtocollHelper.cs" />
|
||||||
<Compile Include="Basics\Helper\RichTextBoxHelper.cs" />
|
<Compile Include="Basics\Helper\RichTextBoxHelper.cs" />
|
||||||
<Compile Include="Basics\Helper\UiElementHelper.cs" />
|
<Compile Include="Basics\Helper\UiElementHelper.cs" />
|
||||||
|
|||||||
@@ -1035,73 +1035,7 @@ namespace FasdDesktopUi.Pages.SearchPage
|
|||||||
|
|
||||||
private bool TryOpenTicketOverviewRelationExternally(cF4sdApiSearchResultRelation relation)
|
private bool TryOpenTicketOverviewRelationExternally(cF4sdApiSearchResultRelation relation)
|
||||||
{
|
{
|
||||||
try
|
return TicketDeepLinkHelper.TryOpenTicketRelationExternally(relation);
|
||||||
{
|
|
||||||
var ticketConfig = cFasdCockpitConfig.Instance?.Global?.TicketConfiguration;
|
|
||||||
if (ticketConfig == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var isIncident = IsIncidentRelation(relation, out var activityType);
|
|
||||||
var openExternally = isIncident
|
|
||||||
? ticketConfig.OverviewOpenIncidentsExternally
|
|
||||||
: ticketConfig.OverviewOpenTicketsExternally;
|
|
||||||
|
|
||||||
if (!openExternally)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var url = BuildTicketOverviewDeepLink(relation.id, activityType, isIncident);
|
|
||||||
if (string.IsNullOrWhiteSpace(url))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
new cBrowsers().Start("default", url);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
LogException(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool IsIncidentRelation(cF4sdApiSearchResultRelation relation, out string activityType)
|
|
||||||
{
|
|
||||||
activityType = null;
|
|
||||||
|
|
||||||
if (relation?.Infos != null && relation.Infos.TryGetValue("ActivityType", out var activityTypeValue))
|
|
||||||
activityType = activityTypeValue;
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(activityType))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return activityType.IndexOf("Incident", StringComparison.OrdinalIgnoreCase) >= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string BuildTicketOverviewDeepLink(Guid ticketId, string activityType, bool isIncident)
|
|
||||||
{
|
|
||||||
if (ticketId == Guid.Empty)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
var server = cCockpitConfiguration.Instance?.m42ServerConfiguration?.Server;
|
|
||||||
if (string.IsNullOrWhiteSpace(server))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
var baseUrl = server.TrimEnd('/');
|
|
||||||
if (!baseUrl.StartsWith("http://", StringComparison.OrdinalIgnoreCase) &&
|
|
||||||
!baseUrl.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
baseUrl = "https://" + baseUrl;
|
|
||||||
}
|
|
||||||
if (!baseUrl.EndsWith("/wm", StringComparison.OrdinalIgnoreCase))
|
|
||||||
baseUrl += "/wm";
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(activityType))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
var viewOptionsJson = $"{{\"embedded\":false,\"objectId\":\"{ticketId}\",\"type\":\"{activityType}\",\"viewType\":\"preview\",\"archived\":0}}";
|
|
||||||
var viewOptionsEncoded = Uri.EscapeDataString(viewOptionsJson);
|
|
||||||
|
|
||||||
return $"{baseUrl}/app-ServiceDesk/?view-options={viewOptionsEncoded}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task RunTicketSearchAsync(string ticketName, Guid ticketId, string userName, string sids, bool suppressUi = false)
|
private Task RunTicketSearchAsync(string ticketName, Guid ticketId, string userName, string sids, bool suppressUi = false)
|
||||||
|
|||||||
Reference in New Issue
Block a user