Ejemplo n.º 1
0
        public ClientRequestModel(Administrator administrator)
        {
            ServiceLocator.Current.GetInstance<IUnityContainer>().BuildUp(this);
            CurrentAdministrator = administrator;

            Reset();
        }
Ejemplo n.º 2
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            container = new UnityContainer();
            container.RegisterInstance(container);
            ServiceLocator.SetLocatorProvider(() => new UnityServiceLocator(container));

            configuration = new ConfigurationManager(Product.Simulator.AppName, SpecialFolder.ApplicationData);
            container.RegisterInstance(configuration);

            loginSettings = configuration.GetSection<LoginSettings>(LoginSettings.SectionKey);
            container.RegisterInstance(loginSettings);

            loginFormSettings = configuration.GetSection<LoginFormSettings>(LoginFormSettings.SectionKey);
            container.RegisterInstance(loginFormSettings);

            hubSettings = configuration.GetSection<HubSettings>(HubSettings.SectionKey);
            container.RegisterInstance(hubSettings);

            while (true)
            {
                var loginForm = new LoginForm(UserRole.Administrator);
                if (loginForm.ShowDialog() == DialogResult.OK)
                {
                    configuration.Save();

                    endpoint = loginSettings.Endpoint;
                    currentUser = loginForm.CurrentUser as QueueAdministrator;
                    sessionId = currentUser.SessionId;

                    container.RegisterInstance<User>(currentUser);
                    container.RegisterInstance<QueueAdministrator>(currentUser);

                    RegisterServices();

                    loginForm.Dispose();

                    using (var f = new SimulatorForm())
                    {
                        Application.Run(f);

                        if (f.IsLogout)
                        {
                            ResetSettings();
                            continue;
                        }
                    }
                }

                break;
            }
        }
Ejemplo n.º 3
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            container = new UnityContainer();
            container.RegisterInstance(container);
            ServiceLocator.SetLocatorProvider(() => new UnityServiceLocator(container));

            configuration = new ConfigurationManager(Product.Administrator.AppName, SpecialFolder.ApplicationData);
            container.RegisterInstance(configuration);

            applicationSettings = configuration.GetSection<ApplicationSettings>(ApplicationSettings.SectionKey);
            container.RegisterInstance(applicationSettings);

            administratorSettings = configuration.GetSection<AdministratorSettings>(AdministratorSettings.SectionKey);
            container.RegisterInstance(administratorSettings);

            loginSettings = configuration.GetSection<LoginSettings>(LoginSettings.SectionKey);
            container.RegisterInstance(loginSettings);

            loginFormSettings = configuration.GetSection<LoginFormSettings>(LoginFormSettings.SectionKey);
            container.RegisterInstance(loginFormSettings);

            ParseOptions();

            if (options.AutoLogin)
            {
                endpoint = options.Endpoint;

                try
                {
                    using (var serverUserService = new UserService(endpoint))
                    using (var channelManager = serverUserService.CreateChannelManager())
                    using (var channel = channelManager.CreateChannel())
                    {
                        sessionId = Guid.Parse(options.SessionId);
                        currentUser = channel.Service.OpenUserSession(sessionId).Result as QueueAdministrator;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.InnerException.Message);
                    return;
                }

                container.RegisterInstance<User>(currentUser);
                container.RegisterInstance<QueueAdministrator>(currentUser);

                RegisterServices();

                Application.Run(new AdministratorForm());
            }
            else
            {
                while (true)
                {
                    var loginForm = new LoginForm(UserRole.Administrator);
                    if (loginForm.ShowDialog() == DialogResult.OK)
                    {
                        configuration.Save();

                        endpoint = loginSettings.Endpoint;
                        currentUser = loginForm.CurrentUser as QueueAdministrator;
                        sessionId = currentUser.SessionId;

                        container.RegisterInstance<User>(currentUser);
                        container.RegisterInstance<QueueAdministrator>(currentUser);

                        RegisterServices();

                        loginForm.Dispose();

                        using (var f = new AdministratorForm())
                        {
                            Application.Run(f);

                            if (f.IsLogout)
                            {
                                ResetSettings();
                                continue;
                            }
                        }
                    }

                    break;
                }
            }
        }