Exemplo n.º 1
0
 //------------------------------------------------------
 protected virtual void AddFils(CElementDeGantt elt)
 {
     if (!m_listeFils.Contains(elt))
     {
         m_listeFils.Add(elt);
     }
 }
Exemplo n.º 2
0
 private void AddElement(CElementDeGantt element)
 {
     if (!m_elements.Contains(element))
     {
         m_elements.Add(element);
     }
     foreach (CElementDeGantt elt in element.ElementsFils)
     {
         AddElement(elt);
     }
 }
Exemplo n.º 3
0
        //-----------------------------------
        public override void RangeProjets(
            IEnumerable <CElementDeGanttProjet> lstEltsProjets,
            CElementDeGantt elementParent)
        {
            Dictionary <string, List <CElementDeGanttProjet> > lstCles = new Dictionary <string, List <CElementDeGanttProjet> >();

            foreach (CElementDeGanttProjet elt in lstEltsProjets)
            {
                CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(elt.ProjetAssocie);
                CResultAErreur result             = FormuleGroupe.Eval(ctx);
                string         strVal             = "?";
                if (result && result.Data != null)
                {
                    strVal = result.Data.ToString();
                }
                List <CElementDeGanttProjet> lstElts = null;
                if (!lstCles.TryGetValue(strVal, out lstElts))
                {
                    lstElts         = new List <CElementDeGanttProjet>();
                    lstCles[strVal] = lstElts;
                }
                lstElts.Add(elt);
            }
            foreach (KeyValuePair <string, List <CElementDeGanttProjet> > kv in lstCles)
            {
                CElementDeGanttGroupe groupe = new CElementDeGanttGroupe(elementParent, kv.Key);
                groupe.Image = Image;
                if (ParametreFils == null)
                {
                    foreach (CElementDeGanttProjet elt in kv.Value)
                    {
                        elt.ElementParent = groupe;
                    }
                }
                else
                {
                    ParametreFils.RangeProjets(kv.Value, groupe);
                }
            }
        }
Exemplo n.º 4
0
 //------------------------------------------------------
 protected void RemoveFils(CElementDeGantt elt)
 {
     m_listeFils.Remove(elt);
 }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
0
 public CBaseGantt(CElementDeGantt elementRacine)
 {
     AddElement(elementRacine);
 }
Exemplo n.º 7
0
 //------------------------------------------
 public abstract void RangeProjets(IEnumerable <CElementDeGanttProjet> lstEltsProjets, CElementDeGantt elementParent);