private void LoginVM_AuthenticationCompleted(object sender, AuthenticationCompletedEventArgs e)
        {
            if (e.Authorised)
            {
                var originalVM = content as IDisposable;

                e.Context.Password = e.Context.Password.Copy();

                var allTradesVM = new AllTradesViewModel(e.Context);
                allTradesVM.ExistCommand = new RelayCommand(param => OnRequestClose());

                Content = allTradesVM;

                if (originalVM != null)
                {
                    originalVM.Dispose();
                }
            }
        }
예제 #2
0
        private void Login(bool saveCredential)
        {
            FlyingMessageContext context = null;
            var authorised = false;
            Exception exception = null;

            try
            {
                var loginService = IocContainer.Container.Resolve<ILoginService>();
                var config = IocContainer.Container.Resolve<IConfigRepository>();

                FlyingMessageContext.Current.HostUrl = config.HostUrl;
                FlyingMessageContext.Current.LoginName = userName;
                FlyingMessageContext.Current.Password = password.SecurePassword;

                context = FlyingMessageContext.Current;

                if (loginService.Login())
                {
                    if (saveCredential)
                    {
                        config.UserName = userName;
                        config.RememberAccount = rememberPassword;
                        if (rememberPassword)
                        {
                            var cryptographyService = IocContainer.Container.Resolve<ICryptographyService>();
                            config.EncryptedPassword = cryptographyService.Protect(
                                password.SecurePassword.ConvertToString());
                            config.RememberAccount = rememberPassword;
                        }
                        else
                        {
                            config.EncryptedPassword = string.Empty;
                        }
                        config.Update();
                    }
                    authorised = true;
                }
                else
                {
                    Message = new MessageItem(MessageLevel.Error,
                        I18NUtility.GetString("I18N_MessageBoxTitle"),
                        I18NUtility.GetString("I18N_LoginFailed"));
                }
            }
            catch(Exception ex)
            {
                exception = ex;
                LoggerUtility.WriteMessage(Severity.Error, 
                    I18NUtility.GetString("I18N_LoginFailedWithDetails"), ex);

                Message = new MessageItem(MessageLevel.Error,
                        I18NUtility.GetString("I18N_MessageBoxTitle"),
                        I18NUtility.GetString("I18N_LoginFailedWithDetails", ex.Message));
            }
            finally
            {
                FlyingMessageContext.Current = null;
            }

            var eventArgs = new AuthenticationCompletedEventArgs(context, authorised, exception);
            OnAuthenticationCompleted(eventArgs);
        }
예제 #3
0
 private void OnAuthenticationCompleted(AuthenticationCompletedEventArgs e)
 {
     if (authenticationCompleted != null)
     {
         authenticationCompleted(this, e);
     }
 }