Beispiel #1
0
        public void SendNotification(NamedPipeMessages.Notification.Request request)
        {
            string pipeName = Path.Combine(Path.GetTempPath(), NotificationServerPipeName);

            using (NamedPipeClient client = new NamedPipeClient(pipeName))
            {
                if (client.Connect())
                {
                    try
                    {
                        client.SendRequest(request.ToMessage());
                    }
                    catch (Exception ex)
                    {
                        EventMetadata metadata = new EventMetadata();
                        metadata.Add("Area", nameof(NotificationHandler));
                        metadata.Add("Exception", ex.ToString());
                        metadata.Add(TracingConstants.MessageKey.ErrorMessage, "MacOS notification display error");
                        this.tracer.RelatedError(metadata, $"MacOS notification: {request.Title} - {request.Message}.");
                    }
                }
                else
                {
                    this.tracer.RelatedError($"ERROR: Communication failure with native notification display tool. Notification info: {request.Title} - {request.Message}.");
                }
            }
        }
Beispiel #2
0
 public void SendNotification(NamedPipeMessages.Notification.Request request)
 {
     using (NamedPipeClient client = new NamedPipeClient(GVFSConstants.Service.UIName))
     {
         if (client.Connect())
         {
             try
             {
                 if (!client.TrySendRequest(request.ToMessage()))
                 {
                     this.tracer.RelatedInfo("Failed to send notification request to " + GVFSConstants.Service.UIName);
                 }
             }
             catch (Exception ex)
             {
                 EventMetadata metadata = new EventMetadata();
                 metadata.Add("Exception", ex.ToString());
                 metadata.Add("Identifier", request.Id);
                 this.tracer.RelatedError(metadata, $"{nameof(this.SendNotification)}- Could not send notification request({request.Id}. {ex.ToString()}");
             }
         }
         else
         {
             this.tracer.RelatedError($"{nameof(this.SendNotification)}- Could not connect with GVFS.Service.UI, failed to send notification request({request.Id}.");
         }
     }
 }
Beispiel #3
0
        public void SendNotification(ITracer tracer, NamedPipeMessages.Notification.Request request)
        {
            NamedPipeClient client;

            if (!this.TryOpenConnectionToUIProcess(tracer, out client))
            {
                this.TerminateExistingProcess(tracer, GVFSConstants.Service.UIName);

                if (!ProcessAsCurrentUser.Run(
                        tracer,
                        Configuration.Instance.GVFSServiceUILocation,
                        string.Empty,
                        showWindow: false))
                {
                    tracer.RelatedError("Could not start " + GVFSConstants.Service.UIName);
                    return;
                }

                this.TryOpenConnectionToUIProcess(tracer, out client);
            }

            if (client == null)
            {
                tracer.RelatedError("Failed to connect to " + GVFSConstants.Service.UIName);
                return;
            }

            try
            {
                if (!client.TrySendRequest(request.ToMessage()))
                {
                    tracer.RelatedInfo("Failed to send notification request to " + GVFSConstants.Service.UIName);
                }
            }
            finally
            {
                client.Dispose();
            }
        }
        public void SendNotification(int sessionId, NamedPipeMessages.Notification.Request request)
        {
            NamedPipeClient client;

            if (!this.TryOpenConnectionToUIProcess(out client))
            {
                this.TerminateExistingProcess(GSDConstants.Service.UIName);

                CurrentUser currentUser = new CurrentUser(this.tracer, sessionId);
                if (!currentUser.RunAs(
                        Configuration.Instance.GSDServiceUILocation,
                        string.Empty))
                {
                    this.tracer.RelatedError("Could not start " + GSDConstants.Service.UIName);
                    return;
                }

                this.TryOpenConnectionToUIProcess(out client);
            }

            if (client == null)
            {
                this.tracer.RelatedError("Failed to connect to " + GSDConstants.Service.UIName);
                return;
            }

            try
            {
                if (!client.TrySendRequest(request.ToMessage()))
                {
                    this.tracer.RelatedInfo("Failed to send notification request to " + GSDConstants.Service.UIName);
                }
            }
            finally
            {
                client.Dispose();
            }
        }