Exemple #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);
            }
        }
Exemple #2
0
        public void GenerateHeadings()
        {
            try
            {
                PrayerModel prayerModel = FreshIOC.Container.Resolve <IPrayerModel>() as PrayerModel;

                DateTime startDate = new DateTime(2018, 12, 15, 6, 0, 0);
                DateTime endDate   = new DateTime(2019, 1, 31, 18, 0, 0);
                string   htmlText  = MakePrayers(prayerModel, startDate, endDate, PrayerSeason.PrayerSect.AllSections, true);

                WriteFile("APrayers", startDate, endDate, htmlText);

                //startDate = new DateTime(2019, 12, 15, 6, 0, 0);
                //endDate = new DateTime(2020, 1, 31, 18, 0, 0);
                //htmlText = MakePrayers(prayerModel, startDate, endDate, PrayerSeason.PrayerSect.AllSections);
                //WriteFile("APrayers", startDate, endDate, htmlText);

                //startDate = new DateTime(2020, 12, 15, 6, 0, 0);
                //endDate = new DateTime(2021, 1, 31, 18, 0, 0);
                //htmlText = MakePrayers(prayerModel, startDate, endDate, PrayerSeason.PrayerSect.AllSections);
                //WriteFile("APrayers", startDate, endDate, htmlText);
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"GeneratePrayers exception: {ex.Message}\n{ex.StackTrace}");
                WriteErrorFile("GeneratePrayers2", ex);
            }
        }
Exemple #3
0
        public void GeneratePrayers()
        {
            try
            {
                int         startYear   = 2019;
                DateTime    startDate   = new DateTime(startYear, 1, 1, 6, 0, 0);
                PrayerModel prayerModel = FreshIOC.Container.Resolve <IPrayerModel>() as PrayerModel;

                for (int i = 1; i <= 2; i++)                   // years
                {
                    for (int j = 1; j <= 12; j++)              // months
                    {
                        DateTime endDate  = startDate.AddMonths(1);
                        string   htmlText = MakePrayers(prayerModel, startDate, endDate, PrayerSeason.PrayerSect.AllSections);

                        WriteFile("Prayers", startDate, endDate, htmlText);
                        startDate = endDate;
                    }
                    startDate = new DateTime(startYear + i, 1, 1, 6, 0, 0);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"GeneratePrayers exception: {ex.StackTrace}");
                WriteErrorFile("GeneratePrayers", ex);
            }
        }
Exemple #4
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);
        }
        public override void Init(object initData)
        {
            Debug.WriteLine("PrayerPageModel.Init()");
            base.Init(initData);

            try
            {
                _prayerModel       = FreshIOC.Container.Resolve <IPrayerModel>() as PrayerModel;
                _dominicanCalender = FreshIOC.Container.Resolve <IDominicanCalender>() as DominicanCalender;

                if (initData is null)
                {
                    return;
                }

                // get date time passed in
                string[] data = (initData as string).Split(' ');
                if (data.Length != 2)
                {
                    return;                                                         // WTF !!!
                }
                string stringDate = data[0] + " " + data[1];
                _date = DateTime.ParseExact(stringDate, "yyyyMMdd HH:mm", CultureInfo.CurrentCulture);

                _fontIncrement   = (Device.Idiom == TargetIdiom.Phone) ? 4 : 8;
                _htmlEndTemplate = PrayerSeason.LoadEndHtml();

                if (Application.Current.Properties.ContainsKey("FontSize"))
                {
                    _fontSize = (int)Application.Current.Properties["FontSize"];
                    if (_fontSize < 1)
                    {
                        _fontSize = 12;
                    }
                }
                else
                {   // first time thru or they haven't updated the font size yet
                    _fontSize = (Device.Idiom == TargetIdiom.Phone) ? 16 : 20;
                }
                _htmlStart = string.Format(_htmlStartTemplate, _fontSize);
                _htmlEnd   = string.Format(_htmlEndTemplate, _fontSize);

                DisplayPrayer(_date);
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"PrayerPageModel.Init() - Error: {ex.Message}\n{ex.InnerException}");
            }
            Debug.WriteLine("PrayerPageModel.Init() - FIN");
        }
Exemple #6
0
        public void SetIOC()
        {
            try
            {
                FreshIOC.Container.Register <IPrayerModel, PrayerModel>();
                FreshIOC.Container.Register <IPrayerPageModel, PrayerPageModel>();
                FreshIOC.Container.Register <IDatabaseModel, DatabaseModel>();
                FreshIOC.Container.Register <IFeastsModel, FeastsModel>();
                FreshIOC.Container.Register <IDominicanCalender, DominicanCalender>();

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


                _desktopFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "DailyPrayers");
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"SetIOC exception: {ex.Message}\n{ex.StackTrace}");
                WriteErrorFile("SetIOC", ex);
            }
        }
Exemple #7
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);
        }