示例#1
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);
              }
        }
示例#2
0
        public ActionResult GetProjectConfigurationBuilds(string projectName, string projectConfigurationName)
        {
            if (string.IsNullOrEmpty(projectName))
              {
            return BadRequest();
              }

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

              var projectConfigurationModel = new ProjectConfigurationModel(projectConfigurationName);

              List<ProjectConfigurationBuildViewModel> projectConfigurationBuildViewModels =
            _agentService.GetProjectConfigurationBuilds(
              projectName,
              projectConfigurationModel.ConfigurationName,
              projectConfigurationModel.BranchName,
              _maxProjectConfigurationBuildsCount)
              .Select(
            pcb =>
              new ProjectConfigurationBuildViewModel
              {
                Id = pcb.Id,
                Number = pcb.Number,
                StartDateStr = pcb.StartDate
              })
              .ToList();

              return
            Json(
              new { projectConfigurationBuilds = projectConfigurationBuildViewModels },
              JsonRequestBehavior.AllowGet);
        }