Exemple #1
0
        public FormArbre(Personne p, Personne parent, int pbas = int.MaxValue)
        {
            this.fiche  = ServPersonne.Fiche(p);
            this.parent = parent;
            this.maitre = p;

            int limite = pbas == int.MaxValue ? int.MaxValue : pbas--;

            IEnumerable <Personne> sescouples = new CoupleServiceAPI().Partenaires(p.id).Select(j => new PersonneServiceAPI().Donner(j)).ToList();

            //if (couples == null) couples = new List<Personne>();
            this.couples = new List <Personne>();


            this.descendants  = new List <FormArbre>();
            this.dXescendants = new Dictionary <Personne, IList <FormArbre> >();
            IEnumerable <Descendant> prog = new PersonneServiceAPI().DonnerLesEnfants(p.id).OrderBy(j => j.parent == null?int.MaxValue:j.parent.id).ThenBy(j => j.enfant == null?int.MaxValue:j.enfant.id);

            if (pbas > 0)
            {
                int memParentId     = -1;
                IList <FormArbre> d = new List <FormArbre>();
                foreach (Descendant desc in prog)
                {
                    if (memParentId != (desc.parent == null?0:desc.parent.id))
                    {
                        d           = new List <FormArbre>();
                        memParentId = desc.parent == null?0:desc.parent.id;
                        this.couples.Add(desc.parent == null?new Personne {
                            id = 0
                        }:desc.parent);
                        var y = "oo";
                        d.Add(new FormArbre(desc.enfant, desc.parent, limite));
                        dXescendants.Add(desc.parent == null?new Personne {
                            id = 0
                        }:desc.parent, d);
                    }
                    else
                    {
                        d.Add(new FormArbre(desc.enfant, desc.parent, limite));
                    }
                    descendants.Add(new FormArbre(new PersonneServiceAPI().Donner(desc.enfant.id), desc.parent, limite));
                }
                IEnumerable <Personne> tempCouple = couples;
                foreach (Personne pp in sescouples.Where(j => !tempCouple.Select(k => k.id).Contains(j.id)))
                {
                    this.couples.Add(pp);
                    //descendants.Add(new FormArbre(pp, null, limite));
                }
            }
            if (pbas == 0)
            {
                foreach (Personne pp in sescouples)
                {
                    descendants.Add(new FormArbre(this.maitre, new PersonneServiceAPI().Donner(pp.id), -1));
                    IList <FormArbre> xx = new List <FormArbre>();
                }
                this.couples = sescouples.ToList();
            }

            this.fichespartenaire = new Dictionary <int, IList <string> >();
            foreach (Personne pp in couples)
            {
                this.fichespartenaire.Add(pp.id, ServPersonne.Fiche(pp));
            }
            descendants.OrderBy(j => j.maitre.id);
        }
Exemple #2
0
 public F2ormArbre(Personne p, Personne parent, int pbas = int.MaxValue)
 {
 }