Пример #1
0
        private async void SignInCommandExecute(PasswordBox password)
        {
            // 1.
            IsSigningIn = true;
            try
            {
                // TODO: If the server implements decryption function, the following code will be used.
                var mountUser = await _mountUserRepository.CreateAsync(Username,
                                                                       password.Password.Length <= 117?password.Password.ToMd5().EncryptByRSA() : password.Password); // 117 is the maximum allowable encryption length of RSA (1024).

                mountUser.IsRememberPassword = IsRememberPassword;
                mountUser.IsAutoSignIn       = IsAutoSignIn;
                Logger.Log($"User: \"{Username}\" has successfully logged in.", Category.Info, Priority.Low);
                // 2.Shows the main window.
                new MainWindow().Show();
                Logger.Log("MainWindow has been created and displayed.", Category.Info, Priority.Low);
                // 3.Closes the SignIn window.
                (Application.Current.Resources[SignWindow.Key] as SignWindow)?.Close();
                Logger.Log("SignWindow has been closed.", Category.Info, Priority.Low);
            }
            catch (LoginException loginEx)
            {
                Logger.Log($"Login exception: {loginEx.Message}", Category.Warn, Priority.Low);
                new MessageDialog(UiStringResources.MessageDialogTitle_LoginException, loginEx.Message).ShowDialog();
            }
            catch (System.Runtime.Remoting.ServerException serverEx)
            {
                Logger.Log($"Server exception: {serverEx.Message}", Category.Exception, Priority.High);
                new MessageDialog(UiStringResources.MessageDialogTitle_LoginException, serverEx.Message).ShowDialog();
            }
            finally
            {
                IsSigningIn = false;
            }
        }
Пример #2
0
        private async void LoginServiceAccountCommandExecute(PasswordBox password)
        {
            IsSigningIn = true;
            try
            {
                var mountUser = await _mountUserRepository.CreateAsync(LocalDiskUserName, password.Password);

                mountUser.IsRememberPassword = IsRememberPassword;
                mountUser.IsAutoSignIn       = IsAutoSignIn;
                var netDiskUsers = mountUser.GetAllNetDiskUsers();
                NetDiskUsers = new ObservableCollection <INetDiskUser>();
                foreach (var item in netDiskUsers)
                {
                    NetDiskUsers.Add(item);
                }
                IsLoginServiceAccount = true;
            }
            catch (LoginException loginEx)
            {
                Logger.Log($"Login exception: {loginEx.Message}", Category.Warn, Priority.Low);
                new MessageDialog(UiStringResources.MessageDialogTitle_LoginException, loginEx.Message).ShowDialog();
            }
            catch (System.Runtime.Remoting.ServerException serverEx)
            {
                Logger.Log($"Server exception: {serverEx.Message}", Category.Exception, Priority.High);
                new MessageDialog(UiStringResources.MessageDialogTitle_LoginException, serverEx.Message).ShowDialog();
            }
            IsSigningIn = false;
        }