Exemplo n.º 1
0
        public List <Onah> CalculateProblemOnahs()
        {
            //Clears the list and gets it ready to accept new problems
            if (this.ProblemOnahList == null)
            {
                this.ProblemOnahList = new List <Onah>();
            }
            else
            {
                this.ProblemOnahList.Clear();
            }

            //A list of Onahs that need to be kept. This first list is worked out from the list of Entries.
            //Problem Onahs are searched for from the date of each entry until the number of months specified in the
            //Property Setting "numberMonthsAheadToWarn"
            this.SetEntryListDependentProblemOnahs();

            //Get the onahs that need to be kept for Kavuahs of yom hachodesh, sirug,
            //and other Kavuahs that are not dependent on the actual entry list
            this.SetIndependentKavuahProblemOnahs();

            //Clean out doubles
            Onah.ClearDoubleOnahs(this.ProblemOnahList);
            this.ProblemOnahList.Sort(Onah.CompareOnahs);

            return(this.ProblemOnahList);
        }
Exemplo n.º 2
0
        private void SetEntryDependentKavuahProblemOnahs(Entry entry, IEnumerable <Entry> otherEntries)
        {
            //Kavuah Haflagah - with or without Maayan Pasuach
            foreach (Kavuah kavuah in this.KavuahList.Where(k =>
                                                            k.KavuahType.In(KavuahType.Haflagah, KavuahType.HaflagaMaayanPasuach) && k.Active))
            {
                Onah kavuahHaflaga = entry.AddDays(kavuah.Number - 1);
                kavuahHaflaga.DayNight = kavuah.DayNight;
                if (!otherEntries.Any(e => e > entry && e < kavuahHaflaga))
                {
                    this.AddProblemOnah(kavuahHaflaga, "קבוע " + kavuah.ToString());
                }
            }

            //Kavuah Dilug Haflagos - from each actual entry.
            foreach (Kavuah kavuah in this.KavuahList.Where(k =>
                                                            k.KavuahType == KavuahType.DilugHaflaga && k.Active))
            {
                Onah kavuahDilugHaflaga = entry.AddDays(entry.Interval + kavuah.Number - 1);
                kavuahDilugHaflaga.DayNight = kavuah.DayNight;
                if (!otherEntries.Any(e => e > entry && e < kavuahDilugHaflaga))
                {
                    this.AddProblemOnah(kavuahDilugHaflaga, "קבוע " + kavuah.ToString() + " ע\"פ ראייה");
                }
            }
        }
