Ejemplo n.º 1
0
        private static void ParseKomplet()
        {
            var hymnuses = _db.QueryAllHymnus().ToList();
            var days     = _db.QueryAllKomplet(); // und vesper

            foreach (var d in days)
            {
                var h = new Hour
                {
                    Date       = d.Date,
                    BookPart   = d.BookPart,
                    PeriodName = d.PeriodName,
                    Type       = d.Type
                };

                var doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(d.Text);

                //var orDefault = doc.DocumentNode.SelectNodes("//*[@class=\"red\"]");
                var f  = doc.DocumentNode.ChildNodes.FindFirst("h3");
                var ht = f.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling;
                h.Hymnus = P(ht.InnerHtml);

                // Psalm 1
                var a = string.Empty;
                var n = string.Empty;
                var c = string.Empty;
                var t = string.Empty;

                var pst1 = GetPsalmSext(ht.NextSibling.NextSibling.NextSibling, out a, out n, out c, out t);
                h.Antiphon1     = P(a);
                h.PsalmName1    = P(n);
                h.PsalmComment1 = P(c);
                h.PsalmText1    = P(t);

                var pst2 = pst1;
                // Psalm 2
                if (!pst1.NextSibling.NextSibling.NextSibling.InnerText.Contains("KURZLESUNG"))
                {
                    // var at2 = ;
                    pst2 = GetPsalmSext(pst1.NextSibling.NextSibling.NextSibling.NextSibling, out a, out n, out c, out t);

                    h.Antiphon2     = P(a);
                    h.PsalmName2    = P(n);
                    h.PsalmComment2 = P(c);
                    h.PsalmText2    = P(t);
                }

                /* h.Antiphon2 = at2.InnerText;
                 *
                 * var psn2 = at2.NextSibling;
                 * h.PsalmName2 = psn2.InnerText;
                 *
                 * var psc2 = psn2.NextSibling;
                 * h.PsalmComment2 = psc2.InnerText;
                 *
                 * var pst2 = psc2.NextSibling;
                 * if (pst2.Name == "p")
                 * {
                 *  h.PsalmComment2 = $"{h.PsalmComment2} | {pst2.InnerText}";
                 *  pst2 = pst2.NextSibling;
                 * }
                 * h.PsalmText2 = ParsePsalm(pst2);*/

                // Psalm 3
//                var pst3 = GetPsalm(pst2.NextSibling.NextSibling.NextSibling.NextSibling, out a, out n, out c, out t);
//
//                h.Antiphon3 = P(a);
//                h.PsalmName3 = P(n);
//                h.PsalmComment3 = P(c);
//                h.PsalmText3 = P(t);

                /* var at3 = pst1.NextSibling.NextSibling.NextSibling.NextSibling;
                 * h.Antiphon3 = at3.InnerText;
                 *
                 * var psn3 = at3.NextSibling;
                 * h.PsalmName3 = psn3.InnerText;
                 *
                 * var psc3 = psn3.NextSibling;
                 * h.PsalmComment3 = psc3.InnerText;
                 *
                 * var pst3 = psc3.NextSibling;
                 * if (pst3.Name == "p")
                 * {
                 *  h.PsalmComment3 = $"{h.PsalmComment3} | {pst3.InnerText}";
                 *  pst3 = pst3.NextSibling;
                 * }
                 * h.PsalmText3 = ParsePsalm(pst3);*/

                var rn = pst2.NextSibling.NextSibling.NextSibling;
                h.ReadingName = P(rn.InnerText);
                var rt = rn.NextSibling;
                h.ReadingText = P(ParsePsalm(rt));
                var resp = rt.NextSibling.NextSibling;
                h.Responsorium = P(resp.InnerHtml);

                var cant = GetPsalm(resp.NextSibling.NextSibling, out a, out n, out c, out t);
                h.CanticumAntiphon = P(a);
                //h.PsalmName3 = n;
                //h.PsalmComment3 = c;
                h.CanticumText = P(t);



                var or = cant.NextSibling.NextSibling.NextSibling.NextSibling;
                h.Oration = P(or.InnerHtml);
                _db.Add(h);
                if (!hymnuses.Select(ho => ho.Text).Contains(h.Hymnus))
                {
                    var nhymnus = new Hymnus()
                    {
                        Type = h.Type,
                        Text = h.Hymnus
                    };
                    hymnuses.Add(nhymnus);
                    _db.Add(nhymnus);
                }
                Console.WriteLine("{0} - {1}", d.Type, d.Date);
            }
        }
Ejemplo n.º 2
0
 public void Add(Hymnus h)
 {
     this.Insert(h);
 }