Exemplo n.º 1
0
        //Lavet af jeres

        internal List<Tuple<Product, int>> SaveOrder(Order order)
        {
            List<Product> used = new List<Product>();
            int amount = 0;
            List<Tuple<Product, int>> prodAmount = new List<Tuple<Product, int>>();
            foreach (Product item in order.ProductList)
            {
                if (!used.Contains(item))
                {
                    used.Add(item);
                    amount = 0;
                    foreach (Product item2 in order.ProductList)
                    {
                        if (item == item2)
                        {
                            amount++;
                        }
                    }
                    Tuple<Product, int> prodAM = new Tuple<Product, int>(item, amount);


                }
            }
            return prodAmount;
        }
Exemplo n.º 2
0
        internal string allocateMachine(Order order)
        {
            List<Machine> machinesToUse = persistence.Database.getDatabase().getMachines();
            foreach (Product prod in order.ProductList)
            {
                foreach (Task task in prod.TaskList)
                {
                    int value = 0;
                    List<Machine> newMAchines = new List<Machine>();
                    foreach (Machine item in machinesToUse)
                    {
                        if (item.MachineType1 == task.MachineType)
                        {
                            newMAchines.Add(item);
                        }
                    }
                    newMAchines = newMAchines.OrderBy(x => x.AcumalatedTime).ToList();

                    value = newMAchines[0].AcumalatedTime + task.Varighed;
                    Production pro = new Production(value, order, newMAchines[0], task, false);
                    List<Production> listPT = newMAchines[0].ProductTimes;
                    newMAchines[0].AcumalatedTime = value;
                    listPT.Add(pro);
                    newMAchines[0].ProductTimes = listPT;
                }
            }
            persistence.Database.getDatabase().addOrder(order);
            return "The order has been added";
        }
Exemplo n.º 3
0
 internal Production(int start, Order o, Machine m, Task t, bool done)
 {
     StartProduction = start;
     Order = o;
     Machine = m;
     Task = t;
     this.Done = done;
 }
Exemplo n.º 4
0
 internal int getTimeOnOrder(Order order)
 {
     List<Machine> machinesToUse = persistence.Database.getDatabase().getMachines();
     int value = 0;
     foreach (Product item in order.ProductList)
     {
         foreach (Task item2 in item.TaskList)
         {
             List<Machine> newMAchines = new List<Machine>();
             foreach (Machine item3 in machinesToUse)
             {
                 if (item2.MachineType == item3.MachineType1)
                 {
                     newMAchines.Add(item3);
                 }
             }
             if (value < (newMAchines.Min(x => x.AcumalatedTime) + item2.Varighed))
             {
                 value = newMAchines.Min(x => x.AcumalatedTime) + item2.Varighed;
             }
         }
     }
     return value;
 }
