Exemple #1
0
 //VeryfiedClassInfo[] ch_classes=null)
 //public VeryfiedClassInfo[] checked_classes;
 public TreeNode(TreeNode l_child = null, TreeNode r_child =null, Rule new_rule = null, bool isleaf = false)
 {
     left_child = l_child;
     right_child = r_child;
     rule = new_rule;
     is_leaf = isleaf;
     //checked_classes = ch_classes;
 }
Exemple #2
0
        public TreeNode GetNodeWithRequest(int node_ID)
        {
            String req = "SELECT * FROM NODE WHERE ID = '" + node_ID +"'";
            TreeNode res = new TreeNode();
            SQLiteCommand cmd = new SQLiteCommand(conn);
            int rule_id = 0;
            int left_child_id=0;
            int right_child_id=0;
            int is_leaf=0;
            cmd.Transaction = trans;
            cmd.CommandText = req;
            try
            {
                SQLiteDataReader r = cmd.ExecuteReader();
                string line = String.Empty;
                //res = new TreeNode();
                //TreeNode node;
                while (r.Read())
                {
                    //node = new TreeNode();
                    //node.ID = int.Parse(string.Format("{0}", r["ID"]));
                    left_child_id = int.Parse(string.Format("{0}", r["LEFT_CHILD_ID"]));
                    right_child_id = int.Parse(string.Format("{0}", r["RIGHT_CHILD_ID"]));
                    rule_id = int.Parse(string.Format("{0}", r["RULE_ID"]));
                    is_leaf = int.Parse(string.Format("{0}", r["IS_LEAF"]));
                }
                r.Close();
            }
            catch (SQLiteException ex)
            {
                Console.WriteLine(ex.Message);
                return null;
            }

            res.rule = GetRuleWithRequest("SELECT * FROM RULE WHERE ID ='"+ rule_id +"'");

            if (is_leaf == 0)//если тек узел не лист
            {
                res.is_leaf = false;
                res.left_child = GetNodeWithRequest(left_child_id);
                res.right_child = GetNodeWithRequest(right_child_id);
            }
            else
            {
                res.is_leaf = true;
                res.left_child = null;
                res.right_child = null;
            }

            return res;
        }