예제 #1
0
        private void SaveScanSettings()
        {
            SettingsDAO settingsDao = new SettingsDAO();

            settingsDao.SetSetting("AutoScanIntervalValue", tbScanInterval.Text, false);
            settingsDao.SetSetting("AutoScanNetwork", Convert.ToString(cbEnableScan.Checked), false);
            settingsDao.SetSetting("AutoScanDeployAgent", Convert.ToString(cbDeployAgent.Checked), false);
            settingsDao.SetSetting("AutoScanIntervalUnits", Convert.ToString(cbScanInterval.SelectedItem.ToString()), false);

            AuditWizardServiceController _serviceController = new Layton.AuditWizard.Common.AuditWizardServiceController();

            LaytonServiceController.ServiceStatus serviceStatus = _serviceController.CheckStatus();

            if (serviceStatus == LaytonServiceController.ServiceStatus.Running)
            {
                _serviceController.RestartService();
            }
            else
            {
                if (serviceStatus != LaytonServiceController.ServiceStatus.NotInstalled)
                {
                    _serviceController.Start();
                }
            }

            DesktopAlert.ShowDesktopAlert("Settings have been updated.");
        }
        /// <summary>
        /// Set the state of the various buttons and other fields on this form based on the
        /// current state of the service
        /// </summary>
        /// <param name="serviceStatus"></param>
        private void SetDisplayStates()
        {
            // Get the current status of the service
            LaytonServiceController.ServiceStatus serviceStatus = _serviceController.CheckStatus();

            // Select the appropriate status image to show
            switch (serviceStatus)
            {
            case LaytonServiceController.ServiceStatus.Running:
                pbServiceStatus.Image = Properties.Resources.active;
                break;

            case LaytonServiceController.ServiceStatus.Stopped:
                pbServiceStatus.Image = Properties.Resources.stopped;
                break;

            case LaytonServiceController.ServiceStatus.NotInstalled:
                pbServiceStatus.Image = Properties.Resources.notinstalled;
                break;

            default:
                pbServiceStatus.Image = Properties.Resources.unavailable;
                break;
            }

            // The start button is valid so long as the service is currently in a 'stopped' or
            // 'not installed' state
            bnStart.Enabled = ((serviceStatus == LaytonServiceController.ServiceStatus.NotInstalled) ||
                               (serviceStatus == LaytonServiceController.ServiceStatus.Stopped));

            // Stop is enabled if the service is currently in a 'Running' State
            bnStop.Enabled = (serviceStatus == LaytonServiceController.ServiceStatus.Running);

            // Remove is enabled if the service is stopped
            bnRemove.Enabled = (serviceStatus == LaytonServiceController.ServiceStatus.Stopped);

            // We cannot change the logon credentials UNLESS the service is stopped
            panelLogonCredentials.Enabled = (serviceStatus == LaytonServiceController.ServiceStatus.NotInstalled);
        }