예제 #1
0
        /// <summary>
        /// 主过程协调一切事宜
        /// </summary>
        public bool Main()
        {
            if (_WB.Document.GetElementById("fleetstatusrow") == null)
            {
                //_WB.Navigate(_Navigate.EndUrl);
                _GalaxySystem.Goto(_SerInfo.WebsiteEx, _Navigate._Session);
                _Log.AddWarning(_GalaxySystem.GetSystme() + "页面分析错误,重新载入并分析");
                return(true);
            }

            //Planet[] Planet = new Planet[15];//为了每次都有新的数据,所以创建新对象
            //使用新的结构存储数据

            ExPlanet[] ExPlanet = new ExPlanet[15];
            //Rankings[] Rankings =new Rankings [15]

            GetUserInfo(ExPlanet);     //数据获得

            _IOData.OutData(ExPlanet); //数据保存

            _SystemCount++;

            _GalaxySystem.SystemInc();//转入下一个星系
            if (_GalaxySystem.Overflow() == 4)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
예제 #2
0
        /// <summary>
        /// 导入数据用
        /// </summary>
        /// <param name="spPath"></param>
        /// <param name="spPBar"></param>
        public void InData(string spPath, ProgressBar spPBar)
        {
            DataTable DT = _Access.Find("galaxy", "ID", -1);

            // DT.ReadXmlSchema(spPath);
            DT.ReadXml(spPath);

            spPBar.Maximum = DT.Rows.Count;


            string OutStr = "INSERT INTO galaxy ( GalaxySystem, Galaxy, System, Location, PlanetName, Moon, MoonSize, Metal, Crystal, Username, [Union], vacation, inactive, longinactive, banned, Spy, [Date], [Memo],[Rankings],[UnionRankings],[Members],[Ni] ) 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}',Rankings = {18} ,UnionRankings = {19} , Members ={20} , Ni={21}" +
                               "where  GalaxySystem='{0}' ";

            //作废,再次心痛
            ////添加
            //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}";

            for (int i = 0; i < DT.Rows.Count; i++)
            {
                ExPlanet spInfo = new ExPlanet();
                spInfo.Galaxy       = Convert.ToInt32(DT.Rows[i]["Galaxy"]);
                spInfo.System       = Convert.ToInt32(DT.Rows[i]["System"].ToString());
                spInfo.Location     = Convert.ToInt32(DT.Rows[i]["Location"].ToString());
                spInfo.PlanetName   = DT.Rows[i]["PlanetName"].ToString();
                spInfo.Moon         = Convert.ToBoolean(DT.Rows[i]["Moon"]);
                spInfo.MoonSize     = Convert.ToInt32(DT.Rows[i]["MoonSize"]);
                spInfo.Metal        = Convert.ToInt32(DT.Rows[i]["Metal"]);
                spInfo.Crystal      = Convert.ToInt32(DT.Rows[i]["Crystal"]);
                spInfo.Username     = DT.Rows[i]["Username"].ToString();
                spInfo.Union        = DT.Rows[i]["Union"].ToString();
                spInfo.Vacation     = Convert.ToBoolean(DT.Rows[i]["vacation"]);
                spInfo.Inactive     = Convert.ToBoolean(DT.Rows[i]["inactive"]);
                spInfo.LongInactive = Convert.ToBoolean(DT.Rows[i]["longinactive"]);
                spInfo.Banned       = Convert.ToBoolean(DT.Rows[i]["banned"]);
                spInfo.Spy          = DT.Rows[i]["Spy"].ToString();
                spInfo.Date         = Convert.ToDateTime(DT.Rows[i]["Date"].ToString());
                spInfo.Memo         = DT.Rows[i]["Memo"].ToString();


                string Rankings      = "0";
                string UnionRankings = "0";
                string Members       = "0";

                if (DT.Rows[i]["Rankings"].ToString() != "")
                {
                    Rankings = DT.Rows[i]["Rankings"].ToString();
                }
                if (DT.Rows[i]["UnionRankings"].ToString() != "")
                {
                    UnionRankings = DT.Rows[i]["UnionRankings"].ToString();
                }
                if (DT.Rows[i]["Members"].ToString() != "")
                {
                    Members = DT.Rows[i]["Members"].ToString();
                }

                string[] Par = { spInfo.Galaxy.ToString() + ":" + spInfo.System.ToString() + ":" + spInfo.Location.ToString(),
                                 spInfo.Galaxy.ToString(),                                                                    spInfo.System.ToString(),   spInfo.Location.ToString(), spInfo.PlanetName,                 spInfo.Moon.ToString(),     spInfo.MoonSize.ToString(),
                                 spInfo.Metal.ToString(),                                                                     spInfo.Crystal.ToString(),  spInfo.Username,            spInfo.Union,                      spInfo.Vacation.ToString(), spInfo.Inactive.ToString(),
                                 spInfo.LongInactive.ToString(),                                                              spInfo.Banned.ToString(),   spInfo.Spy,                 DateTime.Now.ToString("yyyy-M-d"), "''",
                                 Rankings,                                                                                    UnionRankings,              Members,                    DT.Rows[i]["Ni"].ToString() };

                try
                {
                    DataTable DT2 = _Access.Find("galaxy", "GalaxySystem", DT.Rows[i]["GalaxySystem"].ToString());
                    if (DT2.Rows.Count == 1)
                    {//有相同数据,采用更新
                        if (spInfo.Date > Convert.ToDateTime(DT2.Rows[0]["Date"].ToString()))
                        {
                            _Access.ReutnSqlEcx(UpDataStr, Par);
                        }
                    }
                    else if (DT2.Rows.Count == 0)
                    {//没有数据,采用添加
                        _Access.ReutnSqlEcx(OutStr, Par);
                    }
                    else if (DT2.Rows.Count > 1)
                    {//有多条数据,先删除在添加
                        _Access.FastDel("galaxy", "GalaxySystem", DT.Rows[i]["GalaxySystem"].ToString());
                        _Access.ReutnSqlEcx(OutStr, Par);
                    }
                }
                catch (Exception ee)
                {
                    _Log.AddError("<InData>" + ee.Message);
                }
                Application.DoEvents();
                spPBar.Value = i + 1;
            }
        }