Beispiel #1
0
 public bool IsTriggerStart(DateTime currDate)
 {
     if (currDate >= StartDate && currDate < StartDate.AddMilliseconds(TimeListener.OffsetMillisecond))
     {
         PreExcuteDate = StartDate;
         IsEnd         = false;
         return(true);
     }
     return(false);
 }
        private static DateTime SetDateWithChecks(DateTime obj, int year, int month, int day, int?hour, int?minute, int?second, int?millisecond)
        {
            DateTime StartDate;

            if (year == 0)
            {
                StartDate = new DateTime(obj.Year, 1, 1, 0, 0, 0, 0);
            }
            else
            {
                if (DateTime.MaxValue.Year < year)
                {
                    StartDate = new DateTime(DateTime.MinValue.Year, 1, 1, 0, 0, 0, 0);
                }
                else if (DateTime.MinValue.Year > year)
                {
                    StartDate = new DateTime(DateTime.MaxValue.Year, 1, 1, 0, 0, 0, 0);
                }
                else
                {
                    StartDate = new DateTime(year, 1, 1, 0, 0, 0, 0);
                }
            }

            if (month == 0)
            {
                StartDate = StartDate.AddMonths(obj.Month - 1);
            }
            else
            {
                StartDate = StartDate.AddMonths(month - 1);
            }
            if (day == 0)
            {
                StartDate = StartDate.AddDays(obj.Day - 1);
            }
            else
            {
                StartDate = StartDate.AddDays(day - 1);
            }
            if (!hour.HasValue)
            {
                StartDate = StartDate.AddHours(obj.Hour);
            }
            else
            {
                StartDate = StartDate.AddHours(hour.Value);
            }
            if (!minute.HasValue)
            {
                StartDate = StartDate.AddMinutes(obj.Minute);
            }
            else
            {
                StartDate = StartDate.AddMinutes(minute.Value);
            }
            if (!second.HasValue)
            {
                StartDate = StartDate.AddSeconds(obj.Second);
            }
            else
            {
                StartDate = StartDate.AddSeconds(second.Value);
            }
            if (!millisecond.HasValue)
            {
                StartDate = StartDate.AddMilliseconds(obj.Millisecond);
            }
            else
            {
                StartDate = StartDate.AddMilliseconds(millisecond.Value);
            }

            return(StartDate);
        }