This commit is contained in:
Meik
2026-02-13 09:30:46 +01:00
parent 352dc42ae7
commit 86ce7e89e1
4 changed files with 238 additions and 127 deletions

View File

@@ -1,6 +1,8 @@
using System;
using System.Diagnostics;
using System.Reflection;
using C4IT.FASD.Base;
using C4IT.Logging;
using static C4IT.Logging.cLogManager;
namespace FasdDesktopUi.Basics.Services.Models
{
@@ -13,6 +15,13 @@ namespace FasdDesktopUi.Basics.Services.Models
{
public int GetPollingMinutes(TileScope scope)
{
MethodBase CM = null;
if (cLogManager.DefaultLogger.IsDebug)
{
CM = MethodBase.GetCurrentMethod();
LogMethodBegin(CM);
}
int minutes = scope == TileScope.Role
? cF4sdTicketConfig.DefaultOverviewPollingRole
: cF4sdTicketConfig.DefaultOverviewPollingPersonal;
@@ -29,7 +38,11 @@ namespace FasdDesktopUi.Basics.Services.Models
}
catch (Exception ex)
{
Debug.WriteLine($"[TicketOverview] Settings fallback to defaults: {ex.Message}");
LogException(ex);
}
finally
{
LogMethodEnd(CM);
}
if (minutes < 1)

View File

@@ -1,19 +1,22 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
using C4IT.FASD.Base;
using C4IT.FASD.Cockpit.Communication;
using C4IT.Logging;
using FasdDesktopUi.Basics.Models;
using FasdDesktopUi.Basics.Services.Models;
#if isDemo
using System.Net;
using FasdCockpitCommunicationDemo;
using System.Text.RegularExpressions;
#endif
#if isDemo
using System.Net;
using FasdCockpitCommunicationDemo;
using System.Text.RegularExpressions;
#endif
using static C4IT.Logging.cLogManager;
namespace FasdDesktopUi.Basics.Services
{
@@ -304,18 +307,25 @@ namespace FasdDesktopUi.Basics.Services
private async Task FetchScopeAsync(TileScope scope)
{
if (!_isEnabled)
return;
var communication = _communicationSource.Resolve();
if (communication == null)
MethodBase CM = null;
if (cLogManager.DefaultLogger.IsDebug)
{
ScheduleFetchRetry(scope);
return;
CM = MethodBase.GetCurrentMethod();
LogMethodBegin(CM);
}
try
{
if (!_isEnabled)
return;
var communication = _communicationSource.Resolve();
if (communication == null)
{
ScheduleFetchRetry(scope);
return;
}
_isDemo = communication.IsDemo();
var rawCounts = await communication.GetTicketOverviewCounts(OverviewKeys, scope == TileScope.Role).ConfigureAwait(false);
@@ -339,9 +349,13 @@ namespace FasdDesktopUi.Basics.Services
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"[TicketOverview] Fetch {scope} failed: {ex}");
LogException(ex);
ScheduleFetchRetry(scope);
}
finally
{
LogMethodEnd(CM);
}
}
#endregion
@@ -790,41 +804,59 @@ namespace FasdDesktopUi.Basics.Services
private void ScheduleFetchRetry(TileScope scope)
{
if (!_isEnabled)
return;
lock (_retryScopes)
MethodBase CM = null;
if (cLogManager.DefaultLogger.IsDebug)
{
_retryScopes.Add(scope);
if (_retryScheduled)
return;
_retryScheduled = true;
CM = MethodBase.GetCurrentMethod();
LogMethodBegin(CM);
}
_ = _dispatcher.InvokeAsync(async () =>
try
{
try
{
await Task.Delay(TimeSpan.FromSeconds(5)).ConfigureAwait(false);
TileScope[] scopes;
lock (_retryScopes)
{
scopes = _retryScopes.ToArray();
_retryScopes.Clear();
_retryScheduled = false;
}
if (!_isEnabled)
return;
foreach (var pendingScope in scopes)
{
await FetchAsync(pendingScope).ConfigureAwait(false);
}
}
catch (Exception ex)
lock (_retryScopes)
{
System.Diagnostics.Debug.WriteLine($"[TicketOverview] Retry scheduling failed: {ex}");
_retryScopes.Add(scope);
if (_retryScheduled)
return;
_retryScheduled = true;
}
});
_ = _dispatcher.InvokeAsync(async () =>
{
try
{
await Task.Delay(TimeSpan.FromSeconds(5)).ConfigureAwait(false);
TileScope[] scopes;
lock (_retryScopes)
{
scopes = _retryScopes.ToArray();
_retryScopes.Clear();
_retryScheduled = false;
}
foreach (var pendingScope in scopes)
{
await FetchAsync(pendingScope).ConfigureAwait(false);
}
}
catch (Exception ex)
{
LogException(ex);
}
});
}
catch (Exception ex)
{
LogException(ex);
}
finally
{
LogMethodEnd(CM);
}
}
#endregion