示例#1
0
        //	public void addOrUpdate(ParamItemTable obj) {
        //		if ( hashMap.get(obj.getGroupCode()) == null ) {
        //			add(obj);
        //		}
        //		else {
        //			update(obj);
        //		}
        //	}

//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void initializeCache() throws Exception
        public virtual void initializeCache()
        {
            bool    hasOpenedSession = o_prjDBUtil.hasOpenedSession();
            Session session          = o_prjDBUtil.currentSession();

            hashMap.Clear();

            //System.out.println("Seeking for: "+code);

            IEnumerator <ParamItemTable> iter = session.createQuery("from ParamItemTable o where o.projectId = " + o_prjDBUtil.ProjectUrlId).iterate();

            //System.out.println("Processing: "+prj);
            while (iter.MoveNext())
            {
                ParamItemTable paramItemTable = (ParamItemTable)iter.Current;
                //System.out.println("Adding: "+groupCodeTable);
                ParamItemGroupCode gc = new ParamItemGroupCode(this, paramItemTable);
                hashMap[gc.ToString()] = gc;
            }

            if (!hasOpenedSession)
            {
                o_prjDBUtil.closeSession();
            }
        }
//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)
        {
            assertMinArgCount(paramArrayOfExpr, 4);
            for (sbyte b = 0; b < paramArrayOfExpr.Length; b++)
            {
                if (paramArrayOfExpr[b] is org.boris.expr.ExprEvaluatable)
                {
                    paramArrayOfExpr[b] = evalArg(paramIEvaluationContext, paramArrayOfExpr[b]);
                }
            }
            string        str1          = "p.IFCNUMVAL:unitFactorQuery";
            string        str2          = (paramArrayOfExpr[0] is ExprString) ? ((ExprString)paramArrayOfExpr[0]).str : paramArrayOfExpr[0].ToString();
            string        str3          = (paramArrayOfExpr[1] is ExprString) ? ((ExprString)paramArrayOfExpr[1]).str : paramArrayOfExpr[1].ToString();
            string        str4          = (paramArrayOfExpr[2] is ExprString) ? ((ExprString)paramArrayOfExpr[2]).str : paramArrayOfExpr[2].ToString();
            string        str5          = (paramArrayOfExpr[3] is ExprString) ? ((ExprString)paramArrayOfExpr[3]).str : paramArrayOfExpr[3].ToString();
            string        str6          = (paramArrayOfExpr.Length >= 5) ? ((paramArrayOfExpr[4] is ExprString) ? ((ExprString)paramArrayOfExpr[4]).str : paramArrayOfExpr[4].ToString()) : null;
            int           i             = findQtyType(str5);
            ProjectDBUtil projectDBUtil = ProjectDBUtil.currentProjectDBUtil();

            if (projectDBUtil == null)
            {
                return(new ExprTakeoff(-1.0D, null));
            }
            decimal bigDecimal = BigDecimalMath.ZERO;

            ConditionTable[] arrayOfConditionTable = null;
            bool             @bool = projectDBUtil.hasOpenedSession();

            try
            {
                string str7 = "SELECT e.IFCTITLE as \"title\", e.IFCDESCRIPTION as \"description\", e.IFCBUILDING as \"building\", e.IFCSTOREY as \"storey\", e.IFCLAYER as \"layer\", e.IFCLOCATION as \"location\", e.IFCMATERIAL as \"bimMaterial\", e.IFCOBJECTTYPE as \"bimType\",e.IFCFILE as \"databaseName\", '  ' as \"username\", '  ' as \"password\", e.IFCFNAME as \"host\", e.CNDID as \"bidNo\", e.CNDID as \"cndNo\", e.CNDID as \"cndId\", e.IFCID as \"globalId\", e.IFCOBJECTTYPE as \"cndType\", 'BIM' as \"takeOffType\", e.IFCQTY2 as \"quantity2\", e.IFCQTY3 as \"quantity3\", NULL as \"quantityF\",e.IFCQTYNAME2 as \"quantity2Name\", e.IFCQTYNAME3 as \"quantity3Name\", '  ' as \"quantityFName\",e.IFCUOM2 as \"unit2\", e.IFCUOM3 as \"unit3\", '  ' as \"unitF\", '  ' as \"formulaF\", p.IFCPROPNAME as \"quantity1Name\", ':unitParam' as \"unit1\", (:quantityQuery) as \"quantity1\", 1 as \"defaultQuantity\" FROM IFCELEMENT AS e INNER JOIN IFCPROPERTY p ON e.ELEMID = p.ELEMID WHERE e.PRJID = :prjId AND (p.IFCNUMVAL is not null AND e.IFCMODEL = ':modelName' AND p.IFCPROPNAME = :propertyNameParam AND e.IFCOBJECTTYPE = ':objectTypeParam' AND p.IFCQTYTYPE = :quantityTypeParam)";
                if (StringUtils.isNullOrBlank(str3))
                {
                    str7 = StringUtils.replaceAll(str7, "AND e.IFCOBJECTTYPE=':objectTypeParam'", "");
                }
                else
                {
                    str7 = StringUtils.replaceAll(str7, ":objectTypeParam", str3);
                }
                if (StringUtils.isNullOrBlank(str5))
                {
                    str7 = StringUtils.replaceAll(str7, "AND p.IFCQTYTYPE = :quantityTypeParam", "");
                }
                else
                {
                    str7 = StringUtils.replaceAll(str7, ":quantityTypeParam", "" + i);
                }
                str7 = StringUtils.replaceAll(str7, ":modelName", str2);
                int j = 5;
                if (!StringUtils.isNullOrBlank(str6))
                {
                    str7 = str7 + " AND (" + str6 + ")";
                    j    = 5 + StringUtils.numberOfOccurences(str6, '?');
                }
                int    k    = j;
                string str8 = (k < paramArrayOfExpr.Length) ? ((ExprString)paramArrayOfExpr[k]).str : null;
                if (!string.ReferenceEquals(str8, null))
                {
                    str7 = StringUtils.replaceAll(str7, ":quantityQuery", str8);
                }
                else
                {
                    str7 = StringUtils.replaceAll(str7, ":quantityQuery", str1);
                    str7 = StringUtils.replaceAll(str7, ":unitFactorQuery", makeUnitFactorQuery(i, str5));
                }
                if (!str4.StartsWith("QUERY", StringComparison.Ordinal))
                {
                    str7 = StringUtils.replaceAll(str7, ":propertyNameParam", "'" + str4 + "'");
                }
                else
                {
                    str4 = StringUtils.replace(str4, "QUERY", "");
                    str7 = StringUtils.replaceAll(str7, ":propertyNameParam", str4);
                }
                string str9  = (++k < paramArrayOfExpr.Length) ? ((ExprString)paramArrayOfExpr[k]).str : null;
                string str10 = (++k < paramArrayOfExpr.Length) ? ((ExprString)paramArrayOfExpr[k]).str : null;
                if (StringUtils.isNullOrBlank(str10))
                {
                    str7 = StringUtils.replaceAll(str7, ":unitParam", str5);
                }
                else
                {
                    str7 = StringUtils.replaceAll(str7, ":unitParam", str10);
                }
                str7 = StringUtils.replaceAll(str7, ":prjId", "" + projectDBUtil.ProjectUrlId);
                Query query = projectDBUtil.currentSession().createSQLQuery(str7);
                sbyte b1    = 5;
                for (b1 = 5; b1 < j; b1++)
                {
                    sbyte b3 = b1;
                    if (paramArrayOfExpr[b3] is ExprString)
                    {
                        query = query.setString(b3 - 5, ((ExprString)paramArrayOfExpr[b3]).str);
                    }
                    else if (paramArrayOfExpr[b3] is ExprDouble)
                    {
                        query = query.setDouble(b3 - 5, ((ExprDouble)paramArrayOfExpr[b3]).doubleValue());
                    }
                    else if (paramArrayOfExpr[b3] is ExprInteger)
                    {
                        query = query.setInteger(b3 - 5, ((ExprInteger)paramArrayOfExpr[b3]).intValue());
                    }
                    else if (paramArrayOfExpr[b3] is ExprBoolean)
                    {
                        query = query.setBoolean(b3 - 5, ((ExprBoolean)paramArrayOfExpr[b3]).booleanValue());
                    }
                    else if (paramArrayOfExpr[b3] is ExprArray)
                    {
                        Expr[] arrayOfExpr = ((ExprArray)paramArrayOfExpr[b3]).InternalArray;
                        if (arrayOfExpr.Length == 0)
                        {
                            return(new ExprTakeoff(bigDecimal.doubleValue(), arrayOfConditionTable));
                        }
                        List <object> arrayList = new List <object>(arrayOfExpr.Length);
                        foreach (Expr expr in arrayOfExpr)
                        {
                            if (expr is ExprNumber)
                            {
                                arrayList.Add(Convert.ToDouble(((ExprNumber)expr).doubleValue()));
                            }
                            else if (expr is ExprString)
                            {
                                arrayList.Add(((ExprString)paramArrayOfExpr[b3]).str);
                            }
                            else
                            {
                                arrayList.Add(paramArrayOfExpr[b3].ToString());
                            }
                        }
                        query = query.setParameter(b3 - 5, arrayList);
                    }
                    else
                    {
                        query = query.setString(b3 - 5, paramArrayOfExpr[b3].ToString());
                    }
                }
                System.Collections.IList list = query.list();
                arrayOfConditionTable = new ConditionTable[list.Count];
                sbyte b2 = 0;
                foreach (object[] arrayOfObject in list)
                {
                    ConditionTable conditionTable = new ConditionTable();
                    conditionTable.Title           = castToString(arrayOfObject[0]);
                    conditionTable.Description     = castToString(arrayOfObject[1]);
                    conditionTable.Building        = castToString(arrayOfObject[2]);
                    conditionTable.Storey          = castToString(arrayOfObject[3]);
                    conditionTable.Layer           = castToString(arrayOfObject[4]);
                    conditionTable.Location        = castToString(arrayOfObject[5]);
                    conditionTable.BimMaterial     = castToString(arrayOfObject[6]);
                    conditionTable.BimType         = castToString(arrayOfObject[7]);
                    conditionTable.DatabaseName    = castToString(arrayOfObject[8]);
                    conditionTable.Username        = castToString(arrayOfObject[9]);
                    conditionTable.Password        = castToString(arrayOfObject[10]);
                    conditionTable.Host            = castToString(arrayOfObject[11]);
                    conditionTable.BidNo           = (int?)arrayOfObject[12];
                    conditionTable.CndNo           = (int?)arrayOfObject[13];
                    conditionTable.CndId           = (int?)arrayOfObject[14];
                    conditionTable.GlobalId        = castToString(arrayOfObject[15]);
                    conditionTable.CndType         = castToString(arrayOfObject[16]);
                    conditionTable.TakeOffType     = castToString(arrayOfObject[17]);
                    conditionTable.Quantity2       = (decimal)arrayOfObject[18];
                    conditionTable.Quantity3       = (decimal)arrayOfObject[19];
                    conditionTable.QuantityF       = (decimal)arrayOfObject[20];
                    conditionTable.Quantity2Name   = castToString(arrayOfObject[21]);
                    conditionTable.Quantity3Name   = castToString(arrayOfObject[22]);
                    conditionTable.QuantityFName   = castToString(arrayOfObject[23]);
                    conditionTable.Unit2           = castToString(arrayOfObject[24]);
                    conditionTable.Unit3           = castToString(arrayOfObject[25]);
                    conditionTable.UnitF           = castToString(arrayOfObject[26]);
                    conditionTable.FormulaF        = castToString(arrayOfObject[27]);
                    conditionTable.Quantity1Name   = castToString(arrayOfObject[28]);
                    conditionTable.Unit1           = castToString(arrayOfObject[29]);
                    conditionTable.Quantity1       = (decimal)arrayOfObject[30];
                    conditionTable.PickType        = ConditionTable.PICK_ELEMENTS;
                    conditionTable.DefaultQuantity = Convert.ToInt32(1);
                    bigDecimal = bigDecimal + conditionTable.Quantity1;
                    if (!string.ReferenceEquals(str9, null))
                    {
                        conditionTable.Quantity1Name = str9;
                    }
                    arrayOfConditionTable[b2++] = conditionTable;
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.ToString());
                Console.Write(exception.StackTrace);
                if (!@bool)
                {
                    projectDBUtil.closeSession();
                }
                throw new ExprException(exception.Message);
            }
            if (!@bool)
            {
                projectDBUtil.closeSession();
            }
            return(new ExprTakeoff(bigDecimal.doubleValue(), arrayOfConditionTable));
        }
