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;
        }
示例#2
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;
        }