public void top20Algorithm()
 {
     using ( SoccerScoreSqlite matches = new SoccerScoreSqlite(Conn.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();
             MatchAnalysisResult mar = new MatchAnalysisResult();
             mar.LiveTableLibID= r.id;
             mar.PreAlgorithm = "top20";
             mar.PreMatchCount = r.Top20Count;
             mar.HomeGoals =(float) r.HomeGoals;
             mar.AwayGoals = (float)r.AwayGoals;
             mar.HomeW = r.hWin;
             mar.HomeD = r.hDraw;
             mar.HomeL = r.hLose;
             mar.FitWinLoss = (float)r.CureFitWinLoss;
             mar.FitGoals = (float) r.CureFitGoals;
             mar.FitOddEven = (float)r.CureFitOddEven;
             matches.MatchAnalysisResult.InsertOnSubmit(mar);
            
         }
         matches.SubmitChanges();
     }
 }
 private void TreeNodeLoad(TreeNode tn)
 {
     foreach (var ltl in ltls)
     {
         double? fit = 0, goals = 0, wdl = 0;
         //加入live_table数据
         strNode = ltl.LiveTableLibID + "," + ltl.MatchType + "," + ltl.MatchTime + "::" + ltl.HomeTeam + "::" + ltl.AwayTeam + "::" + ltl.Status;
         mar = marAll.Where(o => o.LiveTableLibID == ltl.LiveTableLibID).OrderByDescending(o => o.AnalysisResultID).FirstOrDefault();
         if (mar != null)  //有运行过算法
         {
             //加入match_analysis数据
             strNode += "||" + mar.ResultFit + "::" + mar.ResultGoals + "::" + mar.ResultWDL + "::" + mar.FitWinLoss + "::" +
                             mar.HomeGoals + "::" + mar.AwayGoals + "::" + (mar.HomeGoals - mar.AwayGoals) + "::" +
                             mar.HomeW.ToString() + "::" + mar.HomeD.ToString() + "::" + mar.HomeL.ToString();
             if (mar.ResultTBLibID != null)  //有导入了结果
             {
                 //加入result_tb数据
                 rtl = rtlAll.Where(e => e.ResultTBLibID== mar.ResultTBLibID).FirstOrDefault();
                 strNode += "||" + rtl.MatchTime.Value.ToShortDateString() + "::" +
                                     rtl.FullHomeGoals.ToString() + "-" + rtl.FullAwayGoals.ToString() + "::" +
                                     rtl.Odds + "::" + rtl.WinLossBig + "::" + rtl.HomeTeam + "::" + rtl.AwayTeam;
             }
             fit = mar.FitWinLoss;
             goals = mar.HomeGoals - mar.AwayGoals;
             wdl = mar.HomeW - mar.HomeL;
         }
         //加入bj单场数据
         foreach (var lo in loAll)
             if (ltl.HomeTeam.Contains(lo.MatchOrder1hOmeName) || ltl.AwayTeam.Contains(lo.MatchOrder1aWayName))   //有匹配bj单场的数据
                 strNode += "********" + lo.Value + ">>" + lo.MatchOrder1hAndicapNumber;
         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;
     }
 }