Logging
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
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
|
||||
@@ -14,6 +16,7 @@ using System.Net;
|
||||
using FasdCockpitCommunicationDemo;
|
||||
using System.Text.RegularExpressions;
|
||||
#endif
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Basics.Services
|
||||
{
|
||||
@@ -303,6 +306,15 @@ namespace FasdDesktopUi.Basics.Services
|
||||
}
|
||||
|
||||
private async Task FetchScopeAsync(TileScope scope)
|
||||
{
|
||||
MethodBase CM = null;
|
||||
if (cLogManager.DefaultLogger.IsDebug)
|
||||
{
|
||||
CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!_isEnabled)
|
||||
return;
|
||||
@@ -314,8 +326,6 @@ namespace FasdDesktopUi.Basics.Services
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_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
|
||||
@@ -789,6 +803,15 @@ namespace FasdDesktopUi.Basics.Services
|
||||
#region Retry Handling
|
||||
|
||||
private void ScheduleFetchRetry(TileScope scope)
|
||||
{
|
||||
MethodBase CM = null;
|
||||
if (cLogManager.DefaultLogger.IsDebug)
|
||||
{
|
||||
CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!_isEnabled)
|
||||
return;
|
||||
@@ -822,10 +845,19 @@ namespace FasdDesktopUi.Basics.Services
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"[TicketOverview] Retry scheduling failed: {ex}");
|
||||
LogException(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -9,10 +9,12 @@ using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
|
||||
using C4IT.FASD.Cockpit.Communication;
|
||||
using C4IT.Logging;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.Services;
|
||||
using FasdDesktopUi.Basics.Services.Models;
|
||||
using FasdDesktopUi.Pages.SearchPage;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
namespace FasdDesktopUi.Basics.UserControls
|
||||
{
|
||||
public partial class TicketOverview : UserControl
|
||||
@@ -175,6 +177,15 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
|
||||
#region Methods
|
||||
private async void TicketOverview_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MethodBase CM = null;
|
||||
if (cLogManager.DefaultLogger.IsDebug)
|
||||
{
|
||||
CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (_isInitialized)
|
||||
return;
|
||||
@@ -194,11 +205,20 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"[TicketOverview] Refresh after toggle failed: {ex}");
|
||||
LogException(ex);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetSelection()
|
||||
{
|
||||
@@ -218,7 +238,16 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
|
||||
private async Task RefreshCountsAsync(bool useRoleTickets)
|
||||
{
|
||||
MethodBase CM = null;
|
||||
if (cLogManager.DefaultLogger.IsDebug)
|
||||
{
|
||||
CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
}
|
||||
|
||||
Dictionary<string, int> counts = null;
|
||||
try
|
||||
{
|
||||
var service = TicketOverviewUpdateService.Instance;
|
||||
|
||||
if (service != null)
|
||||
@@ -231,7 +260,7 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"[TicketOverview] Service refresh failed: {ex}");
|
||||
LogException(ex);
|
||||
counts = null;
|
||||
}
|
||||
}
|
||||
@@ -252,8 +281,26 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
UpdateHighlightState(useRoleTickets);
|
||||
}, DispatcherPriority.Background);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<Dictionary<string, int>> LoadCountsFallbackAsync(bool useRoleTickets)
|
||||
{
|
||||
MethodBase CM = null;
|
||||
if (cLogManager.DefaultLogger.IsDebug)
|
||||
{
|
||||
CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var counts = CategorySetters.ToDictionary(item => item.Key, _ => 0);
|
||||
var communication = cFasdCockpitCommunicationBase.Instance;
|
||||
@@ -273,13 +320,24 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"[TicketOverview] Fallback load failed for '{kvp.Key}': {ex}");
|
||||
LogException(ex);
|
||||
counts[kvp.Key] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return counts;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
|
||||
return CategorySetters.ToDictionary(item => item.Key, _ => 0);
|
||||
}
|
||||
|
||||
public void UpdateCounts(IDictionary<string, int> counts, bool useRoleTickets)
|
||||
{
|
||||
|
||||
@@ -1403,6 +1403,13 @@ namespace FasdDesktopUi.Pages.SearchPage
|
||||
}
|
||||
private async void TicketOverview_SelectionRequested(object sender, TicketOverviewSelectionRequestedEventArgs e)
|
||||
{
|
||||
MethodBase CM = null;
|
||||
if (cLogManager.DefaultLogger.IsDebug)
|
||||
{
|
||||
CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var app = Application.Current as FasdDesktopUi.App;
|
||||
@@ -1421,7 +1428,6 @@ namespace FasdDesktopUi.Pages.SearchPage
|
||||
|
||||
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 firstRelation = relations.FirstOrDefault();
|
||||
string displayText = header;
|
||||
if (firstRelation != null)
|
||||
@@ -1486,8 +1492,10 @@ namespace FasdDesktopUi.Pages.SearchPage
|
||||
LogException(ex);
|
||||
CancledSearchAction();
|
||||
}
|
||||
System.Diagnostics.Debug.WriteLine(
|
||||
$"[TicketOverview] Key={e.Key}, UseRoleScope={e.UseRoleScope}, Count={e.Count}");
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
private string BuildHeaderText(string key, bool useRoleScope, int? count = null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user