aktueller Stand
This commit is contained in:
@@ -6,7 +6,8 @@ using System.Windows;
|
||||
using System.Windows.Documents;
|
||||
using System.Linq;
|
||||
using System.Windows.Input;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Threading;
|
||||
|
||||
using C4IT.FASD.Base;
|
||||
using C4IT.Logging;
|
||||
@@ -26,6 +27,8 @@ using Newtonsoft.Json;
|
||||
using FasdDesktopUi.Basics.Services.ProtocollService;
|
||||
using FasdDesktopUi.Basics.Services.SupportCase;
|
||||
using FasdDesktopUi.Basics.Services.RelationService;
|
||||
using FasdDesktopUi.Basics.Services.SupportCase.Controllers;
|
||||
using C4IT.F4SD.SupportCaseProtocoll.Models;
|
||||
|
||||
|
||||
namespace FasdDesktopUi.Basics
|
||||
@@ -100,10 +103,10 @@ namespace FasdDesktopUi.Basics
|
||||
QuickActionProtocollHelper = new cQuickActionProtocollHelper(this);
|
||||
}
|
||||
|
||||
public static async Task<cSupportCaseDataProvider> GetDataProviderForAsync(List<cF4sdApiSearchResultRelation> storedRelations, cF4sdApiSearchResultRelation selectedRelation, IRelationService relationService)
|
||||
{
|
||||
try
|
||||
{
|
||||
public static async Task<cSupportCaseDataProvider> GetDataProviderForAsync(cF4sdApiSearchResultRelation selectedRelation, IRelationService relationService)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (selectedRelation == null)
|
||||
{
|
||||
Debug.Assert(true, "The selected relation must not be null here!");
|
||||
@@ -147,43 +150,68 @@ namespace FasdDesktopUi.Basics
|
||||
cSupportCaseDataProvider.CurrentProvider = null;
|
||||
}
|
||||
|
||||
if (!DataProviders.TryGetValue(MainIdentity.Id, out var _result))
|
||||
{
|
||||
_result = new cSupportCaseDataProvider();
|
||||
DataProviders.Add(MainIdentity.Id, _result);
|
||||
}
|
||||
|
||||
_result.NamedParameterEntries = new cNamedParameterList(_result);
|
||||
|
||||
_result.StartCase(MainIdentity.Id);
|
||||
if (!DataProviders.TryGetValue(MainIdentity.Id, out var _result))
|
||||
{
|
||||
_result = new cSupportCaseDataProvider();
|
||||
DataProviders.Add(MainIdentity.Id, _result);
|
||||
}
|
||||
|
||||
await EnsureSupportCasePagesAsync();
|
||||
|
||||
_result.NamedParameterEntries = new cNamedParameterList(_result);
|
||||
|
||||
_result.StartCase(MainIdentity.Id);
|
||||
|
||||
var supportCase = SupportCaseFactory.Get(MainIdentity, relationService, _result);
|
||||
cSupportCaseDataProvider.detailsPage.SetSupportCase(supportCase);
|
||||
cSupportCaseDataProvider.slimPage.SetSupportCase(supportCase);
|
||||
var supportCaseProcessor = SupportCaseProcessorFactory.Get(MainIdentity.Id);
|
||||
var supportCaseController = new SupportCaseController();
|
||||
|
||||
supportCaseProcessor.SetSupportCase(supportCase);
|
||||
supportCaseController.SetSupportCaseProcessor(supportCaseProcessor, Identities);
|
||||
|
||||
if (cSupportCaseDataProvider.detailsPage == null || cSupportCaseDataProvider.slimPage == null)
|
||||
{
|
||||
LogEntry("Support case pages are not initialized; aborting case start.", LogLevels.Error);
|
||||
return null;
|
||||
}
|
||||
|
||||
cSupportCaseDataProvider.detailsPage.SetSupportCaseController(supportCaseController);
|
||||
cSupportCaseDataProvider.slimPage.SetSupportCaseController(supportCaseController);
|
||||
|
||||
var Status = await _result.SetViewDataAsync(requiredInformationClasses, Identities, true);
|
||||
|
||||
cF4sdApiSearchResultRelation relationToFocus = GetRelationToFocus(selectedRelation, relationService.GetLoadedRelations());
|
||||
// relation to focus may not have all identities
|
||||
supportCaseController.UpdateFocusedCaseRelation(relationToFocus);
|
||||
if (!Status)
|
||||
return null;
|
||||
|
||||
var selectedHealthCard = _result.HealthCardDataHelper?.SelectedHealthCard;
|
||||
if (selectedHealthCard != null)
|
||||
_ = cHealthCard.GetRequiredTables(selectedHealthCard); // todo the healthcard is not selected at this point
|
||||
|
||||
if (detailsPage?.WidgetCollection != null)
|
||||
detailsPage.WidgetCollection.WidgetDataList = supportCaseController.GetWidgetData();
|
||||
if (detailsPage?.DataHistoryCollectionUserControl != null)
|
||||
detailsPage.DataHistoryCollectionUserControl.HistoryDataList = supportCaseController.GetHistoryData();
|
||||
if (detailsPage?.CustomizableSectionUc != null)
|
||||
detailsPage.CustomizableSectionUc.ContainerCollections = supportCaseController.GetContainerData();
|
||||
|
||||
CurrentProvider = _result;
|
||||
|
||||
// start the direct connection
|
||||
if (_result.DirectConnectionHelper.IsDirectConnectionActive is false)
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await _result.DirectConnectionHelper.DirectConnectionStartAsync();
|
||||
}
|
||||
catch { }
|
||||
});
|
||||
|
||||
// start the slim or detaild page
|
||||
bool shouldSkipSlimView = Identities.Any(identity => identity.Class is enumFasdInformationClass.Ticket) || cFasdCockpitConfig.Instance.Global.ShouldSkipSlimView;
|
||||
if (shouldSkipSlimView)
|
||||
cSupportCaseDataProvider.detailsPage?.Show();
|
||||
else
|
||||
cSupportCaseDataProvider.slimPage.Show();
|
||||
bool shouldSkipSlimView = (Identities?.Any(identity => identity.Class is enumFasdInformationClass.Ticket) ?? false)
|
||||
|| (cFasdCockpitConfig.Instance?.Global?.ShouldSkipSlimView ?? false);
|
||||
if (shouldSkipSlimView)
|
||||
{
|
||||
cSupportCaseDataProvider.detailsPage?.Show();
|
||||
cSupportCaseDataProvider.slimPage?.Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
cSupportCaseDataProvider.slimPage?.Show();
|
||||
cSupportCaseDataProvider.detailsPage?.Hide();
|
||||
}
|
||||
|
||||
return _result;
|
||||
}
|
||||
@@ -194,11 +222,35 @@ namespace FasdDesktopUi.Basics
|
||||
return null;
|
||||
}
|
||||
|
||||
public void StartCase(Guid userId)
|
||||
private static cF4sdApiSearchResultRelation GetRelationToFocus(cF4sdApiSearchResultRelation selectedRelation, IEnumerable<cF4sdApiSearchResultRelation> loadedRelations)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
if (selectedRelation.Type != enumF4sdSearchResultClass.User)
|
||||
return selectedRelation;
|
||||
|
||||
cF4sdIdentityEntry alternativeIdentity = selectedRelation.Identities.FirstOrDefault(i => i.Class != enumFasdInformationClass.User);
|
||||
cF4sdApiSearchResultRelation relationToFocus = loadedRelations.FirstOrDefault(r => r.id == alternativeIdentity?.Id && cF4sdIdentityEntry.GetFromSearchResult(r.Type) == alternativeIdentity.Class);
|
||||
|
||||
if (relationToFocus is null)
|
||||
return selectedRelation;
|
||||
|
||||
relationToFocus.Identities = selectedRelation.Identities;
|
||||
return relationToFocus;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(ex);
|
||||
}
|
||||
|
||||
return selectedRelation;
|
||||
}
|
||||
|
||||
public void StartCase(Guid userId)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
lock (caseIdLockObject)
|
||||
{
|
||||
@@ -238,11 +290,28 @@ namespace FasdDesktopUi.Basics
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task EnsureSupportCasePagesAsync()
|
||||
{
|
||||
if (detailsPage != null && slimPage != null)
|
||||
return;
|
||||
|
||||
if (Application.Current == null)
|
||||
return;
|
||||
|
||||
await Application.Current.Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
if (slimPage == null)
|
||||
slimPage = new Pages.SlimPage.SlimPageView();
|
||||
if (detailsPage == null)
|
||||
detailsPage = new Pages.DetailsPage.DetailsPageView();
|
||||
}, DispatcherPriority.Normal);
|
||||
}
|
||||
|
||||
public async Task CloseCaseAsync()
|
||||
{
|
||||
@@ -452,35 +521,12 @@ namespace FasdDesktopUi.Basics
|
||||
}
|
||||
}
|
||||
|
||||
var isOk = await HealthCardDataHelper.LoadingHelper.GetHealthCardRawDataAsync(new cF4sdHealthCardRawDataRequest()
|
||||
{
|
||||
Identities = Identities,
|
||||
Tables = requiredTables.ToList(),
|
||||
MaxAge = cF4SDCockpitXmlConfig.Instance?.HealthCardConfig?.SearchResultAge ?? 14
|
||||
});
|
||||
|
||||
if (isNewCase)
|
||||
HealthCardDataHelper.LoadingHelper.LastDataRequest = DateTime.Now;
|
||||
|
||||
if (isOk == false)
|
||||
{
|
||||
string identityString = "";
|
||||
|
||||
foreach (var identity in Identities)
|
||||
{
|
||||
identityString += "\n" + identity.Id + " (Type: " + identity.Class + ")";
|
||||
}
|
||||
|
||||
LogEntry($"Error trying to receive healthcard data for following identities: {identityString}", LogLevels.Error);
|
||||
CustomMessageBox.Show($"Error trying to receive healthcard data for following identities: {identityString}", "Data Error", enumHealthCardStateLevel.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
var slimPageData = await HealthCardDataHelper.SlimCard.GetDataAsync();
|
||||
var detailsPageData = await HealthCardDataHelper.DetailPage.GetDataAsync();
|
||||
|
||||
slimPage?.SetPropertyValues(slimPageData);
|
||||
detailsPage?.SetPropertyValues(detailsPageData);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -545,11 +591,6 @@ namespace FasdDesktopUi.Basics
|
||||
}
|
||||
relationIdentity.CopyTo(existingIdentity);
|
||||
}
|
||||
else
|
||||
{
|
||||
Identities.Add(relationIdentity.CreateCopy());
|
||||
ComputerAdded |= relationIdentity.Class == enumFasdInformationClass.Computer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -561,16 +602,6 @@ namespace FasdDesktopUi.Basics
|
||||
var searchResultInfoClass = cF4sdIdentityEntry.GetFromSearchResult(searchResultRelation.Type);
|
||||
await SetViewDataAsync(new List<enumFasdInformationClass>() { searchResultInfoClass }, Identities, false);
|
||||
|
||||
if (ComputerAdded)
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await DirectConnectionHelper.DirectConnectionStartAsync();
|
||||
}
|
||||
catch { }
|
||||
});
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user