Exemple #1
0
 private async void OnCurrentUserChanged(object sender,
                                         UserChangedEventArgs e)
 {
     await UpdateAvatarSource(
         e.NewUser.Id)
     .ConfigureAwait(false);
 }
        private async void OnCurrentUserChanged(object sender,
                                                UserChangedEventArgs e)
        {
            if (e.NewUser.Id == -1)
            {
                return;
            }

            await UpdatePost()
            .ConfigureAwait(true);

            await StorageManager.SetPostCommentDraft(
                e.OldUser.Id,
                ViewModel.CurrentPostData.Id,
                WriteComment.CommentText,
                WriteComment.IsAnonymous)
            .ConfigureAwait(true);

            var draft = await StorageManager.GetPostCommentDraft(
                e.NewUser.Id,
                ViewModel.CurrentPostData.Id)
                        .ConfigureAwait(true);

            if (!string.IsNullOrEmpty(draft.CommentText))
            {
                WriteComment.CommentText = draft.CommentText;
                WriteComment.IsAnonymous = draft.IsAnonymous;

                WriteComment.ContentTextBox.ScrollToEnd();
                WriteComment.ContentTextBox.CaretIndex = draft.CommentText.Length;
                WriteComment.ContentTextBox.Focus();
            }
        }
        private async void _accountService_UserChanged(object sender, UserChangedEventArgs e)
        {
            var shoppingCartMerged = false;

            _cachedShoppingCart = null;
            if (e.NewUserInfo != null)
            {
                // User successfully signed in.
                if (e.OldUserInfo == null)
                {
                    shoppingCartMerged = await _shoppingCartService.MergeShoppingCartsAsync(_shoppingCartId, e.NewUserInfo.UserName);
                }

                _shoppingCartId = e.NewUserInfo.UserName;
            }
            else
            {
                // User signed out.
                _shoppingCartId = Guid.NewGuid().ToString();
            }

            _sessionStateService.SessionState[ShoppingCartIdKey] = _shoppingCartId;
            RaiseShoppingCartUpdated();

            if (shoppingCartMerged)
            {
                // At this point, you could notify the user that their shopping cart was merged
                // with their online shopping cart. If you do this, follow these guidelines:
                // http://msdn.microsoft.com/en-us/library/windows/apps/hh465304.aspx#flyouts
            }
        }
        private async void OnCurrentUserChanged(object sender, UserChangedEventArgs e)
        {
            if (e.NewUser.Id == -1)
            {
                return;
            }

            if (ViewModel.CurrentPostData == null)
            {
                return;
            }

            ViewModel.CurrentPostData.OwnerId = e.NewUser.Id;

            if (ViewModel.CurrentPostData.OwnerId == -1)
            {
                return;
            }

            var result = await UserApi.GetProfileById(
                ViewModel.CurrentPostData.OwnerId.Value)
                         .ConfigureAwait(true);

            if (result.Data == null)
            {
                return;
            }

            ViewModel.CurrentPostData.OwnerNickname = result.Data.Nickname;
            ViewModel.CurrentPostData.OwnerPhotoUrl = result.Data.PhotoUrl;
        }
Exemple #5
0
        private static void UserWatcher_UserRemoved(UserWatcher sender, UserChangedEventArgs args)
        {
            UserImpl signoutUser;

            if (trackingUsers.TryGetValue(args.User.NonRoamableId, out signoutUser))
            {
                signoutUser.UserSignedOut();
            }
        }
		public static void OnUserChanged(UserChangedEventArgs userChangedEventArgs)
		{
			if (userChangedEventArgs.IsReconnect)
			{
				FiresecManager.FiresecService.GKAddMessage(EventName.Смена_пользователя, userChangedEventArgs.OldName + " вышел. " + userChangedEventArgs.NewName + " вошел");
			}
			else
			{
				FiresecManager.FiresecService.GKAddMessage(EventName.Вход_пользователя_в_систему, "");
			}
		}
Exemple #7
0
        private async void OnCurrentUserChanged(object sender, UserChangedEventArgs e)
        {
            if (e.NewUser.Id == -1)
            {
                return;
            }

            _autoUpdateCountTimer.Stop();

            btnRefresh.IsEnabled = false;

            await ShowLoadingGrid(true)
            .ConfigureAwait(true);

            svPosts.IsEnabled = false;


            if (lstPosts.Children.Count == 0)
            {
                return;
            }

            var tasks = new List <Task>(lstPosts.Children.Count);

            foreach (var post in lstPosts.Children)
            {
                if (!(post is PostWidget postWidget))
                {
                    continue;
                }

                tasks.Add(postWidget.UpdatePost());

                if (tasks.Count % 5 == 0)
                {
                    await Task.Delay(TimeSpan.FromMilliseconds(500))
                    .ConfigureAwait(true);
                }
            }

            await Task.WhenAll(tasks)
            .ConfigureAwait(true);


            svPosts.IsEnabled = true;

            await ShowLoadingGrid(false)
            .ConfigureAwait(true);

            btnRefresh.IsEnabled = true;

            _autoUpdateCountTimer.Start();
        }
