private async Task <bool> AuthenticateUserAsync()
        {
            if (string.IsNullOrEmpty(GlobalData.Instance.AggregatedConfig.GetInterfaceItem().BmsAddress))
            {
                DialogContent = Messages.WarningUserCenterIpNotConfigured;

                return(false);
            }
            Log.Logger.Debug("【**********************************************************************************】");

            Log.Logger.Debug($"【login step1】:get imei token begins");
            ResponseResult getImeiToekenResult =
                await
                _bmsService.GetImeiToken(GlobalData.Instance.SerialNo,
                                         GlobalData.Instance.AggregatedConfig.DeviceKey);

            Log.Logger.Debug($"【login step1】:get imei token ends");

            if (getImeiToekenResult.Status != "0")
            {
                DialogContent = getImeiToekenResult.Message;
                return(false);
            }

            Log.Logger.Debug($"【login step2】:get userinfo begins");
            ResponseResult getUserInfoResult = await _bmsService.GetUserInfo();

            Log.Logger.Debug($"【login step2】:get userinfo ends");

            if (getUserInfoResult.Status != "0")
            {
                DialogContent = getUserInfoResult.Message;
                return(false);
            }

            UserInfo userInfo = getUserInfoResult.Data as UserInfo;

            if (userInfo != null)
            {
                UserInfo globalUserInfo = IoC.Get <UserInfo>();
                globalUserInfo.CloneUserInfo(userInfo);


                return(true);
            }

            if (userInfo.GetNube() == null)
            {
                DialogContent = "未开通视讯号!";
                return(false);
            }

            Log.Logger.Error($"【get user info via device no. failed】:user info is null");
            DialogContent = Messages.ErrorLoginFailed;
            return(false);
        }
        private async Task <bool> AuthenticateUserAsync()
        {
            if (string.IsNullOrEmpty(GlobalData.Instance.AggregatedConfig.GetInterfaceItem().BmsAddress))
            {
                HasErrorMsg("-1", Messages.WarningUserCenterIpNotConfigured);
                return(false);
            }
            Log.Logger.Debug("【**********************************************************************************】");
            Log.Logger.Debug($"【login step1】:apply for token begins");
            ResponseResult bmsTokenResult =
                await _bmsService.ApplyForToken(UserName, Password, GlobalData.Instance.SerialNo);

            Log.Logger.Debug($"【login step1】:apply for token ends");

            if (HasErrorMsg(bmsTokenResult.Status, bmsTokenResult.Message))
            {
                return(false);
            }

            Log.Logger.Debug($"【login step2】:get userinfo begins");
            ResponseResult userInfoResult = await _bmsService.GetUserInfo();

            Log.Logger.Debug($"【login step2】:get userinfo ends");

            if (HasErrorMsg(userInfoResult.Status, userInfoResult.Message))
            {
                return(false);
            }

            UserInfo userInfo = userInfoResult.Data as UserInfo;

            if (userInfo != null)
            {
                UserInfo globalUserInfo = IoC.Get <UserInfo>();
                userInfo.Pwd = Password;
                globalUserInfo.CloneUserInfo(userInfo);

                return(true);
            }

            if (userInfo.GetNube() == null)
            {
                HasErrorMsg("-1", "未开通视讯号!");
                return(false);
            }

            Log.Logger.Error($"【get user info via account failed】:user info is null");
            HasErrorMsg("-1", Messages.ErrorLoginFailed);
            return(false);
        }
        public LoginViewModel(Window loginView)
        {
            _windowManager        = IoC.Get <IMeetingWindowManager>();
            _loginView            = loginView;
            _userInfo             = IoC.Get <UserInfo>();
            _bmsService           = IoC.Get <IBms>();
            _visualizeShellSevice = IoC.Get <IVisualizeShell>();
            _loginView.Closing   += _loginView_Closing;

            LoginCommand          = DelegateCommand.FromAsyncHandler(LoginAsync);
            LoadCommand           = DelegateCommand.FromAsyncHandler(LoadAsync);
            SaveSettingCommand    = DelegateCommand.FromAsyncHandler(SaveSettingAsync);
            ShowSettingCommand    = new DelegateCommand(ShowSettingAsync);
            TopMostTriggerCommand = new DelegateCommand(TriggerTopMost);
            ShowLogCommand        = DelegateCommand.FromAsyncHandler(ShowLogAsync);
        }