Beispiel #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            SystemPrincipal customPrincipal = new SystemPrincipal();

            AppDomain.CurrentDomain.SetThreadPrincipal(customPrincipal);

            base.OnStartup(e);

            Smart365OperationsBootstrapper bootStrapper = new Smart365OperationsBootstrapper();

            bootStrapper.Run();

            ShutdownMode = ShutdownMode.OnExplicitShutdown;

            LoginScreen loginWindow = bootStrapper.Container.Resolve <LoginScreen>();
            //AuthenticationViewModel viewModel =
            //    new AuthenticationViewModel(bootStrapper.Container.Resolve<IAuthenticationService>());
            //loginWindow.DataContext = viewModel;
            bool?logonResult = loginWindow.ShowDialog();
            var  viewModel   = loginWindow.ViewModel as AuthenticationViewModel;

            if (logonResult.HasValue && viewModel != null && viewModel.IsAuthenticated)
            {
                bootStrapper.Show();
                Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
            }
            else
            {
                Application.Current.Shutdown(1);
            }
        }
Beispiel #2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            bool can_execute = true;

            try
            {
                mutex = new System.Threading.Mutex(false, "SMART365CLIENT", out can_execute);
            }
            catch (Exception ex)
            {
            }
            if (can_execute)
            {
                SystemPrincipal customPrincipal = new SystemPrincipal();
                AppDomain.CurrentDomain.SetThreadPrincipal(customPrincipal);

                base.OnStartup(e);

                Smart365OperationsBootstrapper bootStrapper = new Smart365OperationsBootstrapper();
                bootStrapper.Run();

                ShutdownMode = ShutdownMode.OnExplicitShutdown;

                LoginScreen loginWindow = bootStrapper.Container.Resolve <LoginScreen>();
                //AuthenticationViewModel viewModel =
                //    new AuthenticationViewModel(bootStrapper.Container.Resolve<IAuthenticationService>());
                //loginWindow.DataContext = viewModel;
                bool?logonResult = loginWindow.ShowDialog();
                var  viewModel   = loginWindow.ViewModel as AuthenticationViewModel;
                if (logonResult.HasValue && viewModel != null && viewModel.IsAuthenticated)
                {
                    bootStrapper.Show(viewModel.DisplayName);
                    Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
                }
                else
                {
                    Application.Current.Shutdown(1);
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("SMART365CLIENT already running!");
                Application.Current.Shutdown(1);
            }
        }