コード例 #1
0
ファイル: WhiteBlackCore.cs プロジェクト: radtek/Portfolio
        public WhiteBlackCore(string groupname, AccountInfo account)
        {
            base.Caption        = account.UserName;
            base.Key            = account.Email;
            base.CurrentAccount = account;
            base.Proxy          = ConfigCtrl.GetProxy();
            base.Delay          = ConfigCtrl.GetDelay();
            base.Initial();

            Operation = ConfigCtrl.GetOperation(groupname, account);
            Task      = ConfigCtrl.GetTask("", "", true);

            _gPark   = new GamePark();
            _gBite   = new GameBite();
            _gSlave  = new GameSlave();
            _gHouse  = new GameHouse();
            _gGarden = new GameGarden();
            _gRanch  = new GameRanch();
            _gFish   = new GameFish();
            _gCafe   = new GameCafe();
            //不要clone validatecode 事件
            _gPark.Clone(this, true);
            _gBite.Clone(this, true);
            _gSlave.Clone(this, true);
            _gHouse.Clone(this, true);
            _gGarden.Clone(this, true);
            _gRanch.Clone(this, true);
            _gFish.Clone(this, true);
            _gCafe.Clone(this, true);
        }
コード例 #2
0
ファイル: WhiteBlackCore.cs プロジェクト: jojozhuang/Projects
        public WhiteBlackCore(string groupname, AccountInfo account)
        {
            base.Caption = account.UserName;
            base.Key = account.Email;
            base.CurrentAccount = account;
            base.Proxy = ConfigCtrl.GetProxy();
            base.Delay = ConfigCtrl.GetDelay();
            base.Initial();

            Operation = ConfigCtrl.GetOperation(groupname, account);
            Task = ConfigCtrl.GetTask("", "", true);

            _gPark = new GamePark();
            _gBite = new GameBite();
            _gSlave = new GameSlave();
            _gHouse = new GameHouse();
            _gGarden = new GameGarden();
            _gRanch = new GameRanch();
            _gFish = new GameFish();
            _gCafe = new GameCafe();
            //不要clone validatecode 事件
            _gPark.Clone(this, true);
            _gBite.Clone(this, true);
            _gSlave.Clone(this, true);
            _gHouse.Clone(this, true);
            _gGarden.Clone(this, true);
            _gRanch.Clone(this, true);
            _gFish.Clone(this, true);
            _gCafe.Clone(this, true);
        }
