Exemple #1
0
        public override bool Evaluate(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actualObj)
        {
            object expectedValue = base.GetExpected(evaluator, baseRow, baseColumn);
            object actualValue   = actualObj.GetValue();

            return(this.CheckCondition(expectedValue, actualValue));
        }
Exemple #2
0
        /// <summary>
        /// Returns a specified value of the rule if the cell satisfies the condition.
        /// </summary>
        /// <param name="evaluator">The evaluator.</param>
        /// <param name="baseRow">The row index.</param>
        /// <param name="baseColumn">The column index.</param>
        /// <param name="actual">The current value.</param>
        /// <returns>Returns the conditional number value.</returns>
        public override object Evaluate(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actual)
        {
            this.lastActualValue = actual;
            object obj2 = actual.GetValue(baseRow, baseColumn);

            if (obj2 != null)
            {
                double num;
                try
                {
                    num = ConditionValueConverter.ToDouble(obj2);
                }
                catch (InvalidCastException)
                {
                    return(null);
                }
                double?nullable  = base.GetActualValue(evaluator, baseRow, baseColumn, 0, actual);
                double?nullable2 = base.GetActualValue(evaluator, baseRow, baseColumn, 2, actual);
                if (nullable.HasValue && nullable2.HasValue)
                {
                    return(ScaleRule.EvaluateColor(ScaleRule.Evaluate2Scale(num, nullable.Value, nullable2.Value), this.MinimumColor, this.MaximumColor));
                }
            }
            return(null);
        }
