Beispiel #1
0
        public void OutData(CR_Galaxy.ExPlanet[] spExInfo)
        {
            //作废,心疼啊
            //string OutStr = "INSERT INTO galaxy ( [Galaxy], [System], [Location], [PlanetName], [Username], [Rankings], [Union], [UnionRankings], [Members], [Moon], [vacation], [inactive], [longinactive], [banned], [Spy], [Date],[Memo],[GalaxySystem] ) VALUES (" +
            //    "{0}, {1}, {2}, '{3}', '{4}', {5}, '{6}', {7}, {8}, {9}, {10}, {11}, {12}, {13}, {14}, '{15}',{16},'{17}')";

            //string UpDataStr = "UPDATE galaxy SET [PlanetName]='{3}', [Username]='{4}', [Rankings]={5}, [Union]='{6}', [UnionRankings]={7}, [Members]={8}, [Moon]={9}, [vacation]={10}, [inactive]={11}," +
            //    "[longinactive]={12}, [banned]= {13}, [Spy]={14}, [Date]= '{15}',[Memo]={16},[GalaxySystem]='{17}' where  [Galaxy]={0} and [System]={1} and [Location]={2}";

            string OutStr = "INSERT INTO galaxy ( GalaxySystem, Galaxy, System, Location, PlanetName, Moon, MoonSize, Metal, Crystal, Username, [Union], vacation, inactive, longinactive, banned, Spy, [Date], [Memo],Ni,[Rankings], [UnionRankings], [Members] ) VALUES (" +
                            "'{0}', {1},{2}, {3}, '{4}', {5}, {6}, {7}, {8}, '{9}', '{10}', {11}, {12}, {13}, {14}, '{15}', '{16}', '{17}',{18},{19},{20},{21})";

            string UpDataStr = "UPDATE galaxy SET galaxy.GalaxySystem = '{0}', galaxy.Galaxy = {1}, galaxy.System = {2}, galaxy.Location = {3}, galaxy.PlanetName = '{4}', galaxy.Moon = {5}, galaxy.MoonSize = {6}, galaxy.Metal = {7}, " +
                               "galaxy.Crystal = {8}, galaxy.Username = '******', galaxy.[Union] = '{10}', galaxy.vacation = {11}, galaxy.inactive = {12}, galaxy.longinactive = {13}, galaxy.banned = {14}, galaxy.Spy = '{15}', galaxy.[Date] = '{16}', galaxy.[Memo] = '{17}',galaxy.Ni = {18} ,[Rankings]={19}, [UnionRankings]={20} ,[Members] = {21} " +
                               "where  GalaxySystem='{0}' ";

            string HasStr = "SELECT galaxy.ID,galaxy.inactive,galaxy.Username FROM galaxy WHERE Galaxy={0} and System ={1} and Location={2};";


            for (int i = 0; i <= 14; i++)
            {
                try
                {
                    if ((spExInfo[i].Galaxy == 0) || (spExInfo[i].System == 0) || (spExInfo[i].Location == 0))
                    {
                        continue;
                    }
                    string[] Par =
                    {
                        spExInfo[i].Galaxy.ToString() + ":" + spExInfo[i].System.ToString() + ":" + spExInfo[i].Location.ToString(),
                        spExInfo[i].Galaxy.ToString(),
                        spExInfo[i].System.ToString(),
                        spExInfo[i].Location.ToString(),
                        spExInfo[i].PlanetName,
                        spExInfo[i].Moon.ToString(),
                        spExInfo[i].MoonSize.ToString(),
                        spExInfo[i].Metal.ToString(),
                        spExInfo[i].Crystal.ToString(),
                        spExInfo[i].Username,
                        spExInfo[i].Union,
                        spExInfo[i].Vacation.ToString(),
                        spExInfo[i].Inactive.ToString(),
                        spExInfo[i].LongInactive.ToString(),
                        spExInfo[i].Banned.ToString(),
                        "",
                        DateTime.Now.ToString("yyyy-M-d"),
                        "",
                        "False",
                        spExInfo[i].Rankings.ToString(),
                        spExInfo[i].UnionRankings.ToString(),
                        spExInfo[i].Members.ToString()
                    };

                    DataTable s = (_Access.TableSqlEcx(HasStr, new string[] { spExInfo[i].Galaxy.ToString(), spExInfo[i].System.ToString(), spExInfo[i].Location.ToString() }));
                    //检查搜索到的行数
                    if (s.Rows.Count >= 1)
                    {
                        if (((bool)s.Rows[0]["inactive"] == false) && (spExInfo[i].Inactive == true))
                        {
                            Par[18] = "True";
                        }
                        if (spExInfo[i].Username == s.Rows[0]["Username"].ToString())
                        {
                            spExInfo[i].Spy = s.Rows[0]["Spy"].ToString();
                        }
                        _Access.ReutnSqlEcx(UpDataStr, Par);
                    }
                    else
                    {
                        _Access.ReutnSqlEcx(OutStr, Par);
                    }
                }
                catch (Exception ee)
                {
                    _Log.AddError("<OutData>" + ee.Message);
                }
            }
        }
