Beispiel #1
0
 private async void ExecuteOnLogin()
 {
     try
     {
         IsLoginProgress = true;
         await Task.Factory.StartNew(() =>
         {
             try
             {
                 if (ValidateOnLogin())
                 {
                     var user = UserServiceClient.GetUser(LoginText, AESEncryptor.encryptPassword(Password));
                     if (user != null)
                     {
                         if (user.Status == "online")
                         {
                             Application.Current.Dispatcher.Invoke(() =>
                             {
                                 CustomMessageBox.Show(
                                     Translations.GetTranslation()["Error"].ToString(),
                                     Translations.GetTranslation()["UserAlreadyOnline"].ToString(),
                                     MessageBoxType.Error);
                             });
                             return;
                         }
                         _serializeUser.SerializeUser(user);
                         Application.Current.Dispatcher.Invoke(() =>
                         {
                             var wnd = new MessageMainWnd(user);
                             wnd.Show();
                             view.CloseWindow();
                             IsLoginProgress = false;
                         });
                     }
                 }
             }
             catch (Exception)
             {
             }
         }).ContinueWith(task => { IsLoginProgress = false; });
     }
     catch (Exception)
     {
     }
 }
Beispiel #2
0
        private void InitLogin(string userLogin)
        {
            try
            {
                var user = new User();
                Task.Run(() =>
                {
                    user = UserServiceClient.GetUserByLogin(userLogin);
                }).ContinueWith(task =>
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        try
                        {
                            if (user?.Status == "online")
                            {
                                CustomMessageBox.Show(
                                    Translations.GetTranslation()["Error"].ToString(),
                                    Translations.GetTranslation()["UserAlreadyOnline"].ToString(),
                                    MessageBoxType.Error);

                                IsLoginProgress = false;
                                return;
                            }
                            else if (user == null)
                            {
                                IsLoginProgress = false;
                                return;
                            }

                            var wnd = new MessageMainWnd(user);
                            wnd.Show();
                            view.CloseWindow();
                            IsLoginProgress = false;
                        }
                        catch (Exception)
                        {
                        }
                    });
                });
            }
            catch (Exception)
            {
            }
        }