Exemple #1
0
        /// <summary>
        /// 求值
        /// </summary>
        /// <param name="input"></param>
        /// <param name="companyCD"></param>
        /// <returns></returns>
        public static DataTable ExpDataTable(DataTable input, string companyCD, string expType, int moveRows)
        {
            DataSet ds0      = new XBase.Business.Decision.DataCustLevel().GetList("CompanyCD='" + companyCD + "'");
            int     levelCnt = ds0.Tables[0].Rows.Count;

            levelCnt--;

            DataSet ds = new XBase.Business.Decision.DataModelExp().GetList("CompanyCD='" + companyCD + "' AND ExpType='" + expType + "'");

            if (ds.Tables[0].Rows.Count == 0)
            {
                return(input);
            }

            string exp = ds.Tables[0].Rows[0]["Expressions"].ToString();

            double tconstSec = double.Parse(exp.Split('|')[0]);

            string[] tvarSecs = exp.Split('|')[1].Split(';');

            foreach (DataRow row in input.Rows)
            {
                double result = tconstSec;
                for (int j = 0; j < tvarSecs.Length; j++)
                {
                    string[] pairs = tvarSecs[j].Split(',');

                    result += double.Parse(row[moveRows + int.Parse(pairs[0])].ToString()) * double.Parse(pairs[1]);
                }

                double p = Math.Pow(Math.E, result) / (1 + Math.Pow(Math.E, result));

                if (Double.IsNaN(p))
                {
                    p = 1;
                }


                int lvIdx = (int)(p * levelCnt);



                if (levelCnt == -1)
                {
                    row["CustGrade"] = "未配置等级";
                }
                else
                {
                    row["CustGrade"] = ds0.Tables[0].Rows[lvIdx]["GName"].ToString();
                }
            }

            return(input);
        }
        /// <summary>
        /// 求值
        /// </summary>
        /// <param name="input"></param>
        /// <param name="companyCD"></param>
        /// <returns></returns>
        public static  DataTable ExpDataTable(DataTable input,string companyCD,string expType,int moveRows)
        {
            DataSet ds0 = new XBase.Business.Decision.DataCustLevel().GetList("CompanyCD='" + companyCD + "'");
            int levelCnt = ds0.Tables[0].Rows.Count;
            levelCnt--;

            DataSet ds = new XBase.Business.Decision.DataModelExp().GetList("CompanyCD='" + companyCD + "' AND ExpType='" + expType + "'");
            if (ds.Tables[0].Rows.Count == 0)
                return input;

            string exp = ds.Tables[0].Rows[0]["Expressions"].ToString();

            double tconstSec = double.Parse(exp.Split('|')[0]);
            string[] tvarSecs = exp.Split('|')[1].Split(';');

            foreach (DataRow row in input.Rows)
            {
                double result = tconstSec;
                for (int j = 0; j < tvarSecs.Length; j++)
                {
                    string[] pairs = tvarSecs[j].Split(',');

                    result += double.Parse(row[moveRows+ int.Parse(pairs[0])].ToString()) * double.Parse(pairs[1]);
                }

                double p = Math.Pow(Math.E, result) / (1 + Math.Pow(Math.E, result));

                if (Double.IsNaN(p))
                {
                    p = 1;
                }


                int lvIdx = (int)(p * levelCnt);

             

                if (levelCnt == -1)
                {
                    row["CustGrade"] = "未配置等级";
                }
                else
                {
                    row["CustGrade"] = ds0.Tables[0].Rows[lvIdx]["GName"].ToString();
                }
            }

            return input;
        }