aktueller Stand
This commit is contained in:
@@ -1,85 +1,142 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using C4IT.FASD.Base;
|
using C4IT.FASD.Base;
|
||||||
using C4IT.Logging;
|
using C4IT.Logging;
|
||||||
using FasdDesktopUi.Basics;
|
using FasdDesktopUi.Basics;
|
||||||
using static C4IT.Logging.cLogManager;
|
using static C4IT.Logging.cLogManager;
|
||||||
|
|
||||||
namespace FasdDesktopUi.Basics.Helper
|
namespace FasdDesktopUi.Basics.Helper
|
||||||
{
|
{
|
||||||
internal static class TicketDeepLinkHelper
|
internal static class TicketDeepLinkHelper
|
||||||
{
|
{
|
||||||
internal static bool TryOpenTicketRelationExternally(cF4sdApiSearchResultRelation relation)
|
internal static bool TryOpenTicketRelationExternally(cF4sdApiSearchResultRelation relation)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (relation == null || relation.Type != enumF4sdSearchResultClass.Ticket)
|
if (relation == null || relation.Type != enumF4sdSearchResultClass.Ticket)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var ticketConfig = cFasdCockpitConfig.Instance?.Global?.TicketConfiguration;
|
var ticketConfig = cFasdCockpitConfig.Instance?.Global?.TicketConfiguration;
|
||||||
if (ticketConfig == null)
|
if (ticketConfig == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var isIncident = IsIncidentRelation(relation, out var activityType);
|
var activityType = GetActivityType(relation);
|
||||||
var openExternally = isIncident
|
var openExternally = ShouldOpenExternally(ticketConfig, activityType);
|
||||||
? ticketConfig.OpenIncidentsExternally
|
|
||||||
: ticketConfig.OpenTicketsExternally;
|
|
||||||
|
|
||||||
if (!openExternally)
|
if (!openExternally)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var url = BuildTicketDeepLink(relation.id, activityType);
|
var url = BuildTicketDeepLink(relation.id, activityType);
|
||||||
if (string.IsNullOrWhiteSpace(url))
|
if (string.IsNullOrWhiteSpace(url))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
new cBrowsers().Start("default", url);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetActivityType(cF4sdApiSearchResultRelation relation)
|
||||||
|
{
|
||||||
|
if (relation?.Infos != null && relation.Infos.TryGetValue("ActivityType", out var activityTypeValue))
|
||||||
|
return activityTypeValue;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool ShouldOpenExternally(cF4sdTicketConfig ticketConfig, string activityType)
|
||||||
|
{
|
||||||
|
if (ticketConfig == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (TryGetOverride(ticketConfig.OpenActivitiesExternallyOverrides, activityType, out var overrideValue))
|
||||||
|
return overrideValue;
|
||||||
|
|
||||||
|
return ticketConfig.OpenActivitiesExternally;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool TryGetOverride(IEnumerable<string> overrides, string activityType, out bool value)
|
||||||
|
{
|
||||||
|
value = false;
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(activityType) || overrides == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
foreach (var entry in overrides)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(entry))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var parts = entry.Split(new[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (parts.Length != 2)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var typeName = parts[0].Trim();
|
||||||
|
if (!string.Equals(typeName, activityType, StringComparison.OrdinalIgnoreCase))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!TryParseBool(parts[1], out value))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
new cBrowsers().Start("default", url);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
LogException(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool IsIncidentRelation(cF4sdApiSearchResultRelation relation, out string activityType)
|
private static bool TryParseBool(string value, out bool result)
|
||||||
{
|
{
|
||||||
activityType = null;
|
result = false;
|
||||||
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
if (relation?.Infos != null && relation.Infos.TryGetValue("ActivityType", out var activityTypeValue))
|
|
||||||
activityType = activityTypeValue;
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(activityType))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return activityType.IndexOf("Incident", StringComparison.OrdinalIgnoreCase) >= 0;
|
switch (value.Trim().ToLowerInvariant())
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
case "true":
|
||||||
|
case "1":
|
||||||
|
case "yes":
|
||||||
|
result = true;
|
||||||
|
return true;
|
||||||
|
case "false":
|
||||||
|
case "0":
|
||||||
|
case "no":
|
||||||
|
result = false;
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return bool.TryParse(value, out result);
|
||||||
}
|
}
|
||||||
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}";
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
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}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -140,8 +140,8 @@ namespace FasdDesktopUi.Basics.Services.SupportCase
|
|||||||
{
|
{
|
||||||
return tablesToLoad.All(t =>
|
return tablesToLoad.All(t =>
|
||||||
_rawDataCache.TryGetValue(relation, out var cachedRawData)
|
_rawDataCache.TryGetValue(relation, out var cachedRawData)
|
||||||
&& cachedRawData.Tables.TryGetValue(t, out var cachedTable)
|
&& (cachedRawData?.Tables?.TryGetValue(t, out var cachedTable) ?? false)
|
||||||
&& !cachedTable.IsIncomplete && !cachedTable.Columns.Values.Any(c => c.IsIncomplete)
|
&& cachedTable != null && !cachedTable.IsIncomplete && !cachedTable.Columns.Values.Any(c => c.IsIncomplete)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ namespace FasdDesktopUi.Basics
|
|||||||
if (relationToFocus is null)
|
if (relationToFocus is null)
|
||||||
return selectedRelation;
|
return selectedRelation;
|
||||||
|
|
||||||
relationToFocus.Identities = selectedRelation.Identities;
|
relationToFocus.Identities = selectedRelation.Identities.Clone();
|
||||||
return relationToFocus;
|
return relationToFocus;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -672,7 +672,6 @@ namespace FasdDesktopUi.Basics
|
|||||||
ComputerRemoved |= relationIdentity.Class == enumFasdInformationClass.Computer;
|
ComputerRemoved |= relationIdentity.Class == enumFasdInformationClass.Computer;
|
||||||
ComputerAdded |= relationIdentity.Class == enumFasdInformationClass.Computer;
|
ComputerAdded |= relationIdentity.Class == enumFasdInformationClass.Computer;
|
||||||
}
|
}
|
||||||
relationIdentity.CopyTo(existingIdentity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,7 +153,7 @@
|
|||||||
|
|
||||||
<UIItem Name="StartUp.SplashScreen.NoAuthorization">
|
<UIItem Name="StartUp.SplashScreen.NoAuthorization">
|
||||||
<Language Lang="EN">User is not authorized for Cockpit usage</Language>
|
<Language Lang="EN">User is not authorized for Cockpit usage</Language>
|
||||||
<Language Lang="DE">Nutzer ist nicht für die Cockpit-Nutzung authorisiert</Language>
|
<Language Lang="DE">Nutzer ist nicht für die Cockpit-Nutzung autorisiert</Language>
|
||||||
</UIItem>
|
</UIItem>
|
||||||
|
|
||||||
<UIItem Name="StartUp.SplashScreen.InitAppComponents">
|
<UIItem Name="StartUp.SplashScreen.InitAppComponents">
|
||||||
@@ -280,7 +280,7 @@
|
|||||||
|
|
||||||
<UIItem Name="Searchbar.Status.Unauthorized">
|
<UIItem Name="Searchbar.Status.Unauthorized">
|
||||||
<Language Lang="EN">Not authorized</Language>
|
<Language Lang="EN">Not authorized</Language>
|
||||||
<Language Lang="DE">Nicht authorisiert</Language>
|
<Language Lang="DE">Nicht autorisiert</Language>
|
||||||
</UIItem>
|
</UIItem>
|
||||||
|
|
||||||
<UIItem Name="Searchbar.Placeholder">
|
<UIItem Name="Searchbar.Placeholder">
|
||||||
|
|||||||
Reference in New Issue
Block a user