Пример #1
0
        private ClassifyRule InitRuleLevel(string name, int bm)
        {
            ClassifyRule rlev = new ClassifyRule();

            rlev.ruleBm        = bm;
            rlev.ruleName      = name;
            rlev.SubRulesCount = GetRulesCount(name);
            return(rlev);
        }
Пример #2
0
        private int GetParentId(List <ClassifyRule> levels, string name)
        {
            ClassifyRule rule = levels.Find(delegate(ClassifyRule T) { return(T.ruleName == name); });

            if (rule == null)
            {
                return(-1);
            }
            return(rule.ruleBm);
        }
Пример #3
0
        private int GetParentId(List <ClassifyRule> levels, int bm, int strsublength)
        {
            ClassifyRule rule = levels.Find(delegate(ClassifyRule T) { return(T.ruleBm.ToString().Substring(0, strsublength) == bm.ToString()); });

            if (rule == null)
            {
                return(-1);
            }
            return(rule.ruleBm);
        }
Пример #4
0
        private List <ClassifyRule> GetChildRules(string parentBm, string childMC, string childBm, int length, DataTable result, out int childRulesCount)
        {
            List <ClassifyRule> classifyLevelRules = new List <ClassifyRule>();

            DataRow[] drs   = result.Select(string.Format("substring({0},1,{1})='{2}'", childBm, length, parentBm));
            int       count = 0;
            int       temp  = 0;
            int       bm    = -1;
            string    name  = "";
            int       index = 0;

            foreach (DataRow dr in drs)
            {
                if (int.Parse(dr[childBm].ToString()) != bm &&
                    name != dr[childMC].ToString())
                {
                    ClassifyRule classifyRule = new ClassifyRule();
                    classifyRule = InitRuleLevel(dr[childMC].ToString(), int.Parse(dr[childBm].ToString()));

                    //classifyRule.SubRulesCount = GetRulesCount(dr[childMC].ToString());
                    classifyRule.SubRules = GetChildRules(dr[childBm].ToString(), "SJMLMC", "SJMLBM", 2, result, out temp);
                    if (classifyRule.SubRulesCount > 0 && temp == 0)
                    {
                        count += classifyRule.SubRulesCount;
                    }

                    if (temp > 0)
                    {
                        classifyRule.SubRulesCount = temp;
                        count += classifyRule.SubRulesCount;
                    }

                    classifyLevelRules.Add(classifyRule);

                    bm   = int.Parse(drs[index][childBm].ToString());
                    name = drs[index][childMC].ToString();
                    ++index;
                }
            }
            if (classifyLevelRules.Count > 0)
            {
                if (childMC == "SJMLMC")
                {
                    thirdLevelRules.AddRange(classifyLevelRules);
                }
                else
                {
                    secondLevelRules.AddRange(classifyLevelRules);
                }
            }
            childRulesCount = count;
            return(classifyLevelRules);
        }
Пример #5
0
        private bool GetRuleClassify()
        {
            m_ClassifyLevelRules = new List <ClassifyRule>();
            DataTable result      = null;
            DataTable yjdatatable = null;

            try
            {
                result = SysDbHelper.GetRulesClassifyList(m_strSchemaId);

                if (result == null || result.Rows.Count == 0)
                {
                    return(false);
                }
                yjdatatable = AdoDbHelper.GetDataTable(SysDbHelper.GetSysDbConnection(), string.Format("select yjmlmc,yjmlbm from LR_CheckTypeModel where SchemaId='{0}' group by yjmlmc,yjmlbm order by yjmlbm ", m_strSchemaId));

                foreach (DataRow dr in yjdatatable.Rows)
                {
                    int          parseBm    = int.Parse(dr["YJMLBM"].ToString());
                    ClassifyRule rule       = InitRuleLevel(dr["YJMLMC"].ToString(), parseBm);
                    int          rulesCount = 0;
                    rule.SubRules      = GetChildRules(parseBm.ToString(), "EJMLMC", "EJMLBM", 1, result, out rulesCount);
                    rule.SubRulesCount = rulesCount;//CalculateRulesCount(rule.SubRules);
                    m_ClassifyLevelRules.Add(rule);
                }
            }
            catch (Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());
            }
            finally
            {
                if (result != null)
                {
                    result.Dispose();
                    result = null;
                }
                if (yjdatatable != null)
                {
                    yjdatatable.Dispose();
                    yjdatatable = null;
                }
            }

            return(true);
        }
Пример #6
0
 private ClassifyRule InitRuleLevel(string name, int bm)
 {
     ClassifyRule rlev = new ClassifyRule();
     rlev.ruleBm = bm;
     rlev.ruleName = name;
     rlev.SubRulesCount = GetRulesCount(name);
     return rlev;
 }
Пример #7
0
        private List<ClassifyRule> GetChildRules(string parentBm,string childMC,string childBm,int length,DataTable result,out int childRulesCount)
        {
            List<ClassifyRule> classifyLevelRules = new List<ClassifyRule>();
            DataRow[] drs = result.Select(string.Format("substring({0},1,{1})='{2}'", childBm, length, parentBm));
            int count = 0;
            int temp = 0;
            int bm = -1;
            string name="";
            int index = 0;
            foreach (DataRow dr in drs)
            {
                if (int.Parse(dr[childBm].ToString()) != bm &&
                    name !=dr[childMC].ToString())
                {
                    ClassifyRule classifyRule = new ClassifyRule();
                    classifyRule = InitRuleLevel(dr[childMC].ToString(), int.Parse(dr[childBm].ToString()));

                    //classifyRule.SubRulesCount = GetRulesCount(dr[childMC].ToString());
                    classifyRule.SubRules = GetChildRules(dr[childBm].ToString(), "SJMLMC", "SJMLBM", 2, result, out temp);
                    if (classifyRule.SubRulesCount > 0 && temp == 0)
                    {
                        count += classifyRule.SubRulesCount;
                    }

                    if (temp> 0)
                    {
                        classifyRule.SubRulesCount = temp;
                        count+= classifyRule.SubRulesCount;
                    }

                    classifyLevelRules.Add(classifyRule);

                    bm = int.Parse(drs[index][childBm].ToString());
                    name = drs[index][childMC].ToString();
                    ++index;
                }
            }
            if (classifyLevelRules.Count > 0)
            {
                if (childMC == "SJMLMC")
                {
                    thirdLevelRules.AddRange(classifyLevelRules);
                }
                else
                {
                    secondLevelRules.AddRange(classifyLevelRules);
                }
            }
            childRulesCount = count;
            return classifyLevelRules;
        }