コード例 #1
0
ファイル: Program.cs プロジェクト: otamimi/southwind
        static IServerSouthwind Login(IServerSouthwind result)
        {
            Login milogin = new Login
            {
                Title = "Welcome to Southwind",
                UserName = Settings.Default.UserName,
                Password = "",
                ProductName = "Southwind",
                CompanyName = "Signum Software"
            };

            milogin.LoginClicked += (object sender, EventArgs e) =>
            {
                try
                {
                    result.Login(milogin.UserName, Security.EncodePassword(milogin.Password));

                    Settings.Default.UserName = milogin.UserName;
                    Settings.Default.Save();

                    UserEntity.Current = result.GetCurrentUser();

                    if (UserEntity.Current.CultureInfo != null)
                        Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(UserEntity.Current.CultureInfo.Name);

                    // verificar el tiempo de expiracion
                    var alerta = result.PasswordNearExpired();
                    if (alerta.HasText())
                        MessageBox.Show(alerta);


                    milogin.DialogResult = true;
                }
                catch (IncorrectUsernameException ex)
                {
                    milogin.Error = ex.Message;
                    milogin.FocusUserName();
                }
                catch (IncorrectPasswordException ex)
                {
                    milogin.Error = ex.Message;
                    milogin.FocusPassword();
                }
            };

            milogin.FocusUserName();

            bool? dialogResult = milogin.ShowDialog();
            if (dialogResult == true)
            {
                UserEntity user = result.GetCurrentUser();
                UserEntity.Current = user;

                return result;
            }
            else
            {
                return null;
            }
        } //Login
コード例 #2
0
ファイル: Login.xaml.cs プロジェクト: JackWangCUMT/extensions
 public LoginWindowAutomationPeer(Login login)
     : base(login)
 {
 }