public override bool Execute(out string message) { string batchFile = string.Empty; string batchFileLog = string.Empty; bool result = false; message = string.Empty; try { string uniqueName = Guid.NewGuid().ToString(); batchFile = Path.Combine(GenericHelper.GetTempFolder(this.ServerName), uniqueName) + ".bat"; batchFileLog = Path.Combine(GenericHelper.FormatPath(this.ServerName, this.BTDFProjFileDirectory), "DeployResults", "DeployResults.txt"); string[] btdfProjfiles = Directory.GetFiles(this.BTDFProjFileDirectory, "*.btdfproj", SearchOption.AllDirectories); string[] targetEnvironmentfiles = Directory.GetFiles(this.BTDFProjFileDirectory, this.TargetEnvironment == null ? string.Empty : "*" + this.TargetEnvironment + "*", SearchOption.AllDirectories); this.TargetEnvironment = targetEnvironmentfiles.Count() > 0 ? GenericHelper.FormatPath(this.ServerName, targetEnvironmentfiles[0]) : string.Empty; this.CreateAndSaveBatchFile(GenericHelper.FormatPath(this.ServerName, btdfProjfiles[0]), batchFile, batchFileLog); result = Win32_Process.Create(this.ServerName, batchFile, out message); if (File.Exists(batchFileLog)) { message = message + File.ReadAllText(batchFileLog); } } catch (Exception exe) { message = exe.Message + "-- FAILED"; } finally { if (File.Exists(batchFile)) { File.Delete(batchFile); } } result = (message.Contains("-- FAILED") || message.Contains("Build FAILED.")) ? false : true; return(result); }
public override bool Execute(out string message) { string tempMsiPath = string.Empty; string batchFile = string.Empty; string batchFileLog = string.Empty; bool result = false; string exceptionMessage = string.Empty; message = string.Empty; try { //tempMsiPath = GenericHelper.FormatPath(this.resourceInfo.ServerName, this.resourceInfo.ResourceName); string uniqueName = Guid.NewGuid().ToString(); batchFile = Path.Combine(GenericHelper.GetTempFolder(this.ServerName), uniqueName) + ".bat"; batchFileLog = Path.ChangeExtension(batchFile, "txt"); string[] files = Directory.GetFiles(this.BTDFProjFileDirectory, "*.btdfproj", SearchOption.AllDirectories); string[] files1 = Directory.GetFiles(this.BTDFProjFileDirectory, this.TargetEnvironment == null ? string.Empty : "*" + this.TargetEnvironment + "*", SearchOption.AllDirectories); this.TargetEnvironment = files1.Count() > 0 ? GenericHelper.FormatPath(this.ServerName, files1[0]) : string.Empty; this.CreateAndSaveBatchFile(GenericHelper.FormatPath(this.ServerName, files[0]), batchFile, batchFileLog); result = Win32_Process.Create(this.ServerName, batchFile, out message); if (File.Exists(batchFileLog)) { message = message + File.ReadAllText(batchFileLog); } } catch (Exception exe) { exceptionMessage = exe.Message + "-- FAILED"; } finally { if (File.Exists(tempMsiPath)) { File.Delete(tempMsiPath); } if (File.Exists(batchFile)) { //File.Delete(batchFile); } if (File.Exists(batchFileLog)) { // File.Delete(batchFileLog); } } message = result ? message : exceptionMessage; result = (message.Contains("-- FAILED") || message.Contains("Build FAILED.")) ? false : true; return result; }
public override bool Execute(out string message) { string tempMsiPath = string.Empty; string batchFile = string.Empty; string batchFileLog = string.Empty; bool result = false; message = string.Empty; try { tempMsiPath = GenericHelper.CopyToTempFolder(this.resourceInfo.ServerName, this.resourceInfo.ResourceName); string uniqueName = Guid.NewGuid().ToString(); batchFile = Path.Combine(GenericHelper.GetTempFolder(this.resourceInfo.ServerName), uniqueName) + ".bat"; batchFileLog = Path.ChangeExtension(batchFile, "txt"); CreateAndSaveBatchFile(tempMsiPath, batchFile, batchFileLog); result = Win32_Process.Create(this.resourceInfo.ServerName, batchFile, out message); if (File.Exists(batchFileLog)) { message = message + File.ReadAllText(batchFileLog); } ExtractSettings(GenericHelper.FormatPath(this.resourceInfo.ServerName, this.TargetDir)); } catch (Exception exe) { message = exe.Message; } finally { if (File.Exists(tempMsiPath)) { File.Delete(tempMsiPath); } if (File.Exists(batchFile)) { File.Delete(batchFile); } if (File.Exists(batchFileLog)) { File.Delete(batchFileLog); } } result = (message.Contains("Installation completed successfully") || message.Contains("Configuration completed successfully")) ? true : false; return(result); }