/// <summary> /// Selects the source and destination. /// </summary> /// <param name="promoteCode">The promote code.</param> private static string SelectSourceAndDestination(PromoteCodeModel promoteCode) { var configFileReader = new ConfigFileReader(); ServerDetailsModel serverDetails = configFileReader.ReadConfigFile(new ServerDetailsModel { Region = promoteCode.Region }); var sourceFileName = serverDetails.SourceFileLocation + "\\" + promoteCode.FileName; return(sourceFileName); }
/// <summary> /// Posts the specified promote code. /// </summary> /// <param name="promoteCode">The promote code.</param> /// <returns></returns> public HttpResponseMessage Post(PromoteCodeModel promoteCode) { if (String.IsNullOrEmpty(promoteCode.Region)) { return(base.Request.CreateResponse(HttpStatusCode.BadRequest, "Please specify the region.")); } SelectSourceAndDestination(promoteCode); GetConnectionString(promoteCode.Region); if (!Directory.Exists(DestinationLocation)) { Directory.CreateDirectory(DestinationLocation); } CopyFilesAndZip("\\Scripts.zip"); MoveCodeToServer(); return(base.Request.CreateResponse(HttpStatusCode.Created, "Copy was successful.")); }
/// <summary> /// Posts the specified promote code. /// </summary> /// <param name="promoteCode">The promote code.</param> /// <returns></returns> public async Task <HttpResponseMessage> Post(PromoteCodeModel promoteCode) { if (String.IsNullOrEmpty(promoteCode.Region)) { return(base.Request.CreateResponse(HttpStatusCode.BadRequest, "Please specify the region!")); } string sourceFileName = SelectSourceAndDestination(promoteCode); var serverDetails = new ConfigFileReader().ReadConfigFile(new ServerDetailsModel { Region = promoteCode.Region }); serverDetails.SourceFileName = sourceFileName; //copy destination location to a private variable this.DestinationLocation = serverDetails.DestinationFileLocation; if (!Directory.Exists(serverDetails.DestinationFileLocation)) { Directory.CreateDirectory(serverDetails.DestinationFileLocation); } var fileProcess = new FileProcessHandler(); //Call a method to perform Xcopy fileProcess.ProcessXcopy(serverDetails); fileProcess.DeleteOldFile(serverDetails); fileProcess.ReplaceConfigFile(serverDetails); //perform the deployment to all servers deployment foreach (var server in serverDetails.ServerList) { await MoveCodeToServer(server); } return(Request.CreateResponse(HttpStatusCode.Created, "Deployment Completed")); }
/// <summary> /// Selects the source and destination. /// </summary> /// <param name="promoteCode">The promote code.</param> private void SelectSourceAndDestination(PromoteCodeModel promoteCode) { if (promoteCode.Region == "DEV") { SourceLocation = GetFromConfig("SqlBUILDS"); DestinationLocation = GetFromConfig("SqlDEV"); ServerDeploymentDirectory = GetFromConfig("SqlDevDeploymentDirectory"); IntermediateDirectory = GetFromConfig("SqlTempDirectory"); } if (promoteCode.Region == "ST") { SourceLocation = GetFromConfig("SqlDEV"); DestinationLocation = GetFromConfig("SqlST"); ServerDeploymentDirectory = GetFromConfig("SqlSTDeploymentDirectory"); IntermediateDirectory = GetFromConfig("SqlTempDirectory"); } if (promoteCode.Region == "UAT") { SourceLocation = GetFromConfig("SqlST"); DestinationLocation = GetFromConfig("SqlUAT"); ServerDeploymentDirectory = GetFromConfig("SqlSTDeploymentDirectory"); IntermediateDirectory = GetFromConfig("SqlTempDirectory"); } }