Exemple #1
0
        internal static void Rank(object o)
        {
            string connStr = "Provider=Microsoft.ACE.OLEDB.12.0;data source=rank.accdb";

            try
            {
                using (OleDbConnection dbc = new OleDbConnection(connStr))
                {
                    dbc.Open();
                    DataSet          ds  = new DataSet();
                    OleDbDataAdapter adp = new OleDbDataAdapter();

                    for (int c = 0; c < 15; c++)
                    {
                        ha         = RankInfo.PrepareHttpAccesser(StarScript.ha, universe, c * 100 + 1);
                        ha.Cookies = ccold;
                        IEnumerator i = ccnew.GetEnumerator();
                        while (i.MoveNext())
                        {
                            ha.Cookies.Add((Cookie)i.Current);
                        }
                        ccold = ha.Cookies;
                        ccnew = ha.access();
                        RankInfo[] ris = RankInfo.AnalyzHtml();

                        for (int j = 0; j < ris.Length; j++)
                        {
                            if (ris[j] != null)
                            {
                                adp.InsertCommand = new OleDbCommand(@"insert into rank (rank,player,score,cdate) values ('" + ris[j].Rank + "','" + ris[j].User + "','" + ris[j].Score + "',now())", dbc);
                                adp.InsertCommand.ExecuteNonQuery();
                            }
                        }
                    }
                }
            }
            catch (System.InvalidOperationException ioe)
            {
                if (ioe.ToString().Contains("OLEDB"))
                {
                    MessageBox.Show(ConstString.suggest_db_conn_program_not_install);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            RankScanOverHandler(0);
        }
Exemple #2
0
        internal static RankInfo[] AnalyzHtml()
        {
            RankInfo[] ris = new RankInfo[100];

            HtmlAgilityPack.HtmlDocument h = new HtmlAgilityPack.HtmlDocument();

            h.Load(Strings.HTML_PATH);
            for (int i = 0; i < 100; i++)
            {
                ris[i] = new RankInfo();
                HtmlAgilityPack.HtmlNode hn_user  = h.DocumentNode.SelectSingleNode(XPATH_PLAYER1 + (i + 2) + XPATH_PLAYER2);
                HtmlAgilityPack.HtmlNode hn_score = h.DocumentNode.SelectSingleNode(XPATH_SCORE1 + (i + 2) + XPATH_SCORE2);
                HtmlAgilityPack.HtmlNode hn_rank  = h.DocumentNode.SelectSingleNode(XPATH_RANK1 + (i + 2) + XPATH_RANK2);

                ris[i].User  = hn_user.InnerText;
                ris[i].Score = ProductivityInfo.ToInt(hn_score.InnerText);
                ris[i].Rank  = ProductivityInfo.ToInt(hn_rank.InnerText);
            }
            return(ris);
        }