示例#1
0
        private bool GetCalculatedFieldData()
        {
            if (m_listCalculated == null)
            {
                m_listCalculated = new List <Deteriorate>();
            }
            String  strSelect = "SELECT ATTRIBUTE_,EQUATION,CRITERIA FROM " + cgOMS.Prefix + "ATTRIBUTES_CALCULATED";
            DataSet ds;

            try
            {
                ds = DBMgr.ExecuteQuery(strSelect);
            }
            catch (Exception exception)
            {
                SimulationMessaging.AddMessage(new SimulationMessage("Error: Retrieving Calculated Field data. SQL Message - " + exception.Message));
                return(false);
            }

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                Deteriorate deteriorate = new Deteriorate();

                deteriorate.Attribute = row["ATTRIBUTE_"].ToString();
                deteriorate.Equation  = row["EQUATION"].ToString();
                deteriorate.Criteria  = row["CRITERIA"].ToString();
                m_listCalculated.Add(deteriorate);
            }


            return(true);
        }
示例#2
0
        private double GetOtherConsequence(string key, Hashtable hashAttributeValue, Dictionary <string, double> dictionaryAttributeConsequences)
        {
            List <Deteriorate> listKey = m_listCalculated.FindAll(delegate(Deteriorate deteriorate) { return(deteriorate.Attribute == key); });

            Deteriorate defaultCalculated = null;

            foreach (Deteriorate calculated in listKey)
            {
                if (calculated.Criteria.Trim() == "")
                {
                    defaultCalculated = calculated;
                }
                else
                {
                    if (calculated.IsCriteriaMet(hashAttributeValue))
                    {
                        return(calculated.ApplyDeterioration(hashAttributeValue));
                    }
                }
            }
            return(0);
        }