Esempio n. 1
0
        private async void Login()
        {
            //如果没有登录
            if (_loginUserService.GetUserLoginStatus() == false)
            {
                if (new LoginManage().Login(_loginUserService.DefaultLoginServer()))
                {
                    Status = ViewModelStatus.Querying;
                    //把登录配置保存到本地
                    _localConfiguration.WriteServerInfo(_localConfiguration.ServerInfoList);
                    await _loginUserService.SetUserLogin();

                    _eventAggregator.GetEvent <LoginEvent>().Publish(_loginUserService.LoginInfo);
                    Status = ViewModelStatus.None;
                }
            }
            else
            {
                Xceed.Wpf.Toolkit.MessageBox.Show("请退出后再登陆!!!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                //if (LoginManage.Login(_loginUserService.LoginInfo))
                //{
                //    _loginUserService.SetUserLogin();
                //    _eventAggregator.GetEvent<LoginEvent>().Publish(_loginUserService.LoginInfo);
                //    //把登录配置保存到本地
                //    _localConfiguration.WriteServerInfo(_localConfiguration.ServerInfoList);
                //}
            }
        }
Esempio n. 2
0
        private async void Login(object para)
        {
            ServerInfo serverinfo = para as ServerInfo;

            if (serverinfo == null)
            {
                return;
            }

            try
            {
                if (new LoginManage().Login(_loginUserService.InitLoginServer(serverinfo)))
                {
                    Status = ViewModelStatus.Querying;
                    //把登录配置保存到本地
                    _localConfiguration.WriteServerInfo(ServerInfo);
                    await _loginUserService.SetUserLogin();

                    _eventAggregator.GetEvent <LoginEvent>().Publish(_loginUserService.LoginInfo);

                    //加载数据
                }
            }
            catch (Exception ex)
            {
                _eventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("登录异常", ex));
            }
            finally
            {
                Status = ViewModelStatus.None;
            }
        }