Example #1
0
        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        public override object Clone()
        {
            DateCondition condition = base.Clone() as DateCondition;

            condition.compareType = this.compareType;
            return(condition);
        }
Example #2
0
        bool CheckCondition(int expected, IActualValue actualValue)
        {
            if (this.IgnoreBlank && (actualValue.GetValue() == null))
            {
                return(true);
            }
            object obj2 = actualValue.GetValue(NumberFormatType.DateTime);

            if (obj2 is DateTime)
            {
                if (this.expectTypeId != 0)
                {
                    if (this.expectTypeId == 1)
                    {
                        int?nullable3 = base.GetExpectedInt(null, 0, 0);
                        if (nullable3.HasValue)
                        {
                            return(this.IsEqualsYear(nullable3.Value, (DateTime)obj2));
                        }
                    }
                    else if (this.expectTypeId == 2)
                    {
                        int?nullable4 = base.GetExpectedInt(null, 0, 0);
                        if (nullable4.HasValue)
                        {
                            return(this.IsEqualsQuarter(nullable4.Value, (DateTime)obj2));
                        }
                    }
                    else if (this.expectTypeId == 3)
                    {
                        int?nullable5 = base.GetExpectedInt(null, 0, 0);
                        if (nullable5.HasValue)
                        {
                            return(this.IsEqualsMonth(nullable5.Value, (DateTime)obj2));
                        }
                    }
                    else if (this.expectTypeId == 4)
                    {
                        int?nullable6 = base.GetExpectedInt(null, 0, 0);
                        if (nullable6.HasValue)
                        {
                            return(this.IsEqualsWeek(nullable6.Value, (DateTime)obj2));
                        }
                    }
                    else if (this.expectTypeId == 5)
                    {
                        int?nullable7 = base.GetExpectedInt(null, 0, 0);
                        if (nullable7.HasValue)
                        {
                            return(this.IsEqualsDay(nullable7.Value, (DateTime)obj2));
                        }
                    }
                }
                else
                {
                    DateTime?nullable  = null;
                    DateTime?nullable2 = null;
                    switch (((DateOccurringType)expected))
                    {
                    case DateOccurringType.Today:
                    {
                        DateTime time4 = DateTime.Now;
                        nullable  = new DateTime(time4.Year, time4.Month, time4.Day, 0, 0, 0);
                        nullable2 = new DateTime(time4.Year, time4.Month, time4.Day, 0x17, 0x3b, 0x3b);
                        break;
                    }

                    case DateOccurringType.Yesterday:
                    {
                        DateTime time3 = DateTime.Now;
                        TimeSpan span2 = new TimeSpan(1, 0, 0, 0);
                        time3    -= span2;
                        nullable  = new DateTime(time3.Year, time3.Month, time3.Day, 0, 0, 0);
                        nullable2 = new DateTime(time3.Year, time3.Month, time3.Day, 0x17, 0x3b, 0x3b);
                        break;
                    }

                    case DateOccurringType.Tomorrow:
                    {
                        DateTime time5 = DateTime.Now;
                        TimeSpan span3 = new TimeSpan(1, 0, 0, 0);
                        time5    += span3;
                        nullable  = new DateTime(time5.Year, time5.Month, time5.Day, 0, 0, 0);
                        nullable2 = new DateTime(time5.Year, time5.Month, time5.Day, 0x17, 0x3b, 0x3b);
                        break;
                    }

                    case DateOccurringType.Last7Days:
                    {
                        DateTime time  = DateTime.Now;
                        TimeSpan span  = new TimeSpan(6, 0, 0, 0);
                        DateTime time2 = time - span;
                        nullable  = new DateTime(time2.Year, time2.Month, time2.Day, 0, 0, 0);
                        nullable2 = new DateTime(time.Year, time.Month, time.Day, 0x17, 0x3b, 0x3b);
                        break;
                    }

                    case DateOccurringType.ThisMonth:
                    {
                        DateTime time21 = DateTime.Now;
                        TimeSpan span8  = new TimeSpan(time21.Day - 1, 0, 0, 0);
                        DateTime time22 = time21 - span8;
                        DateTime time24 = time22.AddMonths(1).AddDays(-1.0);
                        nullable  = new DateTime(time22.Year, time22.Month, time22.Day, 0, 0, 0);
                        nullable2 = new DateTime(time24.Year, time24.Month, time24.Day, 0x17, 0x3b, 0x3b);
                        break;
                    }

                    case DateOccurringType.LastMonth:
                    {
                        DateTime time17 = DateTime.Now;
                        TimeSpan span7  = new TimeSpan(time17.Day - 1, 0, 0, 0);
                        DateTime time18 = time17 - span7;
                        DateTime time19 = time18.AddMonths(-1);
                        DateTime time20 = time18.AddDays(-1.0);
                        nullable  = new DateTime(time19.Year, time19.Month, time19.Day, 0, 0, 0);
                        nullable2 = new DateTime(time20.Year, time20.Month, time20.Day, 0x17, 0x3b, 0x3b);
                        break;
                    }

                    case DateOccurringType.NextMonth:
                    {
                        DateTime time25 = DateTime.Now;
                        TimeSpan span9  = new TimeSpan(time25.Day - 1, 0, 0, 0);
                        DateTime time27 = (time25 - span9).AddMonths(1);
                        DateTime time29 = time27.AddMonths(1).AddDays(-1.0);
                        nullable  = new DateTime(time27.Year, time27.Month, time27.Day, 0, 0, 0);
                        nullable2 = new DateTime(time29.Year, time29.Month, time29.Day, 0x17, 0x3b, 0x3b);
                        break;
                    }

                    case DateOccurringType.ThisWeek:
                    {
                        DateTime time10 = DateTime.Now;
                        TimeSpan span5  = new TimeSpan((int)time10.DayOfWeek, 0, 0, 0);
                        DateTime time11 = time10 - span5;
                        DateTime time12 = time11 + new TimeSpan(6, 0, 0, 0);
                        nullable  = new DateTime(time11.Year, time11.Month, time11.Day, 0, 0, 0);
                        nullable2 = new DateTime(time12.Year, time12.Month, time12.Day, 0x17, 0x3b, 0x3b);
                        break;
                    }

                    case DateOccurringType.LastWeek:
                    {
                        DateTime time6 = DateTime.Now;
                        TimeSpan span4 = new TimeSpan((int)time6.DayOfWeek, 0, 0, 0);
                        DateTime time7 = time6 - span4;
                        DateTime time8 = time7 - new TimeSpan(7, 0, 0, 0);
                        DateTime time9 = time8 + new TimeSpan(6, 0, 0, 0);
                        nullable  = new DateTime(time8.Year, time8.Month, time8.Day, 0, 0, 0);
                        nullable2 = new DateTime(time9.Year, time9.Month, time9.Day, 0x17, 0x3b, 0x3b);
                        break;
                    }

                    case DateOccurringType.NextWeek:
                    {
                        DateTime time13 = DateTime.Now;
                        TimeSpan span6  = new TimeSpan((int)time13.DayOfWeek, 0, 0, 0);
                        DateTime time14 = time13 - span6;
                        DateTime time15 = time14 + new TimeSpan(7, 0, 0, 0);
                        DateTime time16 = time15 + new TimeSpan(6, 0, 0, 0);
                        nullable  = new DateTime(time15.Year, time15.Month, time15.Day, 0, 0, 0);
                        nullable2 = new DateTime(time16.Year, time16.Month, time16.Day, 0x17, 0x3b, 0x3b);
                        break;
                    }
                    }
                    if (nullable.HasValue && nullable2.HasValue)
                    {
                        DateCondition     condition  = new DateCondition(DateCompareType.AfterEqualsTo, nullable.Value, null);
                        DateCondition     condition2 = new DateCondition(DateCompareType.BeforeEqualsTo, nullable2.Value, null);
                        RelationCondition condition3 = new RelationCondition(RelationCompareType.And, condition, condition2);
                        return(condition3.Evaluate(null, 0, 0, actualValue));
                    }
                }
            }
            return(false);
        }