Exemplo n.º 3
0
        private void SetOnahBeinenisProblemOnahs(Entry entry, IEnumerable <Entry> otherEntries)
        {
            Kavuah cancelKavuah =
                this.KavuahList.LastOrDefault(k => k.Active && k.CancelsOnahBeinanis);

            //Yom Hachodesh
            this.AddOnahBeinunisProblem(entry.AddMonths(1), "יום החודש", cancelKavuah);

            //Day Thirty
            Onah dayThirty = entry.AddDays(29);

            if (!otherEntries.Any(e => e > entry && e < dayThirty))
            {
                this.AddOnahBeinunisProblem(dayThirty, "יום שלושים", cancelKavuah);
            }

            //Day Thirty One
            Onah dayThirtyOne = entry.AddDays(30);

            if (!otherEntries.Any(e => e > entry && e < dayThirtyOne))
            {
                this.AddOnahBeinunisProblem(dayThirtyOne, "יום ל\"א", cancelKavuah);
            }

            //Haflagah
            if (entry.Interval > 1)
            {
                Onah onasHaflagah = entry.AddDays(entry.Interval - 1);
                if (!otherEntries.Any(e => e > entry && e < onasHaflagah))
                {
                    //Note the Haflaga is always just the Onah it occurred on - not 24 hours  -
                    //even according to those that require it for 30, 31 and Yom Hachodesh.
                    this.AddProblemOnah(onasHaflagah,
                                        "יום הפלגה (" + entry.Interval + ")", cancelKavuah);
                }

                //The Ta"z
                if (this.KeepLongerHaflaga)
                {
                    //Go through all earlier entries in the list that have a longer haflaga than this one  -
                    //and they are not kept anyways due to onah Beinonis
                    //and their haflaga was never surpassed by an Entry after them
                    foreach (Entry e in otherEntries.Where(en =>
                                                           en <entry &&
                                                               en.Interval> entry.Interval &&
                                                           en.Interval != 30 &&
                                                           en.Interval != 31 &&
                                                           !otherEntries.Any(oe => oe > en && oe.Interval > en.Interval)))
                    {
                        Onah nextOne = entry.AddDays(e.Interval - 1);
                        if (!otherEntries.Any(en => en > entry && en < nextOne))
                        {
                            this.AddProblemOnah(nextOne,
                                                "יום הפלגה (" + e.Interval + ") שלא נתבטלה", cancelKavuah);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void AddProblemOnah(Onah onah, string name, Kavuah cancelKavuah = null, bool noOhrZarua = false)
        {
            onah.Name      = name;
            onah.IsIgnored = cancelKavuah != null && cancelKavuah.SettingOnah < onah;
            this.ProblemOnahList.Add(onah);

            if (!noOhrZarua && this.ShowOhrZeruah)
            {
                this.AddProblemOnah(Onah.GetPreviousOnah(onah), "או\"ז של " + name,
                                    cancelKavuah,
                                    noOhrZarua: true);
            }
        }
Exemplo n.º 5
0
        private void AddOnahBeinunisProblem(Onah probOnah, string name, Kavuah cancelKavuah)
        {
            //We don't flag the Ohr Zarua if it's included in Onah Beinonis of 24 hours as Onah Beinonis is stricter.
            this.AddProblemOnah(probOnah, name, cancelKavuah,
                                noOhrZarua: this.OnahBenIs24Hours && probOnah.DayNight == DayNight.Day);

            //If the user wants to keep 24 for the Onah Beinenis
            if (this.OnahBenIs24Hours)
            {
                Onah otherOnah = probOnah.Clone();
                otherOnah.DayNight = otherOnah.DayNight == DayNight.Day ? DayNight.Night : DayNight.Day;
                this.AddProblemOnah(otherOnah, name, cancelKavuah, noOhrZarua: true);
            }
        }
Exemplo n.º 6
0
        public string GetNextOnahText()
        {
            string nextProblemText = "";

            if (this.ProblemOnahList.Count > 0)
            {
                //We need to determine the earliest problem Onah, so we need to do a
                //special sort on the list where the night Onah is before the day one for the same date.
                this.ProblemOnahList.Sort(Onah.CompareOnahs);

                Onah nowProblem  = this.ProblemOnahList.FirstOrDefault(o => (!o.IsIgnored) && Onah.IsSameOnahPeriod(o, this.NowOnah));
                Onah nextProblem = this.ProblemOnahList.FirstOrDefault(o => (!o.IsIgnored) && (Onah.CompareOnahs(o, this.NowOnah) == 1));

                if (nowProblem != null)
                {
                    nextProblemText += "עכשיו הוא " + nowProblem.Name;
                }

                if (nextProblem != null)
                {
                    if (nextProblemText.Length > 0)
                    {
                        nextProblemText += " - ";
                    }
                    nextProblemText += "העונה הבאה בעוד " +
                                       ((nextProblem.DateTime - this.Today).Days + 1).ToString() +
                                       " ימים - בתאריך: " +
                                       nextProblem.DateTime.ToString("dd MMMM yyyy") +
                                       " (" +
                                       nextProblem.HebrewDayNight +
                                       ") שהוא " +
                                       nextProblem.Name;
                }
            }
            return(nextProblemText);
        }
Exemplo n.º 7
0
 private static bool HasSameSettingEntry(Kavuah a, Kavuah b)
 {
     return(a != b &&
            Onah.IsSameOnahPeriod(a.SettingOnah, b.SettingOnah));
 }