public OneDayContemplation GetEmpty()
        {
            OneDayContemplation contemplation = new OneDayContemplation()
            {
                Day = DateTime.Today,
                DayDescription = "",
                Title = "",
                ReadingReference = "",
                ReadingText = "",
                Contemplation1 = "",
                Contemplation2 = "",
                Contemplation3 = "",
                Contemplation4 = "",
                Contemplation5 = "",
                Contemplation6 = "",
                Prayer = ""
            };

            return contemplation;
        }
        public void Save(OneDayContemplation contemplation)
        {
            string xml;

            EnsureDataFolder();

            xml = SerializationHelper.Serialize(contemplation);
            using (var sw = new System.IO.StreamWriter(GetLocalFileName()))
            {
                sw.WriteLine(xml);
            }
        }
Exemplo n.º 3
0
        private List<string> ValidateDay(OneDayContemplation dayContemplation, DayOfWeek expectedDay)
        {
            List<string> issues = new List<string>();
            string dayName = GetDayName(expectedDay);

            if (dayContemplation.Day.DayOfWeek != expectedDay)
                issues.Add(String.Format("{0}: zły dzień tygodnia {1}, a powinien być {0}", dayName, GetDayName(dayContemplation.Day.DayOfWeek)));

            if (dayContemplation.Day.DayOfWeek != expectedDay)
                issues.Add(String.Format("{0}: zła data {1}, a powinino być {2}", dayName, dayContemplation.Day.ToString("dd.MM.yyyy"), Title.SundayDate.AddDays(DiffFromFirstSunday(expectedDay)).ToString("dd.MM.yyyy")));

            if (String.IsNullOrEmpty(dayContemplation.ReadingReference))
                issues.Add(String.Format("{0}: brak odnośnika do czytań", dayName));

            if (String.IsNullOrEmpty(dayContemplation.ReadingText))
                issues.Add(String.Format("{0}: brak tekstu czytań", dayName));

            if (String.IsNullOrEmpty(dayContemplation.Contemplation1) &&
                String.IsNullOrEmpty(dayContemplation.Contemplation2) &&
                String.IsNullOrEmpty(dayContemplation.Contemplation3) &&
                String.IsNullOrEmpty(dayContemplation.Contemplation4) &&
                String.IsNullOrEmpty(dayContemplation.Contemplation5) &&
                String.IsNullOrEmpty(dayContemplation.Contemplation6) )
                issues.Add(String.Format("{0}: nie ma żadnego rozważania", dayName));

            if (String.IsNullOrEmpty(dayContemplation.Prayer))
                issues.Add(String.Format("{0}: brak modlitwy", dayName));

            return issues;
        }
Exemplo n.º 4
0
        private void SendDayPost(OneDayContemplation oneDay)
        {
            string dayName = Localization.Date2PlDayName(oneDay.Day);
            OnNotification("Wysyłam " + dayName);

            string postText = CreatePostText(oneDay);

            onJestProxy.SendPost(Properties.Settings.Default.OnJestUser, Properties.Settings.Default.OnJestPwd, oneDay.Title,
                Properties.Settings.Default.OnJestPostCategory, oneDay.Day, postText);
        }
