コード例 #1
0
ファイル: Acquisition.cs プロジェクト: chenjunsheep/Sxh
        private async Task <bool> GetTokensAsync(UserAccount account, ClientPortionTransferItem project)
        {
            var proxy = new ProxyAcquisition();
            var ret   = await proxy.GetTokenInfoAsync(account, project);

            txtTokenAcquire.Text = ret.TokenAcquire;
            txtToken.Text        = ret.TokenKey;
            return(true);
        }
コード例 #2
0
ファイル: ProxyAcquisition.cs プロジェクト: chenjunsheep/Sxh
        public async Task <TokenAcquisition> GetTokenInfoAsync(UserAccount account, ClientPortionTransferItem project)
        {
            var tokenInfo = new TokenAcquisition();

            if (account != null && account.HasValue && project != null)
            {
                var cookieJar = new CookieContainer();
                using (var handler = new HttpClientHandler
                {
                    CookieContainer = cookieJar,
                    UseCookies = true,
                })
                {
                    using (var client = CreateHttpClient(handler))
                    {
                        var Uri = CreateUri($"/CommissionedAcquisition?projectId={project.projectId}&currentPrice={project.minTransferingPrice}");

                        foreach (Cookie token in account.TokenOffical)
                        {
                            cookieJar.Add(Uri, new Cookie(token.Name, token.Value));
                        }

                        var response = await client.GetAsync(Uri);

                        if (response.IsSuccessStatusCode)
                        {
                            var html = await response.Content.ReadAsStringAsync();

                            RetrieveToken(html, tokenInfo);
                        }
                    }
                }
            }

            return(tokenInfo);
        }