public void top20Algorithm()
        {
            using (DataClassesMatchDataContext matches = new DataClassesMatchDataContext(Conn.conn))
            {
                int i = 0;
                foreach (var id in idExc)
                {
                    i++;
                    ProgressBarDelegate.DoSendPMessage(i);
                    Application.DoEvents();
                    RowNumberLimit r = new RowNumberLimit(id);
                    r.initCurveFit();
                    Match_analysis_result mar = new Match_analysis_result();
                    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();
                    matches.Match_analysis_result.InsertOnSubmit(mar);

                    //2011.10.8  销毁
                    r.Dispose();

                }
                matches.SubmitChanges();
            }
        }
 public void top20Algorithm()
 {
     //using (SoccerScoreCompact match = new SoccerScoreCompact(cnn))
     //{
         int i = 0;
         foreach (var id in idExc)
         {
             i++;
             ProgressBarDelegate.DoSendPMessage(i);
             Application.DoEvents();
             RowNumberLimit r = new RowNumberLimit(id);
             Match_analysis_result mar = new Match_analysis_result();
             mar.Live_table_lib_id = r.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 ;
             Conn.match.Match_analysis_result.InsertOnSubmit(mar);
            
         }
         Conn.match.SubmitChanges();
     //}
 }
        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 DeleteMatch_analysis_result(Match_analysis_result instance);
 partial void UpdateMatch_analysis_result(Match_analysis_result instance);
 partial void InsertMatch_analysis_result(Match_analysis_result instance);
 private void TreeNodeLoad(TreeNode tn)
 {
     foreach (var ltl in ltls)
     {
         double? fit = 0, goals = 0, wdl = 0;
         //加入Live_Table数据
         strNode = ltl.Live_table_lib_id + "," + ltl.Match_type + "," + ltl.Match_time + "::" + ltl.Home_team + "::" + ltl.Away_team + "::" + ltl.Status;
         mar = marAll.Where(o => o.Live_table_lib_id == ltl.Live_table_lib_id).OrderByDescending(o => o.Analysis_result_id).FirstOrDefault();
         if (mar != null)  //有运行过算法
         {
             //加入match_analysis数据
             strNode += "||" + mar.Result_fit + "::" + mar.Result_goals + "::" + mar.Result_wdl + "::" + mar.Fit_win_loss + "::" +
                             mar.Home_goals + "::" + mar.Away_goals + "::" + (mar.Home_goals - mar.Away_goals) + "::" +
                             mar.Home_w.ToString() + "::" + mar.Home_d.ToString() + "::" + mar.Home_l.ToString();
             if (mar.Result_tb_lib_id != null)  //有导入了结果
             {
                 //加入result_tb数据
                 rtl = rtlAll.Where(e => e.Result_tb_lib_id == mar.Result_tb_lib_id).FirstOrDefault();
                 strNode += "||" + rtl.Match_time.Value.ToShortDateString() + "::" +
                                     rtl.Full_home_goals.ToString() + "-" + rtl.Full_away_goals.ToString() + "::" +
                                     rtl.Odds + "::" + rtl.Win_loss_big + "::" + rtl.Home_team + "::" + rtl.Away_team;
             }
             fit = mar.Fit_win_loss;
             goals = mar.Home_goals - mar.Away_goals;
             wdl = mar.Home_w - mar.Home_l;
         }
         //加入bj单场数据
         foreach (var lo in loAll)
             if (ltl.Home_team.Contains(lo.MatchOrder1_HomeName) || ltl.Away_team.Contains(lo.MatchOrder1_AwayName))   //有匹配bj单场的数据
                 strNode += "********" + lo.Value + ">>" + lo.MatchOrder1_HandicapNumber;
         TreeNode child = new TreeNode(strNode);
         tn.Nodes.Add(child);
         //颜色处理
         if (fit < 0) child.ForeColor = Color.Blue;
         if (goals < 0) child.BackColor = Color.Orange;
         if (wdl < 0) child.NodeFont = new Font("Trebuchet MS", 10, FontStyle.Bold);
         if (strNode.Contains(">>")) child.Parent.ForeColor = Color.Red;
     }
 }