Beispiel #1
0
        private static void createReservationObjectsStopAfter(List <ReservationObject> list, string[] rules, DateTime ds, string sOccurences, DateTime end)
        {
            int      stopAfter  = int.Parse(rules[3]);
            int      count      = 0;
            int      occurences = int.Parse(sOccurences);
            DateTime tempDs     = ds;
            DateTime tempDe     = new DateTime(ds.Year, ds.Month, ds.Day, end.Hour, end.Minute, 0);

            do
            {
                if (count < stopAfter)
                {
                    ReservationObject r = new ReservationObject();
                    r.DateStart = tempDs.ToString("yyyy-MM-dd HH:mm");
                    r.DateEnd   = tempDe.ToString("yyyy-MM-dd HH:mm");
                    list.Add(r);
                    count++;

                    tempDs = tempDs.AddDays(occurences);
                    tempDe = tempDe.AddDays(occurences);
                }
                else
                {
                    break;
                }
            }while (tempDe <= end);
        }
Beispiel #2
0
        private static void createWeeklyReservationOnjectsWithoutEnd(List <ReservationObject> list, DateTime ds, DateTime de, List <DayOfWeek> dow, int daysToAdd, DateTime end)
        {
            DateTime tempDs = ds;
            DateTime tempDe = ds.AddDays(daysToAdd);

            do
            {
                int numberOfDays = tempDe.Subtract(tempDs).Days + 1;
                var dates        = Enumerable.Range(0, numberOfDays)
                                   .Select(i => tempDs.AddDays(i))
                                   .Where(d => dow.ToArray().Contains(d.DayOfWeek));

                foreach (DateTime d in dates)
                {
                    DateTime d_start = new DateTime(d.Year, d.Month, d.Day, ds.Hour, ds.Minute, 0);
                    DateTime d_end   = new DateTime(d.Year, d.Month, d.Day, de.Hour, de.Minute, 0);

                    if (d_end <= end)
                    {
                        ReservationObject r = new ReservationObject();
                        r.DateStart = d_start.ToString("yyyy-MM-dd HH:mm");
                        r.DateEnd   = d_end.ToString("yyyy-MM-dd HH:mm");
                        list.Add(r);
                    }
                    else
                    {
                        break;
                    }
                }

                tempDs = tempDs.AddDays(daysToAdd); // tempDe;
                tempDe = tempDe.AddDays(daysToAdd);
            }while (tempDs <= end);
        }
Beispiel #3
0
        private static void createWeeklyReservationObjectsStopOn(List <ReservationObject> list, string[] rules, DateTime ds, DateTime de, List <DayOfWeek> dow, int daysToAdd)
        {
            DateTime stopDate = DateTime.ParseExact(rules[3], "yyyy-MM-dd HH:mm", System.Globalization.CultureInfo.InvariantCulture);
            DateTime tempDs   = ds;
            DateTime tempDe   = ds.AddDays(daysToAdd);

            do
            {
                if (tempDs < stopDate)
                {
                    int numberOfDays = tempDe.Subtract(tempDs).Days + 1;
                    var dates        = Enumerable.Range(0, numberOfDays)
                                       .Select(i => tempDs.AddDays(i))
                                       .Where(d => dow.ToArray().Contains(d.DayOfWeek));

                    foreach (DateTime d in dates)
                    {
                        DateTime d_start = new DateTime(d.Year, d.Month, d.Day, ds.Hour, ds.Minute, 0);
                        DateTime d_end   = new DateTime(d.Year, d.Month, d.Day, de.Hour, de.Minute, 0);

                        ReservationObject r = new ReservationObject();
                        r.DateStart = d_start.ToString("yyyy-MM-dd HH:mm");
                        r.DateEnd   = d_end.ToString("yyyy-MM-dd HH:mm");
                        list.Add(r);
                    }

                    tempDs = tempDs.AddDays(daysToAdd);
                    tempDe = tempDe.AddDays(daysToAdd);
                }
                else
                {
                    break;
                }
            }while (tempDs <= de);
        }
Beispiel #4
0
        private static void createMonthlyReservationObjectWithoutEnd(List <ReservationObject> list, DateTime de, int occurences, DateTime tempDs)
        {
            do
            {
                DateTime          t_start = new DateTime(tempDs.Year, tempDs.Month, tempDs.Day, tempDs.Hour, tempDs.Minute, 0);
                DateTime          t_end   = new DateTime(tempDs.Year, tempDs.Month, tempDs.Day, de.Hour, de.Minute, 0);
                ReservationObject r       = new ReservationObject();
                r.DateStart = t_start.ToString("yyyy-MM-dd HH:mm");
                r.DateEnd   = t_end.ToString("yyyy-MM-dd HH:mm");
                list.Add(r);

                tempDs = tempDs.AddMonths(occurences);
            }while (tempDs <= de);
        }
