aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-05-05 19:24:45 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-05-05 19:24:45 +0300
commit5571ab086f6288b27117e3eaae443415a162403c (patch)
treed189224b3bca6789532516d33d12ea2f0a1327b2 /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
parentdd81a94133e1c5117e06e84cbddf45ffec30acfc (diff)
downloadTango-5571ab086f6288b27117e3eaae443415a162403c.tar.gz
Tango-5571ab086f6288b27117e3eaae443415a162403c.zip
Require Safety Level Operations !
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs48
1 files changed, 45 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..538b1f272 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,10 @@ namespace Tango.PPC.UI.ViewModels
{
private bool _disconnecting;
+ //Full Name, Authentication time
+ private Dictionary<String, DateTime> _authenticatedSafetyUsers;
+ private const int KEEP_SAFETY_AUTHENTICATION_MINUTES = 1;
+
#region Properties
private ExternalBridgeClientConnectedEventArgs _connection;
@@ -64,6 +69,7 @@ namespace Tango.PPC.UI.ViewModels
/// </summary>
public ExternalBridgeViewVM()
{
+ _authenticatedSafetyUsers = new Dictionary<string, DateTime>();
CloseSessionCommand = new RelayCommand(CloseSession, () => !_disconnecting);
}
@@ -133,7 +139,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 +148,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 +157,43 @@ 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 (_authenticatedSafetyUsers.TryGetValue(e.Request.UserName, out lastAuthenticationTime))
+ {
+ if (DateTime.Now < lastAuthenticationTime.AddMinutes(KEEP_SAFETY_AUTHENTICATION_MINUTES))
+ {
+ bypassSafetyConfirmation = true;
+ e.Confirm();
+ _authenticatedSafetyUsers[e.Request.UserName] = DateTime.Now;
+ }
+ }
+
+ if (!bypassSafetyConfirmation)
+ {
+ SafetyLevelOperationsConfirmationViewVM vm = new SafetyLevelOperationsConfirmationViewVM(e);
+ await NotificationProvider.ShowDialog(vm);
+
+ if (vm.DialogResult)
+ {
+ e.Confirm();
+ _authenticatedSafetyUsers[e.Request.UserName] = DateTime.Now;
+ }
+ 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 +205,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.");
}
}