Exemplo n.º 1
0
        void CancelUnpay()
        {
            var order = olist.SelectedOrder;

            if (order == null || !order.Value.Value.Any(s => s.OrderStatus == OrderStatus.NotPay || s.OrderStatus == OrderStatus.ResignNotPaid || s.OrderStatus == OrderStatus.ResignChangeTsNotPaid))
            {
                Information("请先选择您要取消的车票,车票必须为未支付状态。");
                return;
            }
            if (!Question("确定要取消这个订单吗?超过三次就只能换马甲订票了的 ....", true))
            {
                return;
            }

            //取消订单
            var dlg = new YetAnotherWaitingDialog()
            {
                Text = "正在取消未完成订单,请稍等..."
            };

            dlg.WorkCallbackAdvanced = _ =>
            {
                var result = _orderManager.CancelNotComplete(order.Value.Key.SequenceNo, order.Value.Key.pay_resign_flag == "Y" ? "cancel_resign" : "cancel_order");
                _.SetState(result ? ExecutionState.Ok : ExecutionState.Block, "取消" + (result ? "成功" : "失败") + " ....");
                Thread.Sleep(2000);
                AppContext.HostForm.Invoke(LoadOrders);

                Session.OnOrderRefundSuccess(Session, new OrderRefundEventArgs(order.Value.Key, order.Value.Value, false));
            };
            dlg.ShowDialog();
        }
Exemplo n.º 2
0
        void Resign(bool changeTs, OrderItem order, OrderTicket[] tickets)
        {
            if (Session.UserProfile.QueryParams.Count > 0 && !Question("您已经打开了其它的查询,如果继续改签,将会自动关闭它们。\n请注意,在改签过程中,无法查询其它车票,否则会导致改签订单无法正确提交!", true))
            {
                return;
            }

            QueryParam qp      = null;
            string     message = null;

            var dlg = new YetAnotherWaitingDialog();

            dlg.Title        = "正在准备改签,请稍等....";
            dlg.WorkCallback = () =>
            {
                qp = _orderManager.Resign(order, tickets, changeTs, out message);
            };
            dlg.ShowDialog();

            if (qp == null)
            {
                Error("暂时无法改签,请检查您的选择并稍后再试。\n\n错误信息:" + message.DefaultForEmpty("未知错误"));
            }
            else
            {
                qp.OriginalOrder = Tuple.Create(order, tickets);
                //移除所有其他查询
                Session.UserProfile.QueryParams.Clear();
                Session.UserProfile.QueryParams.Add(qp);
            }
        }
