private string UnInstallService(string serviceName, string serviceDir, string adminUser = "", string adminPassword = "") { string errorMsg = ""; try { var process = new ProcessHandler("cmd"); if (!string.IsNullOrEmpty(adminUser)) { process.SetExecUser(adminUser, adminPassword); } process.Execute("sc Stop " + serviceName); process.Execute("sc Delete " + serviceName); errorMsg = process.OutputString; Thread.Sleep(100); Directory.Delete(serviceDir, true); return(errorMsg); } catch (Exception ex) { errorMsg = ex.GetAllMessages(); } return(errorMsg); }
private string InstallService(string serviceName, string serviceDir, string adminUser = "", string adminPassword = "") { string installerDir = RuntimeEnvironment.GetRuntimeDirectory(); string errorMsg = ""; if (!File.Exists(Path.Combine(installerDir, installerExe))) { installerDir = this.WorkDir; } if (!File.Exists(Path.Combine(installerDir, installerExe))) { errorMsg = string.Format(@"'{0}' was not found in '{1}'", installerExe, installerDir); return(errorMsg); } DirectoryUtil.CreateDirectoryIfNotExists(serviceDir); Environment.CurrentDirectory = serviceDir; FileUtil.CopyDirectory(this.ServiceSourceDir, serviceDir, true); var process = new ProcessHandler("cmd"); if (!string.IsNullOrEmpty(adminUser)) { process.SetExecUser(adminUser, adminPassword); } string systemUser = "******" + this.settings.SystemUser; if (!string.IsNullOrEmpty(this.settings.SystemDomain)) { systemUser = "******" + this.settings.SystemUser + "@" + this.settings.SystemDomain; } string stmt = installerDir + string.Format(installerExe + " /ServiceAccount={0} /UserName={1} /Password={2} /ServiceName={3} \"{4}\" ", ServiceAccount.LocalSystem, systemUser, this.settings.SystemPassword, serviceName, Path.Combine(serviceDir, this.ServiceExecutableName)); process.Execute(stmt); string result = process.OutputString; if (result.Contains("Fehler") || result.Contains("Exception") || result.Contains("Rollback")) { errorMsg = "ERROR: Beim Installieren des Dienstes, bitte Logs überprüfen" + Environment.NewLine + Environment.NewLine + result; } return(errorMsg); }
private string StartService(string serviceName, string adminUser = "", string adminPassword = "") { string errorMsg = ""; try { var process = new ProcessHandler("cmd"); if (!string.IsNullOrEmpty(adminUser)) { process.SetExecUser(adminUser, adminPassword); } process.Execute("sc start " + serviceName); errorMsg = process.OutputString; return(errorMsg); } catch (Exception ex) { errorMsg = ex.GetAllMessages(); } return(errorMsg); }
/// <summary> /// Workflow manager task waiting new message and processes it /// </summary> private void ExecuteWatcherProcess() { CloudStorageAccount storageAccount; CloudQueueClient queueClient; CloudQueueMessage currentMessage; //QUEUE infra storageAccount = CloudStorageAccount.Parse(_Configuration.ProcessConfigConn); queueClient = storageAccount.CreateCloudQueueClient(); //TraceInfo auxiliar string txt; //1. Setup() Setup(_Configuration.ProcessConfigConn); //Check if is ON/Pausa if (!_Configuration.IsPaused) { //2. how many process is running in this instance? if (myProcessHandler.CurrentProcessRunning < _Configuration.MaxCurrentProcess) { //2.1 Execute new //3. Peek Message currentMessage = GetNewMessage(queueClient); if (currentMessage != null) { //We have a new message txt = string.Format("[{0}] has a new message, messageId {1}", this.GetType().FullName, currentMessage.Id); Trace.TraceInformation(txt); //3.1 Check if is a posion Message if (!CheckPoison(currentMessage)) { //4. Good Message //4.1 Start process, fire and Forgot txt = string.Format("[{0}] Starting New Process, MessageID {1}", this.GetType().FullName, currentMessage.Id); Trace.TraceInformation(txt); myProcessHandler.Execute(currentMessage); } else { //Send dedletter message txt = string.Format("[{0}] has a new Poison message, messageId {1}", this.GetType().FullName, currentMessage.Id); Trace.TraceWarning(txt); if (SendPoisonMessage(currentMessage)) { InWorkQueue.DeleteMessage(currentMessage); txt = string.Format("[{0}] Deleted Poison message, messageId {1}", this.GetType().FullName, currentMessage.Id); Trace.TraceWarning(txt); } } } else { DateTime x = System.IO.File.GetCreationTime(@".\MediaButler.Common.dll"); txt = string.Format("[{0}][{2}] has not a new message. # current process {1}", this.GetType().FullName, myProcessHandler.CurrentProcessRunning, x.ToString()); Trace.TraceInformation(txt); } } else { txt = string.Format("[{0}] Max number of process in parallel ({1} current {2})", this.GetType().FullName, _Configuration.MaxCurrentProcess, myProcessHandler.CurrentProcessRunning); Trace.TraceInformation(txt); } } else { Trace.TraceInformation("[{0}] Workflow Manager is paused.", this.GetType().FullName); } }