//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.boris.expr.Expr evaluate(org.boris.expr.IEvaluationContext paramIEvaluationContext, org.boris.expr.Expr[] paramArrayOfExpr) throws org.boris.expr.ExprException
        public virtual Expr evaluate(IEvaluationContext paramIEvaluationContext, Expr[] paramArrayOfExpr)
        {
            assertArgCount(paramArrayOfExpr, 0);
            DateTime date = null;

            try
            {
                if (paramIEvaluationContext is ExprAbstractEvaluationContext)
                {
                    ProjectUrlTable projectUrlTable = ((ExprAbstractEvaluationContext)paramIEvaluationContext).ProjectUrlTable;
                    if (projectUrlTable != null)
                    {
                        date = projectUrlTable.ProjectInfoTable.SubmissionDate;
                    }
                    else if (date == null)
                    {
                        date = ProjectDBUtil.currentProjectDBUtil().Properties.getDateProperty("project.submission.date");
                    }
                }
                return((date == null) ? new ExprDouble(ExcelDate.toExcelDate((DateTime.Now).Ticks)) : new ExprDouble(ExcelDate.toExcelDate(date.Ticks)));
            }
            catch (Exception)
            {
                return(new ExprDouble(ExcelDate.toExcelDate(date.Ticks)));
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.boris.expr.Expr evaluateVariable(String paramString) throws org.boris.expr.ExprException
        public virtual Expr evaluateVariable(string paramString)
        {
            string str = paramString;

            paramString = paramString.ToUpper();
            if (hasAdditionalVariable(paramString))
            {
                return(getAdditionalVariableValue(paramString));
            }
            if (this.decimalVariableMap.ContainsKey(paramString))
            {
                return(new ExprDouble(((decimal)this.decimalVariableMap[paramString]).doubleValue()));
            }
            if (this.localVariableMap[paramString] != null)
            {
                this.usedLocalVariablesInFormula.Add(paramString);
                return(new ExprDouble(((decimal)this.localVariableMap[paramString]).doubleValue()));
            }
            if (this.textVariableMap.ContainsKey(paramString))
            {
                return(new ExprString(((string)this.textVariableMap[paramString]).ToString()));
            }
            if (this.dateVariableMap.ContainsKey(paramString))
            {
                DateTime date = (DateTime)this.dateVariableMap[paramString];
                return((date == null) ? new ExprDouble(0.0D) : new ExprDouble(ExcelDate.toExcelDate(date.Ticks)));
            }
            if (this.booleanVariableMap.ContainsKey(paramString))
            {
                return(new ExprBoolean(((bool?)this.booleanVariableMap[paramString]).Value));
            }
            throw new ExprException("Variable " + str + " not found");
        }
Exemple #3
0
 private void setArrayValue(ExprArray paramExprArray, object paramObject, int paramInt1, int paramInt2)
 {
     if (paramObject == null)
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprString(""));
     }
     else if (paramObject is decimal)
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprDouble(((decimal)paramObject).doubleValue()));
     }
     else if (paramObject is BigInteger)
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprInteger(((BigInteger)paramObject).intValue()));
     }
     else if (paramObject is string)
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprString(paramObject.ToString()));
     }
     else if (paramObject is bool?)
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprBoolean(((bool?)paramObject).Value));
     }
     else if (paramObject is long?)
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprInteger(((long?)paramObject).Value));
     }
     else if (paramObject is int?)
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprInteger(((int?)paramObject).Value));
     }
     else if (paramObject is Number)
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprDouble(((Number)paramObject).doubleValue()));
     }
     else if (paramObject is Date)
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprDouble(ExcelDate.toExcelDate(((Date)paramObject).Time)));
     }
     else if (paramObject is Number)
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprDouble(((Number)paramObject).doubleValue()));
     }
     else if (paramObject is Clob)
     {
         Clob clob = (Clob)paramObject;
         paramExprArray.set(paramInt1, paramInt2, new ExprString(StringUtils.clobToString((Clob)paramObject)));
     }
     else
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprString(paramObject.ToString()));
     }
 }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.boris.expr.Expr evaluateVariable(org.boris.expr.IEvaluationContext param1IEvaluationContext, org.boris.expr.ExprVariable param1ExprVariable) throws org.boris.expr.ExprException
            public virtual Expr evaluateVariable(IEvaluationContext param1IEvaluationContext, ExprVariable param1ExprVariable)
            {
                string str1 = param1ExprVariable.Name.ToUpper();

                if (outerInstance.hasAdditionalVariable(str1))
                {
                    return(outerInstance.getAdditionalVariableValue(str1));
                }
                if (outerInstance.localVariablesMap.ContainsKey(str1))
                {
                    return(new ExprDouble(((decimal)outerInstance.localVariablesMap[str1]).doubleValue()));
                }
                string str2 = BoqItemFormulaEvaluator.fieldFromVariable(str1);

                if (string.ReferenceEquals(str2, null))
                {
                    throw new ExprException("Variable " + str1 + " not found");
                }
                object @object = outerInstance.getFieldValue(outerInstance.boqTable, str2);

                if (@object == null)
                {
                    if (BoqItemTable.isFieldDate(str2))
                    {
                        @object = Convert.ToDouble(0.0D);
                    }
                    else
                    {
                        @object = "";
                    }
                }
                ExprBoolean exprBoolean = null;

                if (@object is Number)
                {
                    exprBoolean = new ExprDouble(((Number)@object).doubleValue());
                }
                else if (@object is string)
                {
                    ExprString exprString = new ExprString(@object.ToString());
                }
                else if (@object is DateTime)
                {
                    exprBoolean = new ExprDouble(ExcelDate.toExcelDate(((DateTime)@object).Ticks));
                }
                else if (@object is bool?)
                {
                    exprBoolean = new ExprBoolean(((bool?)@object).Value);
                }
                return(exprBoolean);
            }
