예제 #1
0
        //private ObjectSender OnObjectSend;
        //internal event ObjectSender OnOnbjectRecive
        //{
        //    add { OnObjectSend += new ObjectSender(value); }
        //    remove { OnObjectSend -= new ObjectSender(value); }
        //}


        private void OnObjectRecived(object o)
        {
            if (o.GetType() == typeof(OverviewInfo))
            {
                info = (OverviewInfo)o;
            }
            else if (o.GetType() == typeof(ArrayList))
            {
                balls = (ArrayList)o;
            }
            else if (o.GetType() == typeof(ProductivityInfo))
            {
                pi = (ProductivityInfo)o;
            }
            Object[] list = { this, System.EventArgs.Empty };
            this.outputArea.BeginInvoke(new EventHandler(ShowInfo2), list);
        }
예제 #2
0
        internal static void Productivity(object o)
        {
            ArrayList balls = new ArrayList();

            ha         = ProductivityInfo.PrepareHttpAccesser(universe);
            ha.Referer = referer;
            string baseurl = ha.AccessUrl;

            ha.Cookies = ccold;
            IEnumerator i = ccnew.GetEnumerator();

            while (i.MoveNext())
            {
                ha.Cookies.Add((Cookie)i.Current);
            }
            ccold = ha.Cookies;
            ccnew = ha.access();
            //取得第一个星球的总星球列表
            pi = ProductivityInfo.AnalyzHtml();

            foreach (ProductivityInfo.Ball ball in pi.Balllist)
            {
                ha.Referer   = ha.AccessUrl;
                ha.AccessUrl = baseurl + ball.AccessParm;
                ha.Cookies   = ccold;
                IEnumerator ie = ccnew.GetEnumerator();
                while (ie.MoveNext())
                {
                    ha.Cookies.Add((Cookie)ie.Current);
                }
                ccnew = ha.access();
                //取得每一个星球
                ProductivityInfo piloop = ProductivityInfo.AnalyzHtml();
                balls.Add(piloop);
                MessageEventHandler(100 / pi.Balllist.Count);
            }
            Thread.Sleep(600);
            referer = ha.AccessUrl;
            ObjectEventHandler(pi);
            Thread.Sleep(200);
            ObjectEventHandler(balls);
            Thread.Sleep(200);
        }
예제 #3
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);
        }
예제 #4
0
        internal static ConstructionInfo AnalyzHtml()
        {
            ConstructionInfo ci = new ConstructionInfo();
            HtmlDocument     h  = new HtmlAgilityPack.HtmlDocument();

            h.Load(Strings.HTML_PATH);
            //当前金属矿
            int firstN = 0;

            for (int i = 2; i < 8; i++)
            {
                HtmlNode hn_firstcon = h.DocumentNode.SelectSingleNode(string.Format(XPATH_CONSTRUCTION + "/a", i));
                if (hn_firstcon != null && ("金属矿".Equals(hn_firstcon.InnerText.Trim()) || "机器人工厂".Equals(hn_firstcon.InnerText.Trim())))
                {
                    firstN = i;
                    break;
                }
            }
            if (firstN != 0)
            {
                for (int j = firstN; true; j++)
                {
                    HtmlNode hn_con_name     = h.DocumentNode.SelectSingleNode(string.Format(XPATH_CONSTRUCTION + "/a", j));
                    HtmlNode hn_con_next_1st = h.DocumentNode.SelectSingleNode(string.Format(XPATH_CONSTRUCTION + "/b[1]", j));
                    HtmlNode hn_con_next_2nd = h.DocumentNode.SelectSingleNode(string.Format(XPATH_CONSTRUCTION + "/b[2]", j));
                    HtmlNode hn_con_next_3rd = h.DocumentNode.SelectSingleNode(string.Format(XPATH_CONSTRUCTION + "/b[3]", j));

                    HtmlNode hn_con_need_1st = h.DocumentNode.SelectSingleNode(string.Format(XPATH_CONSTRUCTION + "/font/b[1]", j));
                    HtmlNode hn_con_need_2nd = h.DocumentNode.SelectSingleNode(string.Format(XPATH_CONSTRUCTION + "/font//b[2]", j));
                    HtmlNode hn_con_need_3rd = h.DocumentNode.SelectSingleNode(string.Format(XPATH_CONSTRUCTION + "/font//b[3]", j));

                    if (hn_con_name == null)
                    {
                        break;
                    }
                    else
                    {
                        Construction c = new Construction();
                        c.innerText = hn_con_name.InnerText;
                        //如果是地形改造器,则不需要金属。
                        if ("地形改造器".Equals(c.innerText.Trim()))
                        {
                            c.nextMetal = 0;
                            c.needMetal = 0;
                            if (hn_con_next_1st != null)
                            {
                                c.nextCrystal = ProductivityInfo.ToInt(hn_con_next_1st.InnerText);
                            }
                            if (hn_con_next_2nd != null)
                            {
                                c.nextH = ProductivityInfo.ToInt(hn_con_next_2nd.InnerText);
                            }
                            if (hn_con_need_1st != null)
                            {
                                c.needCrystal = ProductivityInfo.ToInt(hn_con_need_1st.InnerText);
                            }
                            if (hn_con_need_2nd != null)
                            {
                                c.needH = ProductivityInfo.ToInt(hn_con_need_2nd.InnerText);
                            }
                        }
                        else
                        {
                            if (hn_con_next_1st != null)
                            {
                                c.nextMetal = ProductivityInfo.ToInt(hn_con_next_1st.InnerText);
                            }
                            if (hn_con_next_2nd != null)
                            {
                                c.nextCrystal = ProductivityInfo.ToInt(hn_con_next_2nd.InnerText);
                            }
                            if (hn_con_next_3rd != null)
                            {
                                c.nextH = ProductivityInfo.ToInt(hn_con_next_3rd.InnerText);
                            }
                            if (hn_con_need_1st != null)
                            {
                                c.needMetal = ProductivityInfo.ToInt(hn_con_need_1st.InnerText);
                            }
                            if (hn_con_need_2nd != null)
                            {
                                c.needCrystal = ProductivityInfo.ToInt(hn_con_need_2nd.InnerText);
                            }
                            if (hn_con_need_3rd != null)
                            {
                                c.needH = ProductivityInfo.ToInt(hn_con_need_3rd.InnerText);
                            }
                        }
                        ci.allCons.Add(c);
                    }
                }
            }
            return(ci);
        }
