private async void UserLogin() { UserInfoReturnValue userInfo; try { userInfo = await CommonService.GetUserInfo(); } catch (WebException) { MessageBox.Show("无法连接至服务器."); return; } if (userInfo.Status.Code == 1) { _runtime.UserInfo = userInfo.Info; DDnsSharpRuntime.SaveAppConfig(); var mwin = new DDNSMonitorWindow(); mwin.Show(); foreach (Window win in App.Current.Windows) { if (win != mwin) { win.Close(); } } } else { _loginFailedCount++; if (_loginFailedCount == 10) { ErrorMessage = "登陆次数超过已达10次,请5分钟后再试."; if (_loginTimer == null) { _loginTimer = new Timer(); } _loginTimer.Interval = 300000; _loginTimer.Start(); _loginTimer.Elapsed += (o, e) => { _ableToLogin = true; LoginCommand.RaiseCanExecuteChanged(); _loginTimer.Stop(); _loginTimer.Dispose(); _loginTimer = null; }; _ableToLogin = false; LoginCommand.RaiseCanExecuteChanged(); } else { ErrorMessage = userInfo.Status.Message; } } }
private void OnRecordManaged(UpdateModelWrapper obj) { if (Runtime.UpdateList.Count(m => m == obj) <= 0) { Runtime.UpdateList.Add(obj); } DDnsSharpRuntime.AppConfig.UpdateList = (from w in Runtime.UpdateList select w.UnWrap()).ToList(); DDnsSharpRuntime.SaveAppConfig(); }
private void DeleteRecrod(UpdateModelWrapper um) { var mbr = MessageBox.Show("请确认操作.", "注意", MessageBoxButton.YesNo); if (mbr == MessageBoxResult.Yes) { Runtime.UpdateList.Remove(um); DDnsSharpRuntime.AppConfig.UpdateList = (from w in Runtime.UpdateList select w.UnWrap()).ToList(); DDnsSharpRuntime.SaveAppConfig(); } }
private async void OnForceUpdate() { UpdateCurrentIP(); var updateModels = from u in Runtime.UpdateList select u.UnWrap(); try { await DDNS.Start(updateModels, true); } catch (WebException) { MessageBox.Show("无法连接至服务器."); } Runtime.SetUpdateList(updateModels); DDnsSharpRuntime.AppConfig.UpdateList = updateModels.ToList(); DDnsSharpRuntime.SaveAppConfig(); }
private async void OnJob() { try { DDnsSharpRuntime.LoadAppConfig(); await DDNS.Start(DDnsSharpRuntime.AppConfig.UpdateList); DDnsSharpRuntime.SaveAppConfig(); if (timer.Interval > 30000) { timer.Interval = 30000; } } catch (Exception ex) { logger.ErrorException("更新记录时出现意外错误", ex); timer.Interval = 300000; } }