コード例 #1
0
        public int InsertLiveHtmlTableToDB()
        {
            DataTable dt = SevenmLive.GetHtmlTable();

            DataClassesMatchDataContext match = new DataClassesMatchDataContext(Conn.conn);

            if (!Conn.CreateTable(typeof(Live_Table))) { return 0; }
            //var result = match.Live_Table.Where(r => r.Live_table_id > 0);
            //match.Live_Table.DeleteAllOnSubmit(result);
            //match.SubmitChanges();

            string ddate = null;
            string ndate = null; //修改当天完场的问题  2011.6.11
            Queue<string> todayDate = new Queue<string>();

            foreach (DataRow aa in dt.Rows)
            {
                if (HtmlDateToStrLive(aa[1].ToString()) != null)
                {
                    if (HtmlDateToStrLive(aa[1].ToString()).IndexOf("最新賽果") == -1)
                    {
                        ddate = HtmlDateToStrLive(aa[1].ToString());
                        ddate = ddate.Replace("年", "-").Replace("月", "-").Replace("日", " ");
                        todayDate.Enqueue(ddate);
                    }
                    else
                    {
                        todayDate.Dequeue();//删除第1条  2011.6.11 
                        ndate = todayDate.Peek();//取第1个元素  2011.6.11
                        ddate = ndate;
                    }
                }

                if (HtmlTextToStr(aa[3].ToString()) != null)
                {
                    Live_Table lt = new Live_Table();
                    lt.Html_position = aa[0].ToString();
                    lt.Match_type = HtmlTextToStr(aa[2].ToString());
                    lt.S_time = HtmlTextToStr(aa[3].ToString());
                    lt.Home_team = HtmlTextToStr(aa[5].ToString());
                    lt.Full_time_score = HtmlTextToStr(aa[6].ToString());
                    lt.Away_team = HtmlTextToStr(aa[7].ToString());
                    lt.Half_time_score = HtmlTextToStr(aa[8].ToString());
                    lt.S_date = ddate;
                    lt.Home_team_big = HtmlHrefToStr(aa[5].ToString());
                    lt.Away_team_big = HtmlHrefToStr(aa[7].ToString());

                    match.Live_Table.InsertOnSubmit(lt);


                }
            }
            match.SubmitChanges();
            return match.Live_Table.Max(e => e.Live_table_id);
        }
コード例 #2
0
        public decimal InsertLiveHtmlTableToDB()
        {
            DataTable dt = SevenmLive.GetHtmlTable();

            //SoccerScoreCompact match = new SoccerScoreCompact(cnn);

            var result = Conn.match.Live_Table.Where(r => r.Live_table_id > 0);
            Conn.match.Live_Table.DeleteAllOnSubmit(result);
            //Conn.match.SubmitChanges();

            string ddate = null;
            Queue<string> todayDate = new Queue<string>();

            foreach (DataRow aa in dt.Rows)
            {
                if (HtmlDateToStrLive(aa[1].ToString()) != null)
                {
                    if (HtmlDateToStrLive(aa[1].ToString()).IndexOf("最新賽果") == -1)
                    {
                        ddate = HtmlDateToStrLive(aa[1].ToString());
                        ddate = ddate.Replace("年", "-").Replace("月", "-").Replace("日", " ");
                        todayDate.Enqueue(ddate);
                    }
                    else
                    {
                        ddate = todayDate.Dequeue();
                    }
                }

                if (HtmlTextToStr(aa[3].ToString()) != null)
                {
                    Live_Table lt = new Live_Table();
                    lt.Html_position= aa[0].ToString();
                    lt.Match_type = HtmlTextToStr(aa[2].ToString());
                    lt.S_time = HtmlTextToStr(aa[3].ToString());
                    lt.Home_team = HtmlTextToStr(aa[5].ToString());
                    lt.Full_time_score= HtmlTextToStr(aa[6].ToString());
                    lt.Away_team = HtmlTextToStr(aa[7].ToString());
                    lt.Half_time_score = HtmlTextToStr(aa[8].ToString());
                    lt.S_date= ddate;
                    lt.Home_team_big = HtmlHrefToStr(aa[5].ToString());
                    lt.Away_team_big = HtmlHrefToStr(aa[7].ToString());

                    Conn.match.Live_Table.InsertOnSubmit(lt);
                    
                    
                }
                Conn.match.SubmitChanges();
            }

            return Conn.match.Live_Table.Select(e => e.Live_table_id).Max();
        }
コード例 #3
0
 partial void DeleteLive_Table(Live_Table instance);
コード例 #4
0
 partial void UpdateLive_Table(Live_Table instance);
コード例 #5
0
 partial void InsertLive_Table(Live_Table instance);