void OrderSubmitDialogBase_CaptchaLoaded(object sender, EventArgs e) { if (sender == this || (sender as OrderSubmitDialogBase).Session != Session) { return; } VerifyCodeBox?.SetExpires(); OnCaptchaExpired(); }
protected virtual async Task OnCaptchaErrorAsync() { if (SubmitOrderWorker.NeedSlideVc) { _slideVc.Reload(); } else { if (VerifyCodeBox?.AutoVcCode == LastVcCode) { VerifyCodeBox?.MarkError(LastVcCode); } VerifyCodeBox?.LoadVerifyCode(); } await SetAllowOperationAsync(false, true).ConfigureAwait(true); }
protected void LoginButton_Click(object sender, EventArgs e) { try { VerifyCodeBox verifyBox = ControlHelper.FindControl <VerifyCodeBox>(Page, "VerifyCodeBox"); if (verifyBox != null && !verifyBox.IsValid) { throw new EntityException("效验码错误,请输入正确的效验码!"); } Provider.Login(UserName.Text, Password.Text); if (Provider.Current != null) { Response.Redirect("Default.aspx"); } else { XTrace.WriteLine("{0}登录失败,但是没有异常,很是奇怪!", UserName.Text); String msg = "登录失败"; WebHelper.Alert(msg); } } catch (ThreadAbortException) { } catch (Exception ex) { String msg = "登录失败"; if (ex is EntityException) { msg += "," + ex.Message; } else { XTrace.WriteException(ex); } WebHelper.Alert(msg); } }
/// <summary> /// 订单准备成功 /// </summary> /// <param name="queueWarning">是否有排队警告</param> /// <returns></returns> protected virtual async Task PrepareSuccessAsync(bool queueWarning) { PreventCloseFlag = false; SetFocus(); VerifyCodeBox.SetIfNeedVc(SubmitOrderWorker.NeedVc); if (await CanSkipVcAsync().ConfigureAwait(true)) { //TODO 这里将延迟的流程延迟到提交订单中了。 // 现在的延迟不高 //if (SubmitOrderWorker.NeedVcTime > 0) //{ // _safeTime = SubmitOrderWorker.NeedVcTime - (SubmitOrderWorker.VcBaseTime == null ? 0 : (int)(DateTime.Now - SubmitOrderWorker.VcBaseTime.Value).TotalMilliseconds); // //_safeTime = Math.Min(ApiConfiguration.Instance.MinimalVcWaitTimeRunTime, _safeTime); // _delaySubmit = true; // Debug.WriteLine($"[VCTIME] {SubmitOrderWorker.NeedVcTime} [BASETIME] {SubmitOrderWorker.VcBaseTime?.ToString("O")} [DELAYTIME] {_safeTime}"); // StartSafeTimeCountDown(); //} //else if (PassengerInTickets?.Count() > 0 && PassengerInTickets.All(s => s.SeatType != '\0')) { await BeginSubmitOrderAsync().ConfigureAwait(true); } else { await SafeTimeEnd().ConfigureAwait(true); } } else if (SubmitOrderWorker.NeedSlideVc) { //需要滑动验证码 if (_slideVc == null) { _slideVc = new SlideVcControl(Session, SubmitOrderWorker.SlideVcToken, SlideAppId.Order); _slideVc.SlideOk += async(sender, args) => { await SetAllowOperationAsync(true, true); SubmitOrderWorker.SlideSig = _slideVc.Sig; SubmitOrderWorker.SlideCSessionId = _slideVc.CfSessionId; _submitButton.Visible = true; _slideVc.Visible = false; await TryBeginSubmitOrderAsync(); }; VerifyCodeBox.Parent.Controls.Add(_slideVc); _slideVc.Location = VerifyCodeBox.Location + new Size(0, VerifyCodeBox.Size.Height - _slideVc.Height); _slideVc.BringToFront(); } else { _slideVc.Token = SubmitOrderWorker.SlideVcToken; } VerifyCodeBox.Visible = false; _submitButton.Visible = false; await OrderInitSuccessAsync(true).ConfigureAwait(true); } else if (Session.LastVerifyCode != null) { VerifyCodeBox.ValidateImage = Properties.Resources.img_preinput; SubmitOrderWorker.RandCode = Session.LastVerifyCode; await TryBeginSubmitOrderAsync().ConfigureAwait(true); } else { VerifyCodeBox.Visible = false; if (_slideVc != null) { _slideVc.Visible = false; } _submitButton.Visible = true; await OrderInitSuccessAsync(SubmitOrderWorker.NeedVc).ConfigureAwait(true); } }
/// <summary> /// 订票失败 /// </summary> /// <param name="error">错误信息</param> /// <param name="isQueue">是排队后的信息还是排队前信息</param> protected virtual async Task OrderFailedAsync(string error, bool isQueue) { PreventCloseFlag = false; if (OrderEventArgs != null) { OrderEventArgs.OrderSubmitContext.OrderID = null; OrderEventArgs.OrderSubmitContext.Message = error; Session.OnOrderSubmitFailed(OrderEventArgs.OrderSubmitContext.Session, OrderEventArgs); } LastErrorMessage = error; if (error?.IndexOf("出票失败") >= 0) { ApiConfiguration.Instance.MinimalVcWaitTimeRunTime += 100; Trace.TraceInformation($"Increase MinimalVcWaitTimeRunTime to {ApiConfiguration.Instance.MinimalVcWaitTimeRunTime}"); } var ma = new MessageAnalyzer(error); if (ma.NeedRelogin) { if (await OnReloginAsync().ConfigureAwait(true)) { await OnOrderContextInitializeAsync().ConfigureAwait(true); await PrepareOrderAsync().ConfigureAwait(true); } else { Close(); } return; } if (ma.NeedVc) { this.ShowToast("请输入验证码"); await SetAllowOperationAsync(false, true).ConfigureAwait(true); VerifyCodeBox.SetIfNeedVc(SubmitOrderWorker.NeedVc); return; } if (ma.CaptchaError) { await OnCaptchaErrorAsync().ConfigureAwait(true); return; } if (ma.NeedRetry && AutoRetryCount++ < OrderConfiguration.Instance.AutoRetryCountLimit) { await OnOrderContextInitializeAsync().ConfigureAwait(true); await OnRequireRetryAsync().ConfigureAwait(true); return; } if (ma.TicketNotEnough) { //排队人数过多/排队人数已超过剩余票数 //余票不足 //没有足够的票 RecentlySubmitFailedTokenStorageProvider.Instance.AddDisableTicketData(Train); } if (ma.NeedRollbackOrderCommitMethod) { Query.TemporaryDisableFastSubmitOrder = !Query.TemporaryDisableFastSubmitOrder; } if (ma.TicketNotEnough || ma.ErrorElse || ma.NeedRetry) { //订单提交失败 if (AutoResumeAttached) { if (ma.TicketNotEnough) { if (isQueue) { OnQueueFailedNoTicket(); } else { OnSubmitFailed(); } } else { if (isQueue) { OnQueueFailedElse(); } else { OnSubmitFailed(); } } if (BreakOperation) { return; } } if (ma.NeedRollbackOrderCommitMethod) { await OnInformationAsync("当前订单提交已失效,请返回后重试。").ConfigureAwait(true); Close(); return; } //请求确认 if (await OnOrderResubmitAsync(error).ConfigureAwait(true)) { await PrepareOrderAsync().ConfigureAwait(true); } else { Close(); } return; } //身份信息有误/账户信息有误/订单要处理/订单排队中 UiUtility.PlaceFormAtCenter(new OrderNotification(Session, Query, Train, PassengerInTickets, ma.Message, null)); Close(); }