示例#1
0
        protected override void OnStart(string[] args)
        {
            logger.Info("Starting service...");

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

                configuration = new ConfigurationManager(HostMetadata.PortalApp, SpecialFolder.CommonApplicationData);
                container.RegisterInstance(configuration);

                settings = configuration.GetSection<PortalSettings>(PortalSettings.SectionKey);
                container.RegisterInstance(settings);

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

                portalServiceSettings = configuration.GetSection<PortalServiceSettings>(PortalServiceSettings.SectionKey);
                container.RegisterInstance(portalServiceSettings);

                portal = new PortalInstance(settings, loginSettings);
                portal.Start();

                logger.Info("Service started");
            }
            catch (Exception e)
            {
                logger.Error(e);
                throw;
            }
        }
示例#2
0
        private void stopButton_Click(object sender, EventArgs e)
        {
            if (portal == null)
            {
                return;
            }

            portal.Stop();
            portal = null;

            startButton.Enabled = true;
            stopButton.Enabled = false;

            started = false;
        }
示例#3
0
        private void startButton_Click(object sender, EventArgs e)
        {
            try
            {
                startButton.Enabled = false;

                portal = new PortalInstance(settings, loginSettings);
                portal.Start();

                startButton.Enabled = false;
                stopButton.Enabled = true;
                started = true;
            }
            catch (Exception ex)
            {
                startButton.Enabled = true;
                UIHelper.Error(ex);
            }
        }