Exemplo n.º 5
0
 internal string allocateMachineFromOrder(Order order)
 {
     return OrderLine.getOrderLine().allocateMachine(order);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Only used so we can add some premade orders from machineData
 /// </summary>
 /// <param name="o"></param>
 internal string addOrder(Order o)
 {
     return allocateMachineFromOrder(o);
 }
Exemplo n.º 7
0
 internal string addNewOrder(DateTime ordered, DateTime start, DateTime delivery, string adrs)
 {
     Order order = new Order(ordered, start, delivery, adrs, productsToBeAdded);
     productsToBeAdded = new List<Product>();
     return allocateMachineFromOrder(order);
 }
Exemplo n.º 8
0
 internal int estimateOrder(DateTime orderedDate, DateTime startDate, DateTime deliveryDate, string address)
 {
     Order order = new Order(orderedDate, startDate, deliveryDate, address, productsToBeAdded);
     return OrderLine.getOrderLine().getTimeOnOrder(order);
 }
        private void createSomeOrders()
        {
            #region orders 
            List<Order> orders = new List<Order>();

            List<Product> productList = new List<Product>();
            productList.Add(products[0]);
            Order order1 = new Order(new DateTime(2000, 1, 1), new DateTime(2000, 3, 1), new DateTime(2000, 4, 1), "Æblevej", productList);

            productList = new List<Product>();
            productList.Add(products[0]);
            Order order2 = new Order(new DateTime(2000, 1, 1), new DateTime(2000, 3, 1), new DateTime(2000, 4, 1), "Æblevej", productList);

            productList = new List<Product>();
            productList.Add(products[0]);
            Order order3 = new Order(new DateTime(2000, 1, 1), new DateTime(2000, 2, 1), new DateTime(2000, 5, 1), "Æblevej", productList);

            productList = new List<Product>();
            productList.Add(products[3]);
            Order order4 = new Order(new DateTime(2000, 1, 1), new DateTime(2000, 3, 1), new DateTime(2000, 4, 1), "Æblevej", productList);

            productList = new List<Product>();
            productList.Add(products[4]);
            Order order5 = new Order(new DateTime(2000, 1, 1), new DateTime(2000, 3, 1), new DateTime(2000, 4, 1), "Æblevej", productList);

            productList = new List<Product>();
            productList.Add(products[5]);
            Order order6 = new Order(new DateTime(2000, 1, 1), new DateTime(2000, 2, 1), new DateTime(2000, 5, 1), "Æblevej", productList);

            productList = new List<Product>();
            productList.Add(products[6]);
            Order order7 = new Order(new DateTime(2000, 1, 1), new DateTime(2000, 3, 1), new DateTime(2000, 4, 1), "Æblevej", productList);

            productList = new List<Product>();
            productList.Add(products[7]);
            Order order8 = new Order(new DateTime(2000, 1, 1), new DateTime(2000, 2, 1), new DateTime(2000, 5, 1), "Æblevej", productList);

            productList = new List<Product>();
            productList.Add(products[8]);
            Order order9 = new Order(new DateTime(2000, 1, 1), new DateTime(2000, 3, 1), new DateTime(2000, 4, 1), "Æblevej", productList);

            productList = new List<Product>();
            productList.Add(products[9]);
            Order order10 = new Order(new DateTime(2000, 1, 1), new DateTime(2000, 2, 1), new DateTime(2000, 5, 1), "Æblevej", productList);

            productList = new List<Product>();
            productList.Add(products[10]);
            Order order11 = new Order(new DateTime(2000, 1, 1), new DateTime(2000, 2, 1), new DateTime(2000, 5, 1), "Æblevej", productList);

            productList = new List<Product>();
            productList.Add(products[11]);
            Order order12 = new Order(new DateTime(2000, 1, 1), new DateTime(2000, 2, 1), new DateTime(2000, 5, 1), "Æblevej", productList);

            productList = new List<Product>();
            productList.Add(products[12]);
            Order order13 = new Order(new DateTime(2000, 1, 1), new DateTime(2000, 2, 1), new DateTime(2000, 5, 1), "Æblevej", productList);

            productList = new List<Product>();
            productList.Add(products[13]);
            Order order14 = new Order(new DateTime(2000, 1, 1), new DateTime(2000, 2, 1), new DateTime(2000, 5, 1), "Æblevej", productList);

            productList = new List<Product>();
            productList.Add(products[14]);
            Order order15 = new Order(new DateTime(2000, 1, 1), new DateTime(2000, 2, 1), new DateTime(2000, 5, 1), "Æblevej", productList);

            productList = new List<Product>();
            productList.Add(products[5]);
            Order order16 = new Order(new DateTime(2000, 1, 1), new DateTime(2000, 2, 1), new DateTime(2000, 5, 1), "Æblevej", productList);

            productList = new List<Product>();
            productList.Add(products[2]);
            Order order17 = new Order(new DateTime(2000, 1, 1), new DateTime(2000, 2, 1), new DateTime(2000, 5, 1), "Æblevej", productList);

            productList = new List<Product>();
            productList.Add(products[1]);
            Order order18 = new Order(new DateTime(2000, 1, 1), new DateTime(2000, 2, 1), new DateTime(2000, 5, 1), "Æblevej", productList);


            #endregion
            orders.Add(order1);
            orders.Add(order2);
            orders.Add(order3);
            orders.Add(order3);
            orders.Add(order3);
            orders.Add(order4);
            orders.Add(order5);
            orders.Add(order6);
            orders.Add(order7);
            orders.Add(order8);
            orders.Add(order9);
            orders.Add(order10);
            orders.Add(order11);
            orders.Add(order12);
            orders.Add(order13);
            orders.Add(order14);
            orders.Add(order15);
            orders.Add(order16);
            orders.Add(order17);
            orders.Add(order18);
            foreach (var item in orders)
            {
                Controller c = new Controller();
                c.addOrder(item);
            }
        }