public void PredictWaitingTime(List <Table> ptables, List <Customer> pcustomers) { List <Table> tmp_tables = new List <Table>(ptables); List <Table> opt_seat; CustomerManager cus = new CustomerManager(); PlacementOptimizer opt_pl = new PlacementOptimizer(); foreach (var i in pcustomers) { opt_pl.PlaceTabletoCustomer(tmp_tables, i); opt_seat = opt_pl.Get_opt_seat(); if (opt_seat.Count > 0) { i.EstimatedWaitingTime = 0; cus.Update(i); foreach (var j in opt_seat) { tmp_tables.Find(x => x.TableId == j.TableId).TableStatus = TableStatus.Ordering; } } } foreach (var i in tmp_tables) { if (i.TableStatus == TableStatus.Cleaning) { i.TableStatus = TableStatus.Active; } } foreach (var i in pcustomers) { if (i.EstimatedWaitingTime == 0) { continue; } else if (i.EstimatedWaitingTime > 0) { i.EstimatedWaitingTime = i.EstimatedWaitingTime - 1; cus.Update(i); continue; } opt_pl.PlaceTabletoCustomer(tmp_tables, i); opt_seat = opt_pl.Get_opt_seat(); if (opt_seat.Count > 0) { i.EstimatedWaitingTime = 300; cus.Update(i); foreach (var j in opt_seat) { tmp_tables.Find(x => x.TableId == j.TableId).TableStatus = TableStatus.Ordering; } } } }
private void lbList_SelectedIndexChanged(object sender, EventArgs e) { if (lbList.SelectedIndex != -1) { List <Table> opt_seat; //clear data txtCustomerId.Text = ""; txtNoOfPeople.Text = ""; comboBoxWaiterName.Text = ""; nudTableId3.Value = 0; nudTableId2.Value = 0; nudTableId1.Value = 0; //set new data Customer selectedCustomer = diningArea.Customers[lbList.SelectedIndex]; txtCustomerId.Text = selectedCustomer.WaitingNumber.ToString(); txtNoOfPeople.Text = selectedCustomer.NumberofPeople.ToString(); comboBoxWaiterName.DataSource = diningArea.Waiters.Select(waiter => waiter.Name).ToList(); IntelligentRestaurantManager.BLL.PlacementOptimizer opt_place = new IntelligentRestaurantManager.BLL.PlacementOptimizer(); opt_place.PlaceTabletoCustomer((List <Table>)tableManager.GetAll(), selectedCustomer); opt_seat = opt_place.Get_opt_seat(); System.Diagnostics.Debug.WriteLine("debug message"); foreach (var k in opt_seat) { System.Diagnostics.Debug.WriteLine("debug message" + k.TableId); } if (opt_seat.Count >= 3) { nudTableId3.Value = opt_seat[2].TableId; } if (opt_seat.Count >= 2) { nudTableId2.Value = opt_seat[1].TableId; } if (opt_seat.Count >= 1) { nudTableId1.Value = opt_seat[0].TableId; } //get all NumericUpDown contral in groupBox1: 3 List <NumericUpDown> nudTableIds = this.groupBox1.Controls.OfType <NumericUpDown>().ToList(); for (int i = 0; i < selectedCustomer.RecommendedTableId.Length; i++) { if (selectedCustomer.RecommendedTableId[i] > 0) { nudTableIds[i].Value = selectedCustomer.RecommendedTableId[i]; } } } //Todo: waiter name order by workload, i.e. sum of customers }