private void PackageProducedHandler(Emballage package)
        {
            Console.WriteLine("Ligne Commande " + package.Commande.Id + "(Commande " + package.Commande.IdCommandes + ") Reference " + package.Commande.IdReferences + " emballer");
            package.Commande.Etat = 5;
            var Commandes = context.Commandes.Include((x) => x.LignesCommande).Where((x) => x.Id == package.Commande.IdCommandes).First();

            if (!Commandes.LignesCommande.Any((x) => x.Etat != 5))
            {
                Commandes.Etat           = 3;
                Commandes.DateProduction = Program.Date;
                Console.WriteLine("Commande " + Commandes.Id + " terminee");
            }
            var emplacements = context.Emplacements.SingleOrDefault((x) => x.IdReferences == package.Reference.Id);

            if (emplacements != null)
            {
                emplacements.Quantite += package.Quantite;
                Console.WriteLine("Ajout quantite a Emplacement n" + emplacements.Id);
            }
            else
            {
                var list   = context.Emplacements.Where((x) => x.IdReferences == null).ToList();
                var random = new Random();
                emplacements = list[random.Next(0, list.Count)];
                emplacements.IdReferences = package.Reference.Id;
                emplacements.Quantite     = package.Quantite;
                Console.WriteLine("Ajout quantite et Reference a Emplacement n" + emplacements.Id);
            }
            context.SaveChanges();
        }
        public void AddPackage(LignesCommande item)
        {
            var package = new Emballage()
            {
                Commande  = item,
                Reference = item.IdReferencesNavigation,
                Quantite  = item.Quantite,
            };

            package.Compteur = package.Quantite * 3600 / Cadence;
            Packages.Add(package);
            InProduction = true;
        }
 private void InstallNextPackage()
 {
     if (Packages.Count > 0)
     {
         if (actualpackage != null && actualpackage.Reference.IdProduitsNavigation.Equals(Packages.First().Reference.IdProduitsNavigation))
         {
             actualpackage = Packages.First();
         }
         else
         {
             installDelayCompteur = InstallDelay * 60;
             actualpackage        = Packages.First();
             Console.WriteLine("Délai de " + installDelayCompteur + "s sur " + Nom);
         }
         InProduction = true;
     }
     else
     {
         actualpackage = null;
         InProduction  = false;
     }
 }