Exemple #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.boris.expr.Expr evaluate(org.boris.expr.IEvaluationContext paramIEvaluationContext, org.boris.expr.Expr[] paramArrayOfExpr) throws org.boris.expr.ExprException
        public virtual Expr evaluate(IEvaluationContext paramIEvaluationContext, Expr[] paramArrayOfExpr)
        {
            assertArgCount(paramArrayOfExpr, 0);
            try
            {
                if (paramIEvaluationContext is nomitech.common.expr.ExprAbstractEvaluationContext)
                {
                    return(new ExprDouble(ExcelDate.toExcelDate(TimeZoneUtil.getDateInLocalTimeZone(DateTime.Now).Ticks)));
                }
            }
            catch (Exception exception)
            {
                throw new ExprException(exception.Message);
            }
            return(null);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.boris.expr.Expr evaluate(org.boris.expr.IEvaluationContext paramIEvaluationContext, org.boris.expr.Expr[] paramArrayOfExpr) throws org.boris.expr.ExprException
        public virtual Expr evaluate(IEvaluationContext paramIEvaluationContext, Expr[] paramArrayOfExpr)
        {
            assertArgCount(paramArrayOfExpr, 2);
            Expr             expr1            = evalArg(paramIEvaluationContext, paramArrayOfExpr[0]);
            Expr             expr2            = evalArg(paramIEvaluationContext, paramArrayOfExpr[1]);
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(asString(paramIEvaluationContext, expr2, true));

            try
            {
                DateTime date = simpleDateFormat.parse(asString(paramIEvaluationContext, expr1, true));
                return(new ExprDouble(ExcelDate.toExcelDate(date.Ticks)));
            }
            catch (ParseException parseException)
            {
                Console.WriteLine(parseException.ToString());
                Console.Write(parseException.StackTrace);
                return(new ExprDouble(-1.0D));
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void setExprValue(String paramString, Object paramObject) throws org.boris.expr.ExprException
        private void setExprValue(string paramString, object paramObject)
        {
            if (paramObject == null)
            {
                paramObject = "";
            }
            if (paramObject is Number)
            {
                if (paramObject is decimal)
                {
                    set(paramString, ((decimal)paramObject).ToString(), new ExprDouble(((decimal)paramObject).doubleValue()));
                }
                else if (paramObject is long?)
                {
                    set(paramString, ((long?)paramObject).ToString(), new ExprInteger(((Number)paramObject).intValue()));
                }
                else
                {
                    set(paramString, ((Number)paramObject).ToString(), new ExprDouble(((Number)paramObject).doubleValue()));
                }
            }
            else if (paramObject is string)
            {
                set(paramString, paramObject.ToString(), new ExprString(paramObject.ToString()));
            }
            else if (paramObject is DateTime)
            {
                set(paramString, "" + ExcelDate.toExcelDate(((DateTime)paramObject).Ticks), new ExprDouble(ExcelDate.toExcelDate(((DateTime)paramObject).Ticks)));
            }
            else if (paramObject is bool?)
            {
                if (paramObject.Equals(true))
                {
                    set(paramString, "=TRUE()", new ExprBoolean(true));
                }
                else
                {
                    set(paramString, "=FALSE()", new ExprBoolean(false));
                }
            }
        }
Exemple #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.boris.expr.Expr evaluateVariable(org.boris.expr.ExprVariable paramExprVariable) throws org.boris.expr.ExprException
        public virtual Expr evaluateVariable(ExprVariable paramExprVariable)
        {
            string str = paramExprVariable.Name.ToUpper();

            if (hasAdditionalVariable(str))
            {
                return(getAdditionalVariableValue(paramExprVariable.Name.ToUpper()));
            }
            if (this.variableMap.ContainsKey(str))
            {
                ParamItemInputTable paramItemInputTable = (ParamItemInputTable)this.variableMap[paramExprVariable.Name.ToUpper()];
                return(expressionFromVariable(paramItemInputTable, paramExprVariable));
            }
            if (str.Equals("PRODUCTIVITY") && this.acceptProductivity)
            {
                return(new ExprDouble(nextDouble()));
            }
            if (str.Equals("FACTOR") && this.acceptFactorRate)
            {
                return(new ExprDouble(nextDouble()));
            }
            if (this.acceptBoqColumns)
            {
                int i = this.varNames.IndexOf(str);
                if (i == -1)
                {
                    throw new ExprException("Variable " + paramExprVariable + " not found");
                }
                Type clazz = (Type)this.varClasses[i];
                return(clazz.Equals(typeof(decimal)) ? new ExprDouble(nextDouble()) : (clazz.Equals(typeof(Long)) ? new ExprInteger(nextInt()) : (clazz.Equals(typeof(DateTime)) ? new ExprDouble(ExcelDate.toExcelDate(DateTimeHelper.CurrentUnixTimeMillis())) : (clazz.Equals(typeof(Boolean)) ? new ExprBoolean(false) : new ExprString(str)))));
            }
            throw new ExprException("Variable " + paramExprVariable + " not found");
        }
 private void setArrayValue(ExprArray paramExprArray, object paramObject, int paramInt1, int paramInt2)
 {
     if (paramObject == null)
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprString("-"));
     }
     else if (paramObject is HqlResultValue)
     {
         HqlResultValue hqlResultValue = (HqlResultValue)paramObject;
         if (!string.ReferenceEquals(hqlResultValue.StringValue, null))
         {
             paramExprArray.set(paramInt1, paramInt2, new ExprString(hqlResultValue.StringValue));
         }
         else if (hqlResultValue.DecimalValue != null)
         {
             paramExprArray.set(paramInt1, paramInt2, new ExprDouble(hqlResultValue.DecimalValue.doubleValue()));
         }
         else if (hqlResultValue.LongValue != null)
         {
             paramExprArray.set(paramInt1, paramInt2, new ExprInteger(hqlResultValue.LongValue.Value));
         }
         else if (hqlResultValue.BooleanValue != null)
         {
             paramExprArray.set(paramInt1, paramInt2, new ExprBoolean(hqlResultValue.BooleanValue.Value));
         }
         else if (hqlResultValue.DateValue != null)
         {
             paramExprArray.set(paramInt1, paramInt2, new ExprDouble(ExcelDate.toExcelDate(hqlResultValue.DateValue.Ticks)));
         }
     }
     else if (paramObject is decimal)
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprDouble(((decimal)paramObject).doubleValue()));
     }
     else if (paramObject is string)
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprString(paramObject.ToString()));
     }
     else if (paramObject is bool?)
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprBoolean(((bool?)paramObject).Value));
     }
     else if (paramObject is long?)
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprInteger(((long?)paramObject).Value));
     }
     else if (paramObject is int?)
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprInteger(((int?)paramObject).Value));
     }
     else if (paramObject is double?)
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprDouble(((double?)paramObject).Value));
     }
     else if (paramObject is Number)
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprDouble(((Number)paramObject).doubleValue()));
     }
     else if (paramObject is Date)
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprDouble(ExcelDate.toExcelDate(((Date)paramObject).Time)));
     }
     else if (paramObject is Clob)
     {
         Clob clob = (Clob)paramObject;
         paramExprArray.set(paramInt1, paramInt2, new ExprString(StringUtils.clobToString((Clob)paramObject)));
     }
     else
     {
         paramExprArray.set(paramInt1, paramInt2, new ExprString(paramObject.ToString()));
     }
 }