Ejemplo n.º 1
0
 public void StartArrivalStation()
 {
     while (true)
     {
         List <Good> goods = GeneratorClient.GenerateRandomNumberOfGoods();
         foreach (Good g in goods)
         {
             Pallet pallet = new Pallet()
             {
                 count = rnd.Next(10, 200),
                 good  = g,
             };
             Console.WriteLine($"Pallet | Count:{pallet.count} | Good name: {pallet.good.name} | Good manufacturer: {pallet.good.manufacturer} |");
             client.insertPallet(pallet);
             Thread.Sleep(rnd.Next(3000, 5000));
             Console.WriteLine("Pallet inserted!");
         }
     }
 }
Ejemplo n.º 2
0
        public void ExecuteRandomOrders()
        {
            new Thread(() =>
            {
                while (true)
                {
                    Good generatedGood = GeneratorClient.GenerateGood();
                    int goodCount      = rnd.Next(10, 80);
                    int received       = 0;
                    Pallet[] result    = client.retrievePallets(generatedGood, goodCount, StationId);

                    Console.WriteLine($"Requested good | Name: {generatedGood.name} | Manufacturer: {generatedGood.manufacturer} | Good count: {goodCount} |");

                    if (result != null && result.Length > 0)
                    {
                        foreach (Pallet p in result)
                        {
                            received += p.count;
                        }
                        if (received > goodCount)
                        {
                            Pallet leftOver = new Pallet()
                            {
                                count = received - goodCount,
                                good  = generatedGood
                            };
                            Console.WriteLine($"Leftover pallet | Name: {generatedGood.name} | Manufacturer: {generatedGood.manufacturer} | Count: {leftOver.count} |");
                            InsertRemainingPallet(leftOver);
                        }
                        Console.WriteLine($"Number of received pallets : {result.Length}");
                        Console.WriteLine($"Pallets | Count: {result[0].count} | Good name: {result[0].good.name} | good manufacturer: {result[0].good.manufacturer} |");
                    }
                    else
                    {
                        Console.WriteLine("Good not found :(");
                    }
                    Thread.Sleep(rnd.Next(3000, 6000));
                }
            }).Start();
        }