示例#1
0
        private void nextButton_Click(object sender, System.EventArgs e)
        {
            bool errorFound = false;

            try
            {
                ServiceManager.GetSecurityService(GetLoginInfo());
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
                errorFound = true;
            }

            if (!errorFound)
            {
                if (this.rememberCheckBox.Checked)
                {
                    // write the data to a file so we can remember it
                    LoginInfo loginInfo = GetLoginInfo();

                    FileStream      fs        = new FileStream(LOGIN_DATA_FILE, FileMode.Create);
                    BinaryFormatter formatter = new BinaryFormatter();
                    formatter.Serialize(fs, loginInfo);
                    fs.Close();
                }
                else
                {
                    try
                    {
                        if (File.Exists(LOGIN_DATA_FILE))
                        {
                            // delete saved login info if the user doesn't have the
                            // 'remember' box checked
                            File.Delete(LOGIN_DATA_FILE);
                        }
                    }
                    catch (Exception)
                    {   }
                }

                DialogResult = DialogResult.OK;
            }
        }
示例#2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var login  = new LoginDialog();
            var result = login.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            var mainForm = new MainForm();

            mainForm.ShowDialog();

            var secSvc = ServiceManager.GetSecurityService();

            secSvc.SignOut();
        }