static MonthlyRecurrenceSettings GetRecurrenceSettings(string seriesInfo, int modifiedOccurrencesValue, DateTime modifiedEndDate)
        {
            // Get the Recurrence Info object. This makes it easy to work with existing series of date patterns.
            RecurrenceInfo info = MonthlyRecurrenceSettings.GetFriendlyRecurrenceInfo(seriesInfo);

            return(GetRecurrenceSettings(seriesInfo, modifiedOccurrencesValue, info.StartDate, modifiedEndDate));
        }
        static MonthlyRecurrenceSettings GetRecurrenceSettings(string seriesInfo, int modifiedOccurrencesValue, DateTime modifiedStartDate, DateTime modifiedEndDate)
        {
            // Get the Recurrence Info object. This makes it easy to work with existing series of date patterns.
            RecurrenceInfo            info     = MonthlyRecurrenceSettings.GetFriendlyRecurrenceInfo(seriesInfo);
            MonthlyRecurrenceSettings settings = null;

            // Check to see if this is to modify the SeriesInfo and run as endtype for occurrences
            if (modifiedOccurrencesValue != -1)
            {
                info.SetEndDateType(EndDateType.NumberOfOccurrences);
                info.SetNumberOfOccurrences(modifiedOccurrencesValue);
            }
            // Check to see if this is to modify the EndDate and run as endType for EndDate
            if (modifiedEndDate != DateTime.MinValue)
            {
                info.SetEndDateType(EndDateType.SpecificDate);
                info.SetEndDate(modifiedEndDate);
            }

            // Determine the Constructor by the type of End Date.
            // All constructors start with a Start date at a minimum.
            switch (info.EndDateType)
            {
            case EndDateType.NumberOfOccurrences:
                settings = new MonthlyRecurrenceSettings(modifiedStartDate, info.NumberOfOccurrences);
                break;

            case EndDateType.SpecificDate:
                settings = new MonthlyRecurrenceSettings(modifiedStartDate, info.EndDate.Value);
                break;

            case EndDateType.NoEndDate:
                settings = new MonthlyRecurrenceSettings(modifiedStartDate);
                break;
            }

            settings.AdjustmentValue = info.AdjustmentValue;

            // Determine the Type of dates to get, specific, custom, etc.
            switch (info.MonthlyRegenType)
            {
            case MonthlyRegenType.OnSpecificDayOfMonth:
                settings.SetValues(info.MonthlyRegenerateOnSpecificDateDayValue, info.MonthlyRegenEveryXMonths);
                break;

            case MonthlyRegenType.OnCustomDateFormat:
                settings.SetValues(info.MonthlySpecificDatePartOne, info.MonthlySpecificDatePartTwo, info.MonthlyRegenEveryXMonths);
                break;

            case MonthlyRegenType.AfterOccurrenceCompleted:

                break;
            }

            return(settings);
        }
        static DailyRecurrenceSettings GetRecurrenceSettings(string seriesInfo, int modifiedOccurrencesValue, DateTime modifiedStartDate, DateTime modifiedEndDate)
        {
            DailyRecurrenceSettings settings = null;
            RecurrenceInfo          info     = DailyRecurrenceSettings.GetFriendlyRecurrenceInfo(seriesInfo);

            // Check to see if this is to modify the SeriesInfo and run as endtype for occurrences
            if (modifiedOccurrencesValue != -1)
            {
                info.SetEndDateType(EndDateType.NumberOfOccurrences);
                info.SetNumberOfOccurrences(modifiedOccurrencesValue);
            }
            // Check to see if this is to modify the EndDate and run as endType for EndDate
            if (modifiedEndDate != DateTime.MinValue)
            {
                info.SetEndDateType(EndDateType.SpecificDate);
                info.SetEndDate(modifiedEndDate);
            }

            // Determine the Constructor by the type of End Date.
            // All constructors start with a Start date at a minimum.
            switch (info.EndDateType)
            {
            case EndDateType.NumberOfOccurrences:
                settings = new DailyRecurrenceSettings(modifiedStartDate, info.NumberOfOccurrences);
                break;

            case EndDateType.SpecificDate:
                settings = new DailyRecurrenceSettings(modifiedStartDate, info.EndDate.Value);
                break;

            case EndDateType.NoEndDate:
                settings = new DailyRecurrenceSettings(modifiedStartDate);
                break;
            }

            // Determine the Type of dates to get, specific, custom, etc.
            switch (info.DailyRegenType)
            {
            case DailyRegenType.OnEveryXDays:
                settings.SetValues(info.DailyRegenEveryXDays);
                break;

            case DailyRegenType.OnEveryWeekday:
                // This is default. Nothing to set
                break;

            case DailyRegenType.NotSet:

                break;
            }

            return(settings);
        }
