Ejemplo n.º 1
0
        public bool Validate(FamilyTreeStoreBaseClass familyTree, ref ValidationData validationData, String callerXrefId = null) // IList<IndividualClass> individualList)
        {
            bool allFound    = true;
            bool callerFound = (callerXrefId == null);

            //ValidationData validationData = new ValidationData();

            //trace.TraceInformation("Validate: " + this.GetXrefName());
            if (familyChildList != null)
            {
                foreach (FamilyXrefClass person in familyChildList)
                {
                    String xrefName = person.GetXrefName();
                    bool   found    = false;

                    if (callerXrefId == xrefName)
                    {
                        callerFound = true;
                    }

                    FamilyClass family;

                    //family = (FamilyClass)familyTree.familyList[person.GetXrefName()];
                    family = familyTree.GetFamily(person.GetXrefName());

                    found = (family != null);
                    if (!found)
                    {
                        //
                        if (trace.Switch.Level.HasFlag(SourceLevels.Information))
                        {
                            Print();
                            trace.TraceInformation(" Family-child not found: " + xrefName);
                        }
                        allFound = false;
                        //return false;
                    }
                    else
                    {
                        //trace.TraceInformation("Found family-child : " + xrefName);
                    }
                    validationData.familyNo++;
                }
            }
            if (familySpouseList != null)
            {
                foreach (FamilyXrefClass person in familySpouseList)
                {
                    String xrefName = person.GetXrefName();
                    bool   found    = false;

                    if (callerXrefId == xrefName)
                    {
                        callerFound = true;
                    }
                    FamilyClass family;

                    family = familyTree.GetFamily(person.GetXrefName());

                    found = (family != null);
                    if (!found)
                    {
                        //
                        if (trace.Switch.Level.HasFlag(SourceLevels.Information))
                        {
                            Print();
                            trace.TraceInformation(" Spouse not found: " + xrefName);
                        }
                        allFound = false;
                        //return false;
                    }
                    else
                    {
                        //trace.TraceInformation("Found spouse: " + xrefName);
                    }
                    validationData.individualNo++;
                }
            }
            if (noteXrefList != null)
            {
                foreach (NoteXrefClass noteXref in noteXrefList)
                {
                    String xrefName = noteXref.GetXrefName();
                    bool   found    = false;

                    if (callerXrefId == xrefName)
                    {
                        callerFound = true;
                    }
                    NoteClass note;

                    note = familyTree.GetNote(noteXref.GetXrefName());

                    found = (note != null);
                    if (!found)
                    {
                        if (trace.Switch.Level.HasFlag(SourceLevels.Information))
                        {
                            Print();
                            trace.TraceInformation(" Note not found: " + xrefName);
                        }
                        allFound = false;
                        //return false;
                    }
                    else
                    {
                        //trace.TraceInformation("Found spouse: " + xrefName);
                    }
                    validationData.noteNo++;
                }
            }
            //trace.TraceInformation("Validate: " + this.GetXrefName() + " = " + allFound);

            return(allFound && callerFound);
        }