Exemplo n.º 3
0
        void BeginRefundTicket()
        {
            if (_refundQueue.Count == 0)
            {
                _currnetRefundOrder  = null;
                _currentRefundTicket = null;

                if (_refundWaitingDialog != null)
                {
                    _refundWaitingDialog.Close();
                    _refundWaitingDialog = null;
                }
                LoadOrders();
                return;
            }

            var item = _refundQueue.Dequeue();

            _currentRefundTicket = item.Value;
            _currnetRefundOrder  = item.Key;
            //TODO 退票流程
            _orderManager.InitRefundTicket(_currnetRefundOrder, _currentRefundTicket);

            if (_refundWaitingDialog == null)
            {
                _refundWaitingDialog = new YetAnotherWaitingDialog();
            }
            _refundWaitingDialog.SetState(ExecutionState.Running, "正在准备退票 【" + _currentRefundTicket.sequence_no + "】" + _currentRefundTicket.stationTrainDTO.station_train_code + " " + _currentRefundTicket.Passenger.Name);
            if (!_refundWaitingDialog.Visible)
            {
                _refundWaitingDialog.ShowDialog();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 请求保存
        /// </summary>
        /// <returns></returns>
        public override bool Save()
        {
            var nc = NetworkConfiguration.Current;

            if (nc.ProxyType != 3 || nc.ProxyClass == ProxyType.Http)
            {
                PolipoSocks5ToHttpProxyWrapper.Instance.Stop();
            }
            else
            {
                var errMsg = "";

                using (var dlg = new YetAnotherWaitingDialog
                {
                    Title = "正在尝试启动Socks5代理..."
                })
                {
                    dlg.WorkCallbackAdvanced = _ =>
                    {
                        var pw = PolipoSocks5ToHttpProxyWrapper.Instance;
                        pw.Stop().Wait();

                        pw.ParentSocksServerAddress = nc.Socks5ServerAddr;
                        pw.ParentSocksServerPort    = nc.Socks5ServerPort;
                        pw.Start().Wait();

                        if (!pw.IsRunning)
                        {
                            throw new Exception("无法启动应用。");
                        }

                        NetClientHandler.RefreshWebProxy();
                        _.Title = "正在测试代理是否正确...";
                        var client = new NetClient();
                        client.Setting.Timeout = 30000;

                        var str = client.Create <string>(HttpMethod.Get, "https://kyfw.12306.cn/otn/", null).Send();
                        if (!str.IsValid() || str.Result.IndexOf("铁路客户服务中心", StringComparison.Ordinal) == -1)
                        {
                            pw.Stop().Wait();
                            throw new Exception("无法通过指定的Socks5代理服务器访问12306。");
                        }
                    };
                    dlg.ShowDialog(FindForm());

                    errMsg = dlg.Exception?.Message ?? "";
                }

                if (!PolipoSocks5ToHttpProxyWrapper.Instance.IsRunning || !errMsg.IsNullOrEmpty())
                {
                    this.Error("未能成功启动Socks5代理服务器!错误:" + errMsg);
                    return(false);
                }
            }
            NetClientHandler.RefreshWebProxy();

            return(base.Save());
        }
Exemplo n.º 5
0
        /// <summary>
        /// 添加联系人
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void ps_RequestAddPassenger(object sender, EventArgs e)
        {
            if (!Session.UserProfile.IsPassengerLoaded)
            {
                this.ShowInfoToast("当前联系人尚未成功加载,请刷新联系人列表后再试");
                return;
            }

            var topmost = TopMost;

            TopMost = false;

            var adg = new AddPassenger();

            if (adg.ShowDialog() != DialogResult.OK)
            {
                TopMost = topmost;
                return;
            }

            var p   = adg.Passenger;
            var fa  = new PassengerManager(Session);
            var err = string.Empty;
            var wd  = new YetAnotherWaitingDialog()
            {
                Title        = "正在添加联系人,请稍等...",
                WorkCallback = () =>
                {
                    err = fa.AddPassenger(p);
                }
            };

            wd.ShowDialog();
            TopMost = topmost;

            if (!string.IsNullOrEmpty(err))
            {
                this.ShowToast("无法添加联系人:" + err, Properties.Resources.warning_16, Color.DarkRed, glowColor: eToastGlowColor.Red);
                return;
            }

            var po = Session.UserProfile.Passengers.FindMatch(p);

            if (po == null)
            {
                AppContext.HostForm.ShowWarningToastMini("联系人添加成功,但未能查询到联系人信息,请稍后手动刷新联系人列表");
            }
            else if (po.CanAddIntoOrder)
            {
                AddPassengerToList(po);
            }
            else
            {
                var state = p.Verification;
                AppContext.HostForm.ShowWarningToastMini("联系人添加成功,但是无法添加到乘客中:" + state.VerifyMessage);
            }
        }
        void tsDelete_Click(object sender, EventArgs e)
        {
            //删除联系人
            if (list.SelectedIndices.Count == 0)
            {
                AppContext.HostForm.ShowWarningToastMini("您还没有选择联系人唷");
                return;
            }

            var plist = list.SelectedItems.Cast <ListViewItem>()
                        .Select(s => s.Tag as Entity.Web.Passenger)
                        .ToArray();

            var self = plist.FirstOrDefault(s => s.IsUserSelf == "Y");

            if (self != null)
            {
                AppContext.HostForm.ShowInfoToastMini("联系人【" + self.Name + "】是注册账户所用的联系人,无法编辑和删除。");
                return;
            }
            if (plist.Length > 20)
            {
                AppContext.HostForm.ShowInfoToastMini("最多一次删除20联系人,您老选的略多...");
                return;
            }

            if (!Question("确定要消灭联系人 【" + plist.Select(s => s.Name).JoinAsString(", ") + "】 吗?", true))
            {
                return;
            }

            var    dlg    = new YetAnotherWaitingDialog();
            string result = null;

            dlg.Title        = "正在扫地中,请稍等.";
            dlg.WorkCallback = () => result = _manager.DeletePassenger(plist);
            dlg.ShowDialog();
            if (result.IsNullOrEmpty())
            {
                //删除
                list.SuspendLayout();
                var pasList = Session.UserProfile.Passengers;
                plist.ForEach(s =>
                {
                    pasList.Remove(s);
                });

                list.ResumeLayout();

                AppContext.HostForm.ShowSuccessToastMini("联系人删除成功");
            }
            else
            {
                AppContext.HostForm.ShowErrorToastMini("联系人删除可耻地失败了....错误信息:" + result);
            }
        }
Exemplo n.º 7
0
 private void btnRefresh_Click(object sender, System.EventArgs e)
 {
     using (var dlg = new YetAnotherWaitingDialog())
     {
         dlg.WorkCallback = () =>
         {
             if (VerifyCodeRecognizeServiceLoader.VerifyCodeRecognizeEngine.IsLoggedIn)
             {
                 VerifyCodeRecognizeServiceLoader.VerifyCodeRecognizeEngine.RefreshScore();
             }
         };
         dlg.ShowDialog();
     }
     RefreshStatus();
 }
Exemplo n.º 8
0
        void btnOk_Click(object sender, EventArgs e)
        {
            var ori  = txtOrg.Text;
            var newp = txtNew.Text;

            if (string.IsNullOrEmpty(ori))
            {
                this.Information("请输入原始密码");
                return;
            }
            if (string.IsNullOrEmpty(newp) || newp.Length < 6)
            {
                this.Information("请输入新密码,不得少于六位");
                return;
            }
            if (newp != txtConfirm.Text)
            {
                this.Information("新密码和确认密码不一致。");
                return;
            }

            var errmsg = "";
            var worker = new AccountModifyWorker(Session);

            using (var dlg = new YetAnotherWaitingDialog())
            {
                dlg.WorkCallback = () => errmsg = worker.ModifyPassword(ori, newp, txtCode.Text);
                dlg.ShowDialog();
            }

            if (string.IsNullOrEmpty(errmsg))
            {
                var uk = UserKeyDataMap.Current[Session.UserName];
                if (uk != null && !string.IsNullOrEmpty(uk.Password))
                {
                    uk.Password = newp;
                    UserKeyDataMap.Current.Save();
                }

                this.Information("密码修改成功!");
                DialogResult = DialogResult.OK;
                Close();
            }
            else
            {
                this.Error(errmsg);
            }
        }
Exemplo n.º 9
0
        void btnLogin_Click(object sender, System.EventArgs e)
        {
            var cfg    = AutoVcConfig.Instance;
            var engine = VerifyCodeRecognizeServiceLoader.VerifyCodeRecognizeEngine;

            engine.UserName = cfg.UserName;
            engine.Password = cfg.Pasword;

            using (var dlg = new YetAnotherWaitingDialog())
            {
                dlg.WorkCallback = () =>
                {
                    engine.DoLogin();
                    if (engine.IsLoggedIn)
                    {
                        engine.RefreshScore();
                    }
                };
                dlg.ShowDialog();
            }
            RefreshStatus();
        }
        void tsAdd_Click(object sender, EventArgs e)
        {
            var p = new Entity.Web.Passenger()
            {
                AddDate = DateTime.Now
            };
            var ad = new Dialogs.Passenger.AddPassenger(p);

            if (ad.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            //添加联系人
            var dlg    = new YetAnotherWaitingDialog();
            var result = "";

            dlg.Title = "正在记录中, 请稍等.";


            dlg.WorkCallback = () =>
            {
                result = _manager.AddPassenger(p);
            };
            dlg.ShowDialog();

            if (result.IsNullOrEmpty())
            {
                //添加


                AppContext.HostForm.ShowSuccessToastMini("已记录在案...");
            }
            else
            {
                AppContext.HostForm.ShowErrorToastMini("添加联系人可耻地失败了:" + result);
            }
        }
        void tsEdit_Click(object sender, EventArgs e)
        {
            if (ParamData.IsSystemMaintenance)
            {
                return;
            }

            var pas = list.SelectedItems.Cast <ListViewItem>().FirstOrDefault();

            if (pas == null)
            {
                AppContext.HostForm.ShowErrorToastMini("这位客官, 您老倒是翻一个要编辑的人的牌儿啊...");
                return;
            }
            var p = pas.Tag as Entity.Web.Passenger;

            if (p.Type == 3)
            {
                AppContext.HostForm.ShowWarningToastMini("哎呀, 现在还不支持对学生联系人下手哦, 校长重新选一个吧...");
                return;
            }

            ////填充完整资料
            //if (p.BornDate == null)
            //{
            //	//没有完整资料,先刷新
            //	var dg = new FSLib.Windows.Dialogs.YetAnotherWaitingDialog();
            //	Entity.Web.Passenger tp = null;
            //	dg.Title = "正在获得详细资料, 请稍等.";
            //	dg.WorkCallback = () => tp = _manager.FillFullInfo(p);
            //	dg.ShowDialog();

            //	if (tp == null)
            //	{
            //		Information("详细资料刷新失败, 这可能是因为您的联系人中重名的太多导致的...");
            //		return;
            //	}
            //	//刷新现有联系人
            //	_passes.Remove(p);
            //	_passes.Add(tp, pas);
            //	pas.Tag = tp;
            //	p = tp;
            //}

            //原名字
            var oldName   = p.Name;
            var oldIdType = p.IdTypeCode;
            var oldId     = p.IdNo;

            var ad = new AddPassenger(p);

            if (ad.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            //添加联系人
            var dlg    = new YetAnotherWaitingDialog();
            var result = "";

            dlg.Title        = "正在记录中, 请稍等.";
            dlg.WorkCallback = () => result = _manager.EditPassenger(p, oldName, oldIdType, oldId);
            dlg.ShowDialog();

            if (result.IsNullOrEmpty())
            {
                //刷新显示(已废弃,因为完全刷新)
                //RefreshItem(_passes[p]);

                AppContext.HostForm.ShowSuccessToastMini("已记录在案...");
            }
            else
            {
                AppContext.HostForm.ShowErrorToastMini("编辑联系人可耻地失败了:" + result);
            }
        }
        public void RunLoginProcedure(RequireSessionLoginWorker worker)
        {
            using (var wd = new YetAnotherWaitingDialog())
            {
                var vccount = 0;
                IVerifyCodeRecognizeResult vcResult = null;

                wd.WorkCallback      = worker.DoLogin;
                worker.StateChanged += (ss, se) =>
                {
                    wd.SetState(worker.State.ToExecutionState(), worker.Message);
                };
                worker.VerifyCodeError += (x, y) =>
                {
                    if (vcResult != null && VerifyCodeRecognizeServiceLoader.VerifyCodeRecognizeEngine != null)
                    {
                        VerifyCodeRecognizeServiceLoader.VerifyCodeRecognizeEngine.MarkResult(vcResult, false);
                        vcResult = null;
                    }
                };
                worker.RequireEnterVerifyCode += (ss, ee) =>
                {
                    wd.Invoke(() =>
                    {
                        if (vccount > 5 && ProgramConfiguration.Instance.AutoEnterLoginVcCode)
                        {
                            MessageDialog.Information("亲,验证码自动识别失败超过限制,自动识别已经关闭,请手动输入验证码。");
                        }
                        //var vcform = new UI.Dialogs.RequireVcCode
                        //{
                        //	Session = ee.Session,
                        //	EnableAutoVc = vccount < 6 && ProgramConfiguration.Instance.AutoEnterLoginVcCode,
                        //	AutoVcCount = vccount
                        //};
                        //if (vcform.ShowDialog(OwnerForm) == DialogResult.OK)
                        //{
                        //	vcResult = vcform.VcResult;
                        //	vccount = vcform.AutoVcCount;
                        //	ee.VerifyCode = vcform.Code;

                        //	if (vcResult != null)
                        //	{
                        //		//report
                        //		ApiEvents.OnAutoVc(null, new GeneralEventArgs<AutoVcLog>(new AutoVcLog()
                        //																{
                        //																	Account12306 = worker.UserName,
                        //																	TypeID = 0,
                        //																	TodayUsed = AutoVcBaseLimition.GetVcUsed()
                        //																}));

                        //	}
                        //}
                        var vc = new TouchClickVcSimpleForm(ee.Session)
                        {
                            RandCodeType = RandCodeType.SjRand,
                            EnableAutoVc = vccount < 6 && ProgramConfiguration.Instance.AutoEnterLoginVcCode
                        };
                        if (vc.ShowDialog(OwnerForm) == DialogResult.OK)
                        {
                            ee.VerifyCode = vc.Code;
                            vcResult      = vc.AutoVcResult;

                            if (vcResult != null)
                            {
                                vccount++;
                            }
                        }
                    });
                    vccount++;
                };

                wd.ShowDialog(OwnerForm);

                if (EnableFallback && worker.Session == null && (string.IsNullOrEmpty(worker.Message) || worker.Message.IndexOf("密码输入错误") != -1))
                {
                    //返回
                    using (var logindlg = new Login()
                    {
                        PreSelectUser = worker.UserName
                    })
                    {
                        logindlg.ShowDialog(OwnerForm);
                    }
                }
                else if (worker.State == OpearationState.Blocked && !worker.Message.IsNullOrEmpty())
                {
                    MessageDialog.Error(OwnerForm, "尝试登录的时候遇到了问题:\n\n" + worker.Message);
                }
                else if (wd.Exception != null)
                {
                    MessageDialog.Error(OwnerForm, "尝试登录的时候遇到了问题:\n\n" + wd.Exception.ToString());
                }
                if (worker.Session != null && worker.LoginConflict)
                {
                    MessageDialog.Information(OwnerForm, "此次登录检测到会话冲突,如果您此时还在其它的软件或浏览器上登录此账号,它们将会被12306无情地注销掉。\n\n世界就是这样的残酷,多坑点身份证注册几个账号吧……");
                }
            }
        }