private void ExecuteRefreshCommand(SmoothBusyIndicator busyIndicator) { busyIndicator.IsBusy = true; Task.Run(() => { this.UpdateRecommendUsers(); Thread.Sleep(1000); busyIndicator.IsBusy = false; }); }
public bool TryLogin(DelegateCommand <UIElement> loginCommand, SmoothBusyIndicator busyIndicator, UIElement loginButton, LoginModel loginModel) { bool bIsSuccessAuth = false; this.m_Logger.Log("TryLogin Raised", Category.Info, Priority.None); try { Application.Current.Dispatcher.Invoke(() => { loginButton.IsEnabled = false; }); busyIndicator.IsBusy = true; AuthRepository.AccessInfo = this.m_RequestAccessInfoService.RequestAccessInfo(loginModel.Id, loginModel.Password); if (null != AuthRepository.AccessInfo) { AuthRepository.MQKeyInfo = this.m_RequestMQKeysService.RequestMQKeys(AuthRepository.AccessInfo.TokenType, AuthRepository.AccessInfo.AccessToken); if (null != AuthRepository.MQKeyInfo) { var FindMeQuery = Query <UserEntity> .EQ(u => u.Sid, AuthRepository.MQKeyInfo.UserSid); var UserCollection = ConnectionHelper.DB.GetCollection <UserEntity>("UserEntity"); var FindedUser = UserCollection.FindOne(FindMeQuery); if (null == FindedUser) { var Me = new UserEntity(AuthRepository.MQKeyInfo.Account, AuthRepository.MQKeyInfo.UserSid, AuthRepository.MQKeyInfo.NickName, AuthRepository.MQKeyInfo.Interests); UserCollection.Save(Me); } var FindFriendQuery = Query <FriendsEntity> .EQ(u => u.UserSID, AuthRepository.MQKeyInfo.UserSid); var FriendCollection = ConnectionHelper.DB.GetCollection <FriendsEntity>("FriendsEntity"); var FindedFriend = FriendCollection.FindOne(FindFriendQuery); if (null == FindedFriend) { FriendCollection.Save(new FriendsEntity(AuthRepository.MQKeyInfo.UserSid, new List <string>())); } bIsSuccessAuth = true; } } } catch (ArgumentNullException ParameterNullException) { this.m_Logger.Log(ParameterNullException.Message, Category.Exception, Priority.None); } catch (InvalidCastException InvalidCastAboutRequestParameters) { this.m_Logger.Log(InvalidCastAboutRequestParameters.Message, Category.Exception, Priority.None); } catch (Exception UnExpectedException) { this.m_Logger.Log(UnExpectedException.Message, Category.Exception, Priority.None); } finally { busyIndicator.IsBusy = false; Application.Current.Dispatcher.Invoke(() => { loginButton.IsEnabled = true; }); } return(bIsSuccessAuth); }
private void ExecuteInitialLoadedCommand(SmoothBusyIndicator busyIndicator) { this.m_BusyIndicator = busyIndicator; }