示例#1
0
        /// <summary>
        /// Load a new scanner configuration
        /// </summary>
        public void LoadScannerConfiguration()
        {
            ILaytonView tabView = (ILaytonView)WorkItem.RootWorkItem.Workspaces[WorkspaceNames.TabWorkspace].ActiveSmartPart;

            // Display the load configuration screen and if we click OK load the new configuration
            FormLoadScannerConfiguration form = new FormLoadScannerConfiguration(tabView is AuditAgentTabView);

            if (form.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    // Use the Deserialize method to restore the object's state.
                    _auditScannerDefinition = AuditWizardSerialization.DeserializeObject(form.FileName);
                }
                catch (Exception ex)
                {
                    logger.Error("Error in LoadScannerConfiguration using " + form.FileName, ex);
                    MessageBox.Show("Unable to load scanner configuration file", "AuditWizard", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // If the active tab is either the scanner configuration or alert monitor tab then calls
                // its refresh function to pick up the new scanner configuration
                if ((tabView is ScannerConfigurationTabView) || (tabView is AlertMonitorSettingsTabView) || tabView is AuditAgentTabView)
                {
                    tabView.RefreshView();
                }
            }
        }
示例#2
0
        /// <summary>
        /// Update the configuration for ALL deployed AuditAgents
        /// </summary>
        public void ScannerUpdate()
        {
            // Get the list of computers which currently have the AuditAgent deployed (running or not)
            AssetDAO  lwDataAccess = new AssetDAO();
            AssetList listAssets   = new AssetList(lwDataAccess.EnumerateDeployedAssets(), true);

            //if (listAssets.Count == 0)
            //{
            //    MessageBox.Show("Found no assets which already have an AuditAgent deployed.", "AuditWizard", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    return;
            //}

            FormLoadScannerConfiguration form = new FormLoadScannerConfiguration(true, "Select a configuration file to update all assets.");

            if (form.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    // Use the Deserialize method to restore the object's state.
                    //auditScannerDefinition = AuditWizardSerialization.DeserializeObject(form.FileName);

                    string agentIniFileName = Path.Combine(AuditAgentStrings.AuditAgentFilesPath, AuditAgentStrings.AuditAgentIni);
                    File.Copy(form.FileName, agentIniFileName, true);
                }
                catch (System.IO.FileNotFoundException)
                {
                    MessageBox.Show("An error has occurred whilst updating the AuditAgent, please see the log file for further information.",
                                    "AuditWizard", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    // JML TODO log this exception
                    return;
                }
                catch (System.IO.IOException)
                {
                    MessageBox.Show("An error has occurred whilst updating the AuditAgent, please see the log file for further information.",
                                    "AuditWizard", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    // JML TODO log this exception
                    return;
                }
                catch
                {
                    MessageBox.Show("An error has occurred whilst updating the AuditAgent, please see the log file for further information.",
                                    "AuditWizard", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    // JML TODO log this exception
                    return;
                }
            }
            else
            {
                return;
            }

            // Ensure that we at least have a data path
            //if (auditScannerDefinition.DeployPathData == "")
            //{
            //    MessageBox.Show("The audit scanner configuration has not been configured yet", "Audit Scanner Configuration Not Defined");
            //    return;
            //}

            // Write the Agent Ini File to the Agent folder as this will combine the scanner configuration
            // with data taken from the Application Definitions File (publisher mappings etc)
            //string agentIniFileName = Path.Combine(AuditAgentStrings.AuditAgentFilesPath, AuditAgentStrings.AuditAgentIni);
            //if (auditScannerDefinition.WriteTo(agentIniFileName) != 0)
            //{
            //    MessageBox.Show("Error : Failed to write the AuditAgent configuration file", "Deploy Error");
            //    return;
            //}

            // We will pend the operation by adding it to the Operations queue in the database
            // The AuditWizard service works on this queue
            foreach (Asset asset in listAssets)
            {
                Operation newOperation = new Operation(asset.AssetID, Operation.OPERATION.updateconfiguration);
                newOperation.Add();
            }

            MessageBox.Show("The AuditAgent Update Request has been queued for " + listAssets.Count.ToString() + " PC(s) and will be actioned by the AuditWizard Service\n\nYou can check its progress by viewing the Operations Log", "Operations Queued", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }