internal static void NewCheckBill(string url, string mainInfo, string loginSession)
            {
                var handler = new HttpClientHandler()
                {
                    UseCookies = false
                };
                var client = new HttpClient(handler);

                client.DefaultRequestHeaders.Add("Cookie", loginSession);
                Program.Tcp?.Send(new RpCheckBillMessage(mainInfo));
                var resultStream = client.GetAsync(url).Result.Content.ReadAsStreamAsync().Result;

                using (var reader = new StreamReader(resultStream, Encoding.Default))
                {
                    var info       = reader.ReadToEnd();
                    var frmInfo    = HttpUtil.GetElement(info, "usertrade.py", "返回");
                    var billPoster = new BillPoster(frmInfo, loginSession);
                    billPoster.Submit((result, success) =>
                    {
                        if (success)
                        {
                            var t = new Task(() =>
                            {
                                Program.Tcp?.Send(new RpBillSubmitedMessage(RpBillSubmitedMessage.State.Success));
                                Program.setting.LogInfo($"下单成功 {url}", "下单记录");
                            }
                                             );
                            t.Start();
                        }
                        else
                        {
                            var t = new Task(() =>
                            {
                                Program.Tcp?.Send(new RpBillSubmitedMessage(RpBillSubmitedMessage.State.Fail));
                                Program.setting.LogInfo($"{result}\n{url}", "下单记录");
                            }
                                             );
                            t.Start();
                        };
                    });
                }
            }
Beispiel #2
0
        private void TrySubmitBillCallBack(string result, string cookieLogin, string url)
        {
            var frmInfo    = HttpUtil.GetElement(result, "usertrade.py", "返回");
            var billPoster = new BillPoster(frmInfo, cookieLogin);

            this.Invoke((EventHandler) delegate
            {
                billPoster.Submit((reason, success) =>
                {
                    Program.reg.In("Bill").In("record").In(DateTime.Now.ToString("yyyyMMdd")).SetInfo(DateTime.Now.ToString("hhmmssffff"), reason);
                    if (success)
                    {
                        var t = new Task(() =>
                        {
                            Program.Tcp?.Send(new RpBillSubmitedMessage(RpBillSubmitedMessage.State.Success));
                            this.Invoke((EventHandler) delegate
                            {
                                Text = ("下单成功 " + url);
                            });
                        }
                                         );
                        t.Start();
                    }
                    else
                    {
                        var t = new Task(() =>
                        {
                            this.Invoke((EventHandler) delegate
                            {
                                Program.Tcp?.Send(new RpBillSubmitedMessage(RpBillSubmitedMessage.State.Fail, reason));
                                Text = (reason + "\n" + url);
                            });
                        }
                                         );
                        t.Start();
                    };
                    Console.WriteLine(reason);
                }, this);
            });
        }