コード例 #1
0
        public ActionResult CreateContainer(int id)
        {
            WorkerContainersManagement workerContainersManagement = new WorkerContainersManagement();

            UpdateInProgressMessage(id, "Creating Worker Container");
            AsynchronousCallback ContainerThread = new AsynchronousCallback(workerContainersManagement.CreateWorker);
            ContainerThread.BeginInvoke(id, null, null);

            return RedirectToAction("CloudDetails", "CloudManagement", new { id = new WorkerContainersManagement().cloudLookupFromWorkerId(id).CloudId });
        }
コード例 #2
0
        public ActionResult EditPost(Worker worker, bool isQuarantined, int? CloudID, int?[] ServicesList)
        {
            if (!CloudID.HasValue)
                ModelState.AddModelError(String.Empty, "Please choose a cloud");

            if (ModelState.IsValid)
            {
                db.Entry(worker).State = EntityState.Modified;
                db.SaveChanges();

                //Link To Cloud
                var CloudList = db.Clouds.ToList();
                for (int CloudIndex = 0; CloudIndex < CloudList.Count(); CloudIndex++)
                    if (CloudList[CloudIndex].Workers.Where(x => x.WorkerId == worker.WorkerId).Count() > 0)
                        db.Clouds.ToList()[CloudIndex].Workers.Remove(worker);
                db.SaveChanges();
                if (CloudID.HasValue)
                {
                    db.Clouds.Find(CloudID).Workers.Add(worker);
                    db.SaveChanges();
                }

                //Services List
                var worker2 = db.Workers.Include(x => x.Services).Where(x => x.WorkerId == worker.WorkerId).First();

                if (worker2.Services == null)
                    worker2.Services = new List<Service>();

                foreach (var service in db.Services.ToList())
                    worker2.Services.Remove(service);
                db.SaveChanges();

                if (ServicesList != null)
                {
                    foreach (int serviceID in ServicesList)
                    {
                        var service = db.Services.Find(serviceID);
                        worker2.Services.Add(service);
                    }
                    db.SaveChanges();
                }

                WorkerContainersManagement workerContainersManagement = new WorkerContainersManagement();
                workerContainersManagement.RefreshWorker(worker2.WorkerId);

                return RedirectToAction("Dashboard", "Home");
            }
            return View("~/Views/Home/Dashboard.cshtml", worker);
        }
コード例 #3
0
        public ActionResult RefreshAllWorkers(int id)
        {
            WorkerContainersManagement workerContainersManagement = new WorkerContainersManagement();

            workerContainersManagement.RefreshAllWorkers(id);

            return RedirectToAction("CloudDetails", "CloudManagement", new { id = id });
        }
コード例 #4
0
        public ActionResult Details(int id)
        {
            //Get the Worker entity from the database using the given ID
            WorkerContainersManagement workerContainersManagement = new WorkerContainersManagement();

            //Get and pass to the view the machine that has this worker
            Worker worker = db.Workers.Find(id);
            Cloud cloud = workerContainersManagement.cloudLookupFromWorkerId(id);
            ViewBag.Machine = workerContainersManagement.machineLookupFromMasterId(cloud.Master.MasterId);

            //Pass this entity to the view
            return PartialView(worker);
        }