public void JobIsEnded(DeliveryJob job) { Debug.Log("JobIsEnded: " + myRes + " Left jobs " + myJobs.Count.ToString()); myJobs.Remove(job); Debug.Log("JobIsEnded: " + myRes + " Left jobs " + myJobs.Count.ToString()); Debug.Log("JobIsEnded: " + myRes + " Left orders " + myOrders.Count.ToString()); }
// Get : AcceptOrder public ActionResult AcceptOrder(int id) { var deliverId = User.Identity.GetUserName().ToString(); //Create Job Class //Attr: JobId,OrderId,DeliveryPerson, //Attr: InvoicePdf,InvoiceDownloaded,JobStatus, //Attr: AcceptedDate,DeliveryDate DeliveryJob job = new DeliveryJob() { OrderId = id, DeliveryPersonId = deliverId, InvoicePdf = "Not Downloaded", InvoiceDownloaded = false, Status = "Order Accepted", AcceptedDate = DateTime.Now, DeliveryDate = null }; //Save Changes To Database context.deliveryJobs.Add(job); context.SaveChanges(); var or = context.Bookings.Find(id); or.Status = "On Its Way"; // context.Entry(or).State = EntityState.Modified; context.SaveChangesAsync(); return(RedirectToAction("ApprovedOrders", "Delivery")); }
public void OrderIsTaken(Order order, DeliveryJob job, bool isLack) { foreach (ResourceController rc in storeList) { rc.RemoveOrder(order, isLack); } myOrders.Remove(order); myJobs.Add(job); }
//Adjust to download File public ActionResult Invoice(int?id) { DeliveryJob job = context.deliveryJobs.Find(id); int JobOrdId = job.OrderId; if (JobOrdId != 0) { //Update job.InvoicePdf = "Downloaded"; job.InvoiceDownloaded = true; // context.Entry(job).State = EntityState.Modified; context.SaveChangesAsync(); } return(RedirectToAction("PrintInvoice", "Orders", new { idPdf = JobOrdId })); }
void JobEnded() { myJob = null; //Debug.Log("Delivery job ended!"); }
private bool LookForJob() { myJob = jobController.MakeDeliveryJob(moveAgent.Pos); return myJob != null; }
void closeOrder(bool isLack, Order order, DeliveryJob job) { if (isLack) { lackOrderList.Remove(order); } else { overOrderList.Remove(order); } DeliveryJob.lookForAgent(order.position, order.resource).OrderIsTaken(order, job, isLack); }
// Serf asks store to make job for him. public DeliveryJob MakeDeliveryJob (Vector2 serfPoint) { float bestDist = 100f; Order bestOrder = null; DeliveryJob job = null; foreach(Order order in overOrderList) { if ((serfPoint - order.GetPoint()).magnitude < bestDist) { bestOrder = order; bestDist = (serfPoint - order.GetPoint()).magnitude; } } if (bestOrder == null) // There are no overOrders. Look for lackOrder in order to sutisfy it from store. { bestDist = 100f; Debug.Log("****Try to make job from store!"); Debug.Log(lackOrderList.Count); foreach (Order order in lackOrderList) { Debug.Log(notReservedResourceNumber(order.resource) > 0); Debug.Log((serfPoint - order.GetPoint()).magnitude < bestDist); if (notReservedResourceNumber(order.resource) > 0 && (serfPoint - order.GetPoint()).magnitude < bestDist ) { Debug.Log("****Order is the best!"); bestOrder = order; bestDist = (serfPoint - order.GetPoint()).magnitude; } } if (bestOrder == null) // No lackOrders is found. { return null; } // Job is made from store to lackOrder. Debug.Log("****Job from store is made!!!"); job = new DeliveryJob(bestOrder.resource, position, bestOrder.position); closeOrder(true, bestOrder, job); TryReserveResource(bestOrder.resource); return job; } bestDist = 100f; Order bestLackOrder = null; foreach (Order order in lackOrderList) { if (order.resource == bestOrder.resource && (serfPoint - order.GetPoint()).magnitude < bestDist) { bestLackOrder = order; bestDist = (serfPoint - order.GetPoint()).magnitude; } } if( bestLackOrder == null) { // Job is made from overOrder to store. job = new DeliveryJob(bestOrder.resource, bestOrder.position, position); closeOrder(false, bestOrder, job); return job; } job = new DeliveryJob(bestOrder.resource, bestOrder.position, bestLackOrder.position); closeOrder(false, bestOrder, job); closeOrder(true, bestLackOrder, job); return job; }