Esempio n. 1
0
        private void InitPostData(string uname, string pwd)
        {
            HandCodeHelper           helper = new HandCodeHelper();
            IRequestCookieCollection cookie = null;
            var loginState = helper.Login(uname, pwd, ref cookie);

            userCookies = cookie;

            var postUrl  = "http://jnga.app1.magcloud.net/mag/circle/v2/show/contentNew?p=1&step=20";
            var postData = HttpHelper.GET(postUrl, cookie);

            var result = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(postData, new { list = new List <PostInfo>() });

            PostList = result.list;
        }
Esempio n. 2
0
        public void JNGAReword(string uname, string pwd)
        {
            HandCodeHelper           helper = new HandCodeHelper();
            IRequestCookieCollection cookie = new RequestCookieCollection();
            var loginState = 0;

            if (!cookieList.ContainsKey(uname))
            {
                loginState = helper.Login(uname, pwd, ref cookie);
                cookieList.Add(uname, cookie);
                //记录日志
                logger.Info("登陆并设置cookie");
            }
            else
            {
                loginState = 100;
                cookie     = cookieList[uname];
                logger.Info("有cookie免登陆");
            }
            if (loginState == 100)
            {
                var result = helper.Reward(cookie);
                if (result == 1001)
                {
                    logger.Info("cookie过期,重新登陆。");
                    //重新登陆
                    loginState = helper.Login(uname, pwd, ref cookie);
                    cookieList.Remove(uname);
                    cookieList.Add(uname, cookie);
                    //记录日志
                    logger.Info("重新登陆并设置cookie");
                    result = helper.Reward(cookie);
                }

                if (result == 100)
                {
                    //记录日志
                    logger.Info("签到成功!" + result);
                }
                else
                {
                    logger.Info("签到失败尝试重试");
                    throw new Exception("签到失败");
                }
            }
        }
Esempio n. 3
0
 public HomeController(ILogger <HomeController> logger, RedisService redisClient)
 {
     _logger      = logger;
     _redisClient = redisClient;
     helper       = new HandCodeHelper();
 }