Пример #1
0
        private async void _dataServices_GetAllProjects(object sender, EventArgs e)
        {
            var data = (ProjectEventArgs)e;

            if (data.ProjectEventArgsType == ProjectEventArgsType.AllProjects)
            {
                Projets.Clear();
                data.Projets.ForEach(d =>
                {
                    _authServices.GetOneUser(d.OwnerUId);
                    _authServices.GetUser += (o, ev) =>
                    {
                        if (((UserEventArgs)ev).EventType == EventType.UserGet)
                        {
                            if (Projets.Where(p => p.ProjectId == d.ProjectId).Count() == 0)
                            {
                                Projets.Add(new Projet
                                {
                                    Categories  = d.Categories,
                                    ProjectId   = d.ProjectId,
                                    Date        = d.Date,
                                    Description = d.Description,
                                    Name        = d.Name,
                                    OwnerName   = ((UserEventArgs)ev).User.Fullname,
                                    OwnerUId    = d.OwnerUId
                                });
                            }
                        }
                    };
                });
                await Task.Delay(1200);

                IsRunning = false;
            }
        }
 public int countGlErp()
 {
     return(Projets
            .Find(projet => projet.Nom == "ERP")
            .Affectations
            .Count(affectation => affectation.Ingenieur.Specialite == Specialite.GL));
 }
Пример #3
0
 public void ReinitialiserCombinaison()
 //Fonction permettant, quand on a fini une combinaison, de remettre un espace vide à chaque espace
 {
     for (int i = 0; i < Projets.Count(); i++)
     {
         Combinaison[i] = Eleves[0];
     }
 }
Пример #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            Projets projets = db.Projets.Find(id);

            db.Projets.Remove(projets);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #5
0
        //METHODES
        public void AfficherVoeux()
        {
            string affichage = "";

            foreach (string p in Projets)
            {
                affichage += "Projet : " + p + " -- " + Voeux[Projets.IndexOf(p)] + "\n";
            }
            Console.WriteLine(affichage);
        }
Пример #6
0
 public ActionResult Edit([Bind(Include = "id_proj,avancement,date_début,date_fin,id_mod,id_client,id_archi")] Projets projets)
 {
     if (ModelState.IsValid)
     {
         db.Entry(projets).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(projets));
 }
Пример #7
0
 public void Repartir()
 {
     //On met un élève vide dans chaque espace que devra prendre un elève dans la combinaison
     //ça permet de voir si un elève a déjà été mis à la place en question
     for (int i = 0; i < Projets.Count(); i++)
     {
         Combinaison.Add(Eleves[0]);
     }
     TesterCombinaison(Eleves[1]);
 }
Пример #8
0
        public ActionResult Create([Bind(Include = "id_proj,avancement,date_début,date_fin,id_mod,id_client,id_archi")] Projets projets)
        {
            if (ModelState.IsValid)
            {
                db.Projets.Add(projets);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(projets));
        }
Пример #9
0
        // GET: Projets/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Projets projets = db.Projets.Find(id);

            if (projets == null)
            {
                return(HttpNotFound());
            }
            return(View(projets));
        }
Пример #10
0
        private void LancerRepartition(int[,] matrice)
        {
            DateTime start = DateTime.Now;

            NbParProjet = new int[NbProjets];
            //Creation de la matrice
            //CreerMatrice(matrice);
            RetirerZero(matrice);
            //AfficherMatrice(Conversion(matrice));
            MatriceBase = Conversion(matrice);
            bool suppression = true;
            bool echec       = false;
            int  i           = 0;

            while (suppression)
            {
                //Initialisation
                NbParProjet = new int[NbProjets];
                suppression = EquilibrageProjetsMedian(i);
                //suppression = SupprimerProjet(i);
                Matrice  = (double[][])MatriceBase.Clone();
                ProjetsD = (string[])Projets.Clone();
                Matrice  = DupliquerVoeux(Matrice);

                //Repartition
                if (!suppression)
                {
                    if (i == 1)
                    {
                        echec = true;
                        MessageBox.Show("Problème dans les paramètres de répartition. Vérifiez qu'il y a assez de place pour chaque élève, ou qu'il n'y a pas trop de projets obligatoires.");
                    }
                    break;
                }
                Munkres repartition;
                bool    succes;
                repartition = new Munkres(Matrice);
                succes      = repartition.Minimize();
                //AfficherSolution(repartition.Solution);
                //Ecriture
                EcrireCsv(Matrice, repartition.Solution, i);


                //MessageBox.Show("Solution n°"+(i+1)+" : CHECK");
                i++;
            }
            TimeSpan dur = DateTime.Now - start;

            MessageBox.Show("La répartition a bien été effectuée ! Vous avez le choix entre " + i + " solutions différentes.");
        }
