public int InsertLiveHtmlTableToDB(string _html)
        {
            SqlAgilityPackTableXpath tbTag = new SqlAgilityPackTableXpath("live.win.7m.cn");
            HtmlAgilityPackGeneric SevenmLivesg = new HtmlAgilityPackGeneric(_html, tbTag.tbTag, 0);//容易出错,主要路径的转换
            DataTable dt = SevenmLivesg.GetTableOutHtml(); //容易出错,注意方法的转换
            DataClassesMatchDataContext match = new DataClassesMatchDataContext(Conn.conn);
            //if (!Conn.CreateTable(typeof(Live_Single))) { return 0; }
            foreach (DataRow aa in dt.Rows)
            {
                if (aa[8] != null)
                    if (aa[8].ToString() != "")
                        if (aa[8].ToString().Trim() != "")
                        {
                            status = HtmlTextToStr(aa[8].ToString()).Trim();

                            //北京单场
                            if (status != "让球")
                            {
                                if (status.Length >= 1 && status.Length <= 2)
                                {
                                    Live_Single ls = new Live_Single();
                                    status = HtmlTextToStr(aa[9].ToString()).Trim();
                                    ls.Html_position = GetNumber(HtmlTextToStr(aa[0].ToString()));
                                    ls.Home_team_big = GetNumber(HtmlHrefToStr(aa[4].ToString()));
                                    ls.Away_team_big = GetNumber(HtmlHrefToStr(aa[6].ToString()));
                                    ls.Status = status;
                                    match.Live_Single.InsertOnSubmit(ls);
                                }
                            }

                            //竞猜
                            if (status.IndexOf(".") != -1)
                            {
                                Live_Single ls = new Live_Single();
                                ls.Html_position = GetNumber(HtmlTextToStr(aa[0].ToString()));
                                ls.Home_team_big = GetNumber(HtmlHrefToStr(aa[4].ToString()));
                                ls.Away_team_big = GetNumber(HtmlHrefToStr(aa[6].ToString()));
                                ls.Status = status;
                                match.Live_Single.InsertOnSubmit(ls);
                            }
                        }
            }
            match.SubmitChanges();
            return match.Live_Single.Max(e => e.Live_Single_id);
        }
        public void top20Algorithm()
        {
            using (DataClassesMatchDataContext matches = new DataClassesMatchDataContext(Conn.conn))
            {
                int i = 0;
                foreach (int liveid in idExc)
                {
                    i++;
                    ProgressBarDelegate.DoSendPMessage(i);
                    Application.DoEvents();
                    r = new RowNumberLimit(liveid);
                    r.initCurveFit();
                    //match_analysis_result mar = new match_analysis_result();

                    mar = matches.Match_analysis_result
                        .Where(e => e.Live_table_lib_id == liveid)
                        .First();//查找需要更新的数据

                    mar.Live_table_lib_id = r.live_id;
                    mar.Pre_algorithm = "top20";
                    mar.Pre_match_count = r.Top20Count;
                    mar.Home_goals = r.HomeGoals;
                    mar.Away_goals = r.AwayGoals;

                    mar.Home_w = r.hWin;
                    mar.Home_d = r.hDraw;
                    mar.Home_l = r.hLose;

                    mar.Fit_win_loss = r.CureFitWinLoss();
                    mar.Fit_goals = r.CureFitGoals();
                    mar.Fit_odd_even = r.CureFitOddEven();//直接赋值,修改完成

                    //2011.9.22   修改成利用积分进行运算
                    mar.Recent_scores = r.RecentScores; //增加最后一轮的分数
                    mar.Recent_2scores = r.Recent2Scores;
                    mar.Recent_3scores = r.Recent3Scores;
                    mar.Recent_4scores = r.Recent4Scores;
                    mar.Recent_5scores = r.Recent5Scores;
                    mar.Recent_6scores = r.Recent6Scores;


                    //2011.6.22
                    mar.Cross_goals = r.CrossGoals;


                    //2011.6.16
                    //【交战+概率1+拟合+进球+概率30】
                    mar.Myfit =
                        //交战
                        ForecastCross(r.CrossGoals) + ":" +
                        //概率1
                        ForecastD(mar.Home_w, mar.Home_d, mar.Home_l) + ":" +
                        //拟合+进球+概率30
                        ForecastWL(mar.Fit_win_loss, mar.Home_goals, mar.Away_goals, mar.Home_w, mar.Home_l);


                    //更新北京单场
                    sg = lss[r.home_team_big.ToString() + r.away_team_big.ToString()].FirstOrDefault();
                    if (sg != null)
                        mar.Pre_algorithm = sg.Html_position;

                    sgerror = lss[r.away_team_big.ToString() + r.home_team_big.ToString()].FirstOrDefault();
                    if (sgerror != null)
                        mar.Pre_algorithm = sgerror.Html_position;

                    //r.Close();

                    //缩短数据更新周期
                    if (i % 100 == 0)
                    {
                        matches.SubmitChanges();
                        //GC.Collect(); GC.Collect(); Application.DoEvents();
                    }

                    //2011.10.8.   这里销毁
                    r.Dispose();
                }
                matches.SubmitChanges();
            }
        }
 partial void UpdateLive_Single(Live_Single instance);
 partial void DeleteLive_Single(Live_Single instance);
 partial void InsertLive_Single(Live_Single instance);