Inheritance: System.Configuration.ConfigurationSection
Exemple #1
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;
            }
        }
Exemple #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.Operator.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);

            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 QueueOperator;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.InnerException.Message);
                    return;
                }

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

                RegisterServices();

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

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

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

                        RegisterServices();

                        loginForm.Dispose();

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

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

                    break;
                }
            }
        }