示例#3
0
        public virtual void initCache()
        {
            bool    mustCloseSession = !prjDbUtil.hasOpenedSession();
            Session projectSession   = prjDbUtil.currentSession();

            try
            {
                projectVariableMap.Clear();

                IList <ProjectVariableTable> projectVariables = new List <ProjectVariableTable>();
                bool useAllTemplateVariables = prjDbUtil.Properties.getBooleanProperty("project.use.all.projectvariables");
                if (useAllTemplateVariables)
                {
                    projectVariables = projectSession.createQuery("from ProjectVariableTable as o where o.projectId = :projectId").setLong("projectId", prjDbUtil.ProjectUrlId).list();
                }
                else
                {
                    projectVariables = projectSession.createQuery("from ProjectVariableTable as o where o.projectId = :projectId and projectTemplateTable.selected='1'").setLong("projectId", prjDbUtil.ProjectUrlId).list();
                }
                foreach (ProjectVariableTable projectVariableTable in projectVariables)
                {
                    string key   = projectVariableTable.Name;
                    object value = null;

                    if (projectVariableTable.Number.Value)
                    {
                        value = projectVariableTable.StoredValueNum;
                    }
                    else
                    {
                        value = projectVariableTable.StoredValue;
                    }

                    if (value == null)
                    {
                        continue;
                    }

                    projectVariableMap[key] = value;
                }

                if (mustCloseSession)
                {
                    try
                    {
                        projectSession.close();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                        Console.Write(e.StackTrace);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);

                if (mustCloseSession)
                {
                    try
                    {
                        projectSession.close();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                        Console.Write(ex.StackTrace);
                    }
                }
            }
        }
示例#4
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)
        {
            assertMinArgCount(paramArrayOfExpr, 1);
            for (sbyte b = 0; b < paramArrayOfExpr.Length; b++)
            {
                if (paramArrayOfExpr[b] is org.boris.expr.ExprEvaluatable)
                {
                    paramArrayOfExpr[b] = evalArg(paramIEvaluationContext, paramArrayOfExpr[b]);
                }
            }
            if (!(paramArrayOfExpr[0] is ExprString))
            {
                throw new ExprException("Input " + paramArrayOfExpr[0].ToString() + " is not a String.");
            }
            string str = ((ExprString)paramArrayOfExpr[0]).str;
            bool   @bool;

            for (@bool = true; @bool < paramArrayOfExpr.Length; @bool++)
            {
                if (paramArrayOfExpr[@bool] is ExprVariable)
                {
                    paramArrayOfExpr[@bool] = paramIEvaluationContext.evaluateVariable((ExprVariable)paramArrayOfExpr[@bool]);
                }
                if (!(paramArrayOfExpr[@bool] is ExprString) && !(paramArrayOfExpr[@bool] is org.boris.expr.ExprNumber) && !(paramArrayOfExpr[@bool] is ExprBoolean))
                {
                    throw new ExprException("Invalid Parameter Value: " + paramArrayOfExpr[@bool]);
                }
            }
            @bool = true;
            Session       session       = null;
            ProjectDBUtil projectDBUtil = null;

            if (paramIEvaluationContext is ExprAbstractEvaluationContext)
            {
                session = ((ExprAbstractEvaluationContext)paramIEvaluationContext).ProjectDatabaseSession;
                if (session == null)
                {
                    projectDBUtil = ProjectDBUtil.currentProjectDBUtil();
                    if (projectDBUtil == null)
                    {
                        return(new DummyExprArray());
                    }
                    @bool   = projectDBUtil.hasOpenedSession();
                    session = projectDBUtil.currentSession();
                }
            }
            string[] arrayOfString = null;
            try
            {
                Query query = session.createQuery(str);
                query.Cacheable = true;
                for (sbyte b1 = 1; b1 < paramArrayOfExpr.Length; b1++)
                {
                    if (paramArrayOfExpr[b1] is ExprString)
                    {
                        query = query.setString(b1 - true, ((ExprString)paramArrayOfExpr[b1]).str);
                    }
                    else if (paramArrayOfExpr[b1] is ExprDouble)
                    {
                        query = query.setDouble(b1 - true, ((ExprDouble)paramArrayOfExpr[b1]).doubleValue());
                    }
                    else if (paramArrayOfExpr[b1] is ExprInteger)
                    {
                        query = query.setInteger(b1 - true, ((ExprInteger)paramArrayOfExpr[b1]).intValue());
                    }
                    else if (paramArrayOfExpr[b1] is ExprBoolean)
                    {
                        query = query.setBoolean(b1 - true, ((ExprBoolean)paramArrayOfExpr[b1]).booleanValue());
                    }
                }
                System.Collections.IList list = query.list();
                int i = 0;
                if (list.Count != 0)
                {
                    object @object = list[0];
                    if (@object is BaseEntity)
                    {
                        ClassMetadata classMetadata = ((SessionImplementor)session).Factory.getClassMetadata(@object.GetType());
                        arrayOfString = classMetadata.PropertyNames;
                        if (arrayOfString == null)
                        {
                            throw new Exception("Invalid class name: " + @object.GetType());
                        }
                        i = arrayOfString.Length;
                    }
                    else if (@object is object[])
                    {
                        i = (object[])@object.length;
                    }
                    else
                    {
                        i = 1;
                    }
                }
                ExprArray exprArray = new ExprArray(list.Count, i);
                sbyte     b2        = 0;
                foreach (object @object in list)
                {
                    if (@object is object[])
                    {
                        object[] arrayOfObject = (object[])@object;
                        for (sbyte b3 = 0; b3 < arrayOfObject.Length; b3++)
                        {
                            setArrayValue(exprArray, arrayOfObject[b3], b2, b3);
                        }
                    }
                    else if (@object is BaseEntity)
                    {
                        sbyte b3 = 0;
                        foreach (string str1 in arrayOfString)
                        {
                            object object1 = BlankResourceInitializer.getFieldValue((BaseEntity)@object, str1);
                            setArrayValue(exprArray, object1, b2, b3++);
                        }
                    }
                    else if (i == 1)
                    {
                        setArrayValue(exprArray, @object, b2, 0);
                    }
                    else
                    {
                        if (!@bool)
                        {
                            projectDBUtil.closeSession();
                        }
                        throw new ExprException("Not a persistent class: " + @object.GetType().Name);
                    }
                    b2++;
                }
                if (projectDBUtil != null && !@bool)
                {
                    projectDBUtil.closeSession();
                }
                return(exprArray);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.ToString());
                Console.Write(exception.StackTrace);
                if (!@bool)
                {
                    projectDBUtil.closeSession();
                }
                throw new ExprException(exception.Message);
            }
        }
        public static decimal findExchangeRate(ProjectDBUtil paramProjectDBUtil, string paramString, DateTime paramDate)
        {
            if (paramProjectDBUtil == null || StringUtils.isNullOrBlank(paramString))
            {
                return(BigDecimalMath.ONE);
            }
            Currency currency = s_interface.findCurrencyBySymbol(paramProjectDBUtil.Properties.getProperty("project.currency.symbol"));

            if (currency.Code.Equals(paramString))
            {
                return(BigDecimalMath.ONE);
            }
            string  str         = constructKey(paramProjectDBUtil, currency.Code, paramString, paramDate);
            decimal bigDecimal1 = (decimal)s_exchangeRateCache[str];

            if (bigDecimal1 != null)
            {
                return(bigDecimal1);
            }
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMM yyyy", Locale.ENGLISH);
            DateTime         date1            = paramProjectDBUtil.Properties.getDateProperty("project.submission.date");
            int i = paramProjectDBUtil.Properties.getIntProperty("project.constructionduration");

            if (i <= 0)
            {
                i = 1;
            }
            GregorianCalendar gregorianCalendar = new GregorianCalendar();

            gregorianCalendar.Time = date1;
            gregorianCalendar.set(5, 1);
            gregorianCalendar.set(11, 0);
            gregorianCalendar.set(12, 0);
            gregorianCalendar.set(13, 0);
            gregorianCalendar.set(14, 0);
            date1 = gregorianCalendar.Time;
            gregorianCalendar.add(2, i);
            DateTime date2   = gregorianCalendar.Time;
            bool     @bool   = !paramProjectDBUtil.hasOpenedSession() ? 1 : 0;
            Session  session = paramProjectDBUtil.currentSession();
            Query    query   = session.createQuery("from ExchangeRateTable o where o.projectId = :prjId and (o.fromCurrency = :fromCurrency and o.toCurrency = :toCurrency and o.rateDate >= :startDate and o.rateDate <= :endDate) order by o.rateDate asc");

            query.setString("fromCurrency", paramString);
            query.setString("toCurrency", currency.Code);
            query.setDate("startDate", date1);
            query.setDate("endDate", date2);
            query.setLong("prjId", paramProjectDBUtil.ProjectUrlId.Value);
            query.Cacheable = true;
            System.Collections.IEnumerator iterator = query.list().GetEnumerator();
            decimal bigDecimal2 = BigDecimalMath.ONE;
            sbyte   b;

            for (b = 0; iterator.MoveNext(); b++)
            {
                ExchangeRateTable exchangeRateTable = (ExchangeRateTable)iterator.Current;
                if (!b)
                {
                    bigDecimal2 = exchangeRateTable.Rate;
                }
                if (paramDate == null)
                {
                    bigDecimal1 = exchangeRateTable.Rate;
                    break;
                }
                string str1 = simpleDateFormat.format(paramDate);
                string str2 = simpleDateFormat.format(exchangeRateTable.RateDate);
                if (str1.Equals(str2))
                {
                    bigDecimal1 = exchangeRateTable.Rate;
                    break;
                }
            }
            if (@bool)
            {
                paramProjectDBUtil.closeSession();
            }
            if (bigDecimal1 == null)
            {
                bigDecimal1 = bigDecimal2;
            }
            s_exchangeRateCache[str] = bigDecimal1;
            return(bigDecimal1);
        }
        public static decimal findRawMaterialRate(ProjectDBUtil paramProjectDBUtil, string paramString, DateTime paramDate)
        {
            if (paramProjectDBUtil == null || StringUtils.isNullOrBlank(paramString))
            {
                return(BigDecimalMath.ZERO);
            }
            bool             @bool            = !paramProjectDBUtil.hasOpenedSession() ? 1 : 0;
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMM yyyy", Locale.ENGLISH);
            DateTime         date1            = paramProjectDBUtil.Properties.getDateProperty("project.submission.date");
            int i = paramProjectDBUtil.Properties.getIntProperty("project.constructionduration");

            if (i <= 0)
            {
                i = 1;
            }
            GregorianCalendar gregorianCalendar = new GregorianCalendar();

            gregorianCalendar.Time = date1;
            gregorianCalendar.set(5, 1);
            gregorianCalendar.set(11, 0);
            gregorianCalendar.set(12, 0);
            gregorianCalendar.set(13, 0);
            gregorianCalendar.set(14, 0);
            date1 = gregorianCalendar.Time;
            gregorianCalendar.add(2, i);
            DateTime date2   = gregorianCalendar.Time;
            Session  session = paramProjectDBUtil.currentSession();
            Query    query   = session.createQuery("from RawMaterialTable o where o.projectId = " + paramProjectDBUtil.ProjectUrlId + " and (o.code = :code and o.rateDate >= :startDate and o.rateDate <= :endDate) order by o.rateDate asc");

            query.setString("code", paramString);
            query.setDate("startDate", date1);
            query.setDate("endDate", date2);
            query.Cacheable = true;
            System.Collections.IEnumerator iterator = query.list().GetEnumerator();
            decimal bigDecimal1 = BigDecimalMath.ZERO;
            decimal bigDecimal2 = null;
            sbyte   b;

            for (b = 0; iterator.MoveNext(); b++)
            {
                RawMaterialTable rawMaterialTable = (RawMaterialTable)iterator.Current;
                if (!b)
                {
                    bigDecimal1 = rawMaterialTable.Rate;
                }
                if (paramDate == null)
                {
                    bigDecimal2 = rawMaterialTable.Rate;
                    break;
                }
                string str1 = simpleDateFormat.format(paramDate);
                string str2 = simpleDateFormat.format(rawMaterialTable.RateDate);
                if (str1.Equals(str2))
                {
                    bigDecimal2 = rawMaterialTable.Rate;
                    break;
                }
            }
            if (@bool)
            {
                paramProjectDBUtil.closeSession();
            }
            if (bigDecimal2 == null)
            {
                bigDecimal2 = bigDecimal1;
            }
            return(bigDecimal2);
        }