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);
        }
        private async void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            Log.Logger.Debug("【refresh token begins】");
            IBms bmsService = IoC.Get <IBms>();

            ResponseResult refreshResult;

            if (GlobalData.Instance.Device.EnableLogin)
            {
                refreshResult =
                    await
                    bmsService.GetImeiToken(GlobalData.Instance.Device.Id,
                                            GlobalData.Instance.AggregatedConfig.DeviceKey);
            }
            else
            {
                UserInfo userInfo = IoC.Get <UserInfo>();
                refreshResult =
                    await bmsService.ApplyForToken(userInfo.UserName, userInfo.Pwd, GlobalData.Instance.Device.Id);
            }

            Log.Logger.Debug(
                $"【refresh token result】:status={refreshResult.Status}, msg={refreshResult.Message}, data={refreshResult.Data}");

            if (refreshResult.Status == "0")
            {
                IRtClientService rtClientService = IoC.Get <IRtClientService>();

                rtClientService.RefreshToken(bmsService.AccessToken);
            }
            else
            {
                //await Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                //{
                //    SscDialog refreshTokenDialog =
                //        new SscDialog($"{Messages.WarningRefreshTokenFailed}\r\n{refreshResult.Message}");
                //    refreshTokenDialog.ShowDialog();
                //}));
            }
        }