aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2022-04-28 01:46:21 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2022-04-28 01:46:21 +0300
commit59aa6065ebb3481e50c13ec6b4850448fe66186a (patch)
treea0fc681cebd3535bc611c270075d74784daaf324 /Software/Visual_Studio/PPC/Tango.PPC.Common
parentb9b8126eacf4a4391f9725c91328586dd5446d4b (diff)
downloadTango-59aa6065ebb3481e50c13ec6b4850448fe66186a.tar.gz
Tango-59aa6065ebb3481e50c13ec6b4850448fe66186a.zip
FSE Procedures Remote Notifications.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteNotifications/DefaultRemoteNotificationsService.cs80
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteNotifications/IRemoteNotificationsService.cs14
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj4
3 files changed, 97 insertions, 1 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteNotifications/DefaultRemoteNotificationsService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteNotifications/DefaultRemoteNotificationsService.cs
new file mode 100644
index 000000000..5931f56ab
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteNotifications/DefaultRemoteNotificationsService.cs
@@ -0,0 +1,80 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Tango.Core.DI;
+using Tango.Core.Threading;
+using Tango.Integration.ExternalBridge;
+using Tango.PPC.Common.ExternalBridge;
+using Tango.PPC.Common.Notifications;
+using Tango.PPC.Shared.Notifications;
+
+namespace Tango.PPC.Common.RemoteNotifications
+{
+ [TangoCreateWhenRegistered]
+ public class DefaultRemoteNotificationsService : IRemoteNotificationsService
+ {
+ private INotificationProvider _notification;
+
+ public bool Enabled { get; set; } = true;
+
+ public DefaultRemoteNotificationsService(IPPCExternalBridgeService externalBridge, INotificationProvider notificationProvider)
+ {
+ _notification = notificationProvider;
+ externalBridge.RegisterRequestHandler(this);
+ }
+
+ [ExternalBridgeRequestHandlerMethod(typeof(RemoteMessageBoxRequest), RequestHandlerLoggingMode.LogRequestName)]
+ public async Task OnRemoteMessageBoxRequest(RemoteMessageBoxRequest request, String token, ExternalBridgeReceiver receiver)
+ {
+ bool result = false;
+ bool completed = false;
+
+ if (request.Timeout != null)
+ {
+ ThreadFactory.StartNew(() =>
+ {
+ Thread.Sleep(request.Timeout.Value);
+
+ if (!completed)
+ {
+ completed = true;
+ _notification.CurrentMessageBox.Close(false);
+ receiver.SendErrorResponse(new TimeoutException("The user did not respond within the given timeout."), token);
+ }
+ });
+ }
+
+ switch (request.Type)
+ {
+ case RemoteMessageBoxType.Info:
+ await _notification.ShowInfo(request.Message);
+ break;
+ case RemoteMessageBoxType.Warning:
+ await _notification.ShowWarning(request.Message);
+ break;
+ case RemoteMessageBoxType.Question:
+ result = await _notification.ShowQuestion(request.Message);
+ break;
+ case RemoteMessageBoxType.Error:
+ await _notification.ShowError(request.Message);
+ break;
+ default:
+ break;
+ }
+
+ if (completed) return;
+
+ completed = true;
+
+ await receiver.SendGenericResponse(new RemoteMessageBoxResponse() { Result = result }, token);
+ }
+
+ public void OnReceiverDisconnected(ExternalBridgeReceiver receiver)
+ {
+
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteNotifications/IRemoteNotificationsService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteNotifications/IRemoteNotificationsService.cs
new file mode 100644
index 000000000..a3c1d106b
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteNotifications/IRemoteNotificationsService.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Integration.ExternalBridge;
+
+namespace Tango.PPC.Common.RemoteNotifications
+{
+ public interface IRemoteNotificationsService : IPPCService, IExternalBridgeRequestHandler
+ {
+
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj
index 48cb50dff..af3531817 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj
@@ -188,6 +188,8 @@
<Compile Include="RemoteJob\DefaultRemoteJobService.cs" />
<Compile Include="RemoteJob\IRemoteJobService.cs" />
<Compile Include="RemoteActions\IRemoteActionsService.cs" />
+ <Compile Include="RemoteNotifications\DefaultRemoteNotificationsService.cs" />
+ <Compile Include="RemoteNotifications\IRemoteNotificationsService.cs" />
<Compile Include="SQL\DefaultRemoteSqlService.cs" />
<Compile Include="SQL\IRemoteSqlService.cs" />
<Compile Include="Synchronization\DefaultMachineDataSynchronizer.cs" />
@@ -525,7 +527,7 @@
</Target>
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
+ <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file