Esempio n. 4
0
        /// <summary>
        ///     Get the Series Info in a user-friendly object that can be used as a means to
        ///     populate UI controls.
        /// </summary>
        /// <param name="seriesInfo" type="string">
        ///     <para>
        ///         String of the Series Info.
        ///     </para>
        /// </param>
        /// <returns>
        ///     A RecurrenceGenerator.RecurrenceInfo value...
        /// </returns>
        public static RecurrenceInfo GetFriendlySeriesInfo(string seriesInfo)
        {
            RecurrenceInfo returnValue = null;

            switch (seriesInfo[0])
            {
            case 'Y':                       // Yearly
                returnValue = YearlyRecurrenceSettings.GetFriendlyRecurrenceInfo(seriesInfo);
                break;

            case 'M':                       // Monthly
                returnValue = MonthlyRecurrenceSettings.GetFriendlyRecurrenceInfo(seriesInfo);
                break;

            case 'W':                       // Weekly
                returnValue = WeeklyRecurrenceSettings.GetFriendlyRecurrenceInfo(seriesInfo);
                break;

            case 'D':                       // Daily
                returnValue = DailyRecurrenceSettings.GetFriendlyRecurrenceInfo(seriesInfo);
                break;
            }
            return(returnValue);
        }
Esempio n. 5
0
        /// <summary>
        ///     Get the Series Info in a user-friendly object that can be used as a means to
        ///     populate UI controls.
        /// </summary>
        /// <param name="seriesInfo" type="string">
        ///     <para>
        ///         String of the Series Info.
        ///     </para>
        /// </param>
        /// <returns>
        ///     A RecurrenceGenerator.RecurrenceInfo value...
        /// </returns>
        public static RecurrenceInfo GetFriendlySeriesInfo(string seriesInfo)
        {
            RecurrenceInfo returnValue = null;

            switch (seriesInfo.Substring(0, 1))
            {
            case "Y":       // Yearly
                returnValue = YearlyRecurrenceSettings.GetFriendlyRecurrenceInfo(seriesInfo);
                break;

            case "M":       // Monthly
                returnValue = MonthlyRecurrenceSettings.GetFriendlyRecurrenceInfo(seriesInfo);
                break;

            case "W":       // Weekly
                returnValue = WeeklyRecurrenceSettings.GetFriendlyRecurrenceInfo(seriesInfo);
                break;

            case "D":       // Daily
                returnValue = DailyRecurrenceSettings.GetFriendlyRecurrenceInfo(seriesInfo);
                break;
            }
            return(returnValue);
        }
        /// <summary>
        ///     Get a user-friendly class that is a easy way using Properties that define the Series Info
        /// </summary>
        /// <param name="seriesInfo" type="string">
        ///     <para>
        ///         String of Series Info that was first generated by this MonthlyRecurrenceSettings Class object.
        ///     </para>
        /// </param>
        /// <returns>
        ///     A RecurrenceGenerator.RecurrenceInfo value...
        /// </returns>
        internal static RecurrenceInfo GetFriendlyRecurrenceInfo(string seriesInfo)
        {
            RecurrenceInfo info         = new RecurrenceInfo();
            EndDateType    endType      = EndDateType.NotDefined;
            DateTime       endDateValue = DateTime.MinValue;
            int            noOccurrences;

            // Exit if not a Monthly seriesInfo type
            if (!seriesInfo.StartsWith("M"))
            {
                return(null);
            }

            info.SetSeriesInfo(seriesInfo);
            info.SetRecurrenceType(RecurrenceType.Monthly);
            // FORMATTING DEFINITIONS
            //  Y = Yearly Designator
            //  |       0 = Start Date (8 chars)
            //  |       |        1 = End Date (8 chars)
            //  |       |        |        2 = Number of occurrences (4 chars)
            //  |       |        |        |      3 = Regeneration Type (1 char)
            //  |       |        |        |      |    4 = End date type (1 char)
            //  |       |        |        |      |    |      5 = Regenerate on specific date DAY value (2 chars)
            //  |       |        |        |      |    |      |       6 = Custom Date Part One (1 char)
            //  |       |        |        |      |    |      |       |       7 = Custom Date Part Two (1 char)
            //  |       |        |        |      |    |      |       |       |       8 = Adjustment Value (3 chars)
            //  |       |        |        |      |    |      |       |       |       |     9  Regen Every x months
            //  |       |        |        |      |    |      |       |       |       |     |
            // [0]    [1-8]    [9-16]  [17-20]  [21] [22] [23-24]  [25]    [26]    [27-29] [30-32]
            //  M   01082007  20171231   0000    1     1     00      A      A       000    000
            string startDate = seriesInfo.Substring(1, 8);

            DateTime dtStartDate = new DateTime(int.Parse(startDate.Substring(0, 4)), int.Parse(startDate.Substring(4, 2)), int.Parse(startDate.Substring(6, 2)));
            string   endDate     = seriesInfo.Substring(9, 8);

            string occurrences                 = seriesInfo.Substring(17, 4);
            string monthlyRegenType            = seriesInfo.Substring(21, 1);
            string endDateType                 = seriesInfo.Substring(22, 1);
            string regenOnSpecificDateDayValue = seriesInfo.Substring(23, 2);
            string specDatePartOne             = seriesInfo.Substring(25, 1);
            string specDatePartTwo             = seriesInfo.Substring(26, 1);
            string adjustValue                 = seriesInfo.Substring(27, 3);
            int    regenXMonths                = int.Parse(seriesInfo.Substring(30, 3));

            endType       = (EndDateType)(int.Parse(endDateType));
            noOccurrences = int.Parse(occurrences);

            MonthlySpecificDatePartOne partOne = MonthlySpecificDatePartOne.NotSet;
            MonthlySpecificDatePartTwo partTwo = MonthlySpecificDatePartTwo.NotSet;

            if (specDatePartOne == "Z")
            {
                partOne = MonthlySpecificDatePartOne.NotSet;
            }
            else
            {
                partOne = (MonthlySpecificDatePartOne)(Convert.ToInt32(specDatePartOne[0]) - 65);
            }

            if (specDatePartTwo == "Z")
            {
                partTwo = MonthlySpecificDatePartTwo.NotSet;
            }
            else
            {
                partTwo = (MonthlySpecificDatePartTwo)(Convert.ToInt32(specDatePartTwo[0]) - 65);
            }

            endType       = (EndDateType)(int.Parse(endDateType));
            noOccurrences = int.Parse(occurrences);

            // Get the EndDate before any modifications on it are performed
            if (endType == EndDateType.SpecificDate)
            {
                endDateValue = new DateTime(int.Parse(endDate.Substring(0, 4)), int.Parse(endDate.Substring(4, 2)), int.Parse(endDate.Substring(6, 2)));
            }

            info.SetEndDateType(endType);
            // Determine the Constructor by the type of End Date.
            // All constructors start with a Start date at a minimum.
            switch (endType)
            {
            case EndDateType.NumberOfOccurrences:
                info.SetStartDate(dtStartDate);
                info.SetNumberOfOccurrences(noOccurrences);
                break;

            case EndDateType.SpecificDate:
                info.SetStartDate(dtStartDate);
                info.SetEndDate(endDateValue);
                break;

            case EndDateType.NoEndDate:
                info.SetStartDate(dtStartDate);
                break;
            }

            // Set the adjusted values
            info.SetAdjustmentValue(Convert.ToInt32(adjustValue));
            info.SetMonthlyRegenType((MonthlyRegenType)(int.Parse(monthlyRegenType)));

            // Determine the Type of dates to get, specific, custom, etc.
            switch (info.MonthlyRegenType)
            {
            case MonthlyRegenType.OnSpecificDayOfMonth:
                info.SetMonthlyRegenerateOnSpecificDateDayValue(int.Parse(regenOnSpecificDateDayValue));
                info.SetRegenEveryXMonths(regenXMonths);
                break;

            case MonthlyRegenType.OnCustomDateFormat:
                info.SetMonthlySpecificDatePartOne(partOne);
                info.SetMonthlySpecificDatePartTwo(partTwo);
                info.SetRegenEveryXMonths(regenXMonths);
                break;

            case MonthlyRegenType.AfterOccurrenceCompleted:

                break;
            }

            return(info);
        }
        internal static RecurrenceInfo GetFriendlyRecurrenceInfo(string seriesInfo)
        {
            RecurrenceInfo info         = new RecurrenceInfo();
            EndDateType    endType      = EndDateType.NotDefined;
            DateTime       endDateValue = DateTime.MinValue;
            int            noOccurrences;

            // Exit if not a Daily seriesInfo type
            if (!seriesInfo.StartsWith("D"))
            {
                return(null);
            }

            info.SetRecurrenceType(RecurrenceType.Daily);
            info.SetSeriesInfo(seriesInfo);
            // FORMATTING DEFINITIONS
            //  Y = Yearly Designator
            //  |       0 = Start Date (8 chars)
            //  |       |        1 = End Date (8 chars)
            //  |       |        |        2 = Number of occurrences (4 chars)
            //  |       |        |        |      3 = Regeneration Type (1 char)
            //  |       |        |        |      |    4 = End date type (1 char)
            //  |       |        |        |      |    |      5 = Regen Every x weeks
            //  |       |        |        |      |    |      |
            //  |       |        |        |      |    |      |
            // [0]    [1-8]    [9-16]  [17-20]  [21] [22] [23-25]
            //  D   20071231  20171231   0000    1     1    000
            string startDate = seriesInfo.Substring(1, 8);

            DateTime dtStartDate    = new DateTime(int.Parse(startDate.Substring(0, 4)), int.Parse(startDate.Substring(4, 2)), int.Parse(startDate.Substring(6, 2)));
            string   endDate        = seriesInfo.Substring(9, 8);
            string   occurrences    = seriesInfo.Substring(17, 4);
            string   dailyRegenType = seriesInfo.Substring(21, 1);
            string   endDateType    = seriesInfo.Substring(22, 1);
            int      regenXDays     = int.Parse(seriesInfo.Substring(23, 3));

            endType       = (EndDateType)(int.Parse(endDateType));
            noOccurrences = int.Parse(occurrences);

            endType       = (EndDateType)(int.Parse(endDateType));
            noOccurrences = int.Parse(occurrences);

            // Get the EndDate before any modifications on it are performed
            if (endType == EndDateType.SpecificDate)
            {
                endDateValue = new DateTime(int.Parse(endDate.Substring(0, 4)), int.Parse(endDate.Substring(4, 2)), int.Parse(endDate.Substring(6, 2)));
            }

            info.SetEndDateType(endType);
            // Determine the Constructor by the type of End Date.
            // All constructors start with a Start date at a minimum.
            switch (endType)
            {
            case EndDateType.NumberOfOccurrences:
                info.SetStartDate(dtStartDate);
                info.SetNumberOfOccurrences(noOccurrences);
                break;

            case EndDateType.SpecificDate:
                info.SetStartDate(dtStartDate);
                info.SetEndDate(endDateValue);
                break;

            case EndDateType.NoEndDate:
                info.SetStartDate(dtStartDate);
                break;
            }

            info.SetDailyRegenType((DailyRegenType)(int.Parse(dailyRegenType)));
            // Determine the Type of dates to get, specific, custom, etc.
            switch (info.DailyRegenType)
            {
            case DailyRegenType.OnEveryXDays:
                info.SetDailyRegenEveryXDays(regenXDays);
                break;

            case DailyRegenType.OnEveryWeekday:
                // This is default. Nothing to set
                break;

            case DailyRegenType.NotSet:

                break;
            }

            return(info);
        }
        static DailyRecurrenceSettings GetRecurrenceSettings(string seriesInfo, int modifiedOccurrencesValue, DateTime modifiedEndDate)
        {
            RecurrenceInfo info = DailyRecurrenceSettings.GetFriendlyRecurrenceInfo(seriesInfo);

            return(GetRecurrenceSettings(seriesInfo, modifiedOccurrencesValue, info.StartDate, modifiedEndDate));
        }
        internal static RecurrenceInfo GetFriendlyRecurrenceInfo(string seriesInfo)
        {
            RecurrenceInfo info         = new RecurrenceInfo();
            EndDateType    endType      = EndDateType.NotDefined;
            DateTime       endDateValue = DateTime.MinValue;
            int            noOccurrences;

            // Exit if not a Weekly seriesInfo type
            if (!seriesInfo.StartsWith("W"))
            {
                return(null);
            }

            info.SetSeriesInfo(seriesInfo);
            info.SetRecurrenceType(RecurrenceType.Weekly);

            // FORMATTING DEFINITIONS
            //  Y = Yearly Designator
            //  |       0 = Start Date (8 chars)
            //  |       |        1 = End Date (8 chars)
            //  |       |        |        2 = Number of occurrences (4 chars)
            //  |       |        |        |      3 = Regeneration Type (1 char)
            //  |       |        |        |      |    4 = End date type (1 char)
            //  |       |        |        |      |    |      5 = Regenerate on Sunday
            //  |       |        |        |      |    |      |       6 = Regenerate on Monday
            //  |       |        |        |      |    |      |       |       7 = Regenerate on Tuesday
            //  |       |        |        |      |    |      |       |       |       8 = Regenerate on Wednesday
            //  |       |        |        |      |    |      |       |       |       |      9 = Regenerate on Thursday
            //  |       |        |        |      |    |      |       |       |       |      |      10 = Regenerate on Friday
            //  |       |        |        |      |    |      |       |       |       |      |       |      11 = Regenerate on Saturday
            //  |       |        |        |      |    |      |       |       |       |      |       |      |        12  Regen Every x weeks
            //  |       |        |        |      |    |      |       |       |       |      |       |      |         |
            // [0]    [1-8]    [9-16]  [17-20]  [21] [22]  [23]    [24]    [25]    [26]   [27]     [28]   [29]      [30-32]
            //  W   20071231  20171231   0000    1     1     T       T      F        F      F       F      F        000
            string startDate = seriesInfo.Substring(1, 8);

            DateTime dtStartDate = new DateTime(int.Parse(startDate.Substring(0, 4)), int.Parse(startDate.Substring(4, 2)), int.Parse(startDate.Substring(6, 2)));
            string   endDate     = seriesInfo.Substring(9, 8);
            SelectedDayOfWeekValues selectedDays = new SelectedDayOfWeekValues();
            string occurrences     = seriesInfo.Substring(17, 4);
            string weeklyRegenType = seriesInfo.Substring(21, 1);
            string endDateType     = seriesInfo.Substring(22, 1);
            int    regenXWeeks     = int.Parse(seriesInfo.Substring(30, 3));

            endType       = (EndDateType)(int.Parse(endDateType));
            noOccurrences = int.Parse(occurrences);

            selectedDays.Sunday    = (seriesInfo.Substring(23, 1) == "Y") ? true : false;
            selectedDays.Monday    = (seriesInfo.Substring(24, 1) == "Y") ? true : false;
            selectedDays.Tuesday   = (seriesInfo.Substring(25, 1) == "Y") ? true : false;
            selectedDays.Wednesday = (seriesInfo.Substring(26, 1) == "Y") ? true : false;
            selectedDays.Thursday  = (seriesInfo.Substring(27, 1) == "Y") ? true : false;
            selectedDays.Friday    = (seriesInfo.Substring(28, 1) == "Y") ? true : false;
            selectedDays.Saturday  = (seriesInfo.Substring(29, 1) == "Y") ? true : false;

            endType       = (EndDateType)(int.Parse(endDateType));
            noOccurrences = int.Parse(occurrences);

            // Get the EndDate before any modifications on it are performed
            if (endType == EndDateType.SpecificDate)
            {
                endDateValue = new DateTime(int.Parse(endDate.Substring(0, 4)), int.Parse(endDate.Substring(4, 2)), int.Parse(endDate.Substring(6, 2)));
            }

            info.SetEndDateType(endType);
            // Determine the Constructor by the type of End Date.
            // All constructors start with a Start date at a minimum.
            // Determine the Constructor by the type of End Date.
            // All constructors start with a Start date at a minimum.
            switch (endType)
            {
            case EndDateType.NumberOfOccurrences:
                info.SetStartDate(dtStartDate);
                info.SetNumberOfOccurrences(noOccurrences);
                break;

            case EndDateType.SpecificDate:
                info.SetStartDate(dtStartDate);
                info.SetEndDate(endDateValue);
                break;

            case EndDateType.NoEndDate:
                info.SetStartDate(dtStartDate);
                break;
            }

            info.SetWeeklyRegenType((WeeklyRegenType)(int.Parse(weeklyRegenType)));
            // Determine the Type of dates to get, specific, custom, etc.
            switch (info.WeeklyRegenType)
            {
            case WeeklyRegenType.OnEveryXWeeks:
                info.SetSelectedDayOfWeekValues(selectedDays);
                info.SetRegenEveryXWeeks(regenXWeeks);
                break;

            case WeeklyRegenType.NotSet:

                break;
            }

            return(info);
        }