private void VygenerovatOdstavec(CastTextu cast, Bible bible, Kniha kniha) { AktualniTextVerse += "<br/>"; foreach (CastTextu potomek in cast.Potomci) { VygenerovatCastSql(potomek, bible, kniha); } }
private void VygenerovatKnihu(CastTextu cast, Bible bible, Kniha kniha) { foreach (CastTextu potomek in cast.Potomci) { VygenerovatCastSql(potomek, bible, kniha); PridatRozpracovanyVers(); } }
private void VygenerovatRadekPoezie(CastTextu cast, Bible bible, Kniha kniha) { foreach (CastTextu potomek in cast.Potomci) { VygenerovatCastSql(potomek, bible, kniha); } AktualniTextVerse += "<br/>"; }
private void VygenerovatCastKnihy(CastTextu cast, Bible bible, Kniha kniha) { VlozitSqlNadpis(cast is HlavniCastKnihy knihy ? knihy.Nadpis : ((CastKnihy)cast).Nadpis); foreach (CastTextu potomek in cast.Potomci) { VygenerovatCastSql(potomek, bible, kniha); } }
private void VygenerovatCastPoezie(CastTextu cast, Bible bible, Kniha kniha) { if (!string.IsNullOrEmpty(AktualniTextVerse)) { AktualniTextVerse += "<br/>"; } foreach (CastTextu potomek in cast.Potomci) { VygenerovatCastSql(potomek, bible, kniha); } }
public void VygenerovatCastSql(CastTextu cast, Bible bible, Kniha kniha) { switch (cast.GetType().Name) { case "HlavniCastKnihy": PridatRozpracovanyVers(); goto case "CastKnihy"; case "CastKnihy": VygenerovatCastKnihy(cast, bible, kniha); break; case "UvodKapitoly": PridatRozpracovanyVers(); PocitadloVerse = 1; PocitadloKapitol++; break; case "Vers": PridatRozpracovanyVers(); break; case "Poezie": VygenerovatCastPoezie(cast, bible, kniha); break; case "RadekPoezie": VygenerovatRadekPoezie(cast, bible, kniha); break; case "Odstavec": VygenerovatOdstavec(cast, bible, kniha); break; case "FormatovaniTextu": VygenerovatFormatovaniTextu(cast, bible, kniha); break; case "CastPoezie": AktualniTextVerse += $"<h5>{cast.TextovaData}</h5>\n"; break; case "CastTextuSTextem": AktualniTextVerse += cast.TextovaData; break; case "Kniha": VygenerovatKnihu(cast, bible, kniha); break; } }
private void VygenerovatFormatovaniTextu(CastTextu cast, Bible bible, Kniha kniha) { if ((cast as FormatovaniTextu).Kurziva) { AktualniTextVerse += "<i>"; foreach (CastTextu potomek in cast.Potomci) { VygenerovatCastSql(potomek, bible, kniha); } AktualniTextVerse += "</i>"; } }
private Kniha NacistKnihu(XmlNode xml) { Kniha kniha = new Kniha(); kniha.Id = xml.SelectSingleNode("@osisID").InnerText; // Budeme iterativně zpracovávat seznam XML potomků a přidávát // ekvivalenty. List <CastTextu> rodice = new List <CastTextu> { kniha }; // Tento seznam obashuje seznamy XML prvků, které patří do daného rodiče. List <List <XmlNode> > xmlProRodice = new List <List <XmlNode> > { xml.ChildNodes.OfType <XmlNode>().ToList() }; while (rodice.Count > 0) { CastTextu rodic = rodice[0]; rodice.RemoveAt(0); List <XmlNode> xmlProTohotoRodice = xmlProRodice[0]; xmlProRodice.RemoveAt(0); foreach (XmlNode xmlPotomek in xmlProTohotoRodice) { if (xmlPotomek is XmlElement) { XmlElement xmlPotomekElem = xmlPotomek as XmlElement; if ( xmlPotomek.Name == "div" && xmlPotomekElem.HasAttribute("type") && xmlPotomek.Attributes["type"].InnerText == "majorSection") { // Máme major section. HlavniCastKnihy hlavniCast = new HlavniCastKnihy { Nadpis = xmlPotomek.SelectSingleNode("os:title", NsManager).InnerText }; rodic.PridatPotomka(hlavniCast); rodice.Add(hlavniCast); xmlProRodice.Add(xmlPotomek.ChildNodes.OfType <XmlNode>().ToList()); } else if ( xmlPotomek.Name == "div" && xmlPotomekElem.HasAttribute("type") && xmlPotomek.Attributes["type"].InnerText == "section") { CastKnihy castKnihy = new CastKnihy { Nadpis = xmlPotomek.SelectSingleNode("os:title", NsManager).InnerText.Trim('<', '>', '"') }; rodic.PridatPotomka(castKnihy); rodice.Add(castKnihy); xmlProRodice.Add(xmlPotomek.ChildNodes.OfType <XmlNode>().ToList()); } else if ( xmlPotomek.Name == "div" && xmlPotomekElem.HasAttribute("type") && xmlPotomek.Attributes["type"].InnerText == "preface") { // Předmluva. CastKnihy castKnihy = new CastKnihy { Nadpis = xmlPotomek.SelectSingleNode("os:title", NsManager).InnerText }; rodic.PridatPotomka(castKnihy); rodice.Add(castKnihy); xmlProRodice.Add(xmlPotomek.ChildNodes.OfType <XmlNode>().ToList()); } else if (xmlPotomek.Name == "lg") { // Máme báseň. Poezie poezie = new Poezie(); rodic.PridatPotomka(poezie); rodice.Add(poezie); xmlProRodice.Add(xmlPotomek.ChildNodes.OfType <XmlNode>().ToList()); } else if (xmlPotomek.Name == "p") { // Odstavec složený z veršů, řádků básně či dalšího obsahu. Odstavec odstavec = new Odstavec(); rodic.PridatPotomka(odstavec); rodice.Add(odstavec); xmlProRodice.Add(xmlPotomek.ChildNodes.OfType <XmlNode>().ToList()); } else if (xmlPotomek.Name == "chapter") { if (xmlPotomekElem.HasAttribute("osisID") && xmlPotomekElem.HasAttribute("sID")) { UvodKapitoly uvodKapitoly = new UvodKapitoly { Id = xmlPotomek.SelectSingleNode("@osisID", NsManager).InnerText }; rodic.PridatPotomka(uvodKapitoly); rodice.Add(uvodKapitoly); xmlProRodice.Add(xmlPotomek.ChildNodes.OfType <XmlNode>().ToList()); } else { // Konec kapitoly, zatím se neřeší. } } else if (xmlPotomekElem.Name == "verse") { if (xmlPotomekElem.HasAttribute("osisID")) { Vers vers = new Vers { Id = xmlPotomek.SelectSingleNode("@osisID", NsManager).InnerText }; rodic.PridatPotomka(vers); rodice.Add(vers); xmlProRodice.Add(xmlPotomek.ChildNodes.OfType <XmlNode>().ToList()); } else { // Konec verše, zatím se neřeší. } } else if (xmlPotomek.Name == "l") { RadekPoezie radekPoezie = new RadekPoezie(); rodic.PridatPotomka(radekPoezie); rodice.Add(radekPoezie); xmlProRodice.Add(xmlPotomek.ChildNodes.OfType <XmlNode>().ToList()); } else if (xmlPotomek.Name == "note") { // Poznámka (pod čarou). Poznamka poznamka = new Poznamka(); rodic.PridatPotomka(poznamka); rodice.Add(poznamka); xmlProRodice.Add(xmlPotomek.ChildNodes.OfType <XmlNode>().ToList()); } else if (xmlPotomek.Name == "i") { // Poznámka (pod čarou). FormatovaniTextu formatovaniTextu = new FormatovaniTextu { Kurziva = true }; rodic.PridatPotomka(formatovaniTextu); rodice.Add(formatovaniTextu); xmlProRodice.Add(xmlPotomek.ChildNodes.OfType <XmlNode>().ToList()); } else if (xmlPotomek.Name == "head") { // Poznámka (pod čarou). CastPoezie castPoezie = new CastPoezie(); rodic.PridatPotomka(castPoezie); rodice.Add(castPoezie); xmlProRodice.Add(xmlPotomek.ChildNodes.OfType <XmlNode>().ToList()); } else { } } else if (xmlPotomek is XmlText) { // Máme čistě textový záznam. CastTextuSTextem textovaCast = new CastTextuSTextem { /* * TextovaData = HttpUtility.HtmlEncode(Regex.Replace( * xmlPotomek.Value, * "[\\n\\r ]+$", * " ")) */ TextovaData = Regex.Replace( xmlPotomek.Value, "[\\n\\r ]+$", " ") }; rodic.PridatPotomka(textovaCast); rodice.Add(textovaCast); xmlProRodice.Add(xmlPotomek.ChildNodes.OfType <XmlNode>().ToList()); } else { } } } return(kniha); }
private string VygenerovatCastTextu(CastTextu cast, Kniha kniha, Bible bible, bool dlouheCislaVerse) { if (cast is HlavniCastKnihy) { StringBuilder stavec = new StringBuilder(); stavec.Append($"<h2>{(cast as HlavniCastKnihy).Nadpis}</h2>\n"); foreach (CastTextu potomek in cast.Potomci) { stavec.Append(VygenerovatCastTextu(potomek, kniha, bible, dlouheCislaVerse)); } return(stavec.ToString()); } else if (cast is CastKnihy) { StringBuilder stavec = new StringBuilder(); stavec.Append($"<h4>{(cast as CastKnihy).Nadpis}</h4>\n"); foreach (CastTextu potomek in cast.Potomci) { stavec.Append(VygenerovatCastTextu(potomek, kniha, bible, dlouheCislaVerse)); } return(stavec.ToString()); } else if (cast is UvodKapitoly) { return($"<h3>Kapitola {ZiskatKratkeCisloVerse((cast as UvodKapitoly).Id)}</h3>\n"); } else if (cast is Vers) { StringBuilder stavec = new StringBuilder(); if (dlouheCislaVerse) { stavec.Append($"<sup>{ZiskatDlouheCisloVerse((cast as Vers).Id)}</sup>"); } else { // S tooltipem. string kratkeCislo = ZiskatKratkeCisloVerse((cast as Vers).Id); string dlouheCislo = ZiskatDlouheCisloVerse((cast as Vers).Id); stavec.Append($"<sup><a href=\"#\" data-html=\"true\" data-toggle=\"tooltip\" title=\"{HttpUtility.HtmlEncode(dlouheCislo)}\">{kratkeCislo}</a></sup>"); } foreach (CastTextu potomek in cast.Potomci) { stavec.Append(VygenerovatCastTextu(potomek, kniha, bible, dlouheCislaVerse)); } return(stavec.ToString()); } else if (cast is Poznamka) { StringBuilder stavec = new StringBuilder(); foreach (CastTextu potomek in cast.Potomci) { stavec.Append(VygenerovatCastTextu(potomek, kniha, bible, dlouheCislaVerse)); } PouzitaPoznamka poznamka = new PouzitaPoznamka { Text = stavec.ToString(), Id = $"pozn-{PouzitePoznamky.Count + 1}" }; PouzitePoznamky.Add(poznamka); return($"<sup class=\"poznamka\"><a href=\"#\" data-html=\"true\" data-toggle=\"tooltip\" title=\"{HttpUtility.HtmlEncode(poznamka.Text)}\">[{PouzitePoznamky.Count}]</a></sup> "); } else if (cast is Poezie) { StringBuilder stavec = new StringBuilder(); stavec.Append("<p class=\"poezie\">"); foreach (CastTextu potomek in cast.Potomci) { stavec.Append(VygenerovatCastTextu(potomek, kniha, bible, dlouheCislaVerse)); } stavec.Append("</p>"); return(stavec.ToString()); } else if (cast is RadekPoezie) { StringBuilder stavec = new StringBuilder(); foreach (CastTextu potomek in cast.Potomci) { stavec.Append(VygenerovatCastTextu(potomek, kniha, bible, dlouheCislaVerse)); } stavec.Append("<br/>"); return(stavec.ToString()); } else if (cast is Odstavec) { StringBuilder stavec = new StringBuilder(); stavec.Append("<p>"); foreach (CastTextu potomek in cast.Potomci) { stavec.Append(VygenerovatCastTextu(potomek, kniha, bible, dlouheCislaVerse)); } stavec.Append("</p>"); return(stavec.ToString()); } else if (cast is FormatovaniTextu) { StringBuilder stavec = new StringBuilder(); if ((cast as FormatovaniTextu).Kurziva) { stavec.Append("<i>"); foreach (CastTextu potomek in cast.Potomci) { stavec.Append(VygenerovatCastTextu(potomek, kniha, bible, dlouheCislaVerse)); } stavec.Append("</i>"); } return(stavec.ToString()); } else if (cast is CastPoezie) { return($"<h5>{cast.TextovaData}</h5>\n"); } else if (cast is CastTextuSTextem) { return(cast.TextovaData); } else { StringBuilder stavec = new StringBuilder(); foreach (CastTextu potomek in cast.Potomci) { stavec.Append(VygenerovatCastTextu(potomek, kniha, bible, dlouheCislaVerse)); } return(stavec.ToString()); } }
public void VygenerovatCastSql(CastTextu cast, Bible bible, Kniha kniha) { if (cast is HlavniCastKnihy || cast is CastKnihy) { if (cast is HlavniCastKnihy) { PridatRozpracovanyVers(); PocitadloVerse = 1; } VlozitSqlNadpis(cast is HlavniCastKnihy knihy ? knihy.Nadpis : ((CastKnihy)cast).Nadpis); foreach (CastTextu potomek in cast.Potomci) { VygenerovatCastSql(potomek, bible, kniha); } } else if (cast is UvodKapitoly) { PridatRozpracovanyVers(); PocitadloVerse = 1; PocitadloKapitol++; } else if (cast is Vers) { PridatRozpracovanyVers(); } else if (cast is Poezie) { foreach (CastTextu potomek in cast.Potomci) { VygenerovatCastSql(potomek, bible, kniha); } } else if (cast is RadekPoezie) { foreach (CastTextu potomek in cast.Potomci) { VygenerovatCastSql(potomek, bible, kniha); } AktualniTextVerse += "<br/>"; } else if (cast is Odstavec) { foreach (CastTextu potomek in cast.Potomci) { VygenerovatCastSql(potomek, bible, kniha); } } else if (cast is FormatovaniTextu) { if ((cast as FormatovaniTextu).Kurziva) { AktualniTextVerse += "<i>"; foreach (CastTextu potomek in cast.Potomci) { VygenerovatCastSql(potomek, bible, kniha); } AktualniTextVerse += "</i>"; } } else if (cast is CastPoezie) { AktualniTextVerse += $"<h5>{cast.TextovaData}</h5>\n"; } else if (cast is CastTextuSTextem) { AktualniTextVerse += cast.TextovaData; } else if (cast is Kniha) { foreach (CastTextu potomek in cast.Potomci) { PocitadloVerse = 1; VygenerovatCastSql(potomek, bible, kniha); PridatRozpracovanyVers(); } } }
private string VygenerovatCastTextu(CastTextu cast, Kniha kniha, Bible bible, bool dlouheCislaVerse) { if (cast is HlavniCastKnihy) { StringBuilder stavec = new StringBuilder(); stavec.Append($"<h2>{((HlavniCastKnihy) cast).Nadpis}</h2>\n"); foreach (CastTextu potomek in cast.Potomci) { stavec.Append(VygenerovatCastTextu(potomek, kniha, bible, dlouheCislaVerse)); } return(stavec.ToString()); } else if (cast is CastKnihy) { StringBuilder stavec = new StringBuilder(); stavec.Append($"<h4>{((CastKnihy) cast).Nadpis}</h4>\n"); foreach (CastTextu potomek in cast.Potomci) { stavec.Append(VygenerovatCastTextu(potomek, kniha, bible, dlouheCislaVerse)); } return(stavec.ToString()); } else if (cast is UvodKapitoly) { return($"<h3 id=\"{ZiskatIdKapitoly(((UvodKapitoly) cast).Id)}\">Kapitola {ZiskatKratkeCisloVerse(((UvodKapitoly) cast).Id)}</h3>\n"); } else if (cast is Vers) { StringBuilder stavec = new StringBuilder(); stavec.Append($"<sup>{(dlouheCislaVerse ? ZiskatDlouheCisloVerse(bible, (cast as Vers).Id) : ZiskatKratkeCisloVerse(((Vers) cast).Id))}</sup>"); foreach (CastTextu potomek in cast.Potomci) { stavec.Append(VygenerovatCastTextu(potomek, kniha, bible, dlouheCislaVerse)); } return(stavec.ToString()); } else if (cast is Poznamka) { StringBuilder stavec = new StringBuilder(); foreach (CastTextu potomek in cast.Potomci) { stavec.Append(VygenerovatCastTextu(potomek, kniha, bible, dlouheCislaVerse)); } int poradiKnihy = bible.Knihy.IndexOf(kniha); if (!PouzitePoznamky.ContainsKey(poradiKnihy)) { PouzitePoznamky.Add(poradiKnihy, new List <PouzitaPoznamka>()); } PouzitaPoznamka poznamka = new PouzitaPoznamka { Text = stavec.ToString(), Id = $"{PouzitePoznamky[poradiKnihy].Count + 1}" }; PouzitePoznamky[poradiKnihy].Add(poznamka); return($"<sup class=\"poznamka\"><a id=\"{ZiskatIdCitace(kniha, poznamka)}\" href=\"{KnihaPoznamky}#{ZiskatIdPoznamky(kniha, poznamka)}\" epub:type=\"noteref\">[{PouzitePoznamky[poradiKnihy].Count}]</a></sup> "); } else if (cast is Poezie) { StringBuilder stavec = new StringBuilder(); stavec.Append("<div class=\"poezie\">"); foreach (CastTextu potomek in cast.Potomci) { stavec.Append(VygenerovatCastTextu(potomek, kniha, bible, dlouheCislaVerse)); } stavec.Append("</div>"); return(stavec.ToString()); } else if (cast is RadekPoezie) { StringBuilder stavec = new StringBuilder("<p>"); foreach (CastTextu potomek in cast.Potomci) { stavec.Append(VygenerovatCastTextu(potomek, kniha, bible, dlouheCislaVerse)); } stavec.Append("</p>"); return(stavec.ToString()); } else if (cast is Odstavec) { StringBuilder stavec = new StringBuilder(); stavec.Append("<p>"); foreach (CastTextu potomek in cast.Potomci) { stavec.Append(VygenerovatCastTextu(potomek, kniha, bible, dlouheCislaVerse)); } stavec.Append("</p>"); return(stavec.ToString()); } else if (cast is FormatovaniTextu) { StringBuilder stavec = new StringBuilder(); if ((cast as FormatovaniTextu).Kurziva) { stavec.Append("<i>"); foreach (CastTextu potomek in cast.Potomci) { stavec.Append(VygenerovatCastTextu(potomek, kniha, bible, dlouheCislaVerse)); } stavec.Append("</i>"); } return(stavec.ToString()); } else if (cast is CastPoezie) { return($"<h5>{cast.TextovaData}</h5>\n"); } else if (cast is CastTextuSTextem) { return(cast.TextovaData); } else { StringBuilder stavec = new StringBuilder(); foreach (CastTextu potomek in cast.Potomci) { stavec.Append(VygenerovatCastTextu(potomek, kniha, bible, dlouheCislaVerse)); } return(stavec.ToString()); } }