Exemple #1
0
        public UserManager()
        {
            UserInfo = new UserInfo();

            QRCodeInitial = new QRCodeInitial(this);
            ReadyScan     = new ReadyScan(this);
            Scaned        = new Scaned(this);
            Login         = new Login(this);
        }
Exemple #2
0
        /// <summary>
        /// 等待中。。。
        /// 1、扫描
        /// 2、登陆
        /// </summary>
        /// <param name="t"></param>
        /// <returns>
        /// 0 超时
        /// 1 已登陆
        /// </returns>
        void waitFor(int t, int c)
        {
            if (c >= 5 || isquit)
            {
                throw new Exception("wait 已退出");
            }

            string url = String.Format("https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login?loginicon=true&uuid={0}&tip=0&r={1}&_={2}", uuid, ~getcurrentseconds(), getcurrentseconds());
            var    rsp = wc.GetStr(url);

            outLog("wait->" + t + "->" + c + "->" + Serialize.ToJson(rsp));

            if (rsp.err)
            {
                waitFor(t, c + 1);
            }

            var str = rsp.data + "";

            if (str.Contains("code=201"))
            {
                var img = str.Split('\'')[1].TrimEnd('\'');
                lg.headimg = headimg = img;
                lg.status  = 4;//已扫描
                db.SubmitChanges();

                Scaned?.Invoke(headimg);

                waitFor(2, 0);
            }

            if (str.Contains("code=200"))
            {
                var reg = new Regex("window.redirect_uri=\"(\\S+?)\"");
                redirecturl = reg.Match(str).Groups[1].Value;
                if (!String.IsNullOrEmpty(redirecturl))
                {
                    gateway = "https://" + new Uri(redirecturl).Host;
                }
                lg.status = 5;//已登陆
                db.SubmitChanges();
                return;
            }

            waitFor(t, c + 1);
        }