private static ServiceClientModel.YearlyRetentionSchedule GetServiceClientLTRYearlySchedule(YearlyRetentionSchedule psYearly)
        {
            if (psYearly == null)
            {
                return(null);
            }

            ServiceClientModel.YearlyRetentionSchedule serviceClientYearly = new ServiceClientModel.YearlyRetentionSchedule();

            serviceClientYearly.RetentionDuration = new ServiceClientModel.RetentionDuration()
            {
                Count        = psYearly.DurationCountInYears,
                DurationType = ServiceClientModel.RetentionDurationType.Years
            };
            serviceClientYearly.RetentionTimes = GetNullableDateTimeListFromDateTimeList(
                psYearly.RetentionTimes);

            serviceClientYearly.RetentionScheduleFormatType =
                ServiceClientHelpers.GetServiceClientRetentionScheduleFormat(
                    psYearly.RetentionScheduleFormatType);

            if (psYearly.RetentionScheduleFormatType == RetentionScheduleFormat.Daily)
            {
                serviceClientYearly.RetentionScheduleDaily = GetServiceClientLTRDailyRetentionFormat(psYearly.RetentionScheduleDaily);
            }
            else if (psYearly.RetentionScheduleFormatType == RetentionScheduleFormat.Weekly)
            {
                serviceClientYearly.RetentionScheduleWeekly = GetServiceClientLTRWeeklyRetentionFormat(psYearly.RetentionScheduleWeekly);
            }
            serviceClientYearly.MonthsOfYear =
                HelperUtils.EnumListConverter <Month, ServiceClientModel.MonthOfYear>(
                    psYearly.MonthsOfYear).Cast <ServiceClientModel.MonthOfYear?>().ToList();

            return(serviceClientYearly);
        }
