" + cMultiLanguageSupport.GetItem("QuickAction.Copy.Output.Html") + " " + displayValue + "
";
break;
}
@@ -379,11 +372,11 @@ namespace FasdDesktopUi.Basics.Services.ProtocollService
foreach (var value in listOutput.Values[0])
{
- if (ShouldHideQuickActionOutput(value.Key))
+ if (ShouldHideQuickActionOutput(quickActionDefinition, value.Key))
continue;
string headingValue = value.Key;
- if (_quickActionDefinition.ColumnOutputFormattings?.TryGetValue(value.Key, out var outputFormatting) ?? false)
+ if (quickActionDefinition.ColumnOutputFormattings?.TryGetValue(value.Key, out var outputFormatting) ?? false)
headingValue = outputFormatting.Names.GetValue();
output += "";
@@ -442,7 +435,7 @@ namespace FasdDesktopUi.Basics.Services.ProtocollService
output += "";
output += "| ";
- string displayValue = objectOutput.GetDisplayValue(i, _quickActionDefinition.ColumnOutputFormattings);
+ string displayValue = objectOutput.GetDisplayValue(i, quickActionDefinition.ColumnOutputFormattings);
output += !string.IsNullOrWhiteSpace(displayValue) ? displayValue : null;
output += " | ";
@@ -462,7 +455,7 @@ namespace FasdDesktopUi.Basics.Services.ProtocollService
return output;
}
- private string GetQuickActionHtmlValueComparison(List measureValues)
+ private static string GetQuickActionHtmlValueComparison(List measureValues)
{
string output = string.Empty;
@@ -474,6 +467,7 @@ namespace FasdDesktopUi.Basics.Services.ProtocollService
output += "" + cMultiLanguageSupport.GetItem("QuickAction.Copy.Measure.Html") + "
";
cUtility.RawValueFormatter.SetDefaultCulture(new System.Globalization.CultureInfo(cFasdCockpitConfig.Instance.SelectedLanguage));
+ cUtility.RawValueFormatter.SetDefaultTimeZone(TimeZoneInfo.Local);
foreach (var measureValue in measureValues)
{
diff --git a/FasdDesktopUi/Basics/Services/ProtocollService/QuickTipStepProtocollEntry.cs b/FasdDesktopUi/Basics/Services/ProtocollService/QuickTipStepProtocollEntry.cs
index d83f688..c3a8694 100644
--- a/FasdDesktopUi/Basics/Services/ProtocollService/QuickTipStepProtocollEntry.cs
+++ b/FasdDesktopUi/Basics/Services/ProtocollService/QuickTipStepProtocollEntry.cs
@@ -1,27 +1,30 @@
-using C4IT.FASD.Base;
+using C4IT.F4SD.SupportCaseProtocoll.Models;
+using C4IT.FASD.Base;
using C4IT.MultiLanguage;
namespace FasdDesktopUi.Basics.Services.ProtocollService
{
- internal class QuickTipStepProtocollEntry : IProtocollEntry
+ internal static class QuickTipStepProtocollEntryOutput
{
- private readonly cQuickTipElement _quickTipElementDefinition;
- private readonly bool _wasSuccessfull;
-
- public QuickTipStepProtocollEntry(cQuickTipElement quickTipElementDefinition, bool wasSuccessfull)
+ public static QuickTipStepProtocollEntry GetQuickTipStepProtocollEntry(cQuickTipElement quickTipElementDefinition, bool wasSuccessfull)
{
- _quickTipElementDefinition = quickTipElementDefinition;
- _wasSuccessfull = wasSuccessfull;
+ string ascii = GetAsciiOutput(quickTipElementDefinition, wasSuccessfull);
+ string html = GetHtmlOutput(quickTipElementDefinition, wasSuccessfull);
+ return new QuickTipStepProtocollEntry(ascii, html)
+ {
+ Name = quickTipElementDefinition.Name,
+ WasSuccessfull = wasSuccessfull
+ };
}
- public string GetAscii()
+ private static string GetAsciiOutput(cQuickTipElement quickTipElementDefinition, bool wasSuccessfull)
{
string currentLanguage = cMultiLanguageSupport.CurrentLanguage;
try
{
cMultiLanguageSupport.CurrentLanguage = cF4SDCockpitXmlConfig.Instance.HealthCardConfig.ProtocollLanguage ?? currentLanguage;
- string ascii = _wasSuccessfull ? cMultiLanguageSupport.GetItem("QuickTips.Copy.ManualStep.Successfull") : cMultiLanguageSupport.GetItem("QuickTips.Copy.ManualStep.Unsuccessfull");
- return string.Format(ascii, _quickTipElementDefinition?.Names?.GetValue());
+ string ascii = wasSuccessfull ? cMultiLanguageSupport.GetItem("QuickTips.Copy.ManualStep.Successfull") : cMultiLanguageSupport.GetItem("QuickTips.Copy.ManualStep.Unsuccessfull");
+ return string.Format(ascii, quickTipElementDefinition?.Names?.GetValue());
}
finally
{
@@ -29,7 +32,7 @@ namespace FasdDesktopUi.Basics.Services.ProtocollService
}
}
- public string GetHtml()
- => GetAscii();
+ private static string GetHtmlOutput(cQuickTipElement quickTipElementDefinition, bool wasSuccessfull)
+ => GetAsciiOutput(quickTipElementDefinition, wasSuccessfull);
}
}
diff --git a/FasdDesktopUi/Basics/Services/ProtocollService/TextualProtocollEntry.cs b/FasdDesktopUi/Basics/Services/ProtocollService/TextualProtocollEntry.cs
deleted file mode 100644
index 150341d..0000000
--- a/FasdDesktopUi/Basics/Services/ProtocollService/TextualProtocollEntry.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-namespace FasdDesktopUi.Basics.Services.ProtocollService
-{
- internal class TextualProtocollEntry : IProtocollEntry
- {
- private readonly string _asciiText;
- private readonly string _htmlText;
-
- public TextualProtocollEntry(string asciiText, string htmlText)
- {
- _asciiText = asciiText;
- _htmlText = htmlText;
- }
-
- public string GetAscii() => _asciiText;
-
- public string GetHtml() => _htmlText;
- }
-}
diff --git a/FasdDesktopUi/Basics/Services/RelationService/RelationService.cs b/FasdDesktopUi/Basics/Services/RelationService/RelationService.cs
index ca81a80..b8f4a1b 100644
--- a/FasdDesktopUi/Basics/Services/RelationService/RelationService.cs
+++ b/FasdDesktopUi/Basics/Services/RelationService/RelationService.cs
@@ -4,10 +4,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
-using System.Text;
using System.Threading;
using System.Threading.Tasks;
-using System.Windows.Forms;
using static C4IT.Logging.cLogManager;
[assembly: InternalsVisibleTo("F4SD.Cockpit.Client.Test")]
@@ -29,7 +27,7 @@ namespace FasdDesktopUi.Basics.Services.RelationService
{
try
{
- _relations = new List();
+ _relations = relatedTo?.Select(searchResult => new cF4sdApiSearchResultRelation(searchResult)).ToList() ?? new List();
cF4sdStagedSearchResultRelationTaskId gatherRelationTask = await cFasdCockpitCommunicationBase.Instance.StartGatheringRelations(relatedTo, token);
_ = Task.Run(async () =>
diff --git a/FasdDesktopUi/Basics/Services/SupportCase/Controllers/SupportCaseController.cs b/FasdDesktopUi/Basics/Services/SupportCase/Controllers/SupportCaseController.cs
new file mode 100644
index 0000000..29cad06
--- /dev/null
+++ b/FasdDesktopUi/Basics/Services/SupportCase/Controllers/SupportCaseController.cs
@@ -0,0 +1,255 @@
+using C4IT.FASD.Base;
+using C4IT.FASD.Cockpit.Communication;
+using FasdDesktopUi.Basics.CustomEvents;
+using FasdDesktopUi.Basics.Models;
+using FasdDesktopUi.Pages.DetailsPage.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using static C4IT.Logging.cLogManager;
+
+namespace FasdDesktopUi.Basics.Services.SupportCase.Controllers
+{
+ ///
+ /// Used to manage the for the UI via the "
+ ///
+ public class SupportCaseController
+ {
+ private SupportCaseProcessor _supportCaseProcessor;
+ private cF4sdApiSearchResultRelation _focusedRelation;
+ private readonly Dictionary _selectedRelations = new Dictionary();
+ private cHealthCard _selectedHealthcard = null;
+ private bool _hasDirectionConnection = false;
+ public cSupportCaseDataProvider SupportCaseDataProviderArtifact { get => _supportCaseProcessor?.SupportCaseDataProviderArtifact; }
+
+ internal void SetSupportCaseProcessor(SupportCaseProcessor supportCaseProcessor, IEnumerable preselectedIdentities)
+ {
+ IEnumerable preselectedRelations = GetPreselectedRelations(supportCaseProcessor.GetCaseRelations(), preselectedIdentities);
+
+ ResetSelectedRelations(preselectedRelations);
+ _hasDirectionConnection = false;
+
+ if (_supportCaseProcessor != null)
+ {
+ _supportCaseProcessor.AvailableCaseRelationsAdded -= HandleAvailableCaseRelationsAdded;
+ _supportCaseProcessor.CaseDataChanged -= HandleCaseDataChanged;
+ _supportCaseProcessor.SupportCaseDataProviderArtifact.DirectConnectionHelper.DirectConnectionChanged -= HandleDirectConnectionChanged;
+ }
+
+ _supportCaseProcessor = supportCaseProcessor;
+
+ _supportCaseProcessor.AvailableCaseRelationsAdded += HandleAvailableCaseRelationsAdded;
+ _supportCaseProcessor.CaseDataChanged += HandleCaseDataChanged;
+ _supportCaseProcessor.SupportCaseDataProviderArtifact.DirectConnectionHelper.DirectConnectionChanged += HandleDirectConnectionChanged;
+ }
+
+ private IEnumerable GetPreselectedRelations
+ (ILookup loadedRelations, IEnumerable preselectedIdentities)
+ {
+ List preselectedRelations = new List();
+
+ foreach (var relationType in loadedRelations)
+ {
+ foreach (var relation in relationType)
+ {
+ if (relation.Identities.All(ri => preselectedIdentities.Any(i => i.Id == ri.Id)))
+ preselectedRelations.Add(relation);
+ }
+ }
+
+ return preselectedRelations;
+ }
+
+ private void ResetSelectedRelations(IEnumerable preselectedRelations)
+ {
+ try
+ {
+ _selectedRelations.Clear();
+
+ if (preselectedRelations is null)
+ return;
+
+ foreach (var relation in preselectedRelations)
+ {
+ _selectedRelations[cF4sdIdentityEntry.GetFromSearchResult(relation.Type)] = relation;
+ }
+ }
+ catch (Exception ex)
+ {
+ LogException(ex);
+ }
+ }
+
+ private void HandleAvailableCaseRelationsAdded(object sender, RelationEventArgs e)
+ => AvailableCaseRelationsAdded?.Invoke(this, e);
+
+ private void HandleCaseDataChanged(object sender, SupportCaseDataEventArgs e)
+ {
+ CaseDataChanged?.Invoke(this, e);
+
+ _ = Task.Run(async () =>
+ {
+ await UpdateStatusOfSelectedRelations();
+
+ if (!_hasDirectionConnection)
+ await SupportCaseDataProviderArtifact.DirectConnectionHelper.DirectConnectionStartAsync();
+ });
+ }
+
+ private void HandleDirectConnectionChanged(object sender, EventArgs e)
+ {
+ _hasDirectionConnection = SupportCaseDataProviderArtifact.DirectConnectionHelper.IsDirectConnectionActive;
+ }
+
+ ///
+ /// Updates the currently for a support case relevant and shown relation.
+ ///
+ /// Raises
+ internal void UpdateFocusedCaseRelation(cF4sdApiSearchResultRelation relation)
+ {
+ try
+ {
+ _selectedHealthcard = _supportCaseProcessor.GetHealthcardFor(relation);
+ HashSet requiredTables = cHealthCard.GetRequiredTables(_selectedHealthcard);
+ _ = Task.Run(async () => await _supportCaseProcessor.LoadSupportCaseDataAsync(relation, requiredTables));
+
+ List requiredInformationClasses = relation.Identities
+ .Where(i => i.Class != enumFasdInformationClass.User)
+ .Select(i => i.Class)
+ .ToList();
+
+ if (relation.Type == enumF4sdSearchResultClass.User)
+ requiredInformationClasses = new List() { enumFasdInformationClass.User };
+
+ if (requiredInformationClasses.Count == 0)
+ requiredInformationClasses.Add(enumFasdInformationClass.User);
+
+ SupportCaseDataProviderArtifact.HealthCardDataHelper.TrySetSelectedHealthcard(requiredInformationClasses);
+
+ _focusedRelation = relation;
+
+ if (!_selectedRelations.Values.Contains(relation))
+ _hasDirectionConnection = false;
+
+ _selectedRelations[cF4sdIdentityEntry.GetFromSearchResult(relation.Type)] = relation;
+ _ = Task.Run(async () => await UpdateStatusOfSelectedRelations());
+
+ var focusedRelations = new cF4sdApiSearchResultRelation[1] { _focusedRelation };
+ FocusedRelationsChanged?.Invoke(this, new RelationEventArgs()
+ {
+ Relations = focusedRelations.ToLookup(r => cF4sdIdentityEntry.GetFromSearchResult(r.Type), r => r)
+ });
+ }
+ catch (Exception ex)
+ {
+ LogException(ex);
+ }
+ }
+
+ private async Task UpdateStatusOfSelectedRelations()
+ {
+ const string StatusString = "Status";
+
+ try
+ {
+ int? agentUserId = null;
+ int? agentDeviceId = null;
+
+ // todo these values should not be recieved from the NamedParameters, instead from the relation it self
+ if (SupportCaseDataProviderArtifact.NamedParameterEntries.TryGetValue("AgentUserId", out var userNamedParameter))
+ {
+ var value = userNamedParameter.GetValue();
+ if (!string.IsNullOrWhiteSpace(value))
+ agentUserId = int.Parse(value);
+ }
+
+
+ // todo these values should not be recieved from the NamedParameters, instead from the relation it self
+ if (SupportCaseDataProviderArtifact.NamedParameterEntries.TryGetValue("AgentDeviceId", out var deviceNamedParameter))
+ {
+ var value = deviceNamedParameter.GetValue();
+ if (!string.IsNullOrWhiteSpace(value))
+ agentDeviceId = int.Parse(deviceNamedParameter.GetValue());
+ }
+
+ foreach (var relationEntry in _selectedRelations)
+ {
+ if (relationEntry.Value is null)
+ continue;
+
+ string statusValue = "Unknown";
+
+ switch (relationEntry.Key)
+ {
+ case enumFasdInformationClass.Computer:
+ if (!agentDeviceId.HasValue)
+ continue;
+
+ bool isDeviceOnline = await cFasdCockpitCommunicationBase.Instance.GetAgentOnlineStatus(agentDeviceId.Value);
+ statusValue = isDeviceOnline ? "Online" : "Offline";
+ break;
+ case enumFasdInformationClass.User:
+ if (!agentDeviceId.HasValue || !agentUserId.HasValue)
+ continue;
+
+ bool isUserOnline = await cFasdCockpitCommunicationBase.Instance.GetAgentOnlineStatus(agentDeviceId.Value, agentUserId.Value);
+ statusValue = isUserOnline ? "Online" : "Offline";
+ break;
+ case enumFasdInformationClass.Ticket:
+ case enumFasdInformationClass.VirtualSession:
+ case enumFasdInformationClass.MobileDevice:
+ default:
+ continue;
+ }
+
+ if (relationEntry.Value.Infos is null)
+ relationEntry.Value.Infos = new Dictionary();
+
+ relationEntry.Value.Infos[StatusString] = statusValue;
+ }
+
+ IEnumerable newHeadingData = SupportCaseHeadingController.GetHeadingData(_selectedRelations);
+ HeadingDataChanged?.Invoke(this, new HeadingDataEventArgs(newHeadingData));
+ }
+ catch (Exception ex)
+ {
+ LogException(ex);
+ }
+ }
+
+ public async Task RefreshDataForCurrentlyFocusedRelationAsync()
+ {
+ await _supportCaseProcessor.UpdateLatestCaseDataFor(_focusedRelation);
+ }
+
+ public List> GetWidgetData()
+ => _supportCaseProcessor.GetWidgetData(_focusedRelation);
+
+ public cDetailsPageDataHistoryDataModel GetHistoryData()
+ => _supportCaseProcessor.GetHistoryData(_focusedRelation);
+
+ public List GetContainerData()
+ => _supportCaseProcessor.GetContainerData(_focusedRelation);
+
+ public List GetMenuBarData()
+ => _supportCaseProcessor.GetMenuBarData(_focusedRelation);
+
+ ///
+ /// Raised when the currently for a support case relevant and shown relations have been updated.
+ ///
+ public event EventHandler FocusedRelationsChanged;
+
+ ///
+ /// Raised when newly available relations for a support case were added.
+ ///
+ public event EventHandler AvailableCaseRelationsAdded;
+
+ ///
+ /// Raised when the data set of a support case has changed.
+ ///
+ public event EventHandler CaseDataChanged;
+
+ public event EventHandler HeadingDataChanged;
+ }
+}
diff --git a/FasdDesktopUi/Basics/Services/SupportCase/Controllers/SupportCaseHeadingController.cs b/FasdDesktopUi/Basics/Services/SupportCase/Controllers/SupportCaseHeadingController.cs
new file mode 100644
index 0000000..8c266e9
--- /dev/null
+++ b/FasdDesktopUi/Basics/Services/SupportCase/Controllers/SupportCaseHeadingController.cs
@@ -0,0 +1,93 @@
+using C4IT.FASD.Base;
+using C4IT.MultiLanguage;
+using FasdDesktopUi.Basics.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using static C4IT.Logging.cLogManager;
+
+namespace FasdDesktopUi.Basics.Services.SupportCase.Controllers
+{
+ internal class SupportCaseHeadingController
+ {
+ internal static IEnumerable GetHeadingData(Dictionary relations)
+ {
+ try
+ {
+ return Enum.GetValues(typeof(enumFasdInformationClass))
+ .Cast()
+ .Select(informationClass =>
+ {
+ if (relations.TryGetValue(informationClass, out var relation) && relation != null)
+ return GetHeadingDataFor(relation);
+ else
+ return GetEmptyHeadingDataFor(informationClass);
+ });
+ }
+ catch (Exception ex)
+ {
+ LogException(ex);
+ }
+
+ return Enumerable.Empty();
+ }
+
+ private static cHeadingDataModel GetEmptyHeadingDataFor(enumFasdInformationClass informationClass)
+ {
+ string headingText = string.Empty;
+
+ switch (informationClass)
+ {
+ case enumFasdInformationClass.Computer:
+ headingText = cMultiLanguageSupport.GetItem("Header.Select.Computer");
+ break;
+ case enumFasdInformationClass.Ticket:
+ headingText = cMultiLanguageSupport.GetItem("Header.Select.Ticket");
+ break;
+ case enumFasdInformationClass.VirtualSession:
+ headingText = cMultiLanguageSupport.GetItem("Header.Select.VirtualSession");
+ break;
+ case enumFasdInformationClass.MobileDevice:
+ headingText = cMultiLanguageSupport.GetItem("Header.Select.MobileDevice");
+ break;
+ }
+
+ return new cHeadingDataModel() { InformationClass = informationClass, HeadingText = headingText };
+ }
+
+ private static cHeadingDataModel GetHeadingDataFor(cF4sdApiSearchResultRelation relation)
+ {
+ const string StatusString = "Status";
+ bool isOnline = false;
+
+ string statusValue = "Unknown";
+ if (relation?.Infos?.TryGetValue(StatusString, out var statusValueFromDictionary) ?? false)
+ statusValue = statusValueFromDictionary;
+
+ switch (relation.Type)
+ {
+ case enumF4sdSearchResultClass.Computer:
+ case enumF4sdSearchResultClass.User:
+ isOnline = string.Equals(statusValue, "Online", StringComparison.InvariantCultureIgnoreCase);
+ break;
+ case enumF4sdSearchResultClass.Ticket:
+ isOnline = !string.Equals(statusValue, nameof(enumTicketStatus.Closed));
+ break;
+ case enumF4sdSearchResultClass.VirtualSession:
+ isOnline = string.Equals(statusValue, nameof(enumCitrixSessionStatus.Active));
+ break;
+ case enumF4sdSearchResultClass.MobileDevice:
+ break;
+ }
+
+ return new cHeadingDataModel()
+ {
+ HeadingText = string.IsNullOrEmpty(relation.Name) ? relation.DisplayName : relation.Name,
+ InformationClass = cF4sdIdentityEntry.GetFromSearchResult(relation.Type),
+ IsOnline = isOnline,
+ Identities = relation.Identities,
+ Realtion = relation
+ };
+ }
+ }
+}
diff --git a/FasdDesktopUi/Basics/Services/SupportCase/ISupportCase.cs b/FasdDesktopUi/Basics/Services/SupportCase/ISupportCase.cs
index c6ded8f..4e5acd8 100644
--- a/FasdDesktopUi/Basics/Services/SupportCase/ISupportCase.cs
+++ b/FasdDesktopUi/Basics/Services/SupportCase/ISupportCase.cs
@@ -1,8 +1,9 @@
using C4IT.FASD.Base;
-using FasdDesktopUi.Basics.Services.RelationService;
+using FasdDesktopUi.Basics.CustomEvents;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Threading.Tasks;
namespace FasdDesktopUi.Basics.Services.SupportCase
{
@@ -12,10 +13,13 @@ namespace FasdDesktopUi.Basics.Services.SupportCase
void Initialize();
void AddCaseRelations(ILookup