Exemple #1
0
        public PersonneDansArbreIndividuel(Personne p, int pbas = int.MaxValue)
        {
            this.id              = p.id;
            this.nom             = p.nom;
            this.prenom          = p.prenom;
            this.homme           = p.homme;
            this.dateAjout       = p.dateAjout;
            this.dateDeDeces     = p.dateDeDeces;
            this.dateDeNaissance = p.dateDeNaissance;
            this.idPere          = p.idPere;
            this.idMere          = p.idMere;

            int limite = (pbas == int.MaxValue) ? int.MaxValue : pbas - 1;

            this.descendants = new List <PersonneDansArbreIndividuel>();
            if (limite > 0)
            {
                IEnumerable <Personne> leskids = p.Enfants();
                if (leskids != null && leskids.Count() != 0)
                {
                    foreach (Personne pp in leskids)
                    {
                        this.descendants.Add(new PersonneDansArbreIndividuel(pp, limite));
                    }
                }
            }

            /* fiche */
            this.fiche = ServPersonne.Fiche(p);
        }
Exemple #2
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 #3
0
 public static IList <string> VersFiche(this Personne p)
 {
     return(ServPersonne.Fiche(p));
 }