// GET: Deployments/Delete //[FrameworkAuthorization] public ActionResult Delete(string name) { ViewBag.Message = "You are about to delete:"; if (name == null) { ViewBag.Message = "Invalid name. Nothing to display."; return(View()); } Deployment deployment = null; using (var service = DomainLocator.GetRepositoryService()) { var deployments = service.Object.ReadDeployments(); foreach (var deploymentBO in deployments) { if (deploymentBO.Name != name) { continue; } var converter = new Converter(); deployment = converter.Convert(deploymentBO); } } if (deployment == null) { return(HttpNotFound()); } return(View(deployment)); }
// GET: Deployments/RunExecute //[FrameworkAuthorization] public ActionResult RunExecute(string name, string stepAction, int stepId) { if (name == null) { ViewBag.Message = "Invalid name. Nothing to display."; //return View(); Redirect, because RunExecute View does not exist return(RedirectToAction("Execute")); } //ToDo: Check if deployment is verified but allow to execute after additional confirmation using (var service = DomainLocator.GetRepositoryService()) { //Get deployment and its steps. var converter = new Converter(); var deploymentBO = service.Object.ReadDeployment(name); var runDeployment = new RunDeployment { Deployment = converter.Convert(deploymentBO) }; var deploymentSteps = service.Object.ReadDeploymentSteps(name); switch (stepAction) { case "startdeployment": //Set steps' status to init and ... foreach (var deploymentStep in deploymentSteps) { deploymentStep.StepState = BO.DeploymentStepState.Init; service.Object.CreateDeploymentStep(name, deploymentStep); runDeployment.DeploymentSteps.Add(converter.Convert(deploymentStep)); //... the first step's to active only if the list is not empty runDeployment.DeploymentSteps[0].StepState = DeploymentStepState.Active; } //Set deployment's status to active when deployment starts... deploymentBO.Status = BO.DeploymentStatus.Active; service.Object.CreateDeployment(deploymentBO); runDeployment.Deployment.Status = DeploymentStatus.Active; break; //... and change the status of a steps with stepId and matching stepAction case "complete": deploymentSteps.Single(s => s.Id == stepId).StepState = BO.DeploymentStepState.Successful; service.Object.CreateDeploymentStep(name, deploymentSteps.Single(s => s.Id == stepId)); break; case "skip": deploymentSteps.Single(s => s.Id == stepId).StepState = BO.DeploymentStepState.Skipped; service.Object.CreateDeploymentStep(name, deploymentSteps.Single(s => s.Id == stepId)); break; case "failed": deploymentSteps.Single(s => s.Id == stepId).StepState = BO.DeploymentStepState.Failed; service.Object.CreateDeploymentStep(name, deploymentSteps.Single(s => s.Id == stepId)); break; } } return(RedirectToAction("Execute", new { name })); }
// GET: Deployments/Edit //[FrameworkAuthorization] public ActionResult Edit(string name) { if (name == null) { ViewBag.Message = "Invalid name. Nothing to display."; return(View()); } var deployment = new Deployment(); using (var service = DomainLocator.GetRepositoryService()) { var deployments = service.Object.ReadDeployments(); foreach (var deploymentBO in deployments) { if (deploymentBO.Name != name) { continue; } var converter = new Converter(); deployment = converter.Convert(deploymentBO); deployment.ReleaseVersions = new SelectList(service.Object.ReadReleaseVersions()); var configData = service.Object.ReadConfiguration("MainConfiguration"); deployment.Environments = new SelectList(converter.Convert(configData).DeployEnvironments); break; } } return(View(deployment)); }
private void RunInitializeCheck() { using (var service = DomainLocator.GetRepositoryService()) { var configuration = new WEB.Configuration(); var converter = new Converter(); service.Object.CreateConfiguration("MainConfiguration", converter.Convert(configuration)); } }
// GET: Deployments/Execute //[FrameworkAuthorization] public ActionResult Execute(string name) { if (name == null) { ViewBag.Message = "Invalid name. Nothing to display."; return(View()); } var runDeployment = new RunDeployment(); using (var service = DomainLocator.GetRepositoryService()) { var deploymentBO = service.Object.ReadDeployment(name); var converter = new Converter(); runDeployment.Deployment = converter.Convert(deploymentBO); if (runDeployment.Deployment.Status == DeploymentStatus.Active) { var deploymentSteps = service.Object.ReadDeploymentSteps(name); var steps = deploymentSteps as BO.IDeploymentStep[] ?? deploymentSteps.ToArray(); if (steps.Any()) { if (steps.Last().StepState != Domain.Shared.DeploymentStepState.Init && steps.Last().StepState != Domain.Shared.DeploymentStepState.Active) { runDeployment.Deployment.Status = DeploymentStatus.Failed; foreach (var deploymentStep in steps) { if (deploymentStep.StepState != Domain.Shared.DeploymentStepState.Failed) { runDeployment.Deployment.Status = DeploymentStatus.Successful; } } service.Object.CreateDeployment(converter.Convert(runDeployment.Deployment)); return(RedirectToAction("Index")); } foreach (var deploymentStep in steps) { runDeployment.DeploymentSteps.Add(converter.Convert(deploymentStep)); } } else { runDeployment.DeploymentSteps.Add( new DeploymentStep() { Id = 1, Description = "No steps available", StepState = DeploymentStepState.Active } ); } } } return(View(runDeployment)); }
private List <Stakeholder> GetStakeholdersHeadline() { using (var service = DomainLocator.GetRepositoryService()) { var stakeholderList = new List <Stakeholder>(); var configData = service.Object.ReadConfiguration("MainConfiguration"); //Needed only to display all available stakeholders var converter = new Converter(); return(stakeholderList = converter.Convert(configData).Stakeholders); } }
//[FrameworkAuthorization] //[ValidateAntiForgeryToken] public ActionResult Delete(ReleaseCombined releaseCombined, string action) { if (action == "delete") { using (var service = DomainLocator.GetRepositoryService()) { var converter = new Converter(); service.Object.DeleteRelease(converter.Convert(releaseCombined.Release)); return(RedirectToAction("Index")); } } return(View()); }
// GET: Releases //[FrameworkAuthorization] public ActionResult Index() { RunInitializeCheck(); var indexReleaseList = new List <Release>(); using (var service = DomainLocator.GetRepositoryService()) { var releases = service.Object.ReadReleases(); indexReleaseList.AddRange(from releaseBO in releases let converter = new Converter() select converter.Convert(releaseBO)); } return(View(indexReleaseList)); }
//[FrameworkAuthorization] //[ValidateAntiForgeryToken] public ActionResult Delete(Deployment deployment, string action) { if (action != "delete") { return(View()); } using (var service = DomainLocator.GetRepositoryService()) { var converter = new Converter(); service.Object.DeleteDeployment(converter.Convert(deployment)); return(RedirectToAction("Index")); } }
// GET: Deployment //[FrameworkAuthorization] public ActionResult Index() { RunInitializeCheck(); var indexDeploymentList = new List <Deployment>(); using (var service = DomainLocator.GetRepositoryService()) { var deployments = service.Object.ReadDeployments(); indexDeploymentList.AddRange(from deploymentBO in deployments let converter = new Converter() select converter.Convert(deploymentBO)); } return(View(indexDeploymentList)); }
//[FrameworkAuthorization] //[ValidateAntiForgeryToken] public ActionResult Create(Deployment deployment, string action) { switch (action) { case "save": if (ModelState.IsValid) { using (var service = DomainLocator.GetRepositoryService()) { var converter = new Converter(); service.Object.CreateDeployment(converter.Convert(deployment)); } return(RedirectToAction("Index")); } break; //case "verify": // using (var service = DomainLocator.GetVerificationService()) // { // var converter = new Converter(); // using (var repoService = DomainLocator.GetRepositoryService()) // { // deployment.ReleaseVersions = new SelectList(repoService.Object.ReadReleaseVersions()); // var configData = repoService.Object.ReadConfiguration("MainConfiguration"); // deployment.Environments = new SelectList(converter.Convert(configData).DeployEnvironments); // var verifiedMessages = service.Object.Verify(converter.Convert(deployment), "okwarn"); // deployment.Status = DeploymentStatus.Verified; // foreach (var message in verifiedMessages) // { // deployment.VerificationMessages.Add(converter.Convert(message)); // if (message.Status != BO.VerificationStatus.OK) // { // deployment.Status = DeploymentStatus.Init; // } // } // } // } // return View(deployment); } using (var repoService = DomainLocator.GetRepositoryService()) { deployment.ReleaseVersions = new SelectList(repoService.Object.ReadReleaseVersions()); var configData = repoService.Object.ReadConfiguration("MainConfiguration"); var converter = new Converter(); deployment.Environments = new SelectList(converter.Convert(configData).DeployEnvironments); deployment.Status = DeploymentStatus.Init; return(View(deployment)); } }
// GET: Deployments/Create //[FrameworkAuthorization] public ActionResult Create(string name) { var deployment = new Deployment { Name = name }; using (var service = DomainLocator.GetRepositoryService()) { deployment.ReleaseVersions = new SelectList(service.Object.ReadReleaseVersions()); var configData = service.Object.ReadConfiguration("MainConfiguration"); var converter = new Converter(); deployment.Environments = new SelectList(converter.Convert(configData).DeployEnvironments); } return(View(deployment)); }
// GET: Releases/Prepare //[FrameworkAuthorization] public ActionResult Prepare(string version) { if (version == null) { ViewBag.Message = "Invalid version number. Nothing to display."; return(View()); } ReleasePrepared releasePrepared = new ReleasePrepared { StakeholdersHeadline = GetStakeholdersHeadline() }; using (var service = DomainLocator.GetRepositoryService()) { //ToDo: Change to ReadReleaseVersions() and then Read() one Release var releases = service.Object.ReadReleases(); foreach (var releaseBO in releases) { if (releaseBO.Version != version) { continue; } var converter = new Converter(); releasePrepared.Release = converter.Convert(releaseBO); foreach (var releaseUnit in releasePrepared.Release.UnitList) { foreach (var headline in releasePrepared.StakeholdersHeadline) { if (releaseUnit.StakeholderList.Count(x => x.Name == headline.Name) > 0) { continue; } releaseUnit.StakeholderList.Add(headline); } } } } //Create SelectList var participatingStakeholdersUnits = (from releaseUnit in releasePrepared.Release.UnitList from stakeholder in releaseUnit.StakeholderList where stakeholder.IsParticipating select string.Format("{0}~{1}~", releaseUnit.Name, stakeholder.Name)).ToList(); releasePrepared.ReleaseElementOptions = new SelectList(participatingStakeholdersUnits, "Select release unit and team"); return(View(releasePrepared)); }
//[FrameworkAuthorization] //[ValidateAntiForgeryToken] public ActionResult Prepare(ReleasePrepared releasePrepared, string action) { releasePrepared.StakeholdersHeadline = GetStakeholdersHeadline(); switch (action) { case "addreleaseelement": //ToDo: Add list of Release Elements in Domain.Release and add Release Elements here var releaseElement = new ReleaseElement { SelectListPrefix = releasePrepared.ReleaseElementOption, Content = releasePrepared.NewReleaseElement }; //ToDo: catch NullReferenceExeption releasePrepared.Release.UnitList.FirstOrDefault( x => x.Name == releasePrepared.ReleaseElementOption.Split('~')[0]). ReleaseElementsList.Add(releaseElement); //Create SelectList anew var participatingStakeholdersUnits = (from releaseUnit in releasePrepared.Release.UnitList from stakeholder in releaseUnit.StakeholderList where stakeholder.IsParticipating select string.Format("{0}~{1}~", releaseUnit.Name, stakeholder.Name)).ToList(); releasePrepared.ReleaseElementOptions = new SelectList(participatingStakeholdersUnits, "Select release unit and team"); break; case "save": if (ModelState.IsValid) { using (var service = DomainLocator.GetRepositoryService()) { var converter = new Converter(); service.Object.CreateRelease(converter.Convert(releasePrepared.Release)); return(RedirectToAction("Index")); } } break; case "confirmprepare": //ToDo: Add field Status in ??? and set Status here break; } return(View(releasePrepared)); }
// GET: Releases/Delete //[FrameworkAuthorization] public ActionResult Delete(string version) { ViewBag.Message = "You are about to delete:"; if (version == null) { ViewBag.Message = "Invalid version number. Nothing to display."; return(View()); } ReleaseCombined releaseCombined = new ReleaseCombined { StakeholdersHeadline = GetStakeholdersHeadline() }; using (var service = DomainLocator.GetRepositoryService()) { var releases = service.Object.ReadReleases(); foreach (var releaseBO in releases) { if (releaseBO.Version != version) { continue; } var converter = new Converter(); releaseCombined.Release = converter.Convert(releaseBO); foreach (var releaseUnit in releaseCombined.Release.UnitList) { foreach (var headline in releaseCombined.StakeholdersHeadline) { if (releaseUnit.StakeholderList.Count(x => x.Name == headline.Name) > 0) { continue; } releaseUnit.StakeholderList.Add(headline); } } } } return(View(releaseCombined)); }
//[FrameworkAuthorization] //[ValidateAntiForgeryToken] public ActionResult Create(ReleaseCombined releaseCombined, string action) { releaseCombined.StakeholdersHeadline = GetStakeholdersHeadline(); switch (action) { case "addreleaseunit": var releaseUnit = new ReleaseUnit { Name = releaseCombined.NewReleaseUnit }; foreach (var stakeholderHead in releaseCombined.StakeholdersHeadline) { releaseUnit.StakeholderList.Add(new Stakeholder() { Name = stakeholderHead.Name, IsParticipating = false }); } releaseCombined.Release.UnitList.Add(releaseUnit); break; case "save": if (ModelState.IsValid) { using (var service = DomainLocator.GetRepositoryService()) { var converter = new Converter(); service.Object.CreateRelease(converter.Convert(releaseCombined.Release)); } return(RedirectToAction("Index")); } break; case "deletereleaseunit": //ToDo: Complete view and logic break; } return(View(releaseCombined)); }