protected string GetNoteText(GDMNotes ns) { GDMLines noteLines = fTree.GetNoteLines(ns); string result = GMConfig.Instance.ObfuscateEmails ? ObfuscateEmail(noteLines.Text) : noteLines.Text; return(result); }
// Outputs the HTML for the Notes section of the page protected void OutputNotes(HTMLFile f, GDMList <GDMNotes> notes) { if (notes.Count > 0) { // Generate notes list into a local array before adding header title. This is to cope with the case where all notes are nothing but blanks. var noteStrings = new List <string>(notes.Count); foreach (GDMNotes ns in notes) { GDMLines noteLines = fTree.GetNoteLines(ns); string noteText = GMConfig.Instance.ObfuscateEmails ? ObfuscateEmail(noteLines.Text) : noteLines.Text; noteStrings.Add(string.Concat("<li>", EscapeHTML(noteText, false), "</li>")); } if (noteStrings.Count > 0) { f.WriteLine("<div id=\"notes\">"); f.WriteLine("<h1>Notes</h1>"); f.WriteLine("<ul>"); foreach (string note_string in noteStrings) { f.WriteLine(note_string); } f.WriteLine("</ul>"); f.WriteLine("</div> <!-- notes -->"); } } }
/// <summary> /// /// </summary> /// <param name="buffer"></param> /// <returns>prevId, identifier of person</returns> private int ParseBuffer(GDMLines buffer) { int prevId = 0; try { if (buffer.IsEmpty()) { return(prevId); } string s = buffer[0]; string personId = IsPersonLine(s); if (!string.IsNullOrEmpty(personId)) { fLog.Add("> " + fLangMan.LS(ILS.LSID_PersonParsed) + " \"" + personId + "\""); int selfId = 0; GDMIndividualRecord curPerson = ParsePerson(buffer, s, ref selfId); if (NumbersType == PersonNumbersType.pnKonovalov && selfId - prevId > 1) { fLog.Add(">>>> " + fLangMan.LS(ILS.LSID_ParseError_LineSeq)); } prevId = selfId; CheckBuffer(buffer, curPerson); } } catch (Exception ex) { Logger.WriteError("Importer.ParseBuffer()", ex); throw; } return(prevId); }
private GDMIndividualRecord ParsePerson(GDMLines buffer, string str, ref int selfId) { try { selfId = -1; int marrNum = -1; int pid_end = 0; var plRet = ParsePersonLine(str); // extData - (в/б) if (plRet == null) { return(null); } pid_end = plRet.Pos; if (fPersonsList.ContainsKey(plRet.PersId)) { fLog.Add(">>>> " + fLangMan.LS(ILS.LSID_ParseError_NumDuplicate) + " \"" + plRet.PersId + "\"."); return(null); } if (NumbersType == PersonNumbersType.pnKonovalov) { selfId = int.Parse(plRet.PersId); int.TryParse(plRet.MarNum, out marrNum); } str = str.Substring(pid_end).Trim(); GDMSex proposeSex = GetProposeSex(buffer); GDMIndividualRecord result = DefinePerson(str, proposeSex); fPersonsList.Add(plRet.PersId, result); if (!string.IsNullOrEmpty(plRet.ParentId)) { GDMIndividualRecord parent; if (fPersonsList.TryGetValue(plRet.ParentId, out parent)) { AddChild(parent, marrNum, result); } else { fLog.Add(">>>> " + fLangMan.LS(ILS.LSID_ParseError_AncNotFound) + " \"" + plRet.ParentId + "\"."); } } return(result); } catch (Exception ex) { Logger.WriteError("Importer.ParsePerson()", ex); throw; } }
private void WriteCompactFmt(PedigreePerson person) { if (fOptions.PedigreeOptions.IncludeNotes && person.IRec.Notes.Count != 0) { int num = person.IRec.Notes.Count; for (int i = 0; i < num; i++) { GDMLines noteLines = fTree.GetNoteLines(person.IRec.Notes[i]); fWriter.AddParagraph(GKUtils.MergeStrings(noteLines), fTextFont); } } bool spIndex = person.IRec.SpouseToFamilyLinks.Count > 1; int num2 = person.IRec.SpouseToFamilyLinks.Count; for (int i = 0; i < num2; i++) { GDMFamilyRecord family = fTree.GetPtrValue(person.IRec.SpouseToFamilyLinks[i]); if (fBase.Context.IsRecordAccess(family.Restriction)) { GDMIndividualRecord spRec; string st; string unk; if (person.IRec.Sex == GDMSex.svMale) { spRec = fTree.GetPtrValue(family.Wife); st = LangMan.LS(LSID.LSID_WifeSign); unk = LangMan.LS(LSID.LSID_UnkFemale); } else { spRec = fTree.GetPtrValue(family.Husband); st = LangMan.LS(LSID.LSID_HusbSign); unk = LangMan.LS(LSID.LSID_UnkMale); } if (spIndex) { st += (i + 1).ToString(); } st += " - "; if (spRec != null) { st = st + GKUtils.GetNameString(spRec, true, false) + GKUtils.GetPedigreeLifeStr(spRec, fOptions.PedigreeOptions.Format) /* + this.idLink(this.FindPerson(irec))*/; } else { st += unk; } fWriter.AddParagraph(st, fTextFont); } } }
private bool ImportTextContent() { try { fLog.Clear(); GDMLines buffer = new GDMLines(); try { int prev_id = 0; int num = fRawContents.Count; for (int i = 0; i < num; i++) { string line = PrepareLine(fRawContents[i]); RawLine rawLine = (RawLine)fRawContents.GetObject(i); switch (rawLine.Type) { case RawLineType.rltComment: buffer.Add(line); break; case RawLineType.rltPerson: case RawLineType.rltRomeGeneration: case RawLineType.rltEOF: { prev_id = ParseBuffer(buffer); buffer.Clear(); switch (rawLine.Type) { case RawLineType.rltPerson: buffer.Add(line); break; case RawLineType.rltRomeGeneration: fLog.Add("> " + fLangMan.LS(ILS.LSID_Generation) + " \"" + line + "\""); break; case RawLineType.rltEOF: fLog.Add("> EOF."); break; } } break; } } return(true); } finally { } } catch (Exception ex) { Logger.WriteError("Importer.ImportTextContent()", ex); throw; } }
private void CheckSpouses(GDMLines buffer, GDMIndividualRecord curPerson) { int num2 = buffer.Count; for (int i = 0; i < num2; i++) { string line = buffer[i]; if (string.IsNullOrEmpty(line)) { continue; } try { var slRet = ImportUtils.ParseSpouseLine(line); if (slRet != null) { // define sex string spSex = slRet.Spouse; GDMSex sx = (spSex[0] == 'М') ? GDMSex.svMale : GDMSex.svFemale; // extract name line = line.Substring(slRet.Pos).Trim(); if (!string.IsNullOrEmpty(line)) { GDMIndividualRecord spouse = DefinePerson(line, sx); GDMFamilyRecord family = GetFamilyByNum(curPerson, slRet.MarrNum); if (spouse == null || family == null) { // TODO: error to log, reporting causes } else { family.AddSpouse(spouse); // extract marriage date if (!string.IsNullOrEmpty(slRet.ExtData)) { string marrDate = slRet.ExtData.Substring(1, slRet.ExtData.Length - 2).Trim(); if (marrDate != "") { SetEvent(family, GEDCOMTagName.MARR, marrDate); } } } } } } catch (Exception ex) { Logger.WriteError("Importer.CheckSpouses()", ex); } } }
private GDMSex GetProposeSex(GDMLines buffer) { GDMSex result = GDMSex.svUnknown; if (buffer == null) { return(result); } try { int num = buffer.Count; for (int i = 0; i < num; i++) { string line = buffer[i]; if (line.Length <= 2) { continue; } char c1 = line[0]; char c2 = line[1]; if ((c1 == 'М' || c1 == 'Ж') && ((c2 == ' ') || (c2 >= '1' && c2 <= '9'))) { // define sex (if spouse is male, then result = female, else result = male) GDMSex res = (c1 == 'М') ? GDMSex.svFemale : GDMSex.svMale; if (result == GDMSex.svUnknown) { result = res; } else { if (result != res) { fLog.Add(">>>> " + fLangMan.LS(ILS.LSID_SpousesInfoConflict)); return(GDMSex.svUnknown); } else { // matched, checked } } } } } catch (Exception ex) { Logger.WriteError("Importer.GetProposeSex()", ex); } return(result); }
private static void TransformSourceCitation(GDMTree tree, GDMSourceCitation sourCit) { GDMSourceRecord sourRec = tree.CreateSource(); GDMLines description = sourCit.Description; string page = sourCit.Page; int certaintyAssessment = sourCit.CertaintyAssessment; sourRec.Text.Lines.Assign(description); sourCit.Clear(); sourCit.Value = sourRec; sourCit.Page = page; sourCit.CertaintyAssessment = certaintyAssessment; }
protected string GetNoteText(GDMNotes ns) { GDMLines noteLines = fTree.GetNoteLines(ns); string result; if (CConfig.Instance.ObfuscateEmails) { result = ObfuscateEmail(noteLines.Text); } else { result = noteLines.Text; } return(result); }
protected bool IsMatchesMask(GDMLines strList, string mask) { if (strList == null || strList.IsEmpty() || string.IsNullOrEmpty(mask)) { return(false); } if (mask == "*") { return(true); } if (fMask != mask) { fMask = mask; fSimpleMask = GetSimpleMask(fMask); if (fSimpleMask == null) { fRegexMask = new Regex(GKUtils.PrepareMask(fMask), GKUtils.RegexOpts); } } for (int i = 0; i < strList.Count; i++) { string str = strList[i]; bool res; if (fSimpleMask != null) { res = str.IndexOf(fSimpleMask, StringComparison.OrdinalIgnoreCase) >= 0; } else { res = fRegexMask.IsMatch(str, 0); } if (res) { return(true); } } return(false); }
public void Test_SetTagStringsL() { var tag = GDMTag.Create(null, GEDCOMTagsTable.Lookup("TEST"), ""); Assert.IsNotNull(tag); // very long string, 248"A" and " BBB BBBB" var strings = new GDMLines("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA BBB BBBB"); GEDCOMUtils.SetTagStrings(null, strings); GEDCOMUtils.SetTagStrings(tag, strings); Assert.AreEqual(248, tag.StringValue.Length); var strList = GEDCOMUtils.GetTagStrings(tag); Assert.IsNotNull(strList); Assert.AreEqual(1, strList.Count); Assert.AreEqual(strings.Text, strList.Text); }
public override void UpdateContents() { var dataOwner = fDataOwner as IGDMStructWithNotes; if (fSheetList == null || dataOwner == null) { return; } try { fSheetList.ClearItems(); foreach (GDMNotes note in dataOwner.Notes) { GDMLines noteLines = fBaseContext.Tree.GetNoteLines(note); fSheetList.AddItem(note, new object[] { noteLines.Text.Trim() }); } } catch (Exception ex) { Logger.WriteError("NoteLinksListModel.UpdateContents()", ex); } }
private void CheckBuffer(GDMLines buffer, GDMIndividualRecord curPerson) { if (buffer.IsEmpty()) { return; } if (curPerson != null) { CheckSpouses(buffer, curPerson); } GDMNoteRecord noteRec = fTree.CreateNote(); noteRec.Lines.Assign(buffer); if (curPerson != null) { curPerson.AddNote(noteRec); } buffer.Clear(); }
private void ExposePerson(GDMIndividualRecord iRec, string iName) { fWriter.BeginParagraph(TextAlignment.taLeft, 0, 0, 0, true); fWriter.AddParagraphChunkAnchor(iName, fBoldFont, iRec.XRef); fWriter.AddParagraphChunk(GKUtils.GetPedigreeLifeStr(iRec, PedigreeFormat.Compact), fTextFont); fWriter.EndParagraph(); IImage image = fBase.Context.GetPrimaryBitmap(iRec, 0, 0, false); fWriter.AddImage(image); GDMIndividualRecord father, mother; fBase.Context.Tree.GetParents(iRec, out father, out mother); if (father != null) { fWriter.BeginParagraph(TextAlignment.taLeft, 0, 0, 0); fWriter.AddParagraphChunk(LangMan.LS(LSID.LSID_Father) + ": ", fTextFont); fWriter.AddParagraphChunkLink(GKUtils.GetNameString(father, true, false), fLinkFont, father.XRef); fWriter.EndParagraph(); } if (mother != null) { fWriter.BeginParagraph(TextAlignment.taLeft, 0, 0, 0); fWriter.AddParagraphChunk(LangMan.LS(LSID.LSID_Mother) + ": ", fTextFont); fWriter.AddParagraphChunkLink(GKUtils.GetNameString(mother, true, false), fLinkFont, mother.XRef); fWriter.EndParagraph(); } if (IncludeEvents && iRec.HasEvents) { int num = iRec.Events.Count; for (int i = 0; i < num; i++) { GDMCustomEvent evt = iRec.Events[i]; var evtType = evt.GetTagType(); if (evtType == GEDCOMTagType.BIRT || evtType == GEDCOMTagType.DEAT) { continue; } string evtName = GKUtils.GetEventName(evt); string evtVal = evt.StringValue; string evtDesc = GKUtils.GetEventDesc(fBase.Context.Tree, evt, false); string tmp = evtName + ": " + evtVal; if (evtVal != "") { tmp += ", "; } tmp += evtDesc; fWriter.AddParagraph(tmp, fTextFont); } } if (IncludeNotes && iRec.HasNotes) { int num = iRec.Notes.Count; for (int i = 0; i < num; i++) { GDMLines noteLines = fTree.GetNoteLines(iRec.Notes[i]); fWriter.AddParagraph(GKUtils.MergeStrings(noteLines), fTextFont); } } }
private bool ImportTableContent() { try { fLog.Clear(); MSOExcel.Application excel; try { excel = new MSOExcel.Application(); } catch (Exception) { return(false); } excel.Visible = DEBUG_EXCEL; excel.DisplayAlerts = false; excel.WindowState = MSOExcel.XlWindowState.xlMaximized; excel.Workbooks.Open(fFileName); MSOExcel.Worksheet sheet = excel.Worksheets[1] as MSOExcel.Worksheet; //sheet.Activate(); IProgressController progress = AppHost.Progress; GDMLines buffer = new GDMLines(); try { int rowsCount = sheet.UsedRange.Rows.Count; //int colsCount = sheet.UsedRange.Columns.Count; progress.ProgressInit(fLangMan.LS(ILS.LSID_Loading), rowsCount); MSOExcel.Range excelRange = sheet.UsedRange; object[,] valueArray = (object[, ])excelRange.get_Value(MSOExcel.XlRangeValueDataType.xlRangeValueDefault); int prevId = 0; for (int row = 1; row <= rowsCount; row++) { string c1 = GetCell(valueArray, row, 1).Trim(); // position number string c2 = GetCell(valueArray, row, 2).Trim(); // ancestor number string c3 = GetCell(valueArray, row, 3).Trim(); // name, maybe start with the number of marriage string c4 = GetCell(valueArray, row, 4).Trim(); // birth date string c5 = GetCell(valueArray, row, 5).Trim(); // death date string c6 = GetCell(valueArray, row, 6).Trim(); // birth or residence place string s123 = c1 + c2; if (s123 != "" && !string.IsNullOrEmpty(c3) && c3[0] != '/') { s123 += ". " + c3; } else { s123 += c3; } if (s123 == "") { continue; } string line, p_id = ""; RawLineType lineType = RawLineType.rltComment; if (IsGenerationLine(s123)) { line = s123; lineType = RawLineType.rltRomeGeneration; } else { line = s123 + " " + c4 + " " + c5; if (c6 != "") { line = line + ". " + c6 + "."; } line = line.Trim(); p_id = IsPersonLine(line); if (!string.IsNullOrEmpty(p_id)) { lineType = RawLineType.rltPerson; } } switch (lineType) { case RawLineType.rltComment: buffer.Add(line); break; case RawLineType.rltPerson: case RawLineType.rltRomeGeneration: case RawLineType.rltEOF: { prevId = ParseBuffer(buffer); buffer.Clear(); switch (lineType) { case RawLineType.rltPerson: buffer.Add(line); break; case RawLineType.rltRomeGeneration: fLog.Add("> " + fLangMan.LS(ILS.LSID_Generation) + " \"" + line + "\""); break; case RawLineType.rltEOF: fLog.Add("> EOF."); break; } } break; } progress.ProgressStep(row); } // hack: processing last items before end prevId = ParseBuffer(buffer); return(true); } finally { progress.ProgressDone(); buffer.Clear(); buffer = null; excel.Quit(); excel = null; } } catch (Exception ex) { fLog.Add(">>>> " + fLangMan.LS(ILS.LSID_DataLoadError)); Logger.WriteError("Importer.ImportTableContent()", ex); return(false); } }
private void WriteExcessFmt(PedigreePerson person) { fWriter.AddParagraph(LangMan.LS(LSID.LSID_Sex) + ": " + GKUtils.SexStr(person.IRec.Sex), fTextFont); string st = GKUtils.GetLifeExpectancyStr(person.IRec); if (st != "?" && st != "") { fWriter.AddParagraph(LangMan.LS(LSID.LSID_LifeExpectancy) + ": " + st, fTextFont); } GDMIndividualRecord father, mother; fTree.GetParents(person.IRec, out father, out mother); if (father != null) { fWriter.AddParagraphLink(LangMan.LS(LSID.LSID_Father) + ": " + GKUtils.GetNameString(father, true, false) + " ", fTextFont, idLink(father), fLinkFont); } if (mother != null) { fWriter.AddParagraphLink(LangMan.LS(LSID.LSID_Mother) + ": " + GKUtils.GetNameString(mother, true, false) + " ", fTextFont, idLink(mother), fLinkFont); } var evList = new ExtList <PedigreeEvent>(true); try { int i; if (person.IRec.Events.Count > 0) { fWriter.AddParagraph(LangMan.LS(LSID.LSID_Events) + ":", fTextFont); int num = person.IRec.Events.Count; for (i = 0; i < num; i++) { GDMCustomEvent evt = person.IRec.Events[i]; if (!(evt is GDMIndividualAttribute) || fOptions.PedigreeOptions.IncludeAttributes) { evList.Add(new PedigreeEvent(person.IRec, evt)); } } WriteEventList(person, evList); } int num2 = person.IRec.SpouseToFamilyLinks.Count; for (i = 0; i < num2; i++) { GDMFamilyRecord family = fTree.GetPtrValue(person.IRec.SpouseToFamilyLinks[i]); if (!fBase.Context.IsRecordAccess(family.Restriction)) { continue; } GDMIndividualRecord spRec; string unk; if (person.IRec.Sex == GDMSex.svMale) { spRec = fTree.GetPtrValue(family.Wife); st = LangMan.LS(LSID.LSID_Wife) + ": "; unk = LangMan.LS(LSID.LSID_UnkFemale); } else { spRec = fTree.GetPtrValue(family.Husband); st = LangMan.LS(LSID.LSID_Husband) + ": "; unk = LangMan.LS(LSID.LSID_UnkMale); } string sps; if (spRec != null) { sps = st + GKUtils.GetNameString(spRec, true, false) + GKUtils.GetPedigreeLifeStr(spRec, fOptions.PedigreeOptions.Format) /* + this.idLink(this.FindPerson(irec))*/; } else { sps = st + unk; } fWriter.AddParagraph(sps, fTextFont); evList.Clear(); int childrenCount = family.Children.Count; for (int j = 0; j < childrenCount; j++) { GDMIndividualRecord child = fTree.GetPtrValue(family.Children[j]); evList.Add(new PedigreeEvent(child, child.FindEvent(GEDCOMTagType.BIRT))); } WriteEventList(person, evList); } } finally { evList.Dispose(); } if (fOptions.PedigreeOptions.IncludeNotes && person.IRec.Notes.Count != 0) { fWriter.AddParagraph(LangMan.LS(LSID.LSID_RPNotes) + ":", fTextFont); fWriter.BeginList(); int notesCount = person.IRec.Notes.Count; for (int i = 0; i < notesCount; i++) { GDMLines noteLines = fTree.GetNoteLines(person.IRec.Notes[i]); fWriter.AddListItem(" " + GKUtils.MergeStrings(noteLines), fTextFont); } fWriter.EndList(); } }