Exemplo n.º 5
0
        private string CreatePostText(OneDayContemplation contemplation)
        {
            // replace
            string key;
            string dayKey = Properties.Settings.Default.OnJestPostOneDayKey;
            string postText = ReadTemplate(Properties.Settings.Default.OnJestPostTemplate);

            // [sunday_date],
            HtmlReplaceAllText(ref postText, MakeKey(dayKey, Properties.Settings.Default.DayDateKey), Localization.Date2PlStr(contemplation.Day));
            // [sunday_name]
            HtmlReplaceAllText(ref postText, MakeKey(dayKey, Properties.Settings.Default.DayNameKey), Localization.Date2PlDayName(contemplation.Day));
            // sunday_description
            HtmlReplaceAllText(ref postText, MakeKey(dayKey, Properties.Settings.Default.DayDescriptionKey), contemplation.DayDescription);
            // [sunday_title]
            HtmlReplaceAllText(ref postText, MakeKey(dayKey, Properties.Settings.Default.DayTitleKey), contemplation.Title);
            //[sunday_reading_ref]
            HtmlReplaceAllText(ref postText, MakeKey(dayKey, Properties.Settings.Default.DayReadingRefKey), contemplation.ReadingReference);
            //[sunday_contemplation1]
            key = MakeKey(dayKey, Properties.Settings.Default.DayContemplation1Key);
            if (String.IsNullOrEmpty(contemplation.Contemplation1))
                HtmlRemoveTagWithText(ref postText, key);
            else
                HtmlReplaceAllText(ref postText, key, contemplation.Contemplation1);
            //[sunday_contemplation2]
            key = MakeKey(dayKey, Properties.Settings.Default.DayContemplation2Key);
            if (String.IsNullOrEmpty(contemplation.Contemplation2))
                HtmlRemoveTagWithText(ref postText, key);
            else
                HtmlReplaceAllText(ref postText, key, contemplation.Contemplation2);
            //[sunday_contemplation3]
            key = MakeKey(dayKey, Properties.Settings.Default.DayContemplation3Key);
            if (String.IsNullOrEmpty(contemplation.Contemplation3))
                HtmlRemoveTagWithText(ref postText, key);
            else
                HtmlReplaceAllText(ref postText, key, contemplation.Contemplation3);
            //[sunday_contemplation4]
            key = MakeKey(dayKey, Properties.Settings.Default.DayContemplation4Key);
            if (String.IsNullOrEmpty(contemplation.Contemplation4))
                HtmlRemoveTagWithText(ref postText, key);
            else
                HtmlReplaceAllText(ref postText, key, contemplation.Contemplation4);
            //[sunday_contemplation5]
            key = MakeKey(dayKey, Properties.Settings.Default.DayContemplation5Key);
            if (String.IsNullOrEmpty(contemplation.Contemplation5))
                HtmlRemoveTagWithText(ref postText, key);
            else
                HtmlReplaceAllText(ref postText, key, contemplation.Contemplation5);
            //[sunday_contemplation6]
            key = MakeKey(dayKey, Properties.Settings.Default.DayContemplation6Key);
            if (String.IsNullOrEmpty(contemplation.Contemplation6))
                HtmlRemoveTagWithText(ref postText, key);
            else
                HtmlReplaceAllText(ref postText, key, contemplation.Contemplation6);
            //[sunday_prayer]
            key = MakeKey(dayKey, Properties.Settings.Default.DayPrayerKey);
            if (String.IsNullOrEmpty(contemplation.Prayer))
                HtmlRemoveTagWithText(ref postText, key);
            else
                HtmlReplaceAllText(ref postText, key, contemplation.Prayer);

            //[sunday_reading_text]
            key = MakeKey(dayKey, Properties.Settings.Default.DayReadingTextKey);
            if (String.IsNullOrEmpty(contemplation.ReadingText))
                HtmlRemoveTagWithText(ref postText, key);
            else
                HtmlReplaceAllText(ref postText, key, contemplation.ReadingText);

            return postText;
        }
Exemplo n.º 6
0
 private void ReplaceDay(OneDayContemplationVM target, OneDayContemplation source)
 {
     target.Day = source.Day;
     target.DayDescription = source.DayDescription;
     target.Title = source.Title;
     target.ReadingReference = source.ReadingReference;
     target.ReadingText = source.ReadingText;
     target.Contemplation1 = source.Contemplation1;
     target.Contemplation2 = source.Contemplation2;
     target.Contemplation3 = source.Contemplation3;
     target.Contemplation4 = source.Contemplation4;
     target.Contemplation5 = source.Contemplation5;
     target.Contemplation6 = source.Contemplation6;
     target.Prayer = source.Prayer;
 }
Exemplo n.º 7
0
 private void AddContemplationToWeek(OneDayContemplation contemplation)
 {
     switch (contemplation.Day.DayOfWeek)
     {
         case DayOfWeek.Sunday: { ReplaceDay(Sunday, contemplation); break; }
         case DayOfWeek.Monday: { ReplaceDay(Monday, contemplation); break; }
         case DayOfWeek.Tuesday: { ReplaceDay(Tuesday, contemplation); break; }
         case DayOfWeek.Wednesday: { ReplaceDay(Wednesday, contemplation); break; }
         case DayOfWeek.Thursday: { ReplaceDay(Thursday, contemplation); break; }
         case DayOfWeek.Friday: { ReplaceDay(Friday, contemplation); break; }
         case DayOfWeek.Saturday: { ReplaceDay(Saturday, contemplation); break; }
     }
 }
Exemplo n.º 8
0
 private void InitiateData()
 {
     contemplation = dataService.Load();
     IsDirty = false;
 }
Exemplo n.º 9
0
 private void ClearContemplation()
 {
     // Message with custom buttons and callback action.
     dialogService.ShowMessage("Wyczyœciæ wszystkie pola ?",
         "Uwaga",
         buttonConfirmText: "Tak", buttonCancelText: "Nie",
         afterHideCallback: (confirmed) =>
         {
             if (confirmed)
             {
                 contemplation = dataService.GetEmpty();
                 // raise property changed for all properties
                 RaisePropertyChanged(() => Day);
                 RaisePropertyChanged(() => DayDescription);
                 RaisePropertyChanged(() => Title);
                 RaisePropertyChanged(() => ReadingReference);
                 RaisePropertyChanged(() => ReadingText);
                 RaisePropertyChanged(() => Contemplation1);
                 RaisePropertyChanged(() => Contemplation2);
                 RaisePropertyChanged(() => Contemplation3);
                 RaisePropertyChanged(() => Contemplation4);
                 RaisePropertyChanged(() => Contemplation5);
                 RaisePropertyChanged(() => Prayer);
             }
             else
             {
                 // User has pressed the "cancel" button
                 // (or has discared the dialog box).
                 // ...
             }
         });
 }
Exemplo n.º 10
0
 public OneDayContemplationVM(OneDayContemplation contemplation)
 {
     this.contemplation = contemplation;
 }