Beispiel #5
0
        private static void createMonthlyReservationObjectStopOn(List <ReservationObject> list, string[] rules, DateTime de, int occurences, DateTime tempDs)
        {
            DateTime endOn = DateTime.ParseExact(rules[4], "yyyy-MM-dd HH:mm", System.Globalization.CultureInfo.InvariantCulture);

            do
            {
                DateTime          t_start = new DateTime(tempDs.Year, tempDs.Month, tempDs.Day, tempDs.Hour, tempDs.Minute, 0);
                DateTime          t_end   = new DateTime(tempDs.Year, tempDs.Month, tempDs.Day, de.Hour, de.Minute, 0);
                ReservationObject r       = new ReservationObject();
                r.DateStart = t_start.ToString("yyyy-MM-dd HH:mm");
                r.DateEnd   = t_end.ToString("yyyy-MM-dd HH:mm");
                list.Add(r);
                tempDs = tempDs.AddMonths(occurences);
            }while (tempDs <= endOn);
        }
Beispiel #6
0
        private static void createReservationObjectsWithoutEndDate(List <ReservationObject> list, DateTime ds, string sOccurences, DateTime end)
        {
            int      occurences = int.Parse(sOccurences);
            DateTime tempDs     = ds;
            DateTime tempDe     = new DateTime(ds.Year, ds.Month, ds.Day, end.Hour, end.Minute, 0);

            do
            {
                ReservationObject r = new ReservationObject();
                r.DateStart = tempDs.ToString("yyyy-MM-dd HH:mm");
                r.DateEnd   = tempDe.ToString("yyyy-MM-dd HH:mm");
                list.Add(r);

                tempDs = tempDs.AddDays(occurences);
                tempDe = tempDe.AddDays(occurences);
            }while (tempDe <= end);
        }
Beispiel #7
0
        private static void createReservationObjectsStopOn(List <ReservationObject> list, string[] rules, DateTime ds, string sOccurences, DateTime end)
        {
            DateTime stopDate   = DateTime.ParseExact(rules[3], "yyyy-MM-dd HH:mm", System.Globalization.CultureInfo.InvariantCulture);
            int      occurences = int.Parse(sOccurences);
            DateTime tempDs     = ds;
            DateTime tempDe     = new DateTime(ds.Year, ds.Month, ds.Day, end.Hour, end.Minute, 0);

            do
            {
                ReservationObject r = new ReservationObject();
                r.DateStart = tempDs.ToString("yyyy-MM-dd HH:mm");
                r.DateEnd   = tempDe.ToString("yyyy-MM-dd HH:mm");
                list.Add(r);

                tempDs = tempDs.AddDays(occurences);
                tempDe = tempDe.AddDays(occurences);
            }while (tempDe <= stopDate);
        }
Beispiel #8
0
        private static void createWeeklyReservationObjectsStopAfter(List <ReservationObject> list, string[] rules, DateTime ds, DateTime de, List <DayOfWeek> dow, int daysToAdd)
        {
            int stopAfter = int.Parse(rules[4]);
            int count     = 0;

            DateTime tempDs = ds;
            DateTime tempDe = ds.AddDays(daysToAdd);

            do
            {
                if (count < stopAfter)
                {
                    int numberOfDays = tempDe.Subtract(tempDs).Days + 1;
                    var dates        = Enumerable.Range(0, numberOfDays)
                                       .Select(i => tempDs.AddDays(i))
                                       .Where(d => dow.ToArray().Contains(d.DayOfWeek));

                    foreach (DateTime d in dates)
                    {
                        DateTime d_start = new DateTime(d.Year, d.Month, d.Day, ds.Hour, ds.Minute, 0);
                        DateTime d_end   = new DateTime(d.Year, d.Month, d.Day, de.Hour, de.Minute, 0);

                        ReservationObject r = new ReservationObject();
                        r.DateStart = d_start.ToString("yyyy-MM-dd HH:mm");
                        r.DateEnd   = d_end.ToString("yyyy-MM-dd HH:mm");
                        list.Add(r);
                    }

                    tempDs = tempDs.AddDays(daysToAdd);
                    tempDe = tempDe.AddDays(daysToAdd);
                    count++;
                }
                else
                {
                    break;
                }
            }while (tempDs <= tempDe);
        }
Beispiel #9
0
        private static void createMonthlyReservationObjectEndAfter(List <ReservationObject> list, string[] rules, DateTime de, int occurences, DateTime tempDs)
        {
            int stopAfter = int.Parse(rules[4]);
            int count     = 0;

            do
            {
                if (count < stopAfter)
                {
                    DateTime          t_start = new DateTime(tempDs.Year, tempDs.Month, tempDs.Day, tempDs.Hour, tempDs.Minute, 0);
                    DateTime          t_end   = new DateTime(tempDs.Year, tempDs.Month, tempDs.Day, de.Hour, de.Minute, 0);
                    ReservationObject r       = new ReservationObject();
                    r.DateStart = t_start.ToString("yyyy-MM-dd HH:mm");
                    r.DateEnd   = t_end.ToString("yyyy-MM-dd HH:mm");
                    list.Add(r);
                    count++;
                    tempDs = tempDs.AddMonths(occurences);
                }
                else
                {
                    break;
                }
            }while (tempDs <= de);
        }