Exemplo n.º 2
0
        private static ServiceClientModel.YearlyRetentionSchedule GetServiceClientLTRYearlySchedule(YearlyRetentionSchedule psYearly)
        {
            if (psYearly == null)
            {
                return(null);
            }

            ServiceClientModel.YearlyRetentionSchedule serviceClientYearly = new ServiceClientModel.YearlyRetentionSchedule();

            serviceClientYearly.RetentionDuration = new ServiceClientModel.RetentionDuration()
            {
                Count        = psYearly.DurationCountInYears,
                DurationType = ServiceClientModel.RetentionDurationType.Years
            };
            serviceClientYearly.RetentionTimes = psYearly.RetentionTimes;

            serviceClientYearly.RetentionScheduleFormatType = psYearly.RetentionScheduleFormatType.ToString();
            if (psYearly.RetentionScheduleFormatType == RetentionScheduleFormat.Daily)
            {
                serviceClientYearly.RetentionScheduleDaily = GetServiceClientLTRDailyRetentionFormat(psYearly.RetentionScheduleDaily);
            }
            else if (psYearly.RetentionScheduleFormatType == RetentionScheduleFormat.Weekly)
            {
                serviceClientYearly.RetentionScheduleWeekly = GetServiceClientLTRWeeklyRetentionFormat(psYearly.RetentionScheduleWeekly);
            }
            serviceClientYearly.MonthsOfYear = HelperUtils.GetStringListFromEnumList <Month>(psYearly.MonthsOfYear);

            return(serviceClientYearly);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the LongTermRetentionPolicy class.
 /// </summary>
 /// <param name="dailySchedule">Daily retention schedule of the
 /// protection policy.</param>
 /// <param name="weeklySchedule">Weekly retention schedule of the
 /// protection policy.</param>
 /// <param name="monthlySchedule">Monthly retention schedule of the
 /// protection policy.</param>
 /// <param name="yearlySchedule">Yearly retention schedule of the
 /// protection policy.</param>
 public LongTermRetentionPolicy(DailyRetentionSchedule dailySchedule = default(DailyRetentionSchedule), WeeklyRetentionSchedule weeklySchedule = default(WeeklyRetentionSchedule), MonthlyRetentionSchedule monthlySchedule = default(MonthlyRetentionSchedule), YearlyRetentionSchedule yearlySchedule = default(YearlyRetentionSchedule))
 {
     DailySchedule   = dailySchedule;
     WeeklySchedule  = weeklySchedule;
     MonthlySchedule = monthlySchedule;
     YearlySchedule  = yearlySchedule;
     CustomInit();
 }
Exemplo n.º 4
0
        private static YearlyRetentionSchedule GetPSLTRYearlySchedule(ServiceClientModel.YearlyRetentionSchedule serviceClientYearly)
        {
            if (serviceClientYearly == null)
            {
                return(null);
            }

            YearlyRetentionSchedule psYearly = new YearlyRetentionSchedule();

            psYearly.DurationCountInYears        = GetRetentionDurationInYears(serviceClientYearly.RetentionDuration);
            psYearly.RetentionTimes              = ParseDateTimesToUTC(serviceClientYearly.RetentionTimes);
            psYearly.RetentionScheduleFormatType = (RetentionScheduleFormat)Enum.Parse(typeof(RetentionScheduleFormat),
                                                                                       serviceClientYearly.RetentionScheduleFormatType);
            psYearly.RetentionScheduleDaily  = GetPSLTRDailyRetentionFormat(serviceClientYearly.RetentionScheduleDaily);
            psYearly.RetentionScheduleWeekly = GetPSLTRWeeklyRetentionFormat(serviceClientYearly.RetentionScheduleWeekly);
            psYearly.MonthsOfYear            = HelperUtils.GetEnumListFromStringList <Month>(serviceClientYearly.MonthsOfYear);

            return(psYearly);
        }
Exemplo n.º 5
0
        private static YearlyRetentionSchedule GetPSLTRYearlySchedule(ServiceClientModel.YearlyRetentionSchedule serviceClientYearly)
        {
            if (serviceClientYearly == null)
            {
                return(null);
            }

            YearlyRetentionSchedule psYearly = new YearlyRetentionSchedule();

            psYearly.DurationCountInYears        = GetRetentionDurationInYears(serviceClientYearly.RetentionDuration);
            psYearly.RetentionTimes              = ParseDateTimesToUTC(serviceClientYearly.RetentionTimes);
            psYearly.RetentionScheduleFormatType =
                serviceClientYearly.RetentionScheduleFormatType.ToEnum <RetentionScheduleFormat>();
            psYearly.RetentionScheduleDaily  = GetPSLTRDailyRetentionFormat(serviceClientYearly.RetentionScheduleDaily);
            psYearly.RetentionScheduleWeekly = GetPSLTRWeeklyRetentionFormat(serviceClientYearly.RetentionScheduleWeekly);
            psYearly.MonthsOfYear            =
                HelperUtils.EnumListConverter <ServiceClientModel.MonthOfYear?, Month>(
                    serviceClientYearly.MonthsOfYear);

            return(psYearly);
        }
        private static ServiceClientModel.YearlyRetentionSchedule GetServiceClientLTRYearlySchedule(YearlyRetentionSchedule psYearly)
        {
            if (psYearly == null)
            {
                return null;
            }

            ServiceClientModel.YearlyRetentionSchedule serviceClientYearly = new ServiceClientModel.YearlyRetentionSchedule();

            serviceClientYearly.RetentionDuration = new ServiceClientModel.RetentionDuration()
            {
                Count = psYearly.DurationCountInYears,
                DurationType = ServiceClientModel.RetentionDurationType.Years
            };
            serviceClientYearly.RetentionTimes = psYearly.RetentionTimes;

            serviceClientYearly.RetentionScheduleFormatType = psYearly.RetentionScheduleFormatType.ToString();
            if (psYearly.RetentionScheduleFormatType == RetentionScheduleFormat.Daily)
            {
                serviceClientYearly.RetentionScheduleDaily = GetServiceClientLTRDailyRetentionFormat(psYearly.RetentionScheduleDaily);
            }
            else if (psYearly.RetentionScheduleFormatType == RetentionScheduleFormat.Weekly)
            {
                serviceClientYearly.RetentionScheduleWeekly = GetServiceClientLTRWeeklyRetentionFormat(psYearly.RetentionScheduleWeekly);
            }
            serviceClientYearly.MonthsOfYear = HelperUtils.GetStringListFromEnumList<Month>(psYearly.MonthsOfYear);

            return serviceClientYearly;
        }
Exemplo n.º 7
0
        private LongTermRetentionPolicy GetRandomLTRRetentionPolicy()
        {
            List<DateTime> retTimes = new List<DateTime> { DateTime.UtcNow.AddDays(2) };

            DailyRetentionSchedule dailyRetention = new DailyRetentionSchedule()
            {
                RetentionDuration = new RetentionDuration()
                                    {
                                        Count = 10,
                                        DurationType = RetentionDurationType.Days
                                    },
                RetentionTimes = retTimes
            };

            WeeklyRetentionSchedule weeklyRetention = new WeeklyRetentionSchedule()
            {
                RetentionDuration = new RetentionDuration()
                                    {
                                        Count = 10,
                                        DurationType = RetentionDurationType.Weeks
                                    },
                RetentionTimes = retTimes,
                DaysOfTheWeek = new List<string> { ConfigurationManager.AppSettings["ScheduleRunDay"] }
            };

            YearlyRetentionSchedule yearlyRetention = new YearlyRetentionSchedule()
            {
                RetentionDuration = new RetentionDuration()
                {
                    Count = 10,
                    DurationType = RetentionDurationType.Weeks
                },
                RetentionTimes = retTimes,
                RetentionScheduleFormatType = RetentionScheduleFormat.Daily,
                RetentionScheduleDaily = new DailyRetentionFormat()
                {
                    DaysOfTheMonth = new List<Day>()
                    {
                        new Day()
                        {
                            Date = 1,
                            IsLast = false
                        },
                        new Day()
                        {
                            Date = 2,
                            IsLast = true
                        },
                    }
                }
            };

            LongTermRetentionPolicy retPolicy = new LongTermRetentionPolicy()
            {
                DailySchedule = dailyRetention,
                WeeklySchedule = weeklyRetention,
                YearlySchedule = yearlyRetention
            };

            return retPolicy;
        }