示例#1
0
        void loginControl_Login(object sender, LoginEventArgs e)
        {
            this.NotifyMessage("正在登录...");

            var provider = Membership.Provider as FormMembershipProvider;

            if (provider.IsEmpty())
            {
                e.IsSuccess = false;
                e.Message = "未配置 Membership.Provider.";
                return;
            }

            var userName = e.UserName;
            var password = e.Password;

            string msg;
            password = SHA1Helper.Hash(password);
            if (!provider.Login(userName, password, out msg))
            {
                e.IsSuccess = false;
                this.IsLogin = false;
                e.Message = msg;
                this.NotifyMessage("就绪...");
            }
            else
            {
                UserConfig.Current.UserName = e.UserName;
                UserConfig.Current.SavePassword = e.SavePassword;
                if (e.SavePassword)
                {
                    UserConfig.Current.Password = DESHelper.Encrypt(e.Password, Session.MachineInfo.MachineCode);
                }
                UserConfig.Current.Save();

                AppConfig.Current.Load();
                AppConfig.Current.SetTheme();

                e.IsSuccess = true;
                this.IsLogin = true;

                this.NotifyMessage("初始化工作区...");
                this.InitBackstageViewTabItemAndCommand(DisplayMode.AfterLogin);
                InitWorkspace();

                if (AppConfig.Current.ShowWorkSpace)
                    this.navMainMenu.ActiveGroup = sysMyWorkspace;
                else
                    this.navMainMenu.ActiveGroup = systemMenuGroup;

                Form welcome = null;

                if (AppConfig.Current.ShowWelcomePage)
                {
                    this.NotifyMessage("显示欢迎页...");
                    welcome = ShowWelcomePage();
                }

                if (AppConfig.Current.ShowNavigationPage)
                {
                    this.NotifyMessage("显示导航图...");
                    ShowNavigationPage();
                }

                this.NotifyMessage("打开界面...");
                ShowAutoOpenView();

                if (welcome != null)
                    this.tabbedView.ActivateDocument(welcome);

                this.NotifyMessage("就绪...");
            }
        }
示例#2
0
        private void OnLoginEvent()
        {
            this.Enabled = false;
            try
            {
                if (!CheckLoginParamIsRight()) return;

                var handler = (EventHandler<LoginEventArgs>)Events[LoginAuthenticate.EventLogin];
                if (handler != null)
                {
                    var arg = new LoginEventArgs(this.txtUserName.Text, this.txtPassword.Text, this.chkSavePassword.Checked);
                    handler(this, arg);

                    if (!arg.IsSuccess)
                    {
                        MessageService.ShowErrorFormatted("{0}{1}{2}", "登录失败!", Environment.NewLine, arg.Message);

                        this.Enabled = true;
                        this.txtPassword.EditValue = null;
                        this.txtPassword.Focus();
                    }
                }
            }
            finally
            {
                this.Enabled = true;
            }
        }