예제 #5
0
        internal static void Locations(object o)
        {
            ha = LocationsInfo.PrepareHttpAccesser(universe);
            //ha.Referer = referer;
            ha.Cookies = ccold;
            IEnumerator i = ccnew.GetEnumerator();

            while (i.MoveNext())
            {
                ha.Cookies.Add((Cookie)i.Current);
            }
            ccold = ha.Cookies;
            ccnew = ha.access();
            LocationsInfo[] mylis = LocationsInfo.AnalyzHtml();

            ha.AccessMethod = HttpAccesser.ACCESS_METHOD.POST;
            ha.AccessUrl    = "http://" + universe + ".cicihappy.com/ogame/galaxy.php?mode=1";
            ha.Referer      = "http://" + universe + ".cicihappy.com/ogame/galaxy.php?mode=0";
            //Txtout.writeA("银河系,太阳系,行星,联盟,玩家,星球名,月球,度假\r\n", "balls.csv");
            string connStr = "Provider=Microsoft.ACE.OLEDB.12.0;data source=rank.accdb";

            try
            {
                using (OleDbConnection dbc = new OleDbConnection(connStr))
                {
                    dbc.Open();
                    OleDbDataAdapter adp = new OleDbDataAdapter();
                    adp.SelectCommand = new OleDbCommand(@"select max([_id]) as maxid from scanprocess where not complete", dbc);
                    DataTable dt        = new DataTable();
                    string    processid = string.Empty;
                    bool      usecontinue;
                    adp.Fill(dt);
                    if (dt.Rows.Count > 0 && !dt.Rows[0][0].ToString().Equals(string.Empty))
                    {
                        usecontinue = true;
                        processid   = dt.Rows[0][0].ToString();
                    }
                    else
                    {
                        usecontinue = false;
                    }
                    if (usecontinue)
                    {
                        //找到最后一次扫描的最后一个球的坐标 -- galaxy and solar index
                        adp.SelectCommand = new OleDbCommand(@"select top 1 galaxy, solar from 
    (select *,galaxy * 1000 + solar as xuhao from galaxymap where process = " + processid + @")t1 order by xuhao desc", dbc);
                        dt.Columns.Clear();
                        dt.Clear();
                        adp.Fill(dt);
                        int galaxyStart;
                        int solarStart;
                        if (dt.Rows.Count == 0)
                        {
                            galaxyStart = 1;
                            solarStart  = 1;
                        }
                        else
                        {
                            galaxyStart = ProductivityInfo.ToInt(dt.Rows[0][0].ToString());
                            solarStart  = ProductivityInfo.ToInt(dt.Rows[0][1].ToString());
                        }
                        //根据坐标继续扫描
                        GalaxyLoop(processid, galaxyStart, solarStart, adp, dbc);
                    }
                    else
                    {
                        //创建一个新的扫描过程
                        adp.InsertCommand = new OleDbCommand(@"insert into scanprocess (complete, cdate) values (false, now())", dbc);
                        adp.InsertCommand.ExecuteNonQuery();
                        adp.SelectCommand = new OleDbCommand(@"select max([_id]) as maxid from scanprocess where not complete", dbc);
                        dt.Columns.Clear();
                        dt.Clear();
                        adp.Fill(dt);
                        if (dt.Rows.Count > 0)
                        {
                            processid = dt.Rows[0][0].ToString();
                            //从头扫描
                            GalaxyLoop(processid, 1, 1, adp, dbc);
                        }
                    }
                }
            }
            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());
            }
        }