Exemple #8
0
		void OnChangeUser()
		{
			var oldUserName = UserName;
			var result = ServiceFactory.LoginService.ExecuteReconnect();
			if (result)
			{
				var userChangedEventArgs = new UserChangedEventArgs()
				{
					IsReconnect = true,
					OldName = oldUserName,
					NewName = UserName
				};
				ServiceFactory.Events.GetEvent<UserChangedEvent>().Publish(userChangedEventArgs);
			}
		}
        private async void OnUserRemoved(UserWatcher sender, UserChangedEventArgs e)
        {
            User user = e.User;

            // UI work must happen on the UI thread.
            await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
            {
                // Look for the user in our collection and remove it.
                UserViewModel model = FindModelByUserId(user.NonRoamableId);
                if (model != null)
                {
                    Users.Remove(model);
                }
            });
        }
        private async void OnUserUpdated(UserWatcher sender, UserChangedEventArgs e)
        {
            User user = e.User;

            // UI work must happen on the UI thread.
            await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Low, async() =>
            {
                // Look for the user in our collection and update the display name.
                UserViewModel model = FindModelByUserId(user.NonRoamableId);
                if (model != null)
                {
                    model.DisplayName = await GetDisplayNameOrGenericNameAsync(user);
                }
            });
        }
        private async void OnUserAdded(UserWatcher sender, UserChangedEventArgs e)
        {
            User user = e.User;

            // UI work must happen on the UI thread.
            await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Low, async() =>
            {
                // Create the user with "..." as the temporary display name.
                // Add it right away, because it might get removed while the
                // "await GetDisplayNameOrGenericNameAsync()" is running.
                var model = new UserViewModel(user.NonRoamableId, "\u2026");
                Users.Add(model);

                // Try to get the display name.
                model.DisplayName = await GetDisplayNameOrGenericNameAsync(user);
            });
        }
        private async void OnCurrentUserChanged(object sender, UserChangedEventArgs e)
        {
            if (e.NewUser.Id == -1)
            {
                return;
            }

            await UpdatePost()
            .ConfigureAwait(true);

            var result = await UserApi.GetProfileById(
                SettingsManager.PersistentSettings.CurrentUser.Id)
                         .ConfigureAwait(true);

            if (!result.IsError &&
                result.Data != null)
            {
                wdgWriteComment.SetRealUserAvatarSource(result.Data.PhotoUrl);
            }

            await StorageManager.SetPostCommentDraft(
                e.OldUser.Id,
                ViewModel.CurrentPostData.Id,
                wdgWriteComment.CommentText,
                wdgWriteComment.IsAnonymous)
            .ConfigureAwait(true);

            var draft = await StorageManager.GetPostCommentDraft(
                e.NewUser.Id,
                ViewModel.CurrentPostData.Id)
                        .ConfigureAwait(true);

            if (!string.IsNullOrEmpty(draft.CommentText))
            {
                wdgWriteComment.CommentText = draft.CommentText;
                wdgWriteComment.IsAnonymous = draft.IsAnonymous;

                wdgWriteComment.txtContent.ScrollToEnd();
                wdgWriteComment.txtContent.CaretIndex = draft.CommentText.Length;
                wdgWriteComment.txtContent.Focus();
            }
        }
Exemple #13
0
 private void OnCurrentUserChanged(object sender,
                                   UserChangedEventArgs e)
 {
     UpdateContextMenus();
 }
 IReadOnlyList <UserWatcherUpdateKind> IUserChangedEventArgsResolver.ChangedPropertyKinds(UserChangedEventArgs e) => e.ChangedPropertyKinds;
 User IUserChangedEventArgsResolver.User(UserChangedEventArgs e) => e.User;
 /// <summary>
 /// Describes the kinds of changes that triggered the UserChangedEvent.
 /// </summary>
 /// <param name="e">The requested <see cref="UserChangedEventArgs"/>.</param>
 /// <returns>A list of <see cref="UserWatcherUpdateKind"/> that describe the changes to the user.</returns>
 public static IReadOnlyList <UserWatcherUpdateKind> ChangedPropertyKinds(this UserChangedEventArgs e) => Resolver.ChangedPropertyKinds(e);
 /// <summary>
 /// Gets the user.
 /// </summary>
 /// <param name="e">The requested <see cref="UserChangedEventArgs"/>.</param>
 /// <returns>The user.</returns>
 public static User User(this UserChangedEventArgs e) => Resolver.User(e);
