protected TimeBlockBase(TimeIncrements Increment, DateTime Start, DateTime Stop, int StartId, int StopId)
        {
            if (Stop < Start)
            {
                throw new ArgumentException("Stop Time cannot be greater than Start Time");
            }

            if (StartId.Equals(0) || StopId.Equals(0))
            {
                throw new ArgumentException("Start Id and/or Stop Id cannot be 0");
            }

            this.StartId  = StartId;
            this.StopId   = StopId;
            this.Start    = Start;
            this.Stop     = Stop;
            TimeIncrement = Increment;
            StartInterval = DailyTimeIntervals.GetDailyTimeIntervalFromId(StartId);
            StopInterval  = DailyTimeIntervals.GetDailyTimeIntervalFromId(StopId);

            this.Start = Start.Add(StartInterval.TotalTimeSpan);
            this.Stop  = Stop.Add(StopInterval.TotalTimeSpan);

            Duration = this.Stop - this.Start;
        }
Esempio n. 2
0
        void CreateHourlySegments()
        {
            int HourCounter = 0;
            int TotalHours  = Duration.Hours;

            DateTime Start = this.Start;
            DateTime End   = this.Start;

            while (HourCounter < TotalHours)
            {
                if (HourCounter > 0)
                {
                    Start = Start.AddHours(1);
                }
                End = End.AddHours(1);

                StartIntervalId = DailyTimeIntervals.GetTimeIntervalFromHourMinute(Start.Hour, Start.Minute).Id;
                EndIntervalId   = DailyTimeIntervals.GetTimeIntervalFromHourMinute(End.Hour, End.Minute).Id;

                Segments.Add(new TimeSegment(Start, End, StartIntervalId, EndIntervalId));
                HourCounter++;
            }
        }
Esempio n. 3
0
        public TimeSegment(DateTime Start, DateTime Stop, int StartTimeId, int StopTimeId)
        {
            this.StartTimeId = StartTimeId;
            this.StopTimeId  = StopTimeId;

            StartTimeInterval = DailyTimeIntervals.GetDailyTimeIntervalFromId(StartTimeId);
            StopTimeInterval  = DailyTimeIntervals.GetDailyTimeIntervalFromId(StopTimeId);

            this.Start = Start.Add(StartTimeInterval.TotalTimeSpan);
            this.Stop  = Stop.Add(StopTimeInterval.TotalTimeSpan);

            if (this.Stop < this.Start)
            {
                throw new ArgumentException("Stop Time cannot be greater than Start Time");
            }

            if (this.Stop == this.Start)
            {
                throw new ArgumentException("Start Date/Time cannot be the same as Stop Date/Time");
            }

            Duration = this.Stop - this.Start;
        }
Esempio n. 4
0
        void CreateQuarterHourSegments()
        {
            int QuarterCounter    = 0;
            int TotalQuarterHours = Duration.Hours * 4;

            DateTime Start = this.Start;
            DateTime End   = this.Start;

            while (QuarterCounter < TotalQuarterHours)
            {
                if (QuarterCounter > 0)
                {
                    Start = Start.AddMinutes(FifteenMinutes);
                }

                End = End.AddMinutes(FifteenMinutes);

                StartIntervalId = DailyTimeIntervals.GetTimeIntervalFromHourMinute(Start.Hour, Start.Minute).Id;
                EndIntervalId   = DailyTimeIntervals.GetTimeIntervalFromHourMinute(End.Hour, End.Minute).Id;

                Segments.Add(new TimeSegment(Start, End, StartIntervalId, EndIntervalId));
                QuarterCounter++;
            }
        }