예제 #1
0
        private DeploymentStep GetDeploymentStep(DeploymentStepModel model, DeploymentStepType deploymentStepType)
        {
            DeploymentStep deploymentStep;

            if (model.DeploymentStepId == 0)
            {
                deploymentStep                 = new DeploymentStep();
                deploymentStep.Type            = deploymentStepType;
                deploymentStep.BundleVersionId = model.BundleVersionId;
                deploymentStep.OrderIndex      = this.Entities.DeploymentStep.Count(ds => ds.BundleVersionId == model.BundleVersionId) + 1;
                this.Entities.DeploymentStep.Add(deploymentStep);
            }
            else
            {
                deploymentStep = this.Entities.DeploymentStep
                                 .Include("Properties")
                                 .First(ds => ds.Id == model.DeploymentStepId);
            }

            return(deploymentStep);
        }
예제 #2
0
        public ActionResult AddStep(int id, DeploymentStepType deploymentStepType = DeploymentStepType.Undefined)
        {
            this.CheckPermission(UserRoleAction.DeploymentChangeSteps);

            BundleVersion bundleVersion = this.Entities.BundleVersion
                                          .Include("DeploymentSteps")
                                          .First(bv => bv.Id == id);

            List <MachineRole> machineRoles = this.Entities.MachineRole.ToList();

            this.ViewBag.BundleVersion = bundleVersion;
            this.ViewBag.MachineRoles  = machineRoles;

            if (deploymentStepType == DeploymentStepType.Undefined)
            {
                return(this.View("AddStep"));
            }

            this.ViewBag.DeploymentStep = new DeploymentStep();

            if (deploymentStepType == DeploymentStepType.DeployWebSite)
            {
                this.ViewBag.ProjectsSelect = this.Entities.SourceControlVersion
                                              .SelectMany(scv => scv.ProjectVersions)
                                              .Where(pv => pv.ProjectType.HasFlag(ProjectType.Web) && !pv.Project.Properties.Any(p => p.Key == "NotForDeployment" && p.Value == "true"))
                                              .Select(pv => new SelectListItem
                {
                    Text  = pv.SourceControlVersion.SourceControl.Name + " / " + pv.SourceControlVersion.Name + " / " + pv.Name,
                    Value = pv.Id.ToString()
                })
                                              .OrderBy(sli => sli.Text)
                                              .ToList();

                WebSiteDeploymentStepModel model = new WebSiteDeploymentStepModel
                {
                    BundleVersionId = bundleVersion.Id
                };

                return(this.View("EditWebsiteStep", model));
            }

            if (deploymentStepType == DeploymentStepType.DeployDacpac)
            {
                this.ViewBag.ProjectsSelect = this.Entities.SourceControlVersion
                                              .SelectMany(scv => scv.ProjectVersions)
                                              .Where(pv => pv.ProjectType.HasFlag(ProjectType.Database) && !pv.Project.Properties.Any(p => p.Key == "NotForDeployment" && p.Value == "true"))
                                              .Select(pv => new SelectListItem
                {
                    Text  = pv.SourceControlVersion.SourceControl.Name + " / " + pv.SourceControlVersion.Name + " / " + pv.Name,
                    Value = pv.Id.ToString()
                })
                                              .OrderBy(sli => sli.Text)
                                              .ToList();

                DacpacDeploymentStepModel model = new DacpacDeploymentStepModel
                {
                    BundleVersionId = bundleVersion.Id
                };

                return(this.View("EditDacpacStep", model));
            }

            if (deploymentStepType == DeploymentStepType.CopyFiles)
            {
                this.ViewBag.ProjectsSelect = this.Entities.SourceControlVersion
                                              .SelectMany(scv => scv.ProjectVersions)
                                              .Where(pv => pv.ProjectType.HasFlag(ProjectType.ZipArchive) || pv.ProjectType.HasFlag(ProjectType.GulpFile))
                                              .Where(pv => !pv.Project.Properties.Any(p => p.Key == "NotForDeployment" && p.Value == "true"))
                                              .Select(pv => new SelectListItem
                {
                    Text  = pv.SourceControlVersion.SourceControl.Name + " / " + pv.SourceControlVersion.Name + " / " + pv.Name,
                    Value = pv.Id.ToString()
                })
                                              .OrderBy(sli => sli.Text)
                                              .ToList();

                ZipArchiveDeploymentStepModel model = new ZipArchiveDeploymentStepModel
                {
                    BundleVersionId = bundleVersion.Id
                };

                return(this.View("EditZipArchiveStep", model));
            }

            if (deploymentStepType == DeploymentStepType.UpdateHostsFile)
            {
                HostsDeploymentStepModel model = new HostsDeploymentStepModel
                {
                    BundleVersionId = bundleVersion.Id
                };

                return(this.View("EditHostsStep", model));
            }

            if (deploymentStepType == DeploymentStepType.RunSQLScript)
            {
                SqlScriptDeploymentStepModel model = new SqlScriptDeploymentStepModel
                {
                    BundleVersionId = bundleVersion.Id
                };

                return(this.View("EditSqlScriptStep", model));
            }

            if (deploymentStepType == DeploymentStepType.Configuration)
            {
                ConfigDeploymentStepModel model = new ConfigDeploymentStepModel
                {
                    BundleVersionId = bundleVersion.Id
                };

                return(this.View("EditConfigStep", model));
            }

            if (deploymentStepType == DeploymentStepType.RunVsTests)
            {
                this.ViewBag.ProjectsSelect = this.Entities.SourceControlVersion
                                              .SelectMany(scv => scv.ProjectVersions)
                                              .Where(pv => pv.ProjectType.HasFlag(ProjectType.Test) && !pv.Project.Properties.Any(p => p.Key == "NotForDeployment" && p.Value == "true"))
                                              .Select(pv => new SelectListItem
                {
                    Text  = pv.SourceControlVersion.SourceControl.Name + " / " + pv.SourceControlVersion.Name + " / " + pv.Name,
                    Value = pv.Id.ToString()
                })
                                              .OrderBy(sli => sli.Text)
                                              .ToList();

                RunVsTestStepModel model = new RunVsTestStepModel
                {
                    BundleVersionId = bundleVersion.Id
                };

                return(this.View("EditRunTestStep", model));
            }

            throw new AspNetDeployException("Invalid deployment step type");
        }