예제 #1
0
        public static void DealGame(string gameName, int rate)
        {
            WqgameBll gameBll = new WqgameBll();
            WqgameModel game = gameBll.GetModelByName(gameName);
            WqCore bll = new WqCore(new GameInfo(game));
            Random rand = new Random(DateTime.Now.Millisecond);

            int baseRate = GetBaseRateByHour();
            UtilMethod.SaveLog("timerElapsed", gameName + " timer is started. rate is " + rate + ".baseRate is " + baseRate);

            if (rand.Next(baseRate) <= 5)
            {
                //UtilMethod.SaveLog("view", gameName + " is viewed.");
                bll.viewWQ();
                Thread.Sleep(rand.Next(100, 1000));
                if (rand.Next(baseRate) <= 1)
                {
                    bll.viewWQ();
                }
            }

            // 点击频率为1/(baseRate + rate)
            if (rand.Next(baseRate + rate) == 1)
            {
                Thread.Sleep(rand.Next(500, 3000));
                bll.clickWQ();
            }
        }
예제 #2
0
        public static void DealGame(string gameName)
        {
            WqgameBll gameBll = new WqgameBll();
            WqgameModel game = gameBll.GetModelByName(gameName);
            WqCore bll = new WqCore(new GameInfo(game));
            Random rand = new Random(DateTime.Now.Millisecond);

            UtilMethod.SaveLog("manual", gameName + " manual click.");

            bll.viewWQ();
            Thread.Sleep(rand.Next(500, 3000));
            bll.clickWQ();
        }
예제 #3
0
        protected void Application_Start(object sender, EventArgs e)
        {
            UtilMethod.SaveLog("appStart", "Application start.");

            WqgameBll gameBll = new WqgameBll();
            gameList = gameBll.GetAllGames();

            foreach (WqgameModel game in gameList)
            {
                //Timer timer = new Timer(game.interval * 1000);
                //timer.Elapsed += delegate { DealGame(game.name, game.rate); };

                TaskTimer timer = new TaskTimer();
                timer.Interval = game.interval * 1000;
                timer.GameName = game.name;
                timer.Elapsed += new ElapsedEventHandler(TimerEvent);
                timer.Rate = game.rate;
                timer.AutoReset = true;
                timer.Enabled = true;
                timer.Start();

                UtilMethod.SaveLog("timerStart", game.name + "'s timer started. interval:" + game.interval);
                timers.Add(timer);
            }

            //if (this.timer3D == null)
            //{
            //    this.timer3D = new Timer(80 * 1000); // 间隔80秒
            //}
            //this.timer3D.Elapsed += new ElapsedEventHandler(this.timer3D_Elapsed);
            //this.timer3D.AutoReset = true;
            //this.timer3D.Enabled = true;
            //this.timer3D.Start();
        }