Exemple #3
0
 internal override bool IsConditionEvaluateToTrue(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actual)
 {
     if (base.condition != null)
     {
         this.lastActualValue = actual;
         object val = actual.GetValue(baseRow, baseColumn);
         if (val != null)
         {
             double?nullable = ConditionValueConverter.TryDouble(val);
             if (!nullable.HasValue)
             {
                 return(false);
             }
             double currentValue = nullable.Value;
             double?nullable2    = this.CalcuteMinValue(evaluator, baseRow, baseColumn, 0, actual);
             double?nullable3    = this.CalcuteMaxValue(evaluator, baseRow, baseColumn, 2, actual);
             if (nullable2.HasValue && nullable3.HasValue)
             {
                 double?nullable5 = nullable2;
                 double?nullable6 = nullable3;
                 if ((((double)nullable5.GetValueOrDefault()) > ((double)nullable6.GetValueOrDefault())) && (nullable5.HasValue & nullable6.HasValue))
                 {
                     double?nullable4 = nullable3;
                     nullable3 = nullable2;
                     nullable2 = nullable4;
                 }
                 double axisScale = -1.0;
                 this.EvaluateScale(currentValue, nullable2.Value, nullable3.Value, out axisScale);
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #4
0
        /// <summary>
        /// Returns a drawing object based on a specified parameter.
        /// </summary>
        /// <param name="evaluator">The evaluator.</param>
        /// <param name="baseRow">The base row.</param>
        /// <param name="baseColumn">The base column.</param>
        /// <param name="actual">The current value.</param>
        /// <returns>The data bar object.</returns>
        public override object Evaluate(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actual)
        {
            this.lastActualValue = actual;
            object val = actual.GetValue(baseRow, baseColumn);

            if (val != null)
            {
                double?nullable = ConditionValueConverter.TryDouble(val);
                if (!nullable.HasValue)
                {
                    return(null);
                }
                double currentValue = nullable.Value;
                double?nullable2    = this.CalcuteMinValue(evaluator, baseRow, baseColumn, 0, actual);
                double?nullable3    = this.CalcuteMaxValue(evaluator, baseRow, baseColumn, 2, actual);
                if (nullable2.HasValue && nullable3.HasValue)
                {
                    double?nullable5 = nullable2;
                    double?nullable6 = nullable3;
                    if ((((double)nullable5.GetValueOrDefault()) > ((double)nullable6.GetValueOrDefault())) && (nullable5.HasValue & nullable6.HasValue))
                    {
                        double?nullable4 = nullable3;
                        nullable3 = nullable2;
                        nullable2 = nullable4;
                    }
                    double           axisScale = -1.0;
                    double           scale     = this.EvaluateScale(currentValue, nullable2.Value, nullable3.Value, out axisScale);
                    Windows.UI.Color fillColor = ((currentValue < 0.0) && this.useNegativeFillColor) ? this.negativeFillColor : this.color;
                    return(new DataBarDrawingObject(baseRow, baseColumn, fillColor, ((currentValue < 0.0) && this.useNegativeBorderColor) ? this.negativeBorderColor : this.borderColor, this.showBorder, this.axisColor, this.gradient, this.direction, axisScale, scale, this.showBarOnly));
                }
            }
            return(null);
        }
Exemple #5
0
        internal override bool IsConditionEvaluateToTrue(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actual)
        {
            if (base.condition == null)
            {
                return(false);
            }
            this.lastActualValue = actual;
            object obj2 = actual.GetValue(baseRow, baseColumn);

            if (obj2 != null)
            {
                try
                {
                    ConditionValueConverter.ToDouble(obj2);
                }
                catch (InvalidCastException)
                {
                    return(false);
                }
                double?nullable  = base.GetActualValue(evaluator, baseRow, baseColumn, 0, actual);
                double?nullable2 = base.GetActualValue(evaluator, baseRow, baseColumn, 2, actual);
                if (nullable.HasValue && nullable2.HasValue)
                {
                    return(true);
                }
            }
            return(true);
        }
Exemple #6
0
        internal static List <double> GetMinValues(IActualValue actualValue, int rank, ICellRange[] ranges)
        {
            List <double> list = new List <double>();

            if (ranges != null)
            {
                double minValue = double.MinValue;
                int    num2     = 0;
                foreach (ICellRange range in ranges)
                {
                    for (int i = 0; i < range.RowCount; i++)
                    {
                        int row = i + range.Row;
                        for (int j = 0; j < range.ColumnCount; j++)
                        {
                            int    column = j + range.Column;
                            object val    = actualValue.GetValue(row, column);
                            double num7   = 0.0;
                            if (val != null)
                            {
                                double?nullable = ConditionValueConverter.TryDouble(val);
                                if (nullable.HasValue)
                                {
                                    num7 = nullable.Value;
                                    if (num2 < rank)
                                    {
                                        list.Add(num7);
                                        if (num7 > minValue)
                                        {
                                            minValue = num7;
                                        }
                                        num2++;
                                    }
                                    else if (num7 < minValue)
                                    {
                                        list.Remove(minValue);
                                        list.Add(num7);
                                        if (list.IndexOf(minValue) < 0)
                                        {
                                            minValue = num7;
                                            for (int k = 0; k < list.Count; k++)
                                            {
                                                if (list[k] > minValue)
                                                {
                                                    minValue = list[k];
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(list);
        }
Exemple #7
0
        /// <summary>
        /// Evaluates using the specified evaluator.
        /// </summary>
        /// <param name="evaluator">The evaluator.</param>
        /// <param name="baseRow">The base row.</param>
        /// <param name="baseColumn">The base column.</param>
        /// <param name="actualObj">The actual value object.</param>
        /// <returns><c>true</c> if the result is successful; otherwise, <c>false</c>.</returns>
        public override bool Evaluate(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actualObj)
        {
            if ((actualObj.GetValue() == null) && this.IgnoreBlank)
            {
                return(true);
            }
            object obj2 = actualObj.GetValue(NumberFormatType.DateTime);

            if (obj2 is DateTime)
            {
                DateTime?nullable = base.GetExpectedDateTime(evaluator, baseRow, baseColumn);
                if (!nullable.HasValue && this.IgnoreBlank)
                {
                    return(true);
                }
                if (!nullable.HasValue)
                {
                    return(false);
                }
                switch (this.CompareType)
                {
                case DateCompareType.EqualsTo:
                    return(this.IsEquals(nullable.Value, (DateTime)obj2));

                case DateCompareType.NotEqualsTo:
                    return(!this.IsEquals(nullable.Value, (DateTime)obj2));

                case DateCompareType.Before:
                    return(this.IsBefore(nullable.Value, (DateTime)obj2));

                case DateCompareType.BeforeEqualsTo:
                    return(this.IsBefore(nullable.Value, (DateTime)obj2) || this.IsEquals(nullable.Value, (DateTime)obj2));

                case DateCompareType.After:
                    return(this.IsAfter(nullable.Value, (DateTime)obj2));

                case DateCompareType.AfterEqualsTo:
                    return(this.IsAfter(nullable.Value, (DateTime)obj2) || this.IsEquals(nullable.Value, (DateTime)obj2));
                }
            }
            return(false);
        }
Exemple #8
0
        public override bool Evaluate(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actualObj)
        {
            object obj2 = actualObj.GetValue();

            if ((obj2 == null) || obj2.Equals(string.Empty))
            {
                return(this.IgnoreBlank);
            }
            object[] objArray = this.GetValidList(evaluator, baseRow, baseColumn);
            object   obj3     = (obj2 is string) ? new GeneralFormatter().Parse((string)(obj2 as string)) : obj2;
            object   obj4     = obj3;

            if (obj3 is TimeSpan)
            {
                TimeSpan span = (TimeSpan)obj3;
                obj3 = new DateTime(0x76b, 12, 30, span.Hours, span.Minutes, span.Seconds, span.Milliseconds);
            }
            if (objArray != null)
            {
                foreach (object obj5 in objArray)
                {
                    if ((obj5 == null) && (obj2 == null))
                    {
                        return(true);
                    }
                    if (obj5 != null)
                    {
                        if (this.IsNumber(obj5) && this.IsNumber(obj3))
                        {
                            double num;
                            double num2;
                            if ((double.TryParse(obj5.ToString(), (NumberStyles)NumberStyles.Any, (IFormatProvider)CultureInfo.InvariantCulture.NumberFormat, out num) && double.TryParse(obj3.ToString(), (NumberStyles)NumberStyles.Any, (IFormatProvider)CultureInfo.InvariantCulture.NumberFormat, out num2)) && (Math.Round(Math.Abs((double)(num - num2)), 10) <= 1E-10))
                            {
                                return(true);
                            }
                        }
                        else
                        {
                            if (obj5.Equals(obj3))
                            {
                                return(true);
                            }
                            if (((obj5 is TimeSpan) && (obj4 is TimeSpan)) && obj5.Equals(obj4))
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
Exemple #9
0
        /// <summary>
        /// Evaluates using the specified evaluator.
        /// </summary>
        /// <param name="evaluator">The evaluator.</param>
        /// <param name="baseRow">The base row.</param>
        /// <param name="baseColumn">The base column.</param>
        /// <param name="actualObj">The actual value object.</param>
        /// <returns><c>true</c> if the result is successful; otherwise, <c>false</c>.</returns>
        public override bool Evaluate(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actualObj)
        {
            string text;

            if (this.forceValue2Text)
            {
                text = actualObj.GetText();
            }
            else
            {
                object obj2 = actualObj.GetValue();
                if ((obj2 is DateTime) || (obj2 is TimeSpan))
                {
                    return((((this.compareType != TextCompareType.BeginsWith) && (this.compareType != TextCompareType.EndsWith)) && (this.compareType != TextCompareType.Contains)) && (((this.compareType == TextCompareType.DoesNotBeginWith) || (this.compareType == TextCompareType.DoesNotEndWith)) || (this.compareType == TextCompareType.DoesNotContain)));
                }
                text = (obj2 == null) ? actualObj.GetText() : obj2.ToString();
            }
            if (this.IgnoreBlank && string.IsNullOrEmpty(text))
            {
                return(true);
            }
            string expected = base.GetExpectedString(evaluator, baseRow, baseColumn);

            switch (this.CompareType)
            {
            case TextCompareType.EqualsTo:
                return(this.IsEquals(expected, text));

            case TextCompareType.NotEqualsTo:
                return(!this.IsEquals(expected, text));

            case TextCompareType.BeginsWith:
                return(this.IsStartWith(expected, text));

            case TextCompareType.DoesNotBeginWith:
                return(!this.IsStartWith(expected, text));

            case TextCompareType.EndsWith:
                return(this.IsEndWith(expected, text));

            case TextCompareType.DoesNotEndWith:
                return(!this.IsEndWith(expected, text));

            case TextCompareType.Contains:
                return(this.IsContains(expected, text));

            case TextCompareType.DoesNotContain:
                return(!this.IsContains(expected, text));
            }
            return(false);
        }
Exemple #10
0
 internal override bool IsConditionEvaluateToTrue(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actual)
 {
     if (base.condition != null)
     {
         this.lastActualValue = actual;
         object obj2 = actual.GetValue(baseRow, baseColumn);
         if (obj2 != null)
         {
             double num;
             try
             {
                 num = ConditionValueConverter.ToDouble(obj2);
             }
             catch (InvalidCastException)
             {
                 return(false);
             }
             double?nullable  = base.GetActualValue(evaluator, baseRow, baseColumn, 0, actual);
             double?nullable2 = base.GetActualValue(evaluator, baseRow, baseColumn, 1, actual);
             double?nullable3 = base.GetActualValue(evaluator, baseRow, baseColumn, 2, actual);
             if ((nullable.HasValue && nullable3.HasValue) && nullable2.HasValue)
             {
                 double?nullable4 = nullable;
                 double?nullable5 = nullable3;
                 if ((((double)nullable4.GetValueOrDefault()) > ((double)nullable5.GetValueOrDefault())) && (nullable4.HasValue & nullable5.HasValue))
                 {
                     return(false);
                 }
                 double num2      = num;
                 double?nullable6 = nullable;
                 if ((num2 >= ((double)nullable6.GetValueOrDefault())) || !nullable6.HasValue)
                 {
                     double num3      = num;
                     double?nullable7 = nullable3;
                     if ((num3 >= ((double)nullable7.GetValueOrDefault())) && nullable7.HasValue)
                     {
                         return(true);
                     }
                     if ((nullable.Value <= num) && (num <= nullable2.Value))
                     {
                         ScaleRule.Evaluate2Scale(num, nullable.Value, nullable2.Value);
                         return(true);
                     }
                     ScaleRule.Evaluate2Scale(num, nullable2.Value, nullable3.Value);
                 }
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #11
0
 void CalculateLowestValueAndHighestValue(IActualValue actualValue, out double?min, out double?max, ICellRange[] ranges)
 {
     min = 0;
     max = 0;
     if (ranges != null)
     {
         foreach (ICellRange range in ranges)
         {
             for (int i = 0; i < range.RowCount; i++)
             {
                 int row = i + range.Row;
                 for (int j = 0; j < range.ColumnCount; j++)
                 {
                     int    column = j + range.Column;
                     object val    = actualValue.GetValue(row, column);
                     if (val != null)
                     {
                         double?nullable = ConditionValueConverter.TryDouble(val);
                         if (nullable.HasValue)
                         {
                             double num5 = nullable.Value;
                             if (!min.HasValue)
                             {
                                 min = new double?(num5);
                             }
                             if (!max.HasValue)
                             {
                                 max = new double?(num5);
                             }
                             double num7      = num5;
                             double?nullable2 = min;
                             if ((num7 < ((double)nullable2.GetValueOrDefault())) && nullable2.HasValue)
                             {
                                 min = new double?(num5);
                             }
                             double num8      = num5;
                             double?nullable3 = max;
                             if ((num8 > ((double)nullable3.GetValueOrDefault())) && nullable3.HasValue)
                             {
                                 max = new double?(num5);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemple #12
0
        /// <summary>
        /// Returns the specified value of the rule if the cell meets the condition.
        /// </summary>
        /// <param name="evaluator">The evaluator.</param>
        /// <param name="baseRow">The row index.</param>
        /// <param name="baseColumn">The column index.</param>
        /// <param name="actual">The current value.</param>
        /// <returns>Returns the conditional number value.</returns>
        public override object Evaluate(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actual)
        {
            this.lastActualValue = actual;
            object obj2 = actual.GetValue(baseRow, baseColumn);

            if (obj2 != null)
            {
                double num;
                try
                {
                    num = ConditionValueConverter.ToDouble(obj2);
                }
                catch (InvalidCastException)
                {
                    return(null);
                }
                double?nullable  = base.GetActualValue(evaluator, baseRow, baseColumn, 0, actual);
                double?nullable2 = base.GetActualValue(evaluator, baseRow, baseColumn, 1, actual);
                double?nullable3 = base.GetActualValue(evaluator, baseRow, baseColumn, 2, actual);
                if ((nullable.HasValue && nullable3.HasValue) && nullable2.HasValue)
                {
                    double?nullable4 = nullable;
                    double?nullable5 = nullable3;
                    if ((((double)nullable4.GetValueOrDefault()) > ((double)nullable5.GetValueOrDefault())) && (nullable4.HasValue & nullable5.HasValue))
                    {
                        return(null);
                    }
                    double num4      = num;
                    double?nullable6 = nullable;
                    if ((num4 < ((double)nullable6.GetValueOrDefault())) && nullable6.HasValue)
                    {
                        return(this.MinimumColor);
                    }
                    double num5      = num;
                    double?nullable7 = nullable3;
                    if ((num5 >= ((double)nullable7.GetValueOrDefault())) && nullable7.HasValue)
                    {
                        return(this.MaximumColor);
                    }
                    if ((nullable.Value <= num) && (num <= nullable2.Value))
                    {
                        return(ScaleRule.EvaluateColor(ScaleRule.Evaluate2Scale(num, nullable.Value, nullable2.Value), this.MinimumColor, this.MidpointColor));
                    }
                    return(ScaleRule.EvaluateColor(ScaleRule.Evaluate2Scale(num, nullable2.Value, nullable3.Value), this.MidpointColor, this.MaximumColor));
                }
            }
            return(null);
        }
Exemple #13
0
        /// <summary>
        /// Evaluates using the specified evaluator.
        /// </summary>
        /// <param name="evaluator">The evaluator.</param>
        /// <param name="baseRow">The base row.</param>
        /// <param name="baseColumn">The base column.</param>
        /// <param name="actualObj">The actual value object.</param>
        /// <returns><c>true</c> if the result is successful; otherwise, <c>false</c>.</returns>
        public override bool Evaluate(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actualObj)
        {
            object expectedValue = null;
            object actualValue   = actualObj.GetValue();

            if (this.integerValue)
            {
                int?nullable = base.GetExpectedInt(evaluator, baseRow, baseColumn);
                expectedValue = nullable.HasValue ? ((object)((int)nullable.Value)) : null;
            }
            else
            {
                expectedValue = base.GetExpected(evaluator, baseRow, baseColumn);
            }
            return(this.CheckCondition(expectedValue, actualValue));
        }
Exemple #14
0
        /// <summary>
        /// Evaluates using the specified evaluator.
        /// </summary>
        /// <param name="evaluator">The evaluator.</param>
        /// <param name="baseRow">The base row.</param>
        /// <param name="baseColumn">The base column.</param>
        /// <param name="actualObj">The actual value object.</param>
        /// <returns><c>true</c> if the result is successful; otherwise, <c>false</c>.</returns>
        public override bool Evaluate(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actualObj)
        {
            object obj2 = actualObj.GetValue();

            if (obj2 == null)
            {
                return(this.IgnoreBlank);
            }
            if (ConditionValueConverter.IsNumber(obj2))
            {
                obj2 = (double)ConditionValueConverter.TryDouble(obj2).Value;
            }
            bool?nullable = base.GetExpectedBoolean(evaluator, baseRow, baseColumn);

            if (!nullable.HasValue)
            {
                return(false);
            }
            Worksheet     worksheet = evaluator as Worksheet;
            List <object> list      = null;

            if (worksheet != null)
            {
                list = GetDuplicated(actualObj, this.ranges, worksheet.RowCount, worksheet.ColumnCount);
            }
            else
            {
                list = GetDuplicated(actualObj, this.ranges, 0x7fffffff, 0x7fffffff);
            }
            if (list != null)
            {
                if (list.Contains(obj2))
                {
                    return(nullable.Value);
                }
                if (nullable.Value)
                {
                    return(false);
                }
                return(true);
            }
            if (nullable.Value)
            {
                return(false);
            }
            return(true);
        }
Exemple #15
0
        static List <object> GetDuplicated(IActualValue actualValue, ICellRange[] ranges, int maxRowCount = 0x7fffffff, int maxColumnCount = 0x7fffffff)
        {
            Dictionary <object, int> dictionary = new Dictionary <object, int>();

            if (ranges != null)
            {
                foreach (ICellRange range in ranges)
                {
                    int num = Math.Min(range.RowCount, maxRowCount);
                    for (int i = 0; i < num; i++)
                    {
                        int row  = i + range.Row;
                        int num4 = Math.Min(range.ColumnCount, maxColumnCount);
                        for (int j = 0; j < num4; j++)
                        {
                            int    column = j + range.Column;
                            object obj2   = actualValue.GetValue(row, column);
                            if (obj2 != null)
                            {
                                if (ConditionValueConverter.IsNumber(obj2))
                                {
                                    obj2 = (double)ConditionValueConverter.TryDouble(obj2).Value;
                                }
                                int num7 = 0;
                                dictionary.TryGetValue(obj2, out num7);
                                dictionary[obj2] = num7 + 1;
                            }
                        }
                    }
                }
            }
            List <object> list = new List <object>();

            foreach (KeyValuePair <object, int> pair in dictionary)
            {
                if (pair.Value > 1)
                {
                    list.Add(pair.Key);
                }
            }
            return(list);
        }
Exemple #16
0
        /// <summary>
        /// Evaluates using the specified evaluator.
        /// </summary>
        /// <param name="evaluator">The evaluator.</param>
        /// <param name="baseRow">The base row.</param>
        /// <param name="baseColumn">The base column.</param>
        /// <param name="actualObj">The actual value object.</param>
        /// <returns><c>true</c> if the result is successful; otherwise, <c>false</c>.</returns>
        public override bool Evaluate(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actualObj)
        {
            object obj2 = actualObj.GetValue();

            if (obj2 == null)
            {
                return(this.IgnoreBlank);
            }
            int?nullable = base.GetExpectedInt(evaluator, baseRow, baseColumn);

            if (nullable.HasValue)
            {
                List <double> list = null;
                if (this.type == Top10ConditionType.Top)
                {
                    list = GetMaxValues(actualObj, nullable.Value, this.ranges);
                }
                else if (this.type == Top10ConditionType.Bottom)
                {
                    list = GetMinValues(actualObj, nullable.Value, this.ranges);
                }
                if (list != null)
                {
                    double num = 0.0;
                    try
                    {
                        num = ConditionValueConverter.ToDouble(obj2);
                    }
                    catch (InvalidCastException)
                    {
                        return(false);
                    }
                    if (list.Contains(num))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemple #17
0
        /// <summary>
        /// Evaluates using the specified evaluator.
        /// </summary>
        /// <param name="evaluator">The evaluator.</param>
        /// <param name="baseRow">The base row.</param>
        /// <param name="baseColumn">The base column.</param>
        /// <param name="actualObj">The actual value object.</param>
        /// <returns><c>true</c> if the result is successful; otherwise, <c>false</c>.</returns>
        public override bool Evaluate(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actualObj)
        {
            if (this.customValueType == CustomValueType.Formula)
            {
                object val = base.GetExpected(evaluator, baseRow, baseColumn);
                if (this.IgnoreBlank && (val == null))
                {
                    return(true);
                }
                bool?nullable = ConditionValueConverter.TryBool(val);
                if (!nullable.HasValue)
                {
                    return(false);
                }
                return(nullable.Value);
            }
            object objA = actualObj.GetValue();

            switch (this.customValueType)
            {
            case CustomValueType.Empty:
                return((objA == null) || object.Equals(objA, string.Empty));

            case CustomValueType.NonEmpty:
                if (objA == null)
                {
                    return(false);
                }
                return(!object.Equals(objA, string.Empty));

            case CustomValueType.Error:
                return(evaluator.IsCalcError(objA));

            case CustomValueType.NonError:
                return(!evaluator.IsCalcError(objA));
            }
            return(false);
        }
Exemple #18
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);
        }
Exemple #19
0
        /// <summary>
        /// Evaluates using the specified evaluator.
        /// </summary>
        /// <param name="evaluator">The evaluator.</param>
        /// <param name="baseRow">The base row.</param>
        /// <param name="baseColumn">The base column.</param>
        /// <param name="actualObj">The actual value object.</param>
        /// <returns><c>true</c> if the result is successful; otherwise, <c>false</c>.</returns>
        public override bool Evaluate(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actualObj)
        {
            object obj2 = actualObj.GetValue();

            if (this.IgnoreBlank && (obj2 == null))
            {
                return(true);
            }
            this.RebuildFormula(evaluator);
            double?nullable  = base.GetExpectedDouble(evaluator, baseRow, baseColumn);
            double?nullable2 = null;
            object val       = (this.stdValueObject != null) ? this.stdValueObject.GetValue(evaluator, baseRow, baseColumn) : null;

            if (val != null)
            {
                nullable2 = ConditionValueConverter.TryDouble(val);
            }
            if (ConditionValueConverter.IsNumber(obj2))
            {
                double num = ConditionValueConverter.ToDouble(obj2);
                if (nullable.HasValue)
                {
                    switch (this.type)
                    {
                    case AverageConditionType.Above:
                        return(num > nullable.Value);

                    case AverageConditionType.Below:
                        return(num < nullable.Value);

                    case AverageConditionType.EqualOrAbove:
                        return(num >= nullable.Value);

                    case AverageConditionType.EqualOrBelow:
                        return(num <= nullable.Value);

                    case AverageConditionType.Above1StdDev:
                    {
                        this.stdValueObject.GetValue(evaluator, baseRow, baseColumn);
                        if (!nullable2.HasValue)
                        {
                            return(false);
                        }
                        double num2      = num;
                        double?nullable3 = nullable;
                        double num3      = nullable2.Value;
                        double?nullable5 = nullable3.HasValue ? new double?(((double)nullable3.GetValueOrDefault()) + num3) : null;
                        if (num2 <= ((double)nullable5.GetValueOrDefault()))
                        {
                            return(false);
                        }
                        return(nullable5.HasValue);
                    }

                    case AverageConditionType.Below1StdDev:
                    {
                        if (!nullable2.HasValue)
                        {
                            return(false);
                        }
                        double num4      = num;
                        double?nullable6 = nullable;
                        double num5      = nullable2.Value;
                        double?nullable8 = nullable6.HasValue ? new double?(((double)nullable6.GetValueOrDefault()) - num5) : null;
                        if (num4 >= ((double)nullable8.GetValueOrDefault()))
                        {
                            return(false);
                        }
                        return(nullable8.HasValue);
                    }

                    case AverageConditionType.Above2StdDev:
                    {
                        if (!nullable2.HasValue)
                        {
                            return(false);
                        }
                        double num6       = num;
                        double?nullable9  = nullable;
                        double num7       = 2.0 * nullable2.Value;
                        double?nullable11 = nullable9.HasValue ? new double?(((double)nullable9.GetValueOrDefault()) + num7) : null;
                        if (num6 <= ((double)nullable11.GetValueOrDefault()))
                        {
                            return(false);
                        }
                        return(nullable11.HasValue);
                    }

                    case AverageConditionType.Below2StdDev:
                    {
                        if (!nullable2.HasValue)
                        {
                            return(false);
                        }
                        double num8       = num;
                        double?nullable12 = nullable;
                        double num9       = 2.0 * nullable2.Value;
                        double?nullable14 = nullable12.HasValue ? new double?(((double)nullable12.GetValueOrDefault()) - num9) : null;
                        if (num8 >= ((double)nullable14.GetValueOrDefault()))
                        {
                            return(false);
                        }
                        return(nullable14.HasValue);
                    }

                    case AverageConditionType.Above3StdDev:
                    {
                        if (!nullable2.HasValue)
                        {
                            return(false);
                        }
                        double num10      = num;
                        double?nullable15 = nullable;
                        double num11      = 3.0 * nullable2.Value;
                        double?nullable17 = nullable15.HasValue ? new double?(((double)nullable15.GetValueOrDefault()) + num11) : null;
                        if (num10 <= ((double)nullable17.GetValueOrDefault()))
                        {
                            return(false);
                        }
                        return(nullable17.HasValue);
                    }

                    case AverageConditionType.Below3StdDev:
                    {
                        if (!nullable2.HasValue)
                        {
                            return(false);
                        }
                        double num12      = num;
                        double?nullable18 = nullable;
                        double num13      = 3.0 * nullable2.Value;
                        double?nullable20 = nullable18.HasValue ? new double?(((double)nullable18.GetValueOrDefault()) - num13) : null;
                        if (num12 >= ((double)nullable20.GetValueOrDefault()))
                        {
                            return(false);
                        }
                        return(nullable20.HasValue);
                    }
                    }
                }
            }
            return(false);
        }
Exemple #20
0
 internal override bool IsConditionEvaluateToTrue(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actual)
 {
     if (base.condition != null)
     {
         this.TryCache(actual);
         if (base.Contains(baseRow, baseColumn))
         {
             object obj2 = actual.GetValue();
             if (obj2 == null)
             {
                 return(false);
             }
             try
             {
                 double num       = ConditionValueConverter.ToDouble(obj2);
                 double?nullable  = this.GetActualValue(evaluator, baseRow, baseColumn, 0, actual);
                 double?nullable2 = this.GetActualValue(evaluator, baseRow, baseColumn, 1, actual);
                 double?nullable3 = this.GetActualValue(evaluator, baseRow, baseColumn, 2, actual);
                 if (!nullable2.HasValue)
                 {
                     if (nullable.HasValue && nullable3.HasValue)
                     {
                         double?nullable4 = nullable;
                         double?nullable5 = nullable3;
                         if ((((double)nullable4.GetValueOrDefault()) > ((double)nullable5.GetValueOrDefault())) && (nullable4.HasValue & nullable5.HasValue))
                         {
                             return(false);
                         }
                         return(true);
                     }
                 }
                 else if ((nullable.HasValue && nullable3.HasValue) && nullable2.HasValue)
                 {
                     double?nullable6 = nullable;
                     double?nullable7 = nullable3;
                     if ((((double)nullable6.GetValueOrDefault()) > ((double)nullable7.GetValueOrDefault())) && (nullable6.HasValue & nullable7.HasValue))
                     {
                         return(false);
                     }
                     double num2      = num;
                     double?nullable8 = nullable;
                     if ((num2 >= ((double)nullable8.GetValueOrDefault())) || !nullable8.HasValue)
                     {
                         double num3      = num;
                         double?nullable9 = nullable3;
                         if ((num3 >= ((double)nullable9.GetValueOrDefault())) && nullable9.HasValue)
                         {
                             return(true);
                         }
                         Evaluate2Scale(nullable2.Value, nullable.Value, nullable3.Value);
                         if ((nullable.Value <= num) && (num <= nullable2.Value))
                         {
                             return(true);
                         }
                     }
                     return(true);
                 }
             }
             catch
             {
                 return(false);
             }
         }
     }
     return(false);
 }
Exemple #21
0
        /// <summary>
        /// Returns a specified value of the rule if the cell satisfies the condition.
        /// </summary>
        /// <param name="evaluator">The evaluator.</param>
        /// <param name="baseRow">The row index.</param>
        /// <param name="baseColumn">The column index.</param>
        /// <param name="actual">The current object.</param>
        /// <returns>Returns an icon object.</returns>
        public override object Evaluate(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actual)
        {
            object obj2 = actual.GetValue(baseRow, baseColumn);

            if (obj2 == null)
            {
                return(null);
            }
            double num = 0.0;

            if (!FormatConverter.IsNumber(obj2))
            {
                return(null);
            }
            double?nullable = FormatConverter.TryDouble(obj2, false);

            if (!nullable.HasValue)
            {
                return(null);
            }
            num = nullable.Value;
            int num2 = 0;

            if ((this.iconSetType >= Dt.Cells.Data.IconSetType.ThreeArrowsColored) && (this.iconSetType <= Dt.Cells.Data.IconSetType.ThreeSymbolsUncircled))
            {
                num2 = 3;
            }
            else if ((this.iconSetType >= Dt.Cells.Data.IconSetType.FourArrowsColored) && (this.iconSetType <= Dt.Cells.Data.IconSetType.FourTrafficLights))
            {
                num2 = 4;
            }
            else if ((this.iconSetType >= Dt.Cells.Data.IconSetType.FiveArrowsColored) && (this.iconSetType <= Dt.Cells.Data.IconSetType.FiveBoxes))
            {
                num2 = 5;
            }
            if (this.iconCriteria == null)
            {
                return((int)0);
            }
            double maxValue = double.MaxValue;

            for (int i = num2 - 1; i > 0; i--)
            {
                if (i >= (this.iconCriteria.Length + 1))
                {
                    return(new IconDrawingObject(baseRow, baseColumn, this.iconSetType, this.modifyIconIndex(0), this.showIconOnly));
                }
                IconCriterion criterion = this.iconCriteria[i - 1];
                if ((criterion == null) || (criterion.Value == null))
                {
                    return(new IconDrawingObject(baseRow, baseColumn, this.iconSetType, this.modifyIconIndex(0), this.showIconOnly));
                }
                double?nullable2 = this.GetActualValue(evaluator, baseRow, baseColumn, i - 1, actual);
                if (!nullable2.HasValue)
                {
                    return(new IconDrawingObject(baseRow, baseColumn, this.iconSetType, this.modifyIconIndex(0), this.showIconOnly));
                }
                if (criterion.IsGreaterThanOrEqualTo)
                {
                    if ((num < maxValue) && (num >= nullable2.Value))
                    {
                        return(new IconDrawingObject(baseRow, baseColumn, this.iconSetType, this.modifyIconIndex(i), this.showIconOnly));
                    }
                }
                else if ((num < maxValue) && (num > nullable2.Value))
                {
                    return(new IconDrawingObject(baseRow, baseColumn, this.iconSetType, this.modifyIconIndex(i), this.showIconOnly));
                }
            }
            return(new IconDrawingObject(baseRow, baseColumn, this.iconSetType, this.modifyIconIndex(0), this.showIconOnly));
        }
Exemple #22
0
        internal override bool IsConditionEvaluateToTrue(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actual)
        {
            if (base.condition == null)
            {
                return(false);
            }
            object obj2 = actual.GetValue(baseRow, baseColumn);

            if (obj2 == null)
            {
                return(false);
            }
            double num = 0.0;

            if (!FormatConverter.IsNumber(obj2))
            {
                return(false);
            }
            double?nullable = FormatConverter.TryDouble(obj2, false);

            if (!nullable.HasValue)
            {
                return(false);
            }
            num = nullable.Value;
            int num2 = 0;

            if ((this.iconSetType >= Dt.Cells.Data.IconSetType.ThreeArrowsColored) && (this.iconSetType <= Dt.Cells.Data.IconSetType.ThreeSymbolsUncircled))
            {
                num2 = 3;
            }
            else if ((this.iconSetType >= Dt.Cells.Data.IconSetType.FourArrowsColored) && (this.iconSetType <= Dt.Cells.Data.IconSetType.FourTrafficLights))
            {
                num2 = 4;
            }
            else if ((this.iconSetType >= Dt.Cells.Data.IconSetType.FiveArrowsColored) && (this.iconSetType <= Dt.Cells.Data.IconSetType.FiveBoxes))
            {
                num2 = 5;
            }
            if (this.iconCriteria != null)
            {
                double maxValue = double.MaxValue;
                for (int i = num2 - 1; i > 0; i--)
                {
                    if (i >= (this.iconCriteria.Length + 1))
                    {
                        return(true);
                    }
                    IconCriterion criterion = this.iconCriteria[i - 1];
                    if ((criterion == null) || (criterion.Value == null))
                    {
                        return(true);
                    }
                    double?nullable2 = this.GetActualValue(evaluator, baseRow, baseColumn, i - 1, actual);
                    if (!nullable2.HasValue)
                    {
                        return(true);
                    }
                    if (criterion.IsGreaterThanOrEqualTo)
                    {
                        if ((num < maxValue) && (num >= nullable2.Value))
                        {
                            return(true);
                        }
                    }
                    else if ((num < maxValue) && (num > nullable2.Value))
                    {
                        return(true);
                    }
                }
            }
            return(true);
        }
Exemple #23
0
 /// <summary>
 /// Evaluates a specified value of the rule if the cell satisfies the condition.
 /// </summary>
 /// <param name="evaluator">The evaluator.</param>
 /// <param name="baseRow">The row index.</param>
 /// <param name="baseColumn">The column index.</param>
 /// <param name="actual">The current value.</param>
 /// <returns>Returns the conditional number value.</returns>
 public override object Evaluate(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actual)
 {
     this.TryCache(actual);
     if (base.Contains(baseRow, baseColumn))
     {
         object obj2 = actual.GetValue();
         if (obj2 == null)
         {
             return(null);
         }
         try
         {
             double num       = ConditionValueConverter.ToDouble(obj2);
             double?nullable  = this.GetActualValue(evaluator, baseRow, baseColumn, 0, actual);
             double?nullable2 = this.GetActualValue(evaluator, baseRow, baseColumn, 1, actual);
             double?nullable3 = this.GetActualValue(evaluator, baseRow, baseColumn, 2, actual);
             if (!nullable2.HasValue)
             {
                 if (nullable.HasValue && nullable3.HasValue)
                 {
                     double?nullable4 = nullable;
                     double?nullable5 = nullable3;
                     if ((((double)nullable4.GetValueOrDefault()) > ((double)nullable5.GetValueOrDefault())) && (nullable4.HasValue & nullable5.HasValue))
                     {
                         return(null);
                     }
                     return((double)Evaluate2Scale(num, nullable.Value, nullable3.Value));
                 }
             }
             else if ((nullable.HasValue && nullable3.HasValue) && nullable2.HasValue)
             {
                 double?nullable6 = nullable;
                 double?nullable7 = nullable3;
                 if ((((double)nullable6.GetValueOrDefault()) > ((double)nullable7.GetValueOrDefault())) && (nullable6.HasValue & nullable7.HasValue))
                 {
                     return(null);
                 }
                 double num5      = num;
                 double?nullable8 = nullable;
                 if ((num5 < ((double)nullable8.GetValueOrDefault())) && nullable8.HasValue)
                 {
                     return((double)0.0);
                 }
                 double num6      = num;
                 double?nullable9 = nullable3;
                 if ((num6 >= ((double)nullable9.GetValueOrDefault())) && nullable9.HasValue)
                 {
                     return((double)2.0);
                 }
                 Evaluate2Scale(nullable2.Value, nullable.Value, nullable3.Value);
                 if ((nullable.Value <= num) && (num <= nullable2.Value))
                 {
                     return((double)Evaluate2Scale(num, nullable.Value, nullable2.Value));
                 }
                 double num4 = 1.0 + Evaluate2Scale(num, nullable.Value, nullable3.Value);
                 return((double)num4);
             }
         }
         catch
         {
             return(null);
         }
     }
     return(null);
 }