示例#1
0
        //-----------------------------------------------
        public void AddChildsTrouvesParmis(Dictionary <int, List <CProjet> > dicIdsToChilds)
        {
            List <CProjet> lstFils = null;

            if (dicIdsToChilds.TryGetValue(ProjetAssocie.Id, out lstFils))
            {
                foreach (CProjet projet in lstFils)
                {
                    CElementDeGanttProjet eltFils = new CElementDeGanttProjet(this, projet);
                    eltFils.AddChildsTrouvesParmis(dicIdsToChilds);
                }
            }
        }
示例#2
0
        //--------------------------------------------------------------------------------------
        private static CResultAErreur PrepareGantt(
            CParametreNiveauArbreGanttGroupe groupeRacine, 
            CResultAErreur result, 
            CElementDeGantt elementRacine, 
            List<CProjet> lstProjets, 
            CContexteDonnee contexteDeTravail)
        {
            //Isole tous les projets qui n'ont pas leur parent dans la liste des sélectionnés
            HashSet<int> dicsIds = new HashSet<int>();
            foreach (CProjet prj in lstProjets)
                dicsIds.Add(prj.Id);

            /*IEnumerable<CProjet> lstSansRacine = from p in lstProjets
                                                 where
                                                 p.Row[CProjet.c_champIdParent] == DBNull.Value ||
                                                 !dicsIds.Contains((int)p.Row[CProjet.c_champIdParent])
                                                 select p;*/
            List<CProjet> lstSansRacine = new List<CProjet>();
            foreach (CProjet p in lstProjets)
            {
                if (p.Row[CProjet.c_champIdParent] == DBNull.Value ||
                   !dicsIds.Contains((int)p.Row[CProjet.c_champIdParent]))
                    lstSansRacine.Add(p);
            }
            //Crée tous les éléments projet(avant regroupement)           
            List<CElementDeGanttProjet> lstRacines = new List<CElementDeGanttProjet>();
            Dictionary<int, List<CProjet>> dicIdProjetToChild = new Dictionary<int, List<CProjet>>();
            foreach (CProjet projetTest in lstProjets)
            {
                if (projetTest.Row[CProjet.c_champIdParent] != DBNull.Value)
                {
                    int nId = (int)projetTest.Row[CProjet.c_champIdParent];
                    List<CProjet> lstChilds = null;
                    if (!dicIdProjetToChild.TryGetValue(nId, out lstChilds))
                    {
                        lstChilds = new List<CProjet>();
                        dicIdProjetToChild[nId] = lstChilds;
                    }
                    lstChilds.Add(projetTest);
                }
            }
            foreach (CProjet prj in lstSansRacine)
            {
                CElementDeGanttProjet eltProjet = new CElementDeGanttProjet(elementRacine, prj);
                eltProjet.AddChildsTrouvesParmis(dicIdProjetToChild);
                lstRacines.Add(eltProjet);
            }

            CParametreNiveauArbreGanttGroupe groupe = groupeRacine;
            if (groupe != null)
                groupe.RangeProjets(lstRacines, elementRacine);

            elementRacine.RegroupeBarresEnMulti();


            CBaseGantt baseGantt = new CBaseGantt(elementRacine);
            result.Data = baseGantt;
            //Création des liens
            StringBuilder blIdsProjets = new StringBuilder();
            Dictionary<int, CElementDeGantt> dicIdProjetToElements = new Dictionary<int, CElementDeGantt>(baseGantt.GetElements().Count());
            HashSet<CLienDeProjet> lstLiensConcernes = new HashSet<CLienDeProjet>();

            //IDentifie les relations vers les liens
            List<DataRelation> lstRelationsToLien = new List<DataRelation>();
            foreach (DataRelation rel in contexteDeTravail.Tables[CProjet.c_nomTable].ChildRelations)
            {
                if (rel.ChildTable.TableName == CLienDeProjet.c_nomTable)
                    lstRelationsToLien.Add(rel);
            }

            foreach ( IElementDeGantt elt in baseGantt.GetElements() )
            {
                foreach (IElementDeGantt eltDraw in elt.ElementsADessinerSurLaLigne)
                {
                    CElementDeGanttProjet eltPrj = eltDraw as CElementDeGanttProjet;
                    if (eltPrj != null)
                    {
                        int nId = eltPrj.ProjetAssocie.Id;
                        dicIdProjetToElements[nId] = eltPrj;
                        blIdsProjets.Append(nId);
                        blIdsProjets.Append(",");
                        foreach ( DataRelation rel in lstRelationsToLien )
                        {
                            DataRow[] rows = eltPrj.ProjetAssocie.Row.Row.GetChildRows ( rel );
                            foreach ( DataRow row in rows )
                                lstLiensConcernes.Add ( new CLienDeProjet ( row ));
                        }
                    }
                }
            }

            /*CListeObjetsDonnees lstLiensConcernes = new CListeObjetsDonnees(contexteDeTravail, typeof(CLienDeProjet));
            if (blIdsProjets.Length > 0)
            {
                blIdsProjets.Remove(blIdsProjets.Length - 1, 1);
                lstLiensConcernes.Filtre = new CFiltreData(CLienDeProjet.c_champPrjA + " in (" +
                    blIdsProjets.ToString() + ") or " +
                    CLienDeProjet.c_champPrjB + " in (" +
                    blIdsProjets.ToString() + ")");
            }
            else
                lstLiensConcernes.Filtre = new CFiltreDataImpossible();
            lstLiensConcernes.InterditLectureInDB = true;
            lstLiensConcernes.AssureLectureFaite();*/
            foreach (CLienDeProjet lien in lstLiensConcernes)
            {
                CElementDeGantt eltPredecesseur = null;
                CElementDeGantt eltSuccesseur = null;
                if (dicIdProjetToElements.TryGetValue(lien.ProjetA.Id, out eltPredecesseur) &&
                    dicIdProjetToElements.TryGetValue(lien.ProjetB.Id, out eltSuccesseur))
                {
                    eltSuccesseur.AddPredecesseurSansCreation(eltPredecesseur);
                }
            }
            

            
            try
            {
                elementRacine.RecalculAvancement();
            }
            catch (Exception e)
            {
            }
            return result;
        }