Exemple #18
0
 private async void OnCurrentUserChanged(object sender, UserChangedEventArgs e)
 {
     await UpdateProfile()
     .ConfigureAwait(true);
 }
Exemple #19
0
        private async void OnCurrentUserChanged(object sender,
                                                UserChangedEventArgs e)
        {
            if (e.NewUser.Id == -1)
            {
                return;
            }

            _autoUpdateCountTimer.Stop();

            PostsTypesComboBox.IsEnabled = false;
            RefreshPostsButton.IsEnabled = false;

            await ShowLoadingGrid()
            .ConfigureAwait(true);

            PostsScrollViewer.IsEnabled = false;

            try
            {
                var postType =
                    ((KeyValuePair <PostType, string>)PostsTypesComboBox.SelectedItem)
                    .Key;

                switch (postType)
                {
                case PostType.Popular:
                case PostType.New:
                    if (PostsWrapPanel.Children.Count == 0)
                    {
                        break;
                    }

                    var tasks = new List <Task>(
                        PostsWrapPanel.Children.Count);

                    foreach (var post in PostsWrapPanel.Children)
                    {
                        if (!(post is Post postWidget))
                        {
                            continue;
                        }

                        tasks.Add(postWidget
                                  .UpdatePost());

                        if (tasks.Count % 5 == 0)
                        {
                            await Task.Delay(
                                TimeSpan.FromSeconds(0.5))
                            .ConfigureAwait(true);
                        }
                    }

                    await Task.WhenAll(tasks)
                    .ConfigureAwait(true);

                    break;

                case PostType.My:
                case PostType.Favorite:
                    await UpdatePosts()
                    .ConfigureAwait(true);

                    break;

                default:
                    break;
                }
            }
            finally
            {
                PostsScrollViewer.IsEnabled = true;

                await HideLoadingGrid()
                .ConfigureAwait(true);

                RefreshPostsButton.IsEnabled = true;
                PostsTypesComboBox.IsEnabled = true;

                _autoUpdateCountTimer.Start();
            }
        }
		void OnUserChanged(UserChangedEventArgs userChangedEventArgs)
		{
			OnPropertyChanged("HasPermission");
		}
Exemple #21
0
 /// <summary>
 /// Méthode réceptive de l'évenement <see cref="UserChangedEvent"/>
 /// </summary>
 ///
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnUserChanged(object sender, UserChangedEventArgs e)
 {
     CurrentUser = e.NewUser;
     Navigate(new MenuView());
 }
 private void OnSelectedUserChanged(object sender, UserChangedEventArgs userChangedEventArgs)
 {
     User = userChangedEventArgs.User;
 }
        private async void OnUserAdded(UserWatcher sender, UserChangedEventArgs e)
        {
            User user = e.User;

            // UI work must happen on the UI thread.
            await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Low, async () =>
            {
                // Create the user with "..." as the temporary display name.
                // Add it right away, because it might get removed while the
                // "await GetDisplayNameOrGenericNameAsync()" is running.
                var model = new UserViewModel(user.NonRoamableId, "\u2026");
                Users.Add(model);

                // Try to get the display name.
                model.DisplayName = await GetDisplayNameOrGenericNameAsync(user);
            });
        }
        private async void OnUserUpdated(UserWatcher sender, UserChangedEventArgs e)
        {
            User user = e.User;

            // UI work must happen on the UI thread.
            await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Low, async () =>
            {
                // Look for the user in our collection and update the display name.
                UserViewModel model = FindModelByUserId(user.NonRoamableId);
                if (model != null)
                {
                    model.DisplayName = await GetDisplayNameOrGenericNameAsync(user);
                }
            });
        }
