示例#1
0
        public Tree TreeData(string id)
        {
            UserHelper userhelper = new UserHelper();
            MysqlHelper mysqlhelper = new MysqlHelper();
            User one_user = new User();
            one_user.Id = id;
            one_user = mysqlhelper.CheckStatus(one_user);
            Seed final_tree = userhelper.HandleBaidu(one_user);
            string result = "";
            Tree tree = new Tree();
            tree.name = "初中数学上";
            tree.itemStyle.normal.label.show = false;

            foreach (Seed seed in final_tree.children)
            {
                Tree one_tree_2 = new Tree();
                one_tree_2.name = seed.name;
                if (seed.Degree_1 < 20)
                {
                    one_tree_2.itemStyle.normal.color = "#332B2B";
                }
                else
                {
                    one_tree_2.itemStyle.normal.color = "#19C9FF";
                }
                foreach (Seed seed_2 in seed.children)
                {
                    Tree tree_3 = new Tree();
                    tree_3.name = seed_2.name;
                    if (seed_2.Degree_2 < 20)
                    {
                        tree_3.itemStyle.normal.color = "#332B2B";
                    }
                    else
                    {
                        tree_3.itemStyle.normal.color = "#19C9FF";
                    }
                    one_tree_2.children.Add(tree_3);

                }
                tree.children.Add(one_tree_2);
            }

            return tree;
        }
示例#2
0
        public Baidu_Data Updatechapter(string id)
        {
            //string chapter = Regex.Match(data, @"\[(.*?)\]").Groups[1].ToString();
            UserHelper userhelper = new UserHelper();
            MysqlHelper mysqlhelper = new MysqlHelper();
            User one_user = new User();
            one_user.Id = id;
            one_user =mysqlhelper.CheckStatus(one_user);
               string old_result=  HandleU_Chapter(one_user);
            Seed final_tree =   userhelper.HandleBaidu(one_user);
            int change_status = 0;
            try
            {
                if ((DateTime.Now - DateTime.Parse(one_user.last_update)).Days > 7)
                {
                    change_status = 1;
                }
            }
            catch (Exception t)
            {
                change_status = 1;
            }
            string result = "";
            if (final_tree == null)
            {
                return null;
            }
            foreach (Seed seed in final_tree.children)
            {
                result += seed.Degree_1 + ",";
            }
            result = result.Substring(0, result.Length - 1);
            try
            {
                string old_date_string = Regex.Match(one_user.u_Chapter, "(.*?):").Groups[1].ToString();
                DateTime old_date = Convert.ToDateTime(old_date_string);
                if (change_status == 1)
                {
                    mysqlhelper.UpdateChapter(id, result);
                }
            }
            catch
            {

            }
            Baidu_Data baidudata = new Baidu_Data();
            baidudata.RadarNow = result;
            baidudata.RadarOld = old_result;
            return baidudata;
               // return mysqlhelper.UpdateChapter(id,chapter);
        }