Ejemplo n.º 1
0
        private async void InvestForm_Load(object sender, EventArgs e)
        {
            //批量投资
            //Parallel.For(0, this.userIdentifiers.Count, async i =>
            //{
            //});
            for (int i = 0; i < this.userIdentifiers.Count; i++)
            {
                //并行执行
                InvestmentReqeust investmentRequest = new InvestmentReqeust {
                    Amount = this.unitPrise * this.investCount, ClientType = 900, ProductIdentifier = this.productIdentifier, ReturnUrl = "http://www.dev.ad.jinyinmao.com.cn/redirect/Home/?request=http://www.baidu.com", UserIdentifier = this.userIdentifiers[i]
                };
                await this.bankPageCommon.InvestAction(investmentRequest, () => this.hasOverCount += 1, this.GetNextWebbrowser(i + 1));
            }
            Thread thClosed = new Thread(() =>
            {
                while (this.hasOverCount < this.userIdentifiers.Count)
                {
                    Thread.Sleep(3000);
                }
                this.Close();
            })
            {
                IsBackground = true
            };

            thClosed.Start();
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     存管投资
        /// </summary>
        /// <returns></returns>
        public async Task InvestAction(InvestmentReqeust investmentRequest, Action action, WebBrowser webBrowser = null)
        {
            SetWebbrowser.SumitForm(12);
            if (webBrowser == null)
            {
                webBrowser = new WebBrowser();
            }
            webBrowser.ScriptErrorsSuppressed = true;
            //InvestmentReqeust investmentRequest = new InvestmentReqeust { Amount = 10000, CellPhone = registerSuccessInfo.CellPhone, ClientType = 900, ProductIdentifier = "33B97C6537564B3FB349B35C949A930F", ReturnUrl = "http://www.dev.ad.jinyinmao.com.cn/redirect/Home/?request=http://www.baidu.com", Pwd = registerSuccessInfo.Pwd };
            InvestmentResponse investmentResponse = await this.jymService.InvestByService(investmentRequest);

            if (investmentResponse != null)
            {
                BankSercrityInfo bankSercrityInfo = investmentResponse.GatewayResponse;
                string           url = $"http://fsgw.hkmdev.firstpay.com/phoenixFS-fsgw/gateway?data={HttpUtility.UrlEncode(bankSercrityInfo.Data)}&tm={HttpUtility.UrlEncode(bankSercrityInfo.Tm)}&merchantId=M20000002130";
                //添加一个
                webBrowser.Navigate(new Uri(url, UriKind.Absolute));
                int index = 0;
                webBrowser.DocumentCompleted += (obj, e) =>
                {
                    if (webBrowser.ReadyState < WebBrowserReadyState.Complete)
                    {
                        return;
                    }
                    HtmlDocument htmlDocument = webBrowser.Document;
                    if (index == 0)
                    {
                        if (htmlDocument != null)
                        {
                            Thread th = new Thread(() =>
                            {
                                Thread.Sleep(1000);
                                HtmlElement setPwd = htmlDocument.GetElementById("payPassword");
                                setPwd?.SetAttribute("value", "111111");
                                setPwd?.SetAttribute("data-status", "true");
                                HtmlElement submitBtn = htmlDocument.GetElementById("submitBtn");
                                submitBtn?.InvokeMember("click");
                            })
                            {
                                IsBackground = true
                            };
                            th.Start();
                        }
                    }
                    if (index == 2)
                    {
                        action();
                    }
                    ++index;
                };
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     存管投资
        /// </summary>
        /// <param name="reqeust"></param>
        /// <returns></returns>
        public async Task <InvestmentResponse> InvestByService(InvestmentReqeust reqeust)
        {
            try
            {
                string url = $"{BizeBaseUrl}/Investing/Regular";
                //获取token
                string token = ""; // await this.GetAuth(reqeust.UserIdentifier);;
                Client.DefaultRequestHeaders.Remove("X-JYM-Authorization");
                Client.DefaultRequestHeaders.Add("X-JYM-Authorization", token);
                HttpResponseMessage responseMessage = await Client.PostAsJsonAsync(url, reqeust);

                if (responseMessage.StatusCode == HttpStatusCode.OK)
                {
                    return(await responseMessage.Content.ReadAsAsync <InvestmentResponse>());
                }
                return(null);
            }
            catch (Exception)
            {
                return(null);
            }
        }