void SetValues(MonthlySpecificDatePartOne customDatePartOne, MonthlySpecificDatePartTwo customDatePartTwo, int regenEveryXMonths)
 {
     this.regenEveryXMonths = regenEveryXMonths;
     specificDatePartOne    = customDatePartOne;
     specificDatePartTwo    = customDatePartTwo;
     regenType = MonthlyRegenType.OnCustomDateFormat;
 }
 /// <summary>
 /// Get Custom dates such as Last Saturday of the month with option as to the increment of every x-months.
 /// </summary>
 /// <param name="customDatePartOne">Corresponds to Part of month such as First, Last.</param>
 /// <param name="customDatePartTwo">Corresponds to day of the week to get such as Tuesday or Weekend Day.</param>
 /// <param name="regenEveryXMonths">How many months to skip, such as 2 for every other month.</param>
 /// <returns></returns>
 public RecurrenceValues GetValues(MonthlySpecificDatePartOne customDatePartOne, MonthlySpecificDatePartTwo customDatePartTwo, int regenEveryXMonths)
 {
     this.regenEveryXMonths = regenEveryXMonths;
     specificDatePartOne    = customDatePartOne;
     specificDatePartTwo    = customDatePartTwo;
     regenType = MonthlyRegenType.OnCustomDateFormat;
     return(GetValues());
 }
        /// <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);
        }
Exemple #4
0
 internal void SetMonthlySpecificDatePartTwo(MonthlySpecificDatePartTwo monthlySpecificDatePartTwo)
 {
     this.monthlySpecificDatePartTwo = monthlySpecificDatePartTwo;
 }