Ejemplo n.º 1
0
        public void GenerateSection()
        {
            PrayerSeason.PrayerSect prayerSection = PrayerSeason.PrayerSect.AllSections;

            try
            {
                PrayerModel prayerModel = FreshIOC.Container.Resolve <IPrayerModel>() as PrayerModel;

                DateTime startDate = new DateTime(2018, 10, 1, 6, 0, 0);

                for (int i = 1; i <= 12; i++)
                {
                    DateTime endDate = startDate.AddMonths(1);
                    //string htmlText = _prayerPageModel.GeneratePrayers(startDate, endDate, prayerSect, filenames);
                    string htmlText = MakePrayers(prayerModel, startDate, endDate, prayerSection);
                    WriteFile(prayerSection.ToString(), startDate, endDate, htmlText);
                    startDate = endDate;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"GeneratePrayers exception: {ex.StackTrace}");
                WriteErrorFile("GenerateSection", ex);
            }
        }
Ejemplo n.º 2
0
        private void PrayerForDateSection(DateTime date, PrayerSeason.PrayerSect prayerSect)
        {
            //string htmlText = _prayerModel.GeneratePrayers(date, date, prayerSect, true);
            PrayerModel prayerModel = FreshIOC.Container.Resolve <IPrayerModel>() as PrayerModel;
            string      htmlText    = MakePrayers(prayerModel, date, date, prayerSect);

            WriteFile(prayerSect.ToString(), date, date, htmlText);
        }
Ejemplo n.º 3
0
        public string MakePrayers(PrayerModel prayerModel, DateTime startDate, DateTime endDate, PrayerSeason.PrayerSect prayerSect, bool headingsOnly = false)
        {
            Debug.WriteLine($"PrayerModel.MakeTestPrayer( {startDate.ToString()}, {endDate.ToString()}, {prayerSect.ToString()} )");

            string             htmlText  = "";
            DateTime           date      = startDate;
            SortedSet <string> NotFounds = new SortedSet <string>();

            try
            {
                while (date <= endDate)
                {
                    htmlText += (prayerSect == PrayerSeason.PrayerSect.AllSections) ?
                                prayerModel.MakePrayer(date, true, headingsOnly) :
                                prayerModel.MakePrayerSection(date, prayerSect);
                    if (prayerModel.NotFounds.Count > 0)
                    {
                        NotFounds.UnionWith(prayerModel.NotFounds);
                    }

                    date = date.AddHours(12);
                }
            }
            catch (Exception ex)
            {
                htmlText += string.Format($"<p>Error : {ex.Message}<p>on {date.ToString()}");
            }

            if (NotFounds.Count > 0)
            {
                string notFounds = "<big>Not founds:</big><br/>";
                foreach (string filename in NotFounds)
                {
                    notFounds += filename + "<br/>";
                }
                htmlText = notFounds + "<p/>" + htmlText;
            }

            return(htmlText);
        }