Exemple #25
0
		public bool Initialize()
		{
			var result = true;
			LoadingErrorManager.Clear();
			AppConfigHelper.InitializeAppSettings();
			ServiceFactory.Initialize(new LayoutService(), new SecurityService());
			ServiceFactory.ResourceService.AddResource(new ResourceDescription(typeof(Bootstrapper).Assembly, "DataTemplates/Dictionary.xaml"));

			if (ServiceFactory.LoginService.ExecuteConnect(App.Login, App.Password))
			{
				var userChangedEventArgs = new UserChangedEventArgs
				{
					IsReconnect = false
				};
				ServiceFactory.Events.GetEvent<UserChangedEvent>().Publish(userChangedEventArgs);
				App.Login = ServiceFactory.LoginService.Login;
				App.Password = ServiceFactory.LoginService.Password;
				try
				{
					CreateModules();

					LoadingService.ShowLoading("Чтение конфигурации", 15);
					LoadingService.AddCount(GetModuleCount());

					LoadingService.DoStep("Синхронизация файлов");
					FiresecManager.UpdateFiles();

					LoadingService.DoStep("Загрузка конфигурации с сервера");
					FiresecManager.GetConfiguration("Monitor/Configuration");

					GKDriversCreator.Create();
					BeforeInitialize(true);

					LoadingService.DoStep("Старт полинга сервера");
					FiresecManager.StartPoll(false);

					LoadingService.DoStep("Проверка прав пользователя");
					if (FiresecManager.CheckPermission(PermissionType.Oper_Login))
					{
						LoadingService.DoStep("Загрузка клиентских настроек");
						ClientSettings.LoadSettings();
						Notifier.Initialize();

						result = Run();
						SafeFiresecService.ConfigurationChangedEvent += () => { ApplicationService.Invoke(OnConfigurationChanged); };
					}
					else
					{
						MessageBoxService.Show("Нет прав на работу с программой");
						FiresecManager.Disconnect();
					}
					LoadingService.Close();

					if (result)
						AterInitialize();

					//MutexHelper.KeepAlive();
					ProgressWatcher.Run();
					if (Process.GetCurrentProcess().ProcessName != "FireMonitor.vshost")
					{
						RegistrySettingsHelper.SetBool("isException", true);
					}
				}
				catch (Exception e)
				{
					Logger.Error(e, "Bootstrapper.InitializeFs");
					MessageBoxService.ShowException(e);
					if (Application.Current != null)
						Application.Current.Shutdown();
					return false;
				}
			}
			else
			{
				if (Application.Current != null)
					Application.Current.Shutdown();
				return false;
			}
			return result;
		}
Exemple #26
0
        private async void OnCurrentUserChanged(object sender, UserChangedEventArgs e)
        {
            if (e.NewUser.Id == -1)
            {
                return;
            }

            _autoUpdateCountTimer.Stop();

            slcPostTypes.IsEnabled = false;
            btnRefresh.IsEnabled   = false;

            await ShowLoadingGrid(true)
            .ConfigureAwait(true);

            svPosts.IsEnabled = false;

            var postType = ((KeyValuePair <PostType, string>)slcPostTypes.SelectedItem).Key;

            switch (postType)
            {
            case PostType.Popular:
            case PostType.New:
                if (lstPosts.Children.Count == 0)
                {
                    break;
                }

                var tasks = new List <Task>(lstPosts.Children.Count);

                foreach (var post in lstPosts.Children)
                {
                    if (!(post is PostWidget postWidget))
                    {
                        continue;
                    }

                    tasks.Add(postWidget.UpdatePost());

                    if (tasks.Count % 5 == 0)
                    {
                        await Task.Delay(TimeSpan.FromMilliseconds(500))
                        .ConfigureAwait(true);
                    }
                }

                await Task.WhenAll(tasks)
                .ConfigureAwait(true);

                break;

            case PostType.My:
            case PostType.Favorite:
                await UpdatePosts()
                .ConfigureAwait(true);

                break;

            default:
                break;
            }

            svPosts.IsEnabled = true;

            await ShowLoadingGrid(false)
            .ConfigureAwait(true);

            btnRefresh.IsEnabled   = true;
            slcPostTypes.IsEnabled = true;

            _autoUpdateCountTimer.Start();
        }
        private async void OnUserRemoved(UserWatcher sender, UserChangedEventArgs e)
        {
            User user = e.User;

            // UI work must happen on the UI thread.
            await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
            {
                // Look for the user in our collection and remove it.
                UserViewModel model = FindModelByUserId(user.NonRoamableId);
                if (model != null)
                {
                    Users.Remove(model);
                }
            });
        }
 private void OnSelectedUserChanged(object sender, UserChangedEventArgs userChangedEventArgs)
 {
     User = userChangedEventArgs.User;
 }
		void OnUserChanged(UserChangedEventArgs userChangedEventArgs)
		{
			OnPropertyChanged("UserName");
		}