コード例 #1
0
 public void Initialize(string username, ApplicationForm appForm)
 {
     this.appForm     = appForm;
     this.lblProcess  = appForm.lblMessage;
     this.progressBar = appForm.progressBar;
     this.btnImport   = appForm.btnStart;
     try
     {
         UserInfo info = UserController.GetUser(username);
         SecurityContext.SetThreadPrincipal(info);
     }
     catch (Exception ex)
     {
         ShowError("Unable to authenticate user", ex);
         Cancel();
     }
 }
コード例 #2
0
        static void Main()
        {
            Log.WriteApplicationStart();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            Application.ApplicationExit += new EventHandler(OnApplicationExit);
            appForm = new ApplicationForm();
            Application.ThreadException += new ThreadExceptionEventHandler(OnThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnApplicationException);

            ConnectForm connectForm = new ConnectForm();

            if (connectForm.ShowDialog() == DialogResult.OK)
            {
                appForm.InitializeForm(connectForm.Username, connectForm.Password);
                Application.Run(appForm);
            }
        }