public void BeforeDeploy(IDeployerEventSink host) { ServiceStatusWindow wnd = null; try { var msg = "Stopping service..."; wnd = new ServiceStatusWindow {StatusMessage = msg}; wnd.Show(); host.OnNotificationMessage(this, msg); // Pump events to ensure window is shown Application.DoEvents(); wnd.ProgressStep(); // Stop service var wc = new WebClient(); var result = wc.DownloadString(_url + "&action=stop"); if(!result.Contains("Stopped")) { wnd.Hide(); var dialogResult = MessageBox.Show("Unable to stop service. Do you want to deploy anyway?", "Service controller", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if(dialogResult == DialogResult.No) throw new DeployCancelException("Unable to stop service."); } else { wnd.ProgressStep(); // AFter stopping the service it takes a few seconds for it to proper shutdown so we wait a little extra Thread.Sleep(TimeSpan.FromSeconds(5)); host.OnNotificationMessage(this, "Service stopped."); } wnd.Close(); wnd = null; } finally { if(wnd != null) wnd.Close(); } }
public void AfterDeploy(IDeployerEventSink host) { ServiceStatusWindow wnd = null; try { var msg = "Starting service..."; wnd = new ServiceStatusWindow {StatusMessage = msg}; wnd.Show(); host.OnNotificationMessage(this, msg); Application.DoEvents(); wnd.ProgressStep(); // Start service var wc = new WebClient(); var result = wc.DownloadString(_url + "&action=start"); wnd.ProgressStep(); if (!result.Contains("Running")) { wnd.Hide(); MessageBox.Show("Failed to start service. You may need to restart it manually.", "Service controller", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { host.OnNotificationMessage(this, "Service started."); } wnd.Close(); wnd = null; } finally { if(wnd != null) wnd.Close(); } }
/// <summary> /// Indicates that the deployment operation is completed. /// </summary> public void DeployEnd() { Disconnect(); _host = null; }
/// <summary> /// Begins the deployment operation. /// </summary> public void DeployStart(IDeployerEventSink host) { // Clear flags _overwriteall = false; _skipall = false; // Verify that a destination has been set if(string.IsNullOrEmpty(_destinationPath)) { var dialogResult = MessageBox.Show("No destination path has been setup. Would you like to set it now?", "File copy", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if(dialogResult == DialogResult.Yes) ShowConfigureSettingsDialog(null); // If no path has been set here we will abort if(string.IsNullOrEmpty(_destinationPath)) throw new DeployCancelException("No destination path configured."); } }
/// <summary> /// Begins the deployment operation. /// </summary> public void DeployStart(IDeployerEventSink host) { _host = host; Connect(); }