public override bool OpenFile(String fileName, ref IFamilyTreeStoreBaseClass inFamilyTree, CompletedCallback callback) { trace.TraceInformation("GedcomDecoder::OpenFile( " + fileName + ")"); bool result = ReadFile(fileName, ref inFamilyTree); callback(result); return(result); }
public static void CompareTrees(IFamilyTreeStoreBaseClass familyTree1, IFamilyTreeStoreBaseClass familyTree2, ReportCompareResult reportDuplicate, IProgressReporterInterface reporter = null) { IEnumerator <IndividualClass> iterator1; int cnt1 = 0; NameEquivalenceDb equivDb = NameEquivalenceDb.LoadFile(NameEquivalenceDb.GetDefaultFilePath()); if (equivDb == null) { equivDb = new DefaultNameEquivalenceDb(); equivDb.LoadDefault(); bool result = NameEquivalenceDb.SaveFile(NameEquivalenceDb.GetDefaultFilePath(), equivDb); if (!result) { trace.TraceData(TraceEventType.Warning, 0, "File db write failed"); } else { trace.TraceData(TraceEventType.Information, 0, "File db write ok"); } } iterator1 = familyTree1.SearchPerson(null, reporter); trace.TraceData(TraceEventType.Information, 0, "CompareTrees() started"); if (iterator1 != null) { do { IndividualClass person1 = iterator1.Current; cnt1++; if (person1 != null) { trace.TraceData(TraceEventType.Information, 0, " 1:" + cnt1 + " " + person1.GetName()); SearchDuplicates(person1, familyTree1, familyTree2, reportDuplicate, reporter, equivDb); } else { trace.TraceData(TraceEventType.Warning, 0, " 1: person is null" + cnt1); } } while (iterator1.MoveNext()); iterator1.Dispose(); } else { trace.TraceInformation("iter=null"); } trace.TraceInformation("CompareTrees() done"); }
public override bool OpenFile(String fileName, ref IFamilyTreeStoreBaseClass inFamilyTree, CompletedCallback callback) { if (GeniStore != null) { trace.TraceData(TraceEventType.Warning, 0, "Tree is not null"); } GeniStore = (FamilyTreeStoreGeni2)inFamilyTree; trace.TraceInformation("GeniFileType::OpenFile( " + fileName + ")"); GeniStore.SetFile(fileName); if (!GeniStore.CallbackArmed()) { callback(true); } return(true); }
public bool Validate(IFamilyTreeStoreBaseClass 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); }
public static void SearchDuplicates(IndividualClass person1, IFamilyTreeStoreBaseClass familyTree1, IFamilyTreeStoreBaseClass familyTree2, ReportCompareResult reportDuplicate, IProgressReporterInterface reporter = null, NameEquivalenceDb nameEqDb = null) { IndividualEventClass birth = person1.GetEvent(IndividualEventClass.EventType.Birth); IndividualEventClass death = person1.GetEvent(IndividualEventClass.EventType.Death); if (reporter != null) { trace.TraceInformation(reporter.ToString()); } if (((birth != null) && (birth.GetDate() != null) && (birth.GetDate().ValidDate())) || ((death != null) && (death.GetDate() != null) && (death.GetDate().ValidDate()))) { string searchString; if (familyTree2.GetCapabilities().jsonSearch) { searchString = SearchDescriptor.ToJson(SearchDescriptor.GetSearchDescriptor(person1)); } else { searchString = person1.GetName().Replace("*", ""); } IEnumerator <IndividualClass> iterator2 = familyTree2.SearchPerson(searchString); int cnt2 = 0; if (iterator2 != null) { int cnt3 = 0; do { IndividualClass person2 = iterator2.Current; if (person2 != null) { cnt3++; //trace.TraceInformation(reporter.ToString() + " 2:" + person2.GetName()); if ((familyTree1 != familyTree2) || (person1.GetXrefName() != person2.GetXrefName())) { if (ComparePerson(person1, person2, nameEqDb)) { trace.TraceData(TraceEventType.Information, 0, " 2:" + person2.GetName() + " " + person1.GetXrefName() + " " + person2.GetXrefName()); reportDuplicate(familyTree1, person1.GetXrefName(), familyTree2, person2.GetXrefName()); } cnt2++; } } } while (iterator2.MoveNext()); iterator2.Dispose(); trace.TraceInformation(" " + searchString + " matched with " + cnt2 + "," + cnt3); } if (cnt2 == 0) // No matches found for full name { if ((person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.BirthSurname).Length > 0) && (person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.Surname).Length > 0) && !person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.Surname).Equals(person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.BirthSurname))) { String strippedName = person1.GetName().Replace("*", ""); if (strippedName.Contains(person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.Surname))) { String maidenName = strippedName.Replace(person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.Surname), "").Replace(" ", " "); IEnumerator <IndividualClass> iterator3 = familyTree2.SearchPerson(maidenName); //trace.TraceInformation(" Searching Maiden name " + maidenName); if (iterator3 != null) { int cnt3 = 0; do { IndividualClass person2 = iterator3.Current; if (person2 != null) { if ((familyTree1 != familyTree2) || (person1.GetXrefName() != person2.GetXrefName())) { cnt3++; if (ComparePerson(person1, person2, nameEqDb)) { trace.TraceData(TraceEventType.Information, 0, " 2b:" + person2.GetName()); reportDuplicate(familyTree1, person1.GetXrefName(), familyTree2, person2.GetXrefName()); } } } } while (iterator3.MoveNext()); iterator3.Dispose(); trace.TraceInformation(" Maiden name " + maidenName + " mathched with " + cnt3); } } if (strippedName.Contains(person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.BirthSurname))) { String marriedName = strippedName.Replace(person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.BirthSurname), "").Replace(" ", " "); IEnumerator <IndividualClass> iterator3 = familyTree2.SearchPerson(marriedName); //trace.TraceInformation(" Searching Married name " + marriedName); if (iterator3 != null) { int cnt3 = 0; do { //IndividualClass person1 = iterator1.Current; IndividualClass person2 = iterator3.Current; if (person2 != null) { //trace.TraceInformation(reporter.ToString() + " 2:" + person2.GetName()); if ((familyTree1 != familyTree2) || (person1.GetXrefName() != person2.GetXrefName())) { cnt3++; if (ComparePerson(person1, person2, nameEqDb)) { trace.TraceData(TraceEventType.Information, 0, " 2c:" + person2.GetName()); reportDuplicate(familyTree1, person1.GetXrefName(), familyTree2, person2.GetXrefName()); } } } } while (iterator3.MoveNext()); iterator3.Dispose(); trace.TraceInformation(" Married name " + marriedName + " matched to " + cnt3); } } } } } else { trace.TraceData(TraceEventType.Information, 0, "No valid birth or death date for " + person1.GetName().ToString() + " skip duplicate search"); } }
private bool ReadFile(String fileName, ref IFamilyTreeStoreBaseClass inFamilyTree) { printMemory = false;// true; importResult = new FileImportResult(); DebugStringAdd(ref importResult, "GedcomDecoder::Readfile(" + fileName + ") Start " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); familyTree = inFamilyTree; trace.TraceData(TraceEventType.Verbose, 0, familyTree.GetShortTreeInfo()); if (printMemory) { memory = new MemoryClass(); memory.PrintMemory(); } fileBuffer = new FileBufferClass(); fileBuffer.ReadFile(fileName); DebugStringAdd(ref importResult, "GedcomDecoder::Readfile() size " + fileBuffer.GetSize()); if (printMemory) { memory.PrintMemory(); } String HeadString = ""; parsedLines = 0; if (fileBuffer.GetSize() < 12) { importResult = line.GetDebugString(); DebugStringAdd(ref importResult, "gedcom file too small!: " + fileName + ", size:" + fileBuffer.GetSize()); importResult.WriteToFile(fileName); return(false); } Byte[] fileDataBuffer = fileBuffer.GetBuffer(); //DebugStringAdd(ref importResult, ""); string hdrStrText = ""; string linefeed = ""; bool linefeedFound = false; for (int i = 0; i < 20; i++) { char ch = (char)fileDataBuffer[i]; //DebugStringAdd(ref importResult, fileDataBuffer[i].ToString()); HeadString += ch; hdrStrText += ch.ToString() + " "; if (!linefeedFound) { if ((ch == '\n') || (ch == '\r')) { linefeed += ch; } else if (linefeed.Length > 0) { linefeedFound = true; } } } //DebugStringAdd(ref importResult, ""); DebugStringAdd(ref importResult, "Header bytes: " + hdrStrText); if (!linefeedFound) { DebugStringAdd(ref importResult, " Did not find proper linefeed!: " + fileName + ", size:" + fileBuffer.GetSize() + ":" + HeadString); importResult.WriteToFile(fileName); return(false); } line = new GedcomLineStatus(ref importResult, linefeed); if (HeadString.IndexOf("HEAD") < 0) { importResult = line.GetDebugString(); DebugStringAdd(ref importResult, "gedcom file header missing!: " + fileName + ", size:" + fileBuffer.GetSize() + ":" + HeadString); importResult.WriteToFile(fileName); return(false); } familyTree.SetSourceFileType("GEDCOM"); if (printMemory) { memory.PrintMemory(); } Parse(ref importResult); if (printMemory) { memory.PrintMemory(); } trace.TraceData(TraceEventType.Verbose, 0, familyTree.GetShortTreeInfo()); DebugStringAdd(ref importResult, "GedcomDecoder::Readfile() Done " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); importResult.WriteToFile(fileName); return(true); }
public XrefMapList(IFamilyTreeStoreBaseClass familyTree, XrefType type) { xrefMap = new Dictionary <string, XrefMapClass>(); this.familyTree = familyTree; this.type = type; }
public bool ReadFile(String filename, ref IFamilyTreeStoreBaseClass inFamilyTree) { printMemory = false;// true; trace.TraceInformation("TextDecoder::Readfile(" + filename + ") Start " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); familyTree = inFamilyTree; trace.TraceInformation(familyTree.GetShortTreeInfo()); //familyTree.Print(); if (printMemory) { memory = new MemoryClass(); memory.PrintMemory(); } xrefMapLists = new XrefMapLists(inFamilyTree); fileBuffer = new FileBufferClass(); fileBuffer.ReadFile(filename); trace.TraceInformation("TextDecoder::Readfile() size " + fileBuffer.GetSize()); if (printMemory) { memory.PrintMemory(); } String HeadString = ""; trace.TraceInformation("Text file " + filename + " read ok, size " + fileBuffer.GetSize()); if (fileBuffer.GetSize() < 12) { trace.TraceInformation("Text file too small!: " + filename + ", size:" + fileBuffer.GetSize()); return(false); } Byte[] fileDataBuffer = fileBuffer.GetBuffer(); for (int i = 0; i < 12; i++) { trace.TraceInformation(" data:" + (int)fileDataBuffer[i]); HeadString += (char)fileDataBuffer[i]; } trace.TraceInformation(""); familyTree.SetSourceFileType("Text"); if (printMemory) { memory.PrintMemory(); } if (printMemory) { memory.PrintMemory(); } //familyTree.Print(); trace.TraceData(TraceEventType.Verbose, 0, familyTree.GetShortTreeInfo()); trace.TraceInformation("TextDecoder::Readfile() Done " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); string directory = "/tmp/"; if (!Directory.Exists(directory)) { //Directory.CreateDirectory(directory); directory = ""; } if ((directory.Length > 0) && filename.Contains(directory)) { filename = filename.Substring(directory.Length); } Parse(directory + FamilyUtility.MakeFilename(filename + "_text_parsed_" + DateTime.Now.ToString("yyyy-MM-dd_HHmmss") + ".txt")); xrefMapLists.Analyze(trace); return(true); }
public XrefMapLists(IFamilyTreeStoreBaseClass familyTree) { this.familyTree = familyTree; xrefLists = new Dictionary <XrefType, XrefMapList>(); }
public bool Validate(IFamilyTreeStoreBaseClass familyTree, ref ValidationData validationData) { return(true); }
public abstract bool OpenFile(String fileName, ref IFamilyTreeStoreBaseClass inFamilyTree, CompletedCallback callback);