开发者

Show form again if password wrong

开发者 https://www.devze.com 2023-04-12 18:39 出处:网络
I have the following code which check password/login and do other actions: public virtual void run() { if (appInitializer!=null)

I have the following code which check password/login and do other actions:

public virtual void run()
        {
            if (appInitializer!=null)
            {
                ISecurityManager securityManager = appInitializer.SecurityManager;
                if (securityManager!=null)
                {                   
                    if (securityManager.DoLogin())
                    {
                        RegisterDefaultActionsGroup();
                        InitializePlugins(appInitializer.Plugins);
                        ActionsManager.Inst.ApplySecurity(securityManager, securityManager.CurrentUser);
                        mainForm = new MainForm();
                        mainForm.Text = appInitializer.ApplicationTitle;
                        if (appInitializer.ApplicationIcon != null)
                        {
                            mainForm.Icon = appInitializer.ApplicationIcon;
                        }
                        CorrectFormSizes(mainForm);
                        Context[Constants.MainForm] = mainForm;
                        MenuManager.Inst.FillMenu(DefaultGroups.MAIN_MENU, mainForm.MainMenu, ActionClick);
                        if(appInitializer.IsHaveToCreatePanelInfo) PanelInfoManager.Inst.FillInfo(mainForm);
                        if (appInitializer.IsHaveToCreateToolBar)
                        {
                            MenuManager.Inst.FillToolbar(DefaultGroups.MAIN_TOOLBAR, mainForm.MainToolStrip, ActionClick);                            
             开发者_StackOverflow社区           }
                        mainForm.MainToolStrip.Visible = mainForm.MainToolStrip.Items.Count > 0;
                        NotifyPluginsAboutShowing(appInitializer.Plugins);
                        Application.Run(mainForm);
                    }                    
                }
            }
        }

The main method is DoLogin. If it return true then run other actions(fill menu, create toolbar and other).

The problem is that if user enter wrong password then DoLogin returns false and application is closing.

I want that if user enter wrong password then DoLogin (inside of method is created form) run again.

How can I rewrite this code to acomplish this?

Thanks.

PS. The Run is member of my own Framework class. In the Program.cs file is the following code:

static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Framework framework = new Framework(new EArchiveInitializer());
            framework.run();
}


Why not just while (!securityManager.DoLogin()) { }?

0

精彩评论

暂无评论...
验证码 换一张
取 消