Catch exceptions on history updates
This commit is contained in:
parent
c705b4396f
commit
3579d779e8
@ -4,6 +4,8 @@
|
||||
|
||||
using BreCalClient.misc.Api;
|
||||
using BreCalClient.misc.Model;
|
||||
using log4net;
|
||||
using log4net.Core;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
@ -22,6 +24,7 @@ namespace BreCalClient
|
||||
|
||||
private readonly ConcurrentDictionary<int, ShipcallControlModel> _shipcalls;
|
||||
private readonly StaticApi _staticApi;
|
||||
private readonly static ILog _log = LogManager.GetLogger(typeof(HistoryDialog));
|
||||
|
||||
#endregion
|
||||
|
||||
@ -68,15 +71,18 @@ namespace BreCalClient
|
||||
private async void RefreshHistory()
|
||||
{
|
||||
List<History> allHistories = new();
|
||||
this.stackPanel.Children.Clear();
|
||||
|
||||
try
|
||||
{
|
||||
foreach (int shipcall_id in _shipcalls.Keys)
|
||||
{
|
||||
List<History> shipcallHistory = await _staticApi.HistoryGetAsync(shipcall_id);
|
||||
System.Diagnostics.Trace.WriteLine($"{shipcallHistory.Count} history elements loaded for shipcall {shipcall_id}");
|
||||
allHistories.AddRange( shipcallHistory );
|
||||
allHistories.AddRange(shipcallHistory);
|
||||
}
|
||||
|
||||
this.stackPanel.Children.Clear();
|
||||
|
||||
// sort all entries
|
||||
allHistories.Sort((x, y) => { return y.Timestamp.CompareTo(x.Timestamp); });
|
||||
|
||||
@ -97,7 +103,7 @@ namespace BreCalClient
|
||||
if (_shipcalls[history.ShipcallId].Shipcall != null)
|
||||
{
|
||||
ShipcallType? type = _shipcalls[history.ShipcallId].Shipcall?.Type;
|
||||
if (type != null) calltype = (string) (enumToStringConverter.Convert(type ?? ShipcallType.Undefined, typeof(ShipcallType), new(), System.Globalization.CultureInfo.CurrentCulture) ?? "");
|
||||
if (type != null) calltype = (string)(enumToStringConverter.Convert(type ?? ShipcallType.Undefined, typeof(ShipcallType), new(), System.Globalization.CultureInfo.CurrentCulture) ?? "");
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,6 +113,14 @@ namespace BreCalClient
|
||||
}
|
||||
|
||||
Mouse.OverrideCursor = null;
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Here we rather not show a dialog box since it may confuse the user
|
||||
_log.Error(e.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool FilterShipcall(int shipcallId)
|
||||
|
||||
@ -38,7 +38,7 @@ namespace BreCalClient
|
||||
|
||||
#region Fields
|
||||
|
||||
private static Int32 _uiUpdateRunning = 0;
|
||||
private static int _uiUpdateRunning = 0;
|
||||
|
||||
private Credentials? _credentials;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user