aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2020-05-13 13:27:01 +0300
committerAvi Levkovich <avi@twine-s.com>2020-05-13 13:27:01 +0300
commit15dfc2cdcbc2e518c09c1ee75f32ff149d4a337d (patch)
tree4c0b49773706b85282e6f6b1ec3d2e949d3ca22e /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs
parent6a49e917c587dcbbfe8175b8dde73840b7d105fc (diff)
parentcd750d626d3780990797faf09446033bbaa4311c (diff)
downloadTango-15dfc2cdcbc2e518c09c1ee75f32ff149d4a337d.tar.gz
Tango-15dfc2cdcbc2e518c09c1ee75f32ff149d4a337d.zip
commit merge
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs43
1 files changed, 40 insertions, 3 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs
index 4b7d8978e..f10e84d05 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs
@@ -12,6 +12,7 @@ using Tango.PMR.Integration;
using Tango.PPC.Common;
using Tango.PPC.Common.ExternalBridge;
using Tango.PPC.Common.Navigation;
+using Tango.PPC.UI.Dialogs;
namespace Tango.PPC.UI.ViewModels
{
@@ -24,6 +25,8 @@ namespace Tango.PPC.UI.ViewModels
{
private bool _disconnecting;
+ private const int KEEP_SAFETY_AUTHENTICATION_MINUTES = 5;
+
#region Properties
private ExternalBridgeClientConnectedEventArgs _connection;
@@ -133,7 +136,7 @@ namespace Tango.PPC.UI.ViewModels
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="ExternalBridgeClientConnectedEventArgs"/> instance containing the event data.</param>
- private void ExternalBridgeService_ConnectionRequest(object sender, ExternalBridgeClientConnectedEventArgs e)
+ private async void ExternalBridgeService_ConnectionRequest(object sender, ExternalBridgeClientConnectedEventArgs e)
{
LogManager.Log($"External bridge connection request received.\n{e.ToJsonString()}");
@@ -142,8 +145,6 @@ namespace Tango.PPC.UI.ViewModels
e.ApplicationInformation.Version = ApplicationManager.Version.ToString();
e.ApplicationInformation.StartupDate = ApplicationManager.StartUpDate.ToUniversalTime().ToString();
- e.Confirmed = true;
-
Connection = e;
User = Adapter.Users.SingleOrDefault(x => x.Guid == e.Request.UserGuid);
@@ -153,6 +154,41 @@ namespace Tango.PPC.UI.ViewModels
LogManager.Log($"External bridge connection user has been identified as {User.Contact.FullName}");
}
+ if (e.Request.RequireSafetyLevelOperations)
+ {
+ DateTime lastAuthenticationTime;
+ bool bypassSafetyConfirmation = false;
+
+ if (ExternalBridgeReceiver.LastSafetyLevelContactsTimes.TryGetValue(e.Request.UserName, out lastAuthenticationTime))
+ {
+ if (DateTime.Now < lastAuthenticationTime.AddMinutes(KEEP_SAFETY_AUTHENTICATION_MINUTES))
+ {
+ bypassSafetyConfirmation = true;
+ e.Confirm();
+ }
+ }
+
+ if (!bypassSafetyConfirmation)
+ {
+ SafetyLevelOperationsConfirmationViewVM vm = new SafetyLevelOperationsConfirmationViewVM(e);
+ await NotificationProvider.ShowDialog(vm);
+
+ if (vm.DialogResult)
+ {
+ e.Confirm();
+ }
+ else
+ {
+ e.Decline("Safety level connection refused by the remote user.");
+ return;
+ }
+ }
+ }
+ else
+ {
+ e.Confirm();
+ }
+
if (e.Request.Intent == ExternalBridgeLoginIntent.FullControl)
{
LogManager.Log("Navigating to external bridge view...");
@@ -164,6 +200,7 @@ namespace Tango.PPC.UI.ViewModels
}
else
{
+ e.Decline("Connection password did not match the machine external bridge password.");
LogManager.Log("Connection password did not match the machine external bridge password.");
}
}