Ejemplo n.º 1
0
        private List <JumpListHtmlParser> GetAllList()
        {
            var list = new List <JumpListHtmlParser>();

            using var requester = new HttpRequester();
            var idx = 0;

            do
            {
                var HtmlStr = requester.Request(
                    $"http://300report.jumpw.com/list.html?name={MsgDTO.Msg}&index={idx}");

                var listParser = new JumpListHtmlParser();
                listParser.Load(HtmlStr);

                var count = listParser.Matches.Count;
                if (count == 0)
                {
                    break;
                }

                idx += count;
                list.Add(listParser);
            }while (true);

            return(list);
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public ThirdPartyAuthorizeResult Authorize(AuthorizationInput input)
        {
            var tokenRequest = "https://api.weibo.com/oauth2/access_token" +
                               $"?client_id={AppId}&client_secret={AppSecret}&grant_type=authorization_code" +
                               $"&redirect_uri={RedirectUri}&code={input.Code}";
            var tokenResult = HttpRequester.Request(tokenRequest,
                                                    new HttpRequester.RequestOptions
            {
                Method = HttpRequester.HttpMethod.Post
            });
            var authorizeResult = JsonConvert.DeserializeObject <AuthorizeResult>(tokenResult);
            var accessToken     = authorizeResult.access_token;

            var uidRequest = "https://api.weibo.com/2/account/get_uid.json" +
                             $"?access_token={accessToken}";
            var uidResult = HttpRequester.Request(uidRequest, new HttpRequester.RequestOptions());
            var uid       = (string)JsonConvert.DeserializeObject <dynamic>(uidResult).uid;

            var thirdPartyUser = _thirdPartyUserRepository
                                 .GetAll()
                                 .FirstOrDefault(u => u.OpenId == uid);

            if (thirdPartyUser == null)
            {
                var userRequest = "https://api.weibo.com/2/users/show.json"
                                  + $"?access_token={accessToken}&uid={uid}";

                var userResult = HttpRequester.Request(userRequest, new HttpRequester.RequestOptions());
                var user       = JsonConvert.DeserializeObject <UserInfo>(userResult);
                thirdPartyUser = new ThirdPartyUser
                {
                    OpenId      = uid,
                    AccessToken = accessToken,
                    Name        = user.name,
                    NickName    = user.screen_name,
                    ThirdParty  = "Weibo"
                };
                _thirdPartyUserRepository.Insert(thirdPartyUser);
                CurrentUnitOfWork.SaveChanges();
            }
            thirdPartyUser.AccessToken = accessToken;
            CurrentUnitOfWork.SaveChanges();
            return(new ThirdPartyAuthorizeResult
            {
                ThirdPartyUser = new ThirdPartyUserOutput
                {
                    UserId = thirdPartyUser.UserId,
                    Name = thirdPartyUser.NickName,
                    NickName = thirdPartyUser.NickName
                },
                Token = $"OpenId={uid}&date={DateTime.Now:yyyy-MM-dd HH:mm:ss}&type=Weibo".EncryptQueryString(),
                Success = thirdPartyUser.UserId > 0,
                RequireCreateNewUser = thirdPartyUser.UserId == 0
            });
Ejemplo n.º 3
0
        /// <inheritdoc />
        public string GetReactDownloadUrl()
        {
            var data     = HttpRequester.Request(GetSwaggerApiUrl(), new HttpRequester.RequestOptions());
            var postData = $"{{\"spec\":{data}}}";
            var download = HttpRequester.Request(SwaggerUrl,
                                                 new HttpRequester.RequestOptions
            {
                Method = HttpRequester.HttpMethod.Post,
            },
                                                 postData);

            return(DownloadUrl + JsonConvert.DeserializeObject <dynamic>(download).code);
        }
Ejemplo n.º 4
0
        /// <inheritdoc />
        public ThirdPartyAuthorizeResult Authorize(AuthorizationInput input)
        {
            var tokenRequest = "https://api.weixin.qq.com/sns/oauth2/access_token" +
                               $"?appid={AppId}&secret={AppSecret}&code={input.Code}&grant_type=authorization_code";
            var tokenResult     = HttpRequester.Request(tokenRequest, new HttpRequester.RequestOptions());
            var authorizeResult = JsonConvert.DeserializeObject <AuthorizeResult>(tokenResult);
            var accessToken     = authorizeResult.access_token;
            var openId          = authorizeResult.openid;

            if (openId == null)
            {
                return(new ThirdPartyAuthorizeResult {
                    Success = false
                });
            }
            var thirdPartyUser = _thirdPartyUserRepository
                                 .GetAll()
                                 .FirstOrDefault(u => u.OpenId == openId);

            if (thirdPartyUser == null)
            {
                var userRequest = "https://api.weixin.qq.com/sns/userinfo" +
                                  $"?access_token={accessToken}&openid={openId}";
                var userResult = HttpRequester.Request(userRequest, new HttpRequester.RequestOptions());
                var user       = JsonConvert.DeserializeObject <UserInfo>(userResult);
                thirdPartyUser = new ThirdPartyUser
                {
                    OpenId      = openId,
                    AccessToken = accessToken,
                    Name        = user.nickname,
                    NickName    = user.nickname,
                    ThirdParty  = "Weixin"
                };
                _thirdPartyUserRepository.Insert(thirdPartyUser);
                CurrentUnitOfWork.SaveChanges();
            }
            thirdPartyUser.AccessToken = accessToken;
            CurrentUnitOfWork.SaveChanges();
            return(new ThirdPartyAuthorizeResult
            {
                ThirdPartyUser = new ThirdPartyUserOutput
                {
                    UserId = thirdPartyUser.UserId,
                    Name = thirdPartyUser.NickName,
                    NickName = thirdPartyUser.NickName
                },
                Token = $"OpenId={openId}&date={DateTime.Now:yyyy-MM-dd HH:mm:ss}&type=Weixin".EncryptQueryString(),
                Success = thirdPartyUser.UserId > 0,
                RequireCreateNewUser = thirdPartyUser.UserId == 0
            });
Ejemplo n.º 5
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            var gameId  = ((System.Collections.Generic.KeyValuePair <int, string>)cmbGames.SelectedItem).Key;
            var gameMap = new List <GameMap>();

            Enums.ControllerType type;
            foreach (Control item in Controls)
            {
                UserControl itemx;
                if (item.Name.StartsWith("ucHorizontalLine_"))
                {
                    itemx = item as UCHorizontalLine;
                    type  = Enums.ControllerType.HorizontalLine;
                }
                else if (item.Name.StartsWith("ucVerticalLine_"))
                {
                    itemx = item as UCVerticalLine;
                    type  = Enums.ControllerType.VerticalLine;
                }
                else if (item.Name.StartsWith("ucTarget_"))
                {
                    itemx = item as UCTarget;
                    type  = Enums.ControllerType.Target;
                }
                else if (item.Name.StartsWith("ucChar_"))
                {
                    itemx = item as UCCharactor;
                    type  = Enums.ControllerType.Charactor;
                }
                else
                {
                    continue;
                }

                gameMap.Add(new GameMap
                {
                    ControllerType = type,
                    GameId         = gameId,
                    Hight          = itemx.Height,
                    Width          = itemx.Width,
                    PointX         = itemx.Location.X,
                    PointY         = itemx.Location.Y
                });
            }

            _xhrRequester = new HttpRequester($"game/map/{gameId}");
            var result = await _xhrRequester.Request(gameMap);

            MessageBox.Show("Saved");
        }
Ejemplo n.º 6
0
        /// <inheritdoc />
        public ThirdPartyAuthorizeResult Authorize(AuthorizationInput input)
        {
            var tokenRequest = "https://graph.qq.com/oauth2.0/token" +
                               $"?grant_type=authorization_code&client_id={AppId}&client_secret={AppKey}" +
                               $"&code={input.Code}&redirect_uri={RedirectUri}";
            var tokenResult   = HttpRequester.Request(tokenRequest, new HttpRequester.RequestOptions());
            var accessToken   = ParseAccessToken(tokenResult);
            var openIdRequest = "https://graph.qq.com/oauth2.0/me" +
                                $"?access_token={accessToken}";
            var openIdResult   = HttpRequester.Request(openIdRequest, new HttpRequester.RequestOptions());
            var openId         = ParseOpenId(openIdResult);
            var thirdPartyUser = _thirdPartyUserRepository
                                 .GetAll()
                                 .FirstOrDefault(u => u.OpenId == openId);

            if (thirdPartyUser == null)
            {
                var userRequest = "https://graph.qq.com/user/get_user_info" +
                                  $"?access_token={accessToken}&oauth_consumer_key={AppId}&openid={openId}";
                var userResult = HttpRequester.Request(userRequest, new HttpRequester.RequestOptions());
                var user       = JsonConvert.DeserializeObject <UserInfo>(userResult);
                thirdPartyUser = new ThirdPartyUser
                {
                    OpenId      = openId,
                    AccessToken = accessToken,
                    NickName    = user.nickname,
                    ThirdParty  = "QQ"
                };
                _thirdPartyUserRepository.Insert(thirdPartyUser);
                CurrentUnitOfWork.SaveChanges();
            }
            thirdPartyUser.AccessToken = accessToken;
            CurrentUnitOfWork.SaveChanges();
            return(new ThirdPartyAuthorizeResult
            {
                ThirdPartyUser = new ThirdPartyUserOutput
                {
                    UserId = thirdPartyUser.UserId,
                    Name = thirdPartyUser.NickName,
                    NickName = thirdPartyUser.NickName
                },
                Token = $"OpenId={openId}&date={DateTime.Now:yyyy-MM-dd HH:mm:ss}&type=QQ".EncryptQueryString(),
                Success = thirdPartyUser.UserId > 0,
                RequireCreateNewUser = thirdPartyUser.UserId == 0
            });
Ejemplo n.º 7
0
        private async void btnAddGame_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtName.Text))
            {
                Helper.Info(message: "Please provide the game name");
            }
            if (Helper.Confirm())
            {
                var request = new Game()
                {
                    Name = txtName.Text
                };
                var result = await _xhr.Request <Game, Game>(request);

                await _parentWorkbench.LoadGames();

                this.Close();
            }
        }
Ejemplo n.º 8
0
        public void Work()
        {
            var parser = new StarFortuneParser();

            using var requester = new HttpRequester();
            var code = GetStarCode(MsgDTO.Msg);

            if (code < 0)
            {
                ReportCallBack?.Invoke(MsgDTO, "未查找到该星座!");
                return;
            }

            var aimStr  = $"http://astro.sina.cn/fortune/starent?type=day&ast={code}&vt=4";
            var HtmlStr = requester.Request(aimStr);

            parser.Load(HtmlStr);

            ReportCallBack?.Invoke(MsgDTO, parser.Content);
        }
Ejemplo n.º 9
0
        private static List <JumpDetailHtmlParser> GetAllDetails(IEnumerable <JumpListHtmlParser> allList)
        {
            var allDetails = new List <JumpDetailHtmlParser>();

            foreach (var list in allList)
            {
                foreach (var match in list.Matches)
                {
                    var aimStr = $"http://300report.jumpw.com/match.html?id={match.DetailAddr}";
                    using var requester = new HttpRequester();
                    var HtmlStr = requester.Request(aimStr);

                    var dp = new JumpDetailHtmlParser();
                    dp.Load(HtmlStr);

                    allDetails.Add(dp);
                }
            }

            return(allDetails);
        }