コード例 #3
0
ファイル: TaskManager.cs プロジェクト: radtek/Portfolio
        public void TaskRun()
        {
            try
            {
                //重新读取
                Task = ConfigCtrl.GetTask(_taskid, _taskname, false);

                base.ExecutionLog = new StringBuilder();
                base.Proxy        = ConfigCtrl.GetProxy();
                base.Delay        = ConfigCtrl.GetDelay();

                if (Task.RunMode != EnumRunMode.SingleLoop || _singleloopfirst == true)
                {
                    base.Initial(true);
                }
                else
                {
                    base.Initial(false);
                }

                if (Task.ExecutePark)
                {
                    this._matchList = ConfigCtrl.GetMatches();
                }
                if (Task.ExecuteHouse)
                {
                    this._houseFullList.Clear();
                }
                if (Task.ExecuteGarden)
                {
                    this._hasNothingTobeFarmedList.Clear();
                    this._seedsList     = ConfigCtrl.GetSeedsInShop();
                    this._rankSeedsList = ConfigCtrl.GetRankSeeds();
                    this._fruitsList    = ConfigCtrl.GetFruits();
                }
                if (Task.ExecuteRanch)
                {
                    this._hasNothingTobeHelpedList.Clear();
                    this._calfsList    = ConfigCtrl.GetCalvesInShop();
                    this._productsList = ConfigCtrl.GetAnimalProducts();
                }
                if (Task.ExecuteFish)
                {
                    this._fishFrysList    = ConfigCtrl.GetFishFrysInShop();
                    this._fishTacklesList = ConfigCtrl.GetFishTacklesInShop();
                    this._fishMaturedList = ConfigCtrl.GetFishMaturedInMarket();
                }
                if (Task.ExecuteRich)
                {
                    this._assetsList           = ConfigCtrl.GetAssetsInShop();
                    this._advancedPurchaseList = ConfigCtrl.GetAdvancedPurchaseMD();
                }
                if (Task.ExecuteCafe)
                {
                    this._dishesList             = ConfigCtrl.GetDishesInMenu();
                    this._transactiondDishesList = ConfigCtrl.GetTransactionDishes();
                }

                SetMessage(Constants.COMMAND_CLEARLOG);
                //start
                SetMessage("\r\n" + "============================== 开始 ==============================");

                int num = 0;
                foreach (AccountInfo account in Task.Accounts)
                {
                    try
                    {
                        Thread.Sleep(2000);
                        //common
                        base.AllMyFriendsList.Clear();
                        //this._verifyCode = "";
                        this._module = Constants.MSG_TASK;

                        num++;
                        SetMessageLn("------ 共" + Task.Accounts.Count + "个帐户,第" + num + "个帐户:" + account.UserName + "(" + account.Email + ") ------");
                        base.Operation      = ConfigCtrl.GetOperation(Task.GroupName, account);
                        base.CurrentAccount = account;

                        if (Task.RunMode != EnumRunMode.SingleLoop || _singleloopfirst == true)
                        {
                            if (!this.ValidationLogin(account))
                            {
                                continue;
                            }
                            else
                            {
                                _singleloopfirst = false;
                            }
                        }
                        //if (!this.Login(true))
                        //{
                        //    if (base.NeedValidationCode)
                        //    {
                        //        while (base.RetryLogin)
                        //        {
                        //            if (!this.Login(true))
                        //                continue;
                        //            else
                        //                break;
                        //        }
                        //        if (!base.RetryLogin)
                        //            continue;
                        //    }
                        //    else
                        //        continue;
                        //}

                        string content = RequestAllMyFriends();
                        ReadAllMyFriends(content, false);

                        if (Task.ExecutePark)
                        {
                            GamePark gPark = new GamePark();
                            gPark.Clone(this);
                            gPark.MatchesList = this._matchList;
                            gPark.RunPark();
                            this.ExecutionLog = gPark.ExecutionLog;
                        }
                        if (Task.ExecuteBite)
                        {
                            GameBite gBite = new GameBite();
                            gBite.Clone(this);
                            gBite.RunBite();
                            this.ExecutionLog = gBite.ExecutionLog;
                        }
                        if (Task.ExecuteSlave)
                        {
                            GameSlave gSlave = new GameSlave();
                            gSlave.Clone(this);
                            gSlave.RunSlave();
                            this.ExecutionLog = gSlave.ExecutionLog;
                        }
                        if (Task.ExecuteHouse)
                        {
                            GameHouse gHouse = new GameHouse();
                            gHouse.Clone(this);
                            gHouse.HouseFullList = this._houseFullList;
                            gHouse.RunHouse();
                            this.ExecutionLog   = gHouse.ExecutionLog;
                            this._houseFullList = gHouse.HouseFullList;
                        }
                        if (Task.ExecuteGarden)
                        {
                            GameGarden gGarden = new GameGarden();
                            gGarden.Clone(this);
                            gGarden.SeedsList                = this._seedsList;
                            gGarden.RankSeedsList            = this._rankSeedsList;
                            gGarden.FruitsList               = this._fruitsList;
                            gGarden.HasNothingTobeFarmedList = this._hasNothingTobeFarmedList;
                            gGarden.RunGarden();
                            this.ExecutionLog = gGarden.ExecutionLog;
                            this._hasNothingTobeFarmedList = gGarden.HasNothingTobeFarmedList;
                        }
                        if (Task.ExecuteRanch)
                        {
                            GameRanch gRanch = new GameRanch();
                            gRanch.Clone(this);
                            gRanch.CalfsList    = this._calfsList;
                            gRanch.ProductsList = this._productsList;
                            //gRanch.HasNothingTobeHelpedList = this._hasNothingTobeHelpedList;
                            gRanch.RunRanch();
                            this.ExecutionLog = gRanch.ExecutionLog;
                            //this._hasNothingTobeHelpedList = gRanch.HasNothingTobeHelpedList;
                        }

                        if (Task.ExecuteFish)
                        {
                            GameFish gFish = new GameFish();
                            gFish.Clone(this);
                            gFish.FishFrysList    = this._fishFrysList;
                            gFish.FishTacklesList = this._fishTacklesList;
                            gFish.FishMaturedList = this._fishMaturedList;
                            gFish.RunFish();
                            this.ExecutionLog = gFish.ExecutionLog;
                        }

                        if (Task.ExecuteRich)
                        {
                            GameRich gRich = new GameRich();
                            gRich.Clone(this);
                            gRich.AssetsList           = this._assetsList;
                            gRich.AdvancedPurchaseList = this._advancedPurchaseList;
                            gRich.RunRich();
                            this.ExecutionLog = gRich.ExecutionLog;
                        }

                        if (Task.ExecuteCafe)
                        {
                            GameCafe gCafe = new GameCafe();
                            gCafe.Clone(this);
                            gCafe.DishesList             = this._dishesList;
                            gCafe.TransactiondDishesList = this._transactiondDishesList;
                            gCafe.RunCafe();
                            this.ExecutionLog = gCafe.ExecutionLog;
                        }

                        if (Task.RunMode != EnumRunMode.SingleLoop)
                        {
                            this.LogOut(true);
                        }
                    }
                    catch (ThreadAbortException)
                    {
                        //LogHelper.Write("TaskManager.TaskRun", "ThreadAbortException" + account.UserName, LogSeverity.Info);
                    }
                    catch (ThreadInterruptedException)
                    {
                        //LogHelper.Write("TaskManager.TaskRun", "ThreadInterruptedException" + account.UserName, LogSeverity.Info);
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Write("TaskManager.TaskRun", account.UserName, ex, LogSeverity.Error);
                        SetMessageLn("发生异常,此账户操作失败!错误:" + ex.Message);
                    }
                }

                SetMessage("\r\n" + "============================== 完成 ==============================");

                _module = Constants.MSG_TASK;
                if (Task.SendLog && !String.IsNullOrEmpty(Task.ReceiverEmail))
                {
                    SendRemindMail();
                }

                if (Task.WriteLogToFile)
                {
                    TraceLog.WriteLogToFile(Task.TaskName, this.ExecutionLog.ToString());
                }
            }
            catch (ThreadAbortException)
            {
                //LogHelper.Write("TaskManager.TaskRun", "AferAllAccounts-ThreadAbortException", LogSeverity.Info);
            }
            catch (ThreadInterruptedException)
            {
                //LogHelper.Write("TaskManager.TaskRun", "AferAllAccounts-ThreadInterruptedException", LogSeverity.Info);
            }
            catch (Exception ex)
            {
                LogHelper.Write("TaskManager.TaskRun", ex);
                SetMessageLn("发生异常,本次任务已中止!错误:" + ex.Message);
            }
        }
