Ejemplo n.º 1
0
 private async void Login()
 {
     try
     {
         var userInfo = await CommonService.GetUserInfo();
         if (userInfo.Status.Code == 1)
         {
             var runtime = MonitorIoc.Current.Get<MonitorRuntime>();
             runtime.UserInfo = userInfo.Info;
             var win = new DDNSMonitorWindow();
             if (!mconfig.HideOnStartup)
                 win.Show();
             this.Close();
         }
         else if (userInfo.Status.Code == -1)
         {
             ShowLoginWindow();
         }
         else
         {
             MessageBox.Show(userInfo.Status.Message);
         }
     }
     catch (WebException)
     {
         MessageBox.Show("无法连接至服务器..");
         ShowLoginWindow();
     }
 }
Ejemplo n.º 2
0
        private async void Login()
        {
            try
            {
                var userInfo = await CommonService.GetUserInfo();

                if (userInfo.Status.Code == 1)
                {
                    var runtime = MonitorIoc.Current.Get <MonitorRuntime>();
                    runtime.UserInfo = userInfo.Info;
                    var win = new DDNSMonitorWindow();
                    if (!mconfig.HideOnStartup)
                    {
                        win.Show();
                    }
                    this.Close();
                }
                else if (userInfo.Status.Code == -1)
                {
                    ShowLoginWindow();
                }
                else
                {
                    MessageBox.Show(userInfo.Status.Message);
                }
            }
            catch (WebException)
            {
                MessageBox.Show("无法连接至服务器..");
                ShowLoginWindow();
            }
        }
Ejemplo n.º 3
0
 public static void ShowFromTray()
 {
     var montior = new DDNSMonitorWindow();
     montior.Show();
     CloseAllWindowsBut(new []{montior});
 }
Ejemplo n.º 4
0
        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;
                }
            }
        }