|
@@ -63,6 +63,7 @@ using SortDirection = InABox.Core.SortDirection;
|
|
using PRSDesktop.Components.Spreadsheet;
|
|
using PRSDesktop.Components.Spreadsheet;
|
|
using InABox.Wpf.Reports;
|
|
using InABox.Wpf.Reports;
|
|
using Comal.Classes.SecurityDescriptors;
|
|
using Comal.Classes.SecurityDescriptors;
|
|
|
|
+using System.Threading;
|
|
|
|
|
|
namespace PRSDesktop;
|
|
namespace PRSDesktop;
|
|
|
|
|
|
@@ -462,15 +463,19 @@ public partial class MainWindow : IPanelHostControl
|
|
{
|
|
{
|
|
Dispatcher.Invoke(() =>
|
|
Dispatcher.Invoke(() =>
|
|
{
|
|
{
|
|
- var cancelled = false;
|
|
|
|
- var success = Progress.ShowModal("Reconnecting", "Exit PRS", (progress, ct) =>
|
|
|
|
|
|
+ var reconnection = new ReconnectionWindow();
|
|
|
|
+ var cancellationTokenSource = new CancellationTokenSource();
|
|
|
|
+
|
|
|
|
+ reconnection.OnCancelled = () => cancellationTokenSource.Cancel();
|
|
|
|
+
|
|
|
|
+ var ct = cancellationTokenSource.Token;
|
|
|
|
+ var work = () =>
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
DateTime lost = DateTime.Now;
|
|
DateTime lost = DateTime.Now;
|
|
while (!client.IsConnected() && !ct.IsCancellationRequested)
|
|
while (!client.IsConnected() && !ct.IsCancellationRequested)
|
|
{
|
|
{
|
|
- progress.Report($"Connection lost - ({(DateTime.Now - lost):hh\\:mm})");
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
Logger.Send(LogType.Error, ClientFactory.UserID, "Reconnecting - ({0:hh\\:mm})", DateTime.Now - lost);
|
|
Logger.Send(LogType.Error, ClientFactory.UserID, "Reconnecting - ({0:hh\\:mm})", DateTime.Now - lost);
|
|
@@ -486,7 +491,6 @@ public partial class MainWindow : IPanelHostControl
|
|
// TODO: Remove this suppression
|
|
// TODO: Remove this suppression
|
|
if (e1.Message.StartsWith("The socket is connected, you needn't connect again!"))
|
|
if (e1.Message.StartsWith("The socket is connected, you needn't connect again!"))
|
|
{
|
|
{
|
|
- cancelled = true;
|
|
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -496,14 +500,26 @@ public partial class MainWindow : IPanelHostControl
|
|
Logger.Send(LogType.Information, ClientFactory.UserID, "Reconnected");
|
|
Logger.Send(LogType.Information, ClientFactory.UserID, "Reconnected");
|
|
ClientFactory.Validate(ClientFactory.SessionID);
|
|
ClientFactory.Validate(ClientFactory.SessionID);
|
|
Logger.Send(LogType.Information, ClientFactory.UserID, "Validated");
|
|
Logger.Send(LogType.Information, ClientFactory.UserID, "Validated");
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|
|
Logger.Send(LogType.Error, ClientFactory.UserID, $"Reconnect Failed: {e.Message}");
|
|
Logger.Send(LogType.Error, ClientFactory.UserID, $"Reconnect Failed: {e.Message}");
|
|
}
|
|
}
|
|
- });
|
|
|
|
- if (!success || cancelled)
|
|
|
|
|
|
+ return false;
|
|
|
|
+ };
|
|
|
|
+ var task = Task.Run(() =>
|
|
|
|
+ {
|
|
|
|
+ var result = work();
|
|
|
|
+ Dispatcher.Invoke(() =>
|
|
|
|
+ {
|
|
|
|
+ reconnection.Close();
|
|
|
|
+ });
|
|
|
|
+ return result;
|
|
|
|
+ }, ct);
|
|
|
|
+ reconnection.ShowDialog();
|
|
|
|
+ if (!task.Result)
|
|
{
|
|
{
|
|
Close();
|
|
Close();
|
|
}
|
|
}
|