aktueller Stand
This commit is contained in:
@@ -64,13 +64,15 @@ namespace FasdDesktopUi.Pages.SearchPage
|
||||
// Aktueller Zustand der Checkbox
|
||||
public bool IsFilterChecked => FilterCheckbox.IsChecked == true;
|
||||
|
||||
public SupportCaseSearchService SearchService { get; } = new SupportCaseSearchService(new RelationService());
|
||||
private readonly IRelationService _relationService = new RelationService();
|
||||
public SupportCaseSearchService SearchService { get; }
|
||||
|
||||
private SearchPageView()
|
||||
{
|
||||
try
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializeComponent();
|
||||
SearchService = new SupportCaseSearchService(_relationService);
|
||||
Visibility = Visibility.Visible;
|
||||
_instance = this;
|
||||
|
||||
@@ -420,7 +422,7 @@ namespace FasdDesktopUi.Pages.SearchPage
|
||||
{
|
||||
await SearchBarUc.SetFixedSearchResultAsync(Class, strInfo, result);
|
||||
|
||||
if (result.AutoContinue && result.Results?.Count == 1)
|
||||
if (result.AutoContinue && result.Results?.Count == 1)
|
||||
{
|
||||
ResultMenu.IndexOfSelectedResultItem = 0;
|
||||
ResultMenu.SelectCurrentResultItem();
|
||||
@@ -561,67 +563,20 @@ namespace FasdDesktopUi.Pages.SearchPage
|
||||
|
||||
}
|
||||
|
||||
private void TicketSearch(cTicketSearchParameters searchInfo)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
if (!Guid.TryParse(searchInfo.ticketId, out var _ticketId))
|
||||
return;
|
||||
|
||||
var _h = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var lstSids = searchInfo.sids?.Split(',').Select((v) => v.Trim()).ToList();
|
||||
var _result = await cFasdCockpitCommunicationBase.Instance.GetUserSearchResults(searchInfo.userName, lstSids);
|
||||
|
||||
if (_result is null || _result.Count == 0 || _result.First().Value.Count == 0)
|
||||
{
|
||||
LogEntry($"No corresponding user could be found for ticket '{searchInfo.ticketName}'", LogLevels.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var UserId = _result.Values.First().First().id;
|
||||
var _ticketRelation = new cF4sdApiSearchResultRelation()
|
||||
{
|
||||
Type = enumF4sdSearchResultClass.Ticket,
|
||||
DisplayName = searchInfo.ticketName,
|
||||
id = _ticketId,
|
||||
Status = enumF4sdSearchResultStatus.Active,
|
||||
Identities = new cF4sdIdentityList
|
||||
{
|
||||
{ new cF4sdIdentityEntry()
|
||||
{
|
||||
Class = enumFasdInformationClass.User,
|
||||
Id = UserId
|
||||
}
|
||||
},
|
||||
{ new cF4sdIdentityEntry()
|
||||
{
|
||||
Class = enumFasdInformationClass.Ticket,
|
||||
Id = _ticketId
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
var filteredResults = new cFilteredResults(_result) { AutoContinue = true, PreSelectedRelation = _ticketRelation };
|
||||
|
||||
var strInfo = string.Format(cMultiLanguageSupport.GetItem("Searchbar.TicketSearch.Info"), searchInfo.ticketName);
|
||||
var _t = ShowExternalSearchInfoAsync(strInfo, filteredResults, enumF4sdSearchResultClass.Ticket);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
private void TicketSearch(cTicketSearchParameters searchInfo)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
if (!Guid.TryParse(searchInfo.ticketId, out var _ticketId))
|
||||
return;
|
||||
_ = RunTicketSearchAsync(searchInfo.ticketName, _ticketId, searchInfo.userName, searchInfo.sids);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
@@ -889,6 +844,12 @@ namespace FasdDesktopUi.Pages.SearchPage
|
||||
new TicketOverviewSelectionRequestedEventHandler(TicketOverview_SelectionRequested), true);
|
||||
cFasdCockpitConfig.Instance.UiSettingsChanged += UiSettingsChanged;
|
||||
|
||||
SearchBarUc.ChangedSearchValue = filteredResults =>
|
||||
{
|
||||
UpdateSearchResults(filteredResults);
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
SearchBarUc.SearchValueChanged += HandleSearchValueChanged;
|
||||
SearchService.RelationsFound += HandleRelationsFound;
|
||||
}
|
||||
@@ -1011,6 +972,83 @@ namespace FasdDesktopUi.Pages.SearchPage
|
||||
}
|
||||
}
|
||||
|
||||
private Task TicketSearchFromOverviewRelationAsync(cF4sdApiSearchResultRelation relation)
|
||||
{
|
||||
if (relation == null || relation.Type != enumF4sdSearchResultClass.Ticket)
|
||||
return Task.CompletedTask;
|
||||
|
||||
var ticketName = string.IsNullOrWhiteSpace(relation.DisplayName) ? relation.Name : relation.DisplayName;
|
||||
var ticketId = relation.id;
|
||||
if (ticketId == Guid.Empty)
|
||||
return Task.CompletedTask;
|
||||
|
||||
string userName = null;
|
||||
string sids = null;
|
||||
|
||||
if (relation.Infos != null)
|
||||
{
|
||||
if (!relation.Infos.TryGetValue("UserDisplayName", out userName))
|
||||
relation.Infos.TryGetValue("UserAccount", out userName);
|
||||
|
||||
if (!relation.Infos.TryGetValue("Sids", out sids))
|
||||
relation.Infos.TryGetValue("UserSid", out sids);
|
||||
}
|
||||
|
||||
return RunTicketSearchAsync(ticketName, ticketId, userName, sids);
|
||||
}
|
||||
|
||||
private Task RunTicketSearchAsync(string ticketName, Guid ticketId, string userName, string sids)
|
||||
{
|
||||
if (ticketId == Guid.Empty)
|
||||
return Task.CompletedTask;
|
||||
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var lstSids = sids?.Split(',').Select((v) => v.Trim()).ToList();
|
||||
var _result = await cFasdCockpitCommunicationBase.Instance.GetUserSearchResults(userName, lstSids);
|
||||
|
||||
if (_result is null || _result.Count == 0 || _result.First().Value.Count == 0)
|
||||
{
|
||||
LogEntry($"No corresponding user could be found for ticket '{ticketName}'", LogLevels.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var userId = _result.Values.First().First().id;
|
||||
var _ticketRelation = new cF4sdApiSearchResultRelation()
|
||||
{
|
||||
Type = enumF4sdSearchResultClass.Ticket,
|
||||
DisplayName = ticketName,
|
||||
id = ticketId,
|
||||
Status = enumF4sdSearchResultStatus.Active,
|
||||
Identities = new cF4sdIdentityList
|
||||
{
|
||||
new cF4sdIdentityEntry()
|
||||
{
|
||||
Class = enumFasdInformationClass.User,
|
||||
Id = userId
|
||||
},
|
||||
new cF4sdIdentityEntry()
|
||||
{
|
||||
Class = enumFasdInformationClass.Ticket,
|
||||
Id = ticketId
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
var filteredResults = new cFilteredResults(_result) { AutoContinue = true, PreSelectedRelation = _ticketRelation };
|
||||
|
||||
var strInfo = string.Format(cMultiLanguageSupport.GetItem("Searchbar.TicketSearch.Info"), ticketName);
|
||||
await ShowExternalSearchInfoAsync(strInfo, filteredResults, enumF4sdSearchResultClass.Ticket);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void PrimeTicketOverviewScope(TileScope scope)
|
||||
{
|
||||
if (_ticketOverviewNotificationScopesPrimed.Add(scope))
|
||||
@@ -1329,8 +1367,8 @@ namespace FasdDesktopUi.Pages.SearchPage
|
||||
SetPendingInformationClasses(new HashSet<enumFasdInformationClass> { enumFasdInformationClass.Ticket });
|
||||
|
||||
var relations = await LoadRelationsForTileAsync(e.Key, e.UseRoleScope, Math.Max(0, e.Count));
|
||||
await PopulateTicketOverviewRelationUsersAsync(relations);
|
||||
Debug.WriteLine($"[TicketOverview] Relations loaded: {relations?.Count ?? 0}");
|
||||
var ticketOverviewRelationService = new RelationService();
|
||||
var firstRelation = relations.FirstOrDefault();
|
||||
string displayText = header;
|
||||
if (firstRelation != null)
|
||||
@@ -1356,13 +1394,13 @@ namespace FasdDesktopUi.Pages.SearchPage
|
||||
{ isSeen = true };
|
||||
_ticketOverviewHistoryEntries.Add(entry);
|
||||
|
||||
var lookup = relations.ToLookup(
|
||||
r => cF4sdIdentityEntry.GetFromSearchResult(r.Type),
|
||||
r =>
|
||||
{
|
||||
var required = new List<enumFasdInformationClass> { cF4sdIdentityEntry.GetFromSearchResult(r.Type) };
|
||||
bool isEnabled = cHealthCardDataHelper.HasAvailableHealthCard(required);
|
||||
string disabledReason = null;
|
||||
var lookup = relations.ToLookup(
|
||||
r => cF4sdIdentityEntry.GetFromSearchResult(r.Type),
|
||||
r =>
|
||||
{
|
||||
var required = new List<enumFasdInformationClass> { cF4sdIdentityEntry.GetFromSearchResult(r.Type) };
|
||||
bool isEnabled = cHealthCardDataHelper.HasAvailableHealthCard(required);
|
||||
string disabledReason = null;
|
||||
if (!isEnabled)
|
||||
{
|
||||
disabledReason = cMultiLanguageSupport.GetItem("Searchbar.NoValidHealthcard") ?? string.Empty;
|
||||
@@ -1372,24 +1410,24 @@ namespace FasdDesktopUi.Pages.SearchPage
|
||||
isEnabled = false;
|
||||
disabledReason = cMultiLanguageSupport.GetItem("Searchbar.Demo.NoTicketDetails") ?? string.Empty;
|
||||
}
|
||||
string trailingUser = null;
|
||||
if (_renderTicketOverviewUserNames && r.Infos != null && r.Infos.TryGetValue("UserDisplayName", out var userDisplayName))
|
||||
{
|
||||
trailingUser = userDisplayName;
|
||||
}
|
||||
string trailingUser = null;
|
||||
if (_renderTicketOverviewUserNames && r.Infos != null && r.Infos.TryGetValue("UserDisplayName", out var userDisplayName))
|
||||
{
|
||||
trailingUser = userDisplayName;
|
||||
}
|
||||
return (cMenuDataBase)new cMenuDataSearchRelation(r)
|
||||
{
|
||||
MenuText = r.DisplayName,
|
||||
TrailingText = trailingUser,
|
||||
UiAction = new cUiProcessSearchRelationAction(entry, r, ticketOverviewRelationService, this)
|
||||
UiAction = new cUiProcessTicketOverviewRelationAction(r.DisplayName, () => TicketSearchFromOverviewRelationAsync(r))
|
||||
{
|
||||
DisplayType = isEnabled ? enumActionDisplayType.enabled : enumActionDisplayType.disabled,
|
||||
Description = isEnabled ? string.Empty : disabledReason,
|
||||
AlternativeDescription = isEnabled ? string.Empty : disabledReason
|
||||
}
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
);
|
||||
ResultMenu.UpdateSearchRelations(lookup);
|
||||
ResultMenu.SetHeaderText(header, hideDetailsCheckbox: true);
|
||||
|
||||
@@ -1491,11 +1529,11 @@ namespace FasdDesktopUi.Pages.SearchPage
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task<List<cF4sdApiSearchResultRelation>> LoadRelationsForTileAsync(string key, bool useRoleScope, int count)
|
||||
{
|
||||
var communication = cFasdCockpitCommunicationBase.Instance;
|
||||
if (communication == null)
|
||||
return new List<cF4sdApiSearchResultRelation>();
|
||||
private async Task<List<cF4sdApiSearchResultRelation>> LoadRelationsForTileAsync(string key, bool useRoleScope, int count)
|
||||
{
|
||||
var communication = cFasdCockpitCommunicationBase.Instance;
|
||||
if (communication == null)
|
||||
return new List<cF4sdApiSearchResultRelation>();
|
||||
try
|
||||
{
|
||||
var relations = await communication.GetTicketOverviewRelations(key, useRoleScope, Math.Max(0, count)).ConfigureAwait(false);
|
||||
@@ -1515,7 +1553,107 @@ namespace FasdDesktopUi.Pages.SearchPage
|
||||
LogException(ex);
|
||||
return new List<cF4sdApiSearchResultRelation>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task PopulateTicketOverviewRelationUsersAsync(List<cF4sdApiSearchResultRelation> relations)
|
||||
{
|
||||
if (relations == null || relations.Count == 0)
|
||||
return;
|
||||
|
||||
foreach (var relation in relations)
|
||||
{
|
||||
if (relation == null || relation.Type != enumF4sdSearchResultClass.Ticket)
|
||||
continue;
|
||||
|
||||
if (relation.Identities == null)
|
||||
relation.Identities = new cF4sdIdentityList();
|
||||
|
||||
var existingUsers = relation.Identities
|
||||
.Where(identity => identity.Class == enumFasdInformationClass.User)
|
||||
.ToList();
|
||||
|
||||
Guid userId = Guid.Empty;
|
||||
if (relation.Infos != null)
|
||||
{
|
||||
if (relation.Infos.TryGetValue("Sids", out var sidsValue) ||
|
||||
relation.Infos.TryGetValue("UserSid", out sidsValue))
|
||||
{
|
||||
var sids = sidsValue?.Split(',')
|
||||
.Select(v => v.Trim())
|
||||
.Where(v => !string.IsNullOrWhiteSpace(v))
|
||||
.ToList();
|
||||
|
||||
if (sids != null && sids.Count > 0)
|
||||
{
|
||||
var communication = cFasdCockpitCommunicationBase.Instance;
|
||||
if (communication != null)
|
||||
{
|
||||
relation.Infos.TryGetValue("UserDisplayName", out var userDisplayName);
|
||||
var result = await communication.GetUserSearchResults(userDisplayName, sids);
|
||||
var user = result?.Values?.FirstOrDefault()?.FirstOrDefault();
|
||||
if (user != null)
|
||||
userId = user.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (userId == Guid.Empty && relation.Infos.TryGetValue("UserAccount", out var userAccount))
|
||||
{
|
||||
relation.Infos.TryGetValue("UserDomain", out var userDomain);
|
||||
if (!string.IsNullOrWhiteSpace(userAccount))
|
||||
{
|
||||
var communication = cFasdCockpitCommunicationBase.Instance;
|
||||
if (communication != null)
|
||||
{
|
||||
userId = await communication.GetUserIdByAccount(userAccount, userDomain ?? string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (userId == Guid.Empty)
|
||||
{
|
||||
if (relation.Infos.TryGetValue("UserId", out var userIdString) ||
|
||||
relation.Infos.TryGetValue("UserGuid", out userIdString) ||
|
||||
relation.Infos.TryGetValue("UserIdentityId", out userIdString))
|
||||
{
|
||||
Guid.TryParse(userIdString, out userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (userId == Guid.Empty)
|
||||
{
|
||||
if (existingUsers.Count == 0)
|
||||
continue;
|
||||
|
||||
if (relation.Infos != null)
|
||||
{
|
||||
if (!relation.Infos.ContainsKey("UserId"))
|
||||
relation.Infos["UserId"] = existingUsers[0].Id.ToString();
|
||||
if (!relation.Infos.ContainsKey("UserGuid"))
|
||||
relation.Infos["UserGuid"] = existingUsers[0].Id.ToString();
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (existingUsers.Count == 0 || existingUsers.Any(identity => identity.Id != userId))
|
||||
{
|
||||
relation.Identities.RemoveAll(identity => identity.Class == enumFasdInformationClass.User);
|
||||
relation.Identities.Add(new cF4sdIdentityEntry
|
||||
{
|
||||
Class = enumFasdInformationClass.User,
|
||||
Id = userId
|
||||
});
|
||||
}
|
||||
|
||||
if (relation.Infos == null)
|
||||
relation.Infos = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
relation.Infos["UserId"] = userId.ToString();
|
||||
relation.Infos["UserGuid"] = userId.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSearchResults(cFilteredResults filteredResults)
|
||||
{
|
||||
@@ -1533,6 +1671,20 @@ namespace FasdDesktopUi.Pages.SearchPage
|
||||
}
|
||||
|
||||
string menuHeaderText = filteredResults?.PreSelectedRelation?.DisplayName;
|
||||
|
||||
if (filteredResults?.PreSelectedRelation != null)
|
||||
{
|
||||
List<cFasdApiSearchResultEntry> selectedResult = filteredResults.Results.Values.FirstOrDefault();
|
||||
var processSearchResult = new cUiProcessSearchResultAction(selectedResult.FirstOrDefault()?.DisplayName, this, selectedResult) { PreSelectedSearchRelation = filteredResults.PreSelectedRelation };
|
||||
Dispatcher.Invoke(async () =>
|
||||
{
|
||||
bool isSearchOngoing = await processSearchResult.RunUiActionAsync(this, this, false, null);
|
||||
if (!isSearchOngoing)
|
||||
Hide();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
ResultMenu.ShowSearchResults(filteredResults, menuHeaderText, this);
|
||||
preSelectedRelation = filteredResults.PreSelectedRelation;
|
||||
|
||||
@@ -1546,8 +1698,6 @@ namespace FasdDesktopUi.Pages.SearchPage
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void CancledSearchAction()
|
||||
{
|
||||
_renderTicketOverviewUserNames = false;
|
||||
@@ -1573,25 +1723,27 @@ namespace FasdDesktopUi.Pages.SearchPage
|
||||
|
||||
Mouse.OverrideCursor = Cursors.Wait;
|
||||
|
||||
switch (e.UiAction)
|
||||
{
|
||||
case cUiProcessSearchResultAction searchResultAction:
|
||||
searchResultAction.PreSelectedSearchRelation = preSelectedRelation;
|
||||
break;
|
||||
case cUiProcessSearchRelationAction _:
|
||||
case cUiProcessSearchHistoryEntry _:
|
||||
break;
|
||||
default:
|
||||
var _t = e.UiAction?.GetType().Name;
|
||||
Debug.Assert(true, $"The UI action '{_t}' is not supported in detailed page");
|
||||
CancledSearchAction();
|
||||
switch (e.UiAction)
|
||||
{
|
||||
case cUiProcessSearchResultAction searchResultAction:
|
||||
searchResultAction.PreSelectedSearchRelation = preSelectedRelation;
|
||||
break;
|
||||
case cUiProcessSearchRelationAction _:
|
||||
case cUiProcessSearchHistoryEntry _:
|
||||
case cUiProcessTicketOverviewRelationAction _:
|
||||
break;
|
||||
default:
|
||||
var _t = e.UiAction?.GetType().Name;
|
||||
Debug.Assert(true, $"The UI action '{_t}' is not supported in detailed page");
|
||||
CancledSearchAction();
|
||||
return;
|
||||
}
|
||||
|
||||
SetSearchResultVisibility(true);
|
||||
if (!await e.UiAction.RunUiActionAsync(sender, null, false, null))
|
||||
CancledSearchAction();
|
||||
}
|
||||
var actionResult = await e.UiAction.RunUiActionAsync(sender, null, false, null);
|
||||
if (!(e.UiAction is cUiProcessTicketOverviewRelationAction) && !actionResult)
|
||||
CancledSearchAction();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
|
||||
Reference in New Issue
Block a user