コード例 #1
0
        private Guid SetDeploymentState(string environmentName, string projectConfigurationName, string projectName)
        {
            Guid deploymentId = Guid.NewGuid();

            var deploymentState =
                new DeploymentState(
                    deploymentId,
                    UserIdentity,
                    projectName,
                    projectConfigurationName,
                    environmentName);

            _deploymentStateProvider.SetDeploymentState(
                deploymentId,
                deploymentState);

            return(deploymentId);
        }
コード例 #2
0
        private ActionResult DoDeployOrSimulate(bool isSimulation, string projectName, string projectConfigurationName, string projectConfigurationBuildId, string targetEnvironmentName, ProjectType?projectType, List <string> targetMachines = null)
        {
            if (string.IsNullOrEmpty(projectName))
            {
                return(BadRequest());
            }

            if (string.IsNullOrEmpty(projectConfigurationName))
            {
                return(BadRequest());
            }

            if (string.IsNullOrEmpty(projectConfigurationBuildId))
            {
                return(BadRequest());
            }

            if (string.IsNullOrEmpty(targetEnvironmentName))
            {
                return(BadRequest());
            }

            if (!projectType.HasValue)
            {
                return(BadRequest());
            }

            try
            {
                Guid deploymentId = Guid.NewGuid();

                var projectConfigurationModel = new ProjectConfigurationModel(projectConfigurationName);

                var deploymentState =
                    new DeploymentState(
                        deploymentId,
                        UserIdentity,
                        projectName,
                        projectConfigurationModel.ConfigurationName,
                        targetEnvironmentName);

                _deploymentStateProvider.SetDeploymentState(
                    deploymentId,
                    deploymentState);

                _agentService.DeployAsync(
                    deploymentId,
                    _sessionService.UniqueClientId,
                    SecurityUtils.CurrentUsername,
                    CreateDeploymentInfo(
                        deploymentId,
                        isSimulation,
                        projectName,
                        projectConfigurationModel.ConfigurationName,
                        projectConfigurationBuildId,
                        targetEnvironmentName,
                        projectType.Value,
                        targetMachines));

                return(Json(new { Status = "OK" }));
            }
            catch (Exception exc)
            {
                return(HandleAjaxError(exc));
            }
        }