Пример #1
0
 private void WriteToClient(NamedPipeMessages.UnmountRepoRequest.Response response)
 {
     NamedPipeMessages.Message message = response.ToMessage();
     if (!this.connection.TrySendResponse(message))
     {
         this.tracer.RelatedError("Failed to send line to client: {0}", message);
     }
 }
Пример #2
0
        private bool RequestUnmount(string rootPath, out string errorMessage)
        {
            errorMessage = string.Empty;
            NamedPipeMessages.UnmountRepoRequest request = new NamedPipeMessages.UnmountRepoRequest();
            request.EnlistmentRoot = rootPath;

            using (NamedPipeClient client = new NamedPipeClient(this.ServicePipeName))
            {
                if (!client.Connect())
                {
                    errorMessage = "Unable to unmount because GVFS.Service is not responding. Run 'sc start GVFS.Service' from an elevated command prompt to ensure it is running.";
                    return(false);
                }

                try
                {
                    client.SendRequest(request.ToMessage());
                    NamedPipeMessages.Message response = client.ReadResponse();
                    if (response.Header == NamedPipeMessages.UnmountRepoRequest.Response.Header)
                    {
                        NamedPipeMessages.UnmountRepoRequest.Response message = NamedPipeMessages.UnmountRepoRequest.Response.FromMessage(response);

                        if (message.State != NamedPipeMessages.CompletionState.Success)
                        {
                            errorMessage = message.UserText;
                            return(false);
                        }
                        else
                        {
                            errorMessage = string.Empty;
                            return(true);
                        }
                    }
                    else
                    {
                        errorMessage = string.Format("GVFS.Service responded with unexpected message: {0}", response);
                        return(false);
                    }
                }
                catch (BrokenPipeException e)
                {
                    errorMessage = "Unable to communicate with GVFS.Service: " + e.ToString();
                    return(false);
                }
            }
        }
Пример #3
0
        public void Run()
        {
            string errorMessage = string.Empty;

            NamedPipeMessages.UnmountRepoRequest.Response response = new NamedPipeMessages.UnmountRepoRequest.Response();

            if (this.Unmount(out errorMessage))
            {
                response.State = NamedPipeMessages.CompletionState.Success;
            }
            else
            {
                response.State    = NamedPipeMessages.CompletionState.Failure;
                response.UserText = errorMessage;
            }

            this.WriteToClient(response);
        }