//[ValidateAntiForgeryToken] public ActionResult Edit([Bind(Include = "Order,SKU,Id,OrderKey,ProjectName,SKUId,GraphSKU,DesignName,RepairQty,Issue,ProcessName,ResponsibleDepartment,Owner,StartDateTime,CompletedDateTime,ElapsedTime,Status,Remark,OrderId,BomComponentId,ParentBomComponentId")] RepairJob repairJob) { if (ModelState.IsValid) { repairJob.ObjectState = ObjectState.Modified; _repairJobService.Update(repairJob); _unitOfWork.SaveChanges(); if (Request.IsAjaxRequest()) { return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } DisplaySuccessMessage("Has update a RepairJob record"); return(RedirectToAction("Index")); } var orderRepository = _unitOfWork.Repository <Order>(); ViewBag.OrderId = new SelectList(orderRepository.Queryable(), "Id", "OrderKey", repairJob.OrderId); var skuRepository = _unitOfWork.Repository <SKU>(); ViewBag.SKUId = new SelectList(skuRepository.Queryable(), "Id", "Sku", repairJob.SKUId); if (Request.IsAjaxRequest()) { var modelStateErrors = String.Join("", this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors.Select(n => n.ErrorMessage))); return(Json(new { success = false, err = modelStateErrors }, JsonRequestBehavior.AllowGet)); } DisplayErrorMessage(); return(View(repairJob)); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { JobHandle jobHandle = new RepairJob { eEntityCommandBuffer = m_EndSimulationEntityCommandBufferSystem.CreateCommandBuffer().ToConcurrent() }.Schedule(this, inputDeps); jobHandle.Complete(); return(jobHandle); }
public EntityEntry <RepairJob> GetRepairJobEntityEntry(RepairJob entity) { if (entity == null) { return(null); } var entry = _context.Entry(entity); return(entry); }
// GET: RepairJobs/Create public ActionResult Create() { RepairJob repairJob = new RepairJob(); //set default value var orderRepository = _unitOfWork.Repository <Order>(); ViewBag.OrderId = new SelectList(orderRepository.Queryable(), "Id", "OrderKey"); var skuRepository = _unitOfWork.Repository <SKU>(); ViewBag.SKUId = new SelectList(skuRepository.Queryable(), "Id", "Sku"); return(View(repairJob)); }
//[ValidateAntiForgeryToken] public ActionResult DeleteConfirmed(int id) { RepairJob repairJob = _repairJobService.Find(id); _repairJobService.Delete(repairJob); _unitOfWork.SaveChanges(); if (Request.IsAjaxRequest()) { return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } DisplaySuccessMessage("Has delete a RepairJob record"); return(RedirectToAction("Index")); }
// GET: RepairJobs/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RepairJob repairJob = _repairJobService.Find(id); if (repairJob == null) { return(HttpNotFound()); } return(View(repairJob)); }
public void MapRepairJobValues(RepairJobInputModel repairJobInputModel, RepairJob repairJobEntity) { if (repairJobInputModel == null) { throw new Exception("InputModel cannot be null."); } if (repairJobEntity == null) { throw new Exception("RepairJob entity not found."); } var repairJobEntityEntry = _repairJobRepository.GetRepairJobEntityEntry(repairJobEntity); repairJobEntityEntry.CurrentValues.SetValues(repairJobInputModel); }
// GET: RepairJobs/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RepairJob repairJob = _repairJobService.Find(id); if (repairJob == null) { return(HttpNotFound()); } var orderRepository = _unitOfWork.Repository <Order>(); ViewBag.OrderId = new SelectList(orderRepository.Queryable(), "Id", "OrderKey", repairJob.OrderId); var skuRepository = _unitOfWork.Repository <SKU>(); ViewBag.SKUId = new SelectList(skuRepository.Queryable(), "Id", "Sku", repairJob.SKUId); return(View(repairJob)); }
public void AddNotices_NoDuplicateListNoneEmpty_Success() { List<Node> testNodes = new List<Node>() { new Node(), new Node() }; List<Node> testNodes2 = new List<Node>() { new Node(), new Node() }; Notice no = new DisruptJob(2, testNodes, ID++); Notice no2 = new DisruptJob(2, testNodes2, ID++); Notice no3 = new DisruptJob(1, testNodes, ID++); Notice no4 = new DisruptJob(1, testNodes2, ID++); Notice no5 = new OccupyJob(1, testNodes, ID++); Notice no6 = new OccupyJob(1, testNodes2, ID++); Notice no7 = new AttackJob(1, testNodes, ID++); Notice no8 = new AttackJob(1, testNodes2, ID++); Notice no9 = new RepairJob(testNodes, ID++); Notice no10 = new RepairJob(testNodes2, ID++); bool addSuccess = nb.CreateAndAddNotice(NoticeBoard.JobType.Disrupt, 2, testNodes, out no); bool addSuccess2 = nb.CreateAndAddNotice(NoticeBoard.JobType.Disrupt, 2, testNodes2, out no2); bool addSuccess3 = nb.CreateAndAddNotice(NoticeBoard.JobType.Disrupt, 1, testNodes, out no3); bool addSuccess4 = nb.CreateAndAddNotice(NoticeBoard.JobType.Disrupt, 1, testNodes2, out no4); bool addSuccess5 = nb.CreateAndAddNotice(NoticeBoard.JobType.Occupy, 1, testNodes, out no5); bool addSuccess6 = nb.CreateAndAddNotice(NoticeBoard.JobType.Occupy, 1, testNodes2, out no6); bool addSuccess7 = nb.CreateAndAddNotice(NoticeBoard.JobType.Attack, 1, testNodes, out no7); bool addSuccess8 = nb.CreateAndAddNotice(NoticeBoard.JobType.Attack, 1, testNodes2, out no8); bool addSuccess9 = nb.CreateAndAddNotice(NoticeBoard.JobType.Repair, 1, testNodes, out no9); bool addSuccess10 = nb.CreateAndAddNotice(NoticeBoard.JobType.Repair, 1, testNodes2, out no10); Assert.True(addSuccess); Assert.True(addSuccess2); Assert.True(addSuccess3); Assert.True(addSuccess4); Assert.True(addSuccess5); Assert.True(addSuccess6); Assert.True(addSuccess7); Assert.True(addSuccess8); Assert.True(addSuccess9); Assert.True(addSuccess10); Assert.AreEqual(10, nb.GetNoticeCount()); }
public void AddNotice_DuplicateExists_Failure() { List<Node> testNodes = new List<Node>() { new Node(), new Node() }; Notice no = new DisruptJob(2, testNodes, ID++); Notice no2 = new DisruptJob(2, testNodes, ID++); Notice no3 = new AttackJob(2, testNodes, ID++); Notice no4 = new AttackJob(2, testNodes, ID++); Notice no5 = new OccupyJob(2, testNodes, ID++); Notice no6 = new OccupyJob(2, testNodes, ID++); Notice no7 = new RepairJob(testNodes, ID++); Notice no8 = new RepairJob(testNodes, ID++); bool addSuccess = nb.CreateAndAddNotice(NoticeBoard.JobType.Disrupt, 2, testNodes, out no); bool addSuccess2 = nb.CreateAndAddNotice(NoticeBoard.JobType.Disrupt, 2, testNodes, out no2); bool addSuccess3 = nb.CreateAndAddNotice(NoticeBoard.JobType.Attack, 2, testNodes, out no3); bool addSuccess4 = nb.CreateAndAddNotice(NoticeBoard.JobType.Attack, 2, testNodes, out no4); bool addSuccess5 = nb.CreateAndAddNotice(NoticeBoard.JobType.Occupy, 2, testNodes, out no5); bool addSuccess6 = nb.CreateAndAddNotice(NoticeBoard.JobType.Occupy, 2, testNodes, out no6); bool addSuccess7 = nb.CreateAndAddNotice(NoticeBoard.JobType.Repair, 1, testNodes, out no7); bool addSuccess8 = nb.CreateAndAddNotice(NoticeBoard.JobType.Repair, 1, testNodes, out no8); Assert.True(addSuccess); Assert.False(addSuccess2); Assert.True(addSuccess3); Assert.False(addSuccess4); Assert.True(addSuccess5); Assert.False(addSuccess6); Assert.True(addSuccess7); Assert.False(addSuccess8); Assert.AreEqual(4, nb.GetNoticeCount()); }
public void FindJobsForAgentsSomeAgentsIsPreferedForMultipleMultiJobs_AllJobsFilledAtStart_Success() { #region setup List<Node> nodes = new List<Node>() { new Node(), new Node(), new Node() }; NabfAgent agent1 = new NabfAgent("a1"), agent2 = new NabfAgent("a2"), agent3 = new NabfAgent("a3"), agent4 = new NabfAgent("a4"), agent5 = new NabfAgent("a5"), agent6 = new NabfAgent("a6"); Notice notice1 = new OccupyJob(2, nodes, ID++), notice2 = new DisruptJob(2, nodes, ID++), notice3 = new AttackJob(2, nodes, ID++), notice4 = new RepairJob(nodes, ID++); //nb.AddNotice(notice1); nb.AddNotice(notice2); nb.AddNotice(notice3); nb.AddNotice(notice4); nb.CreateAndAddNotice(NoticeBoard.JobType.Occupy, 2, nodes, out notice1); nb.CreateAndAddNotice(NoticeBoard.JobType.Disrupt, 2, nodes, out notice2); nb.CreateAndAddNotice(NoticeBoard.JobType.Attack, 2, nodes, out notice3); nb.CreateAndAddNotice(NoticeBoard.JobType.Repair, 1, nodes, out notice4); #endregion #region agent desirability nb.ApplyToNotice(notice1, 110, agent1); nb.ApplyToNotice(notice2, 10, agent1); nb.ApplyToNotice(notice3, 11, agent1); nb.ApplyToNotice(notice4, 1111, agent1); nb.ApplyToNotice(notice1, 120, agent2); nb.ApplyToNotice(notice2, 20, agent2); nb.ApplyToNotice(notice3, 22, agent2); nb.ApplyToNotice(notice4, 2222, agent2); nb.ApplyToNotice(notice1, 130, agent3); nb.ApplyToNotice(notice2, 30, agent3); nb.ApplyToNotice(notice3, 33, agent3); nb.ApplyToNotice(notice1, 140, agent4); nb.ApplyToNotice(notice2, 40, agent4); nb.ApplyToNotice(notice3, 44, agent4); nb.ApplyToNotice(notice1, 150, agent5); nb.ApplyToNotice(notice2, 50, agent5); nb.ApplyToNotice(notice3, 55, agent5); nb.ApplyToNotice(notice1, 99999999, agent6); nb.ApplyToNotice(notice2, 99999999, agent6); nb.ApplyToNotice(notice3, 99999999, agent6); #endregion int evtTriggered = 0; List<Notice> notices = new List<Notice>(); List<List<NabfAgent>> listOfListOfAgents = new List<List<NabfAgent>>(); List<int> averageDesires = new List<int>(); nb.NoticeIsReadyToBeExecutedEvent += (sender, evt) => { notices.Add(evt.Notice); listOfListOfAgents.Add(evt.Agents); averageDesires.Add(evt.Notice.HighestAverageDesirabilityForNotice); evtTriggered++; }; nb.FindJobsForAgents(); Assert.AreEqual(3, evtTriggered); Assert.AreEqual(notice1, notices[0]); Assert.AreEqual(notice4, notices[1]); Assert.AreEqual(notice3, notices[2]); Assert.IsTrue(listOfListOfAgents[0][0].Name == agent6.Name || listOfListOfAgents[0][0].Name == agent5.Name); Assert.IsTrue(listOfListOfAgents[0][1].Name == agent6.Name || listOfListOfAgents[0][1].Name == agent5.Name); Assert.AreEqual(listOfListOfAgents[1][0].Name, agent2.Name); Assert.IsTrue(listOfListOfAgents[2][0].Name == agent4.Name || listOfListOfAgents[2][0].Name == agent3.Name); Assert.IsTrue(listOfListOfAgents[2][1].Name == agent4.Name || listOfListOfAgents[2][1].Name == agent3.Name); Assert.AreEqual((99999999 + 150) / 2, averageDesires[0]); Assert.AreEqual(2222, averageDesires[1]); Assert.AreEqual((44 + 33) / 2, averageDesires[2]); }
public bool CreateAndAddNotice(JobType type, int agentsNeeded, List<Node> whichNodes, out Notice notice) { Notice n = null; Int64 id = _freeID; _freeID++; switch (type) { case JobType.Attack: n = new AttackJob(agentsNeeded, whichNodes, id); break; case JobType.Disrupt: n = new DisruptJob(agentsNeeded, whichNodes, id); break; case JobType.Occupy: n = new OccupyJob(agentsNeeded, whichNodes, id); break; case JobType.Repair: n = new RepairJob(whichNodes, id); break; } if (n == null) throw new ArgumentException("Input to CreateNotice, JoType : " + type.GetType().Name + " was not of appropriate type. It's type was: " + type.GetType()); bool b = AddNotice(n); notice = n; return b; }