aktueller Stand
This commit is contained in:
@@ -10,6 +10,7 @@ using System.Windows.Threading;
|
||||
|
||||
using C4IT.FASD.Cockpit.Communication;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.Services;
|
||||
using FasdDesktopUi.Basics.Services.Models;
|
||||
using FasdDesktopUi.Pages.SearchPage;
|
||||
namespace FasdDesktopUi.Basics.UserControls
|
||||
@@ -217,36 +218,33 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
|
||||
private async Task RefreshCountsAsync(bool useRoleTickets)
|
||||
{
|
||||
var communication = cFasdCockpitCommunicationBase.Instance;
|
||||
Dictionary<string, int> counts = null;
|
||||
var service = TicketOverviewUpdateService.Instance;
|
||||
|
||||
var counts = CategorySetters.ToDictionary(item => item.Key, _ => 0);
|
||||
|
||||
if (communication != null)
|
||||
if (service != null)
|
||||
{
|
||||
var tasks = CategorySetters.ToDictionary(
|
||||
item => item.Key,
|
||||
item => communication.GetTicketOverviewRelations(item.Key, useRoleTickets, 0));
|
||||
|
||||
foreach (var kvp in tasks)
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
var relations = await kvp.Value.ConfigureAwait(false);
|
||||
counts[kvp.Key] = relations?.Count ?? 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"[TicketOverview] Failed to load count for '{kvp.Key}': {ex}");
|
||||
counts[kvp.Key] = 0;
|
||||
}
|
||||
var scope = useRoleTickets ? TileScope.Role : TileScope.Personal;
|
||||
await service.FetchAsync(scope).ConfigureAwait(false);
|
||||
counts = service.GetCountsForScope(useRoleTickets);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"[TicketOverview] Service refresh failed: {ex}");
|
||||
counts = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (counts == null || counts.Count == 0)
|
||||
counts = await LoadCountsFallbackAsync(useRoleTickets).ConfigureAwait(false);
|
||||
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
foreach (var (key, setter) in CategorySetters)
|
||||
{
|
||||
setter(_viewModel, counts[key]);
|
||||
counts.TryGetValue(key, out var value);
|
||||
setter(_viewModel, value);
|
||||
}
|
||||
|
||||
_viewModel.ResetSelection();
|
||||
@@ -255,6 +253,34 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
}, DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
private async Task<Dictionary<string, int>> LoadCountsFallbackAsync(bool useRoleTickets)
|
||||
{
|
||||
var counts = CategorySetters.ToDictionary(item => item.Key, _ => 0);
|
||||
var communication = cFasdCockpitCommunicationBase.Instance;
|
||||
if (communication == null)
|
||||
return counts;
|
||||
|
||||
var tasks = CategorySetters.ToDictionary(
|
||||
item => item.Key,
|
||||
item => communication.GetTicketOverviewRelations(item.Key, useRoleTickets, 0));
|
||||
|
||||
foreach (var kvp in tasks)
|
||||
{
|
||||
try
|
||||
{
|
||||
var relations = await kvp.Value.ConfigureAwait(false);
|
||||
counts[kvp.Key] = relations?.Count ?? 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"[TicketOverview] Fallback load failed for '{kvp.Key}': {ex}");
|
||||
counts[kvp.Key] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return counts;
|
||||
}
|
||||
|
||||
public void UpdateCounts(IDictionary<string, int> counts, bool useRoleTickets)
|
||||
{
|
||||
if (counts == null)
|
||||
@@ -272,6 +298,16 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
}, DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
public void ClearHighlightsForScope(TileScope scope)
|
||||
{
|
||||
var highlightStates = scope == TileScope.Role ? _roleHighlightStates : _personalHighlightStates;
|
||||
if (highlightStates.Count == 0)
|
||||
return;
|
||||
|
||||
highlightStates.Clear();
|
||||
UpdateHighlightState(scope == TileScope.Role);
|
||||
}
|
||||
|
||||
public void SetHighlights(IEnumerable<TileCountChange> changes, bool useRoleTickets)
|
||||
{
|
||||
if (changes != null)
|
||||
|
||||
Reference in New Issue
Block a user