Example #1
0
        public ActionResult AddSchedule(DeploymentScheduleListViewModel deploymentScheduleListViewModel)
        {
            try
            {
                var viewModel = Mapper.Map<DeploymentScheduleListViewModel, DeploymentScheduleViewModel>(deploymentScheduleListViewModel);

                // Set up server list
                SetUpServerList(deploymentScheduleListViewModel);

                //Get deployment
                var deployment = _deploymentService.GetById(deploymentScheduleListViewModel.intDeploymentID);

                if (deployment == null)
                {
                    throw new Exception("Unable to find deployment.");
                }

                // Set up view model
                viewModel.dteStartDate = DateTime.Now.AddDays(1);
                viewModel.dteEndDate = DateTime.Now.AddDays(1);
                viewModel.selectedServer = SessionManager.SelectedServers;
                viewModel.strDeploymentName = deployment.strName;

                // Store view bag data
                ViewBag.ServerCount = SessionManager.SelectedServers.Count();
                ViewBag.StartTime = new SelectList(_deploymentScheduleService.GetScheduleTime(), "Key", "Value", "12:00:00 AM");
                ViewBag.EndTime = new SelectList(_deploymentScheduleService.GetScheduleTime(), "Key", "Value", "4:00:00 AM");
                ViewBag.DeploymentID = deploymentScheduleListViewModel.intDeploymentID;
                ViewBag.DeploymentName = deployment.strName;

                return View(viewModel);

            }
            catch (Exception ex)
            {
                TempData["Message"] = ScreenMessages.ErrorMessage("Standard", ex.Message);

                return RedirectToAction("Error", "Error");
            }
        }
Example #2
0
        private void SetUpServerList(DeploymentScheduleListViewModel deploymentScheduleListViewModel)
        {
            // Set up server list
                if (deploymentScheduleListViewModel.bSelectAll == false)
                {
                    SessionManager.SelectedServers = new List<SelectedServer>();
                    SessionManager.SelectedServers.Clear();

                    string[] storedServersArray = deploymentScheduleListViewModel.storeSelectedServers.Split(',');

                    foreach (var item in storedServersArray)
                    {
                        if (item != "")
                        {
                            var itemArray = item.Split('|');

                            var serverData = _serverService.GetById(Int32.Parse(itemArray[0]));

                            var bEngineering = serverData.Domain.bEngineering;
                            var bPilot = serverData.Domain.bPilot;
                            var strTimeZone = serverData.strTimeZone;
                            var intServerID = Int32.Parse(itemArray[0]);
                            var intDeploymentID = Int32.Parse(itemArray[1]);

                            SessionManager.SelectedServers.Add(new SelectedServer() { intServerID = intServerID, bEngineering = bEngineering, bPilot = bPilot, strTimeZone = strTimeZone, intDeploymentID = intDeploymentID });

                        }
                    }
                }
        }
Example #3
0
        public ActionResult ServersDelete(DeploymentScheduleListViewModel deploymentScheduleListViewModel)
        {
            try
            {
                var deploymentScheduleViewModel = Mapper.Map<DeploymentScheduleListViewModel, DeploymentScheduleViewModel>(deploymentScheduleListViewModel);

                var deploymentSchedule = Mapper.Map<DeploymentScheduleViewModel, DeploymentSchedule>(deploymentScheduleViewModel);

                // Set up server list
                SetUpServerList(deploymentScheduleListViewModel);

                // Set up view model
                deploymentSchedule.selectedServer = SessionManager.SelectedServers;

                SortedSet<int> rnowIDList = _deploymentScheduleService.DeleteSchedules(deploymentSchedule.selectedServer);

                // Update all changes RNOW items
                foreach (var item in rnowIDList)
                {
                    Task.Factory.StartNew(() => new WDT.RNOW.RNOW().ExecuteJob(item));
                }

                // Store view bag data
                ViewBag.Status = "DeleteComplete";

                return View("ServersDelete");

            }
            catch (Exception ex)
            {
                TempData["Message"] = ScreenMessages.ErrorMessage("Standard", ex.Message);

                return RedirectToAction("Error", "Error");
            }
        }