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); }