Пример #11
0
        public bool VerifierComplet()
        {
            foreach (Personne eleve in Eleves)
            {
                if (eleve != Eleves[0])
                {
                    if (eleve.Affinite.Count() != 0)
                    {
                        foreach (Personne e in eleve.Affinite)
                        {
                            if (Projets[Combinaison.IndexOf(e)] != Projets[Combinaison.IndexOf(eleve)])
                            {
                                return(false);
                            }
                        }
                    }
                    int voeux = eleve.RecupererVoeux(Projets[Combinaison.IndexOf(eleve)]);
                    if (voeux < Seuil)
                    {
                        return(false);
                    }

                    if (!Combinaison.Contains(eleve))
                    {
                        return(false);
                    }
                }
            }
            //Attention à séparer mieux les tâches dans le prochain code
            for (int i = 0; i < Projets.Count() - 1; i++)
            {
                //Console.WriteLine(i);
                if (Combinaison[i] != Eleves[0])
                {
                    for (int k = 0; k < NbPlaces; k++)
                    {
                        if (Combinaison[i + k] == Eleves[0])
                        {
                            return(false);
                        }
                    }
                }
                i += 3;
            }
            return(true);
        }
Пример #12
0
        public void TesterCombinaison(Personne eleve)
        //Fonction recursive permettant de tester toutes les possibilités
        {
            int index = Eleves.IndexOf(eleve);

            foreach (string p in eleve.Projets)
            {
                int indexP = Projets.IndexOf(p);
                //Comme va être automatiquement pris seulement le premier projet de la liste quand plusieurs projet sont en fait le même, on regarde si les autres sont libre
                if (Combinaison[indexP] != Eleves[0])
                {
                    bool present = false;
                    int  i       = 0;
                    while ((present == false) && (i < NbPlaces) && (indexP + i < Projets.Count() - 1))
                    {
                        i++;
                        if ((Projets[indexP] == Projets[indexP + i]) && (Combinaison[indexP + i] == Eleves[0]))
                        {
                            present = true;
                            indexP += i;
                        }
                    }
                }

                if (Combinaison[indexP] == Eleves[0])
                {
                    //Condition d'arret de la recursivité : Si on a plus d'élèves à traiter en stock
                    Combinaison[indexP] = eleve;
                    if (index + 1 >= Eleves.Count())
                    {
                        if (VerifierComplet())
                        {
                            CalculerNote();
                        }
                        Combinaison[indexP] = Eleves[0];
                    }
                    else
                    {
                        TesterCombinaison(Eleves[index + 1]);
                        Combinaison[indexP] = Eleves[0];
                    }
                }
            }
        }
Пример #13
0
        public int RecupererVoeux(string projet)
        {
            int index = Projets.IndexOf(projet);

            return(Voeux[index]);
        }
Пример #14
0
 public void AjouterVoeux(string projet, int rang)
 {
     Projets.Add(projet); Voeux.Add(rang);
 }
Пример #15
0
        public int[,] ExtraireCsv(string lien)
        ///Permet d'extraire d'un fichier csv une matrice int[,]
        {
            int           i      = 0;
            StreamReader  reader = new StreamReader(lien);
            List <string> ligne  = new List <string>();;

            //Récupération des projets
            ligne.Add(reader.ReadLine());
            Projets = ligne[0].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

            //Récupération du nombre de places par projets
            ligne[0] = reader.ReadLine();
            string[] nbpp = new string[Projets.Count()];
            nbpp     = ligne[0].Split(new string[] { "," }, StringSplitOptions.None);
            ProjetsV = new int[Projets.Count()];
            int nombre;

            for (int j = 1; j < Projets.Count() + 1; j++)
            {
                //MessageBox.Show("RAS a j=" + j+"  nbpp= "+ nbpp[j]);
                if (nbpp[j] != "")
                {
                    ProjetsV[j - 1] = 1;
                }
            }
            //AfficherNbParProjet();
            //Récupération des voeux
            do
            {
                ligne.Add(reader.ReadLine());
                i++;
            }while (ligne[i] != null);


            int[,] matrice = new int[i - 1, Projets.Count()];
            string[] voeux  = new string[Projets.Count()];
            string[] eleves = new string[i - 1];
            for (int x = 1; x < i; x++)
            {
                voeux = ligne[x].Split(new string[] { "," }, StringSplitOptions.None);

                eleves[x - 1] = voeux[0];
                for (int y = 1; y < Projets.Count() + 1; y++)
                {
                    //MessageBox.Show(x+" "+y+" "+voeux[y]);
                    if (int.TryParse(voeux[y], out nombre))
                    {
                        matrice[x - 1, y - 1] = nombre;
                    }

                    else
                    {
                        matrice[x - 1, y - 1] = 0;
                    }
                    //MessageBox.Show("RAS à x = " + x+" et y = "+y);
                }
            }
            //AfficherMatrice(Conversion(matrice));
            //AfficherListe("Eleves : ", eleves);
            //AfficherListe("Projets : ", Projets);
            //AfficherListe("Nombre par projet : ",ProjetsV.Select(x => x.ToString()).ToArray());
            Eleves = eleves;
            return(matrice);
        }