コード例 #4
0
ファイル: TaskManager.cs プロジェクト: jojozhuang/Projects
        public void TaskRun()
        {
            try
            {
                //重新读取
                Task = ConfigCtrl.GetTask(_taskid, _taskname, false);

                base.ExecutionLog = new StringBuilder();
                base.Proxy = ConfigCtrl.GetProxy();
                base.Delay = ConfigCtrl.GetDelay();

                if (Task.RunMode != EnumRunMode.SingleLoop || _singleloopfirst == true)
                    base.Initial(true);
                else
                    base.Initial(false);

                if (Task.ExecutePark)
                    this._matchList = ConfigCtrl.GetMatches();
                if (Task.ExecuteHouse)
                    this._houseFullList.Clear();
                if (Task.ExecuteGarden)
                {
                    this._hasNothingTobeFarmedList.Clear();
                    this._seedsList = ConfigCtrl.GetSeedsInShop();
                    this._rankSeedsList = ConfigCtrl.GetRankSeeds();
                    this._fruitsList = ConfigCtrl.GetFruits();
                }
                if (Task.ExecuteRanch)
                {
                    this._hasNothingTobeHelpedList.Clear();
                    this._calfsList = ConfigCtrl.GetCalvesInShop();
                    this._productsList = ConfigCtrl.GetAnimalProducts();
                }
                if (Task.ExecuteFish)
                {
                    this._fishFrysList = ConfigCtrl.GetFishFrysInShop();
                    this._fishTacklesList = ConfigCtrl.GetFishTacklesInShop();
                    this._fishMaturedList = ConfigCtrl.GetFishMaturedInMarket();
                }
                if (Task.ExecuteRich)
                {
                    this._assetsList = ConfigCtrl.GetAssetsInShop();
                    this._advancedPurchaseList = ConfigCtrl.GetAdvancedPurchaseMD();
                }
                if (Task.ExecuteCafe)
                {
                    this._dishesList = ConfigCtrl.GetDishesInMenu();
                    this._transactiondDishesList = ConfigCtrl.GetTransactionDishes();
                }

                SetMessage(Constants.COMMAND_CLEARLOG);
                //start
                SetMessage("\r\n" + "============================== 开始 ==============================");

                int num = 0;
                foreach (AccountInfo account in Task.Accounts)
                {
                    try
                    {
                        Thread.Sleep(2000);
                        //common
                        base.AllMyFriendsList.Clear();
                        //this._verifyCode = "";
                        this._module = Constants.MSG_TASK;

                        num++;
                        SetMessageLn("------ 共" + Task.Accounts.Count + "个帐户,第" + num + "个帐户:" + account.UserName + "(" + account.Email + ") ------");
                        base.Operation = ConfigCtrl.GetOperation(Task.GroupName, account);
                        base.CurrentAccount = account;

                        if (Task.RunMode != EnumRunMode.SingleLoop || _singleloopfirst == true)
                        {
                            if (!this.ValidationLogin(account))
                            {
                                continue;
                            }
                            else
                                _singleloopfirst = false;
                        }
                        //if (!this.Login(true))
                        //{
                        //    if (base.NeedValidationCode)
                        //    {
                        //        while (base.RetryLogin)
                        //        {
                        //            if (!this.Login(true))
                        //                continue;
                        //            else
                        //                break;
                        //        }
                        //        if (!base.RetryLogin)
                        //            continue;
                        //    }
                        //    else
                        //        continue;
                        //}

                        string content = RequestAllMyFriends();
                        ReadAllMyFriends(content, false);

                        if (Task.ExecutePark)
                        {
                            GamePark gPark = new GamePark();
                            gPark.Clone(this);
                            gPark.MatchesList = this._matchList;
                            gPark.RunPark();
                            this.ExecutionLog = gPark.ExecutionLog;
                        }
                        if (Task.ExecuteBite)
                        {
                            GameBite gBite = new GameBite();
                            gBite.Clone(this);
                            gBite.RunBite();
                            this.ExecutionLog = gBite.ExecutionLog;
                        }
                        if (Task.ExecuteSlave)
                        {
                            GameSlave gSlave = new GameSlave();
                            gSlave.Clone(this);
                            gSlave.RunSlave();
                            this.ExecutionLog = gSlave.ExecutionLog;
                        }
                        if (Task.ExecuteHouse)
                        {
                            GameHouse gHouse = new GameHouse();
                            gHouse.Clone(this);
                            gHouse.HouseFullList = this._houseFullList;
                            gHouse.RunHouse();
                            this.ExecutionLog = gHouse.ExecutionLog;
                            this._houseFullList = gHouse.HouseFullList;
                        }
                        if (Task.ExecuteGarden)
                        {
                            GameGarden gGarden = new GameGarden();
                            gGarden.Clone(this);
                            gGarden.SeedsList = this._seedsList;
                            gGarden.RankSeedsList = this._rankSeedsList;
                            gGarden.FruitsList = this._fruitsList;
                            gGarden.HasNothingTobeFarmedList = this._hasNothingTobeFarmedList;
                            gGarden.RunGarden();
                            this.ExecutionLog = gGarden.ExecutionLog;
                            this._hasNothingTobeFarmedList = gGarden.HasNothingTobeFarmedList;
                        }
                        if (Task.ExecuteRanch)
                        {
                            GameRanch gRanch = new GameRanch();
                            gRanch.Clone(this);
                            gRanch.CalfsList = this._calfsList;
                            gRanch.ProductsList = this._productsList;
                            //gRanch.HasNothingTobeHelpedList = this._hasNothingTobeHelpedList;
                            gRanch.RunRanch();
                            this.ExecutionLog = gRanch.ExecutionLog;
                            //this._hasNothingTobeHelpedList = gRanch.HasNothingTobeHelpedList;
                        }

                        if (Task.ExecuteFish)
                        {
                            GameFish gFish = new GameFish();
                            gFish.Clone(this);
                            gFish.FishFrysList = this._fishFrysList;
                            gFish.FishTacklesList = this._fishTacklesList;
                            gFish.FishMaturedList = this._fishMaturedList;
                            gFish.RunFish();
                            this.ExecutionLog = gFish.ExecutionLog;
                        }

                        if (Task.ExecuteRich)
                        {
                            GameRich gRich = new GameRich();
                            gRich.Clone(this);
                            gRich.AssetsList = this._assetsList;
                            gRich.AdvancedPurchaseList = this._advancedPurchaseList;
                            gRich.RunRich();
                            this.ExecutionLog = gRich.ExecutionLog;
                        }

                        if (Task.ExecuteCafe)
                        {
                            GameCafe gCafe = new GameCafe();                           
                            gCafe.Clone(this);
                            gCafe.DishesList = this._dishesList;
                            gCafe.TransactiondDishesList = this._transactiondDishesList;
                            gCafe.RunCafe();
                            this.ExecutionLog = gCafe.ExecutionLog;
                        }

                        if (Task.RunMode != EnumRunMode.SingleLoop)
                            this.LogOut(true);
                    }
                    catch (ThreadAbortException)
                    {
                        //LogHelper.Write("TaskManager.TaskRun", "ThreadAbortException" + account.UserName, LogSeverity.Info);
                    }
                    catch (ThreadInterruptedException)
                    {
                        //LogHelper.Write("TaskManager.TaskRun", "ThreadInterruptedException" + account.UserName, LogSeverity.Info);
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Write("TaskManager.TaskRun", account.UserName, ex, LogSeverity.Error);
                        SetMessageLn("发生异常,此账户操作失败!错误:" + ex.Message);
                    }
                }

                SetMessage("\r\n" + "============================== 完成 ==============================");

                _module = Constants.MSG_TASK;
                if (Task.SendLog && !String.IsNullOrEmpty(Task.ReceiverEmail))
                    SendRemindMail();

                if (Task.WriteLogToFile)
                    TraceLog.WriteLogToFile(Task.TaskName, this.ExecutionLog.ToString());
            }
            catch (ThreadAbortException)
            {
                //LogHelper.Write("TaskManager.TaskRun", "AferAllAccounts-ThreadAbortException", LogSeverity.Info);
            }
            catch (ThreadInterruptedException)
            {
                //LogHelper.Write("TaskManager.TaskRun", "AferAllAccounts-ThreadInterruptedException", LogSeverity.Info);
            }
            catch (Exception ex)
            {
                LogHelper.Write("TaskManager.TaskRun", ex);
                SetMessageLn("发生异常,本次任务已中止!错误:" + ex.Message);
            }
        }