Beispiel #2
0
        public void GetUserInfo(ExPlanet[] spExPlanet)
        {
            try
            {
                HtmlElement dom = _WB.Document.GetElementById("fleetstatusrow");
                HtmlElement tt  = dom.Parent.Parent;//到这里获得表格对象

                //  TxtShowWeb.Text = tt.Children[0].Children[2].Children[0].InnerText;
                for (int i = 0; i <= 14; i++)
                {
                    try
                    {
                        spExPlanet[i].Galaxy     = Convert.ToInt32(_GalaxySystem.GetGalaxy());                                   //银河
                        spExPlanet[i].System     = Convert.ToInt32(_GalaxySystem.GetSystme());                                   //太阳系
                        spExPlanet[i].Location   = Convert.ToInt32(tt.Children[0].Children[i + 2].Children[0].InnerText.Trim()); //位置
                        spExPlanet[i].PlanetName = tt.Children[0].Children[i + 2].Children[2].InnerText;                         //玩家名字
                    }
                    catch (Exception ee)
                    {
                        _Log.AddError("<GetUserInfo-星系星系>" + ee.Message);
                    }

                    if (tt.Children[0].Children[i + 2].Children[3].InnerHtml != null)//月球状态
                    {
                        try
                        {
                            string MoonInfo = tt.Children[0].Children[i + 2].Children[3].InnerHtml;
                            if (MoonInfo.IndexOf(_SerInfo.Moon) != -1)
                            {
                                spExPlanet[i].Moon = true;
                                MoonInfo           = MoonInfo.Substring(MoonInfo.IndexOf(_SerInfo.MoonSize) + _SerInfo.MoonSize.Length);
                                MoonInfo           = MoonInfo.Substring(0, MoonInfo.IndexOf(_SerInfo.MoonSizeEnd));
                                if (MoonInfo.IndexOf(".") > -1)
                                {
                                    spExPlanet[i].MoonSize = Convert.ToInt32(MoonInfo.Replace(".", "").Trim());
                                }
                                else
                                {
                                    spExPlanet[i].MoonSize = Convert.ToInt32(MoonInfo.Trim());
                                }
                            }
                        }
                        catch (Exception ee)
                        {
                            _Log.AddError("<GetUserInfo-月球状态>" + ee.Message);
                        }
                    }



                    if (tt.Children[0].Children[i + 2].Children[4].InnerHtml != null)//垃圾情况
                    {
                        try
                        {
                            string Wreckage = tt.Children[0].Children[i + 2].Children[4].InnerHtml;
                            Wreckage = Wreckage.Substring(Wreckage.IndexOf(_SerInfo.Metal) + _SerInfo.Metal.Length);

                            spExPlanet[i].Metal = Convert.ToInt32(Wreckage.Substring(0, Wreckage.IndexOf(_SerInfo.WreckageEnd)).Replace(".", "").Trim());

                            Wreckage = Wreckage.Substring(Wreckage.IndexOf(_SerInfo.Crystal) + _SerInfo.Crystal.Length);
                            spExPlanet[i].Crystal = Convert.ToInt32(Wreckage.Substring(0, Wreckage.IndexOf(_SerInfo.WreckageEnd)).Replace(".", "").Trim());
                        }
                        catch (Exception ee)
                        {
                            _Log.AddError("<GetUserInfo-月球状态>" + ee.Message);
                        }
                    }
                    else
                    {
                        spExPlanet[i].Metal   = 0;
                        spExPlanet[i].Crystal = 0;
                    }


                    //用户名

                    try
                    {
                        spExPlanet[i].Username = tt.Children[0].Children[i + 2].Children[5].InnerText;
                        if (tt.Children[0].Children[i + 2].Children[5].Children != null)
                        {
                            foreach (HtmlElement HE in tt.Children[0].Children[i + 2].Children[5].Children)
                            {
                                switch (HE.InnerText)
                                {
                                case "s":;
                                    break;

                                case "i": spExPlanet[i].Inactive = true;
                                    break;

                                case "I": spExPlanet[i].LongInactive = true;
                                    break;

                                case "u": spExPlanet[i].Vacation = true;
                                    break;

                                case "g": spExPlanet[i].Banned = true;
                                    break;

                                case "n": spExPlanet[i].Username += "(n)";
                                    break;                               //小绿人

                                case "v": spExPlanet[i].Vacation = true; //英国服务器的假期
                                    break;

                                case "b": spExPlanet[i].Banned = true;    //英国服务器的被封
                                    break;

                                default:
                                    spExPlanet[i].Username = HE.InnerText;
                                    break;
                                }
                            }
                        }
                    }
                    catch (Exception ee)
                    {
                        _Log.AddError("<GetUserInfo-用户信息>" + ee.Message);
                    }


                    try
                    {
                        if ((spExPlanet[i].Username != "") && (spExPlanet[i].Username != null))
                        {
                            string PM;
                            PM = tt.Children[0].Children[i + 2].Children[5].InnerHtml;
                            string TmpPM = PM.Substring(PM.IndexOf(_SerInfo.Rankings) + _SerInfo.Rankings.Length, PM.IndexOf(_SerInfo.td) - PM.IndexOf(_SerInfo.Rankings) - _SerInfo.Rankings.Length).Trim();
                            if (TmpPM.Length == 0)
                            {
                                spExPlanet[i].Rankings = 0;
                            }
                            else
                            {
                                spExPlanet[i].Rankings = Convert.ToInt32(TmpPM);
                            }
                        }
                    }
                    catch (Exception ee)
                    {
                        _Log.AddError("<GetUserInfo-用户排名信息>" + ee.Message);
                    }

                    try
                    {
                        spExPlanet[i].Union = tt.Children[0].Children[i + 2].Children[6].InnerText;

                        if ((spExPlanet[i].Union != "") && (spExPlanet[i].Union != null))
                        {
                            string LM;
                            LM = tt.Children[0].Children[i + 2].Children[6].InnerHtml;
                            string TmpPM = LM.Substring(LM.IndexOf(_SerInfo.Rankings) + _SerInfo.Rankings.Length, LM.IndexOf(_SerInfo.Have) - LM.IndexOf(_SerInfo.Rankings) - _SerInfo.Rankings.Length).Trim();
                            if (TmpPM.Length == 0)
                            {
                                spExPlanet[i].UnionRankings = 0;
                            }
                            else
                            {
                                spExPlanet[i].UnionRankings = Convert.ToInt32(TmpPM);
                            }
                            spExPlanet[i].Members = Convert.ToInt32(LM.Substring(LM.IndexOf(_SerInfo.Have) + _SerInfo.Have.Length, LM.IndexOf(_SerInfo.Members) - LM.IndexOf(_SerInfo.Have) - _SerInfo.Have.Length).Trim());
                        }
                    }
                    catch (Exception ee)
                    {
                        _Log.AddError("<GetUserInfo-联盟信息>" + ee.Message);
                    }
                }
            }
            catch (Exception ee)
            {
                _Log.AddError("<GetUserInfo>" + ee.Message);
            }
        }