예제 #6
0
        internal static ProductivityInfo AnalyzHtml()
        {
            ProductivityInfo pi = new ProductivityInfo();

            HtmlDocument h = new HtmlAgilityPack.HtmlDocument();

            HtmlNode.ElementsFlags.Remove("option");
            h.Load(Strings.HTML_PATH);

            //星球列表
            HtmlNode hn_ball = h.DocumentNode.SelectSingleNode(XPATH_BALL_LIST);

            foreach (HtmlNode hn in hn_ball.ChildNodes)
            {
                if ("option".Equals(hn.Name))
                {
                    Ball  ball = new Ball();
                    Regex rx   = new Regex("\\w*(?=\\&nbsp;)");
                    Match m    = rx.Match(hn.InnerText);
                    if (m.Value != null)
                    {
                        ball.Name = m.Value;
                    }
                    else
                    {
                        ball.Name = "Unknow";
                    }
                    rx = new Regex("(?<=\\&nbsp;\\[).*(?=\\]\\&nbsp;\\&nbsp;)");
                    m  = rx.Match(hn.InnerText);
                    if (m.Value != null)
                    {
                        ball.Location = m.Value;
                    }
                    else
                    {
                        ball.Location = "0:0:0";
                    }


                    foreach (HtmlAttribute ha in hn.Attributes)
                    {
                        if ("value".Equals(ha.Name))
                        {
                            ball.AccessParm = ha.Value.Replace("&amp;", "&");
                        }
                    }
                    pi.Balllist.Add(ball);
                }
            }

            //当前球的名字
            HtmlNode hn_ballname = h.DocumentNode.SelectSingleNode(XPATH_BALL_NAME);
            Regex    rr          = new Regex("\"(\\w*)\"");
            Match    mm          = rr.Match(hn_ballname.InnerText);

            pi.CurrentBallName = mm.Groups[1].Value;
            //当前金属存量
            HtmlNode hn_metal = h.DocumentNode.SelectSingleNode(XPATH_METAL);

            pi.Metal = ToInt(hn_metal.InnerText);
            //金属仓库
            HtmlNode hn_metalstore = h.DocumentNode.SelectSingleNode(XPATH_METAL_STORE);

            pi.MetalStore = ToInt(hn_metalstore.InnerText);
            //当前晶体存量
            HtmlNode hn_crystal = h.DocumentNode.SelectSingleNode(XPATH_CRYSTAL);

            pi.Crystal = ToInt(hn_crystal.InnerText);
            //晶体仓库
            HtmlNode hn_crystal_store = h.DocumentNode.SelectSingleNode(XPATH_CRYSTAL_STORE);

            pi.CrystalStore = ToInt(hn_crystal_store.InnerText);
            //当前重氢存量
            HtmlNode hn_h = h.DocumentNode.SelectSingleNode(XPATH_H);

            pi.H = ToInt(hn_h.InnerText);
            //重氢仓库
            HtmlNode hn_hstore = h.DocumentNode.SelectSingleNode(XPATH_H_STROE);

            pi.HStore = ToInt(hn_hstore.InnerText);
            //当前能量
            HtmlNode hn_energy = h.DocumentNode.SelectSingleNode(XPATH_ENERGY);

            pi.Energy = ToInt(hn_energy.InnerText);
            //总能量
            HtmlNode hn_energystore = h.DocumentNode.SelectSingleNode(XPATH_ENERGY_STROE);

            pi.EnergyStroe = ToInt(hn_energystore.InnerText);

            HtmlNode.ElementsFlags.Remove("tr");
            HtmlNode.ElementsFlags.Remove("td");
            //金属产量
            HtmlNode hn_metalp = h.DocumentNode.SelectSingleNode(XPATH_METAL_HOUR);

            if (hn_metalp == null)
            {
                pi.MetalHour = 0;
            }
            else
            {
                pi.MetalHour = ToInt(hn_metalp.InnerText);
            }

            //晶体产量
            HtmlNode hn_crystalp = h.DocumentNode.SelectSingleNode(XPATH_CRYSTAL_HOUR);

            if (hn_crystalp == null)
            {
                pi.CrystalHour = 0;
            }
            else
            {
                pi.CrystalHour = ToInt(hn_crystalp.InnerText);
            }

            //重氢产量
            HtmlNode hn_hp = h.DocumentNode.SelectSingleNode(XPATH_H_HOUR);

            if (hn_hp == null)
            {
                pi.HHour = 0;
            }
            else
            {
                pi.HHour = ToInt(hn_hp.InnerText);
            }
            //太阳能(基地)

            //太阳能(卫星)

            return(pi);
        }