public PageRecoveryAccount1(SubwindowRouter sr) { _sr = sr; InitializeComponent(); _sr.InteractiveTask(() => { int ret; if (!SubwindowDataCollector.Collect(5 * 60 * 1000, out var service, out var character)) { Growl.Error("等待超时,请返回上一页重试"); } _sr.Procedure = null; var local = new RecoveryProcedure(); try { if (string.IsNullOrEmpty(_sr.Username)) { ret = 02_0009; goto FAIL; } ret = local.Step1(_sr.Username, service, character, Helper.GetTrace()); } catch (HttpRequestException ex) { ret = 02_0000 + (int)(ex.Data["StatusCode"]); } catch (Exception) { ret = 02_0000; } FAIL: if (CheckVendor.NotValidResponseCode(ret)) { Growl.Error(MessageVendor.FormatError(ret)); } else { _sr.Procedure = local; SubwindowNavigator.Navigate(SubwindowPage.Recovery2); } }); }
private void Button_Click(object sender, RoutedEventArgs e) { var email = _sr.Email; Task.Run(() => { if (this.Dispatcher != null && !this.Dispatcher.CheckAccess()) { this.Dispatcher.Invoke(() => SendCaptcha.IsEnabled = false); for (var i = 60; i > 0; i--) { this.Dispatcher.Invoke(() => SendCaptcha.Content = $"请稍候({i}s)"); Thread.Sleep(1000); } this.Dispatcher.Invoke(() => SendCaptcha.IsEnabled = true); } else { SendCaptcha.IsEnabled = false; for (var i = 60; i > 0; i--) { SendCaptcha.Content = $"请稍候({i}s)"; Thread.Sleep(1000); } SendCaptcha.IsEnabled = true; } }); _sr.InteractiveTask(() => { int ret; if (CheckVendor.NotValidEmail(email)) { Growl.Error("无效邮件地址"); } _sr.Procedure = null; var local = new RecoveryProcedure(); try { if (string.IsNullOrEmpty(_sr.Username)) { ret = 02_0009; goto FAIL; } ret = local.Step1(_sr.Username, email, Helper.GetTrace()); } catch (HttpRequestException ex) { ret = 02_0000 + (int)(ex.Data["StatusCode"]); } catch (Exception) { ret = 02_0000; } FAIL: if (CheckVendor.NotValidResponseCode(ret)) { Growl.Error(MessageVendor.FormatError(ret)); } else { _sr.Procedure = local; } }); }