示例#1
0
        /// <summary>
        /// Excecutes the specified deploy entity.
        /// </summary>
        /// <param name="deployEntity">The deploy entity.</param>
        public void Excecute(dynamic deployEntity)
        {
            //typecasting dynamic model to ServiceDetailsModel
            var serviceDetailsModel = (ServerDetailsModel) deployEntity;

            //get the instance of FileProcess handler class
            var fileProcessHandler = new FileProcessHandler();

            //process XCOPY function
            fileProcessHandler.ProcessXcopy(serviceDetailsModel);

            //delete the old file
            fileProcessHandler.DeleteOldFile(serviceDetailsModel);

            //replace the config file
            fileProcessHandler.ReplaceConfigFile(serviceDetailsModel);
        }
        /// <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");
        }