Exemple #1
0
        async static Task <double> ProcessTeller(Teller teller, Customer customer)
        {
            double duration = 0;

            try
            {
                if (customer.type == teller.specialtyType)
                {
                    duration = Math.Ceiling(Convert.ToDouble(customer.duration) * Convert.ToDouble(teller.multiplier));
                }
                else
                {
                    duration = Convert.ToDouble(customer.duration);
                }
                await Task.Run(() => { System.Threading.Thread.Sleep(Convert.ToInt32(duration) * 1000); });

                teller.isFree = true;
                return(duration);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error in ProcessTeller -" + ex.Message);
            }
            return(duration);
        }
Exemple #2
0
 private static void IncrementTellerTotalTime(Teller teller, Appointment app, Dictionary <string, double> timeCounter)
 {
     if (tellersTotalTime.ContainsKey(teller.id))
     {
         timeCounter[teller.id] += app.duration;
     }
     else
     {
         timeCounter[teller.id] = app.duration;
     }
 }
Exemple #3
0
 public Appointment(Customer customer, Teller teller)
 {
     this.customer = customer;
     this.teller   = teller;
     if (customer.type == teller.specialtyType)
     {
         this.duration = Math.Ceiling(Convert.ToDouble(customer.duration) * Convert.ToDouble(teller.multiplier));
     }
     else
     {
         this.duration = Convert.ToDouble(customer.duration);
     }
 }
 public Appointment(Customer customer, Teller teller, double duration)
 {
     this.customer = customer;
     this.teller   = teller;
     this.duration = duration;
     //if (customer.type == teller.specialtyType)
     //{
     //    this.duration = Math.Ceiling(Convert.ToDouble(customer.duration) * Convert.ToDouble(teller.multiplier));
     //}
     //else
     //{
     //    this.duration = Convert.ToDouble(customer.duration);
     //}
 }
Exemple #5
0
        static void Calculation(CustomerList customers, TellerList tellers)
        {
            var type1index = 0;
            var type2index = 0;
            var type3index = 0;
            var type4index = 0;

            //----Start customer order by, We can sort the customers by duration and use if there is no first come first serve
            //and replace foreach with  customersSorted instead of Customers.customer
            List <Customer> customersSorted = new List <Customer>();

            customersSorted = customers.Customer.OrderByDescending(c => c.duration).ToList();
            //----End customer order by------------------

            foreach (Customer customer in customers.Customer)
            {
                // Get tellers by type
                var tellersByTypeOnly = tellers.TellerByType(customer.type);
                // ---- Start Prioritize tellers by multiplier, minimum time taken this way by tellers to finish serving customers.
                var tellersByTypePrioritizedMultiplier = tellersByTypeOnly.OrderByDescending(a => a.multiplier).ToList();
                // ---- End Prioritize tellers by multiplier

                //Console.WriteLine("serving customerId: " + customer.Id + " and Type: " + customer.type);

                // Take turns with customer appointments
                Teller servingTeller = new Teller();
                if (customer.type == "1")
                {
                    servingTeller = tellersByTypePrioritizedMultiplier[type1index];
                    type1index++;
                    if (type1index > tellersByTypePrioritizedMultiplier.Count - 1)
                    {
                        type1index = 0;
                    }
                }
                else if (customer.type == "2")
                {
                    servingTeller = tellersByTypePrioritizedMultiplier[type2index];
                    type2index++;
                    if (type2index > tellersByTypePrioritizedMultiplier.Count - 1)
                    {
                        type2index = 0;
                    }
                }
                else if (customer.type == "3")
                {
                    servingTeller = tellersByTypePrioritizedMultiplier[type3index];
                    type3index++;
                    if (type3index > tellersByTypePrioritizedMultiplier.Count - 1)
                    {
                        type3index = 0;
                    }
                }
                else if (customer.type == "4")
                {
                    servingTeller = tellersByTypePrioritizedMultiplier[type4index];
                    type4index++;
                    if (type4index > tellersByTypePrioritizedMultiplier.Count - 1)
                    {
                        type4index = 0;
                    }
                }

                // TODO: prioritize tellers by multiplier


                Console.WriteLine("teller type:" + servingTeller.specialtyType + " tellerId: " + servingTeller.id);
                var appointment = new Appointment(customer, servingTeller);
                appointmentList.Add(appointment);
            }
        }
 public TellerDuration(int index, Teller teller)
 {
     this.index      = index;
     this.multiplier = Convert.ToDouble(teller.multiplier);
     this.duration   = 0;
 }