Exemplo n.º 1
0
        /// <summary>
        /// Export to XPS
        /// </summary>
        public void ExportToXPS()
        {
            // If there are no rows in the grid then we cannot export
            if (_currentGrid.Rows.Count == 0)
            {
                MessageBox.Show("There is no data to Export", "Export Error");
            }

            else
            {
                // First browse for the folder / file that we will save
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.ValidateNames = false;
                saveFileDialog.FileName      = "AuditWizardData.xps";
                saveFileDialog.Filter        = "XML Paper Specification (*.xps)|*.xps";

                if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    UltraGridExporter.Export(saveFileDialog.FileName
                                             , ""
                                             , ""
                                             , ""
                                             , _currentGrid
                                             , Infragistics.Documents.Reports.Report.FileFormat.XPS);

                    DesktopAlert.ShowDesktopAlert("Data successfully exported to '" + saveFileDialog.FileName + "'");
                }
            }
        }
        /// <summary>
        /// Export to PDF
        /// </summary>
        public void ExportToPDF()
        {
            // If there are no rows in the grid then we cannot export
            if (this.applicationsDataSet.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("There is no data to Export", "Export Error");
            }

            else
            {
                // We need to temporarily set the grid view to 'Resize all columns' in order to get
                // the resultant PDF file formatted correctly.
                AutoFitStyle oldStyle = applicationsGridView.DisplayLayout.AutoFitStyle;
                applicationsGridView.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns;

                // First browse for the folder / file that we will save
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.ValidateNames = false;
                saveFileDialog.FileName      = headerLabel.Text + ".pdf";
                saveFileDialog.Filter        = "Adobe Acrobat Document (*.pdf)|*.pdf";

                if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    UltraGridDocumentExporter exporter = new UltraGridDocumentExporter();
                    exporter.Export(applicationsGridView, saveFileDialog.FileName, GridExportFileFormat.PDF);
                    DesktopAlert.ShowDesktopAlert("Data successfully exported to '" + saveFileDialog.FileName + "'");
                }

                // Populate the old autofit style
                this.applicationsGridView.DisplayLayout.AutoFitStyle = oldStyle;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Export to XPS
        /// </summary>
        public void ExportToXPS()
        {
            // If there are no rows in the grid then we cannot export
            if (this.OSDataSet.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("There is no data to Export", "Export Error");
            }

            else
            {
                // First browse for the folder / file that we will save
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.ValidateNames = false;
                saveFileDialog.FileName      = headerLabel.Text + ".xps";
                saveFileDialog.Filter        = "XML Paper Specification (*.xps)|*.xps";

                if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    UltraGridExporter.Export(saveFileDialog.FileName
                                             , "AuditWizard Applications View : " + OSGridView.Text
                                             , "Generated by AuditWizard from Layton Technology, Inc."
                                             , DataStrings.Disclaimer
                                             , OSGridView
                                             , Infragistics.Documents.Reports.Report.FileFormat.XPS);
                    DesktopAlert.ShowDesktopAlert("Data successfully exported to '" + saveFileDialog.FileName + "'");
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// The background worker has completed and as such we need to signal the UI thread of this fact
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundWorkerUpload_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            bnClose.Visible     = true;
            bnClose.Enabled     = true;
            bnCancel.Visible    = false;
            bnUploadAll.Enabled = true;
            lvAudits.SelectedItems.Clear();

            // If we have been returned an error status then we do not display the summary but instead allow the user to see
            // the message reported.
            if ((int)e.Result == -1)
            {
                DesktopAlert.ShowDesktopAlert("Upload complete.");
            }
            else
            {
                DesktopAlert.ShowDesktopAlert("The selected Audit Data file(s) have been successfully uploaded.");

                foreach (AuditDataFile file in _uploadedFiles)
                {
                    foreach (UltraListViewItem listViewItem in lvAudits.Items)
                    {
                        if (listViewItem.Key == file.FileName)
                        {
                            lvAudits.Items.Remove(listViewItem);
                            break;
                        }
                    }
                }

                // Update the status bar
                lblProgress.Text = "Audit(s) uploaded.";
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// save function for the IAdministrationView Interface
        /// </summary>
        public void Save()
        {
            if (!ValidateRequiredValues())
            {
                return;
            }

            auditAgentScannerDefinition.ScannerName = tbName.Text;
            auditAgentScannerDefinition.Filename    = Path.Combine(Application.StartupPath, @"scanners\auditagent\" + auditAgentScannerDefinition.ScannerName + ".xml");

            if (File.Exists(auditAgentScannerDefinition.Filename))
            {
                if (MessageBox.Show("The config file '" + auditAgentScannerDefinition.ScannerName + "' already exists." + Environment.NewLine + Environment.NewLine +
                                    "Do you wish to overwrite the file?", "AuditWizard", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }
            }
            UpdateChanges();

            if (AuditWizardSerialization.SerializeObjectToFile(auditAgentScannerDefinition))
            {
                DesktopAlert.ShowDesktopAlert("The scanner configuration file '" + auditAgentScannerDefinition.ScannerName + "' has been saved.");
            }
        }
Exemplo n.º 6
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.");
        }
Exemplo n.º 7
0
        private void buttonSaveAs_Click(object sender, EventArgs e)
        {
            if (tbCustomReportName.Text.Length == 0)
            {
                MessageBox.Show(
                    "Please enter a name for the custom report.",
                    "Save Custom Report",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);

                return;
            }

            SaveFields();

            BinaryFormatter bf  = new BinaryFormatter();
            MemoryStream    mem = new MemoryStream();

            bf.Serialize(mem, _selectedFields);

            string lReportData = Convert.ToBase64String(mem.ToArray());

            if (_editingReport)
            {
                new ReportsDAO().Update(_customReportId, tbCustomReportName.Text, lReportData);
            }
            else
            {
                DataTable lExistingReports = new ReportsDAO().GetReportsByTypeAndName(ReportsDAO.ReportType.CustomReport, tbCustomReportName.Text);

                if (lExistingReports.Rows.Count > 0)
                {
                    if (MessageBox.Show(
                            "A custom report already exists with this name." + Environment.NewLine + Environment.NewLine +
                            "Do you wish to overwrite?",
                            "Save Custom Report",
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        new ReportsDAO().Update(Convert.ToInt32(lExistingReports.Rows[0][0]), tbCustomReportName.Text, lReportData);
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    new ReportsDAO().Insert(tbCustomReportName.Text, ReportsDAO.ReportType.CustomReport, lReportData);
                }
            }

            bnSaveComplianceReport.Enabled = false;
            _reportSaved = true;
            DesktopAlert.ShowDesktopAlert(String.Format("The custom report '{0}' has been saved.", tbCustomReportName.Text));
        }
Exemplo n.º 8
0
        private void wizardControl_FinishButtonClick(object sender, EventArgs e)
        {
            // We now need to serialize the AlertDefinitions
            TextWriter textWriter = null;

            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(AlertDefinition));

                string alertMonitorDirectory = Path.Combine(Application.StartupPath, "scanners\\alertmonitors\\");
                string fileName = alertMonitorDirectory + _alertDefinition.Name + ".xml";

                if (!Directory.Exists(alertMonitorDirectory))
                {
                    Directory.CreateDirectory(alertMonitorDirectory);
                }

                textWriter = new StreamWriter(fileName);
                serializer.Serialize(textWriter, _alertDefinition);

                // if we were editing and changed name, delete the original
                if (_editing && (_alertDefinition.Name != _originalName))
                {
                    File.Delete(alertMonitorDirectory + _originalName + ".xml");
                }

                DesktopAlert.ShowDesktopAlert("The alert monitor '" + _alertDefinition.Name + "' has been saved.");
            }
            catch (Exception ex)
            {
                logger.Error("Error in wizardControl_FinishButtonClick", ex);
                Utility.DisplayApplicationErrorMessage("An error occurred whilst trying to save the alert definition.");
            }
            finally
            {
                // close text writer
                if (textWriter != null)
                {
                    textWriter.Close();
                }

                // close the form
                Close();
            }
        }
Exemplo n.º 9
0
        private void bnDeleteAllSchedules_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(
                    "Are you sure you want to delete all expired schedules?",
                    "Delete schedules",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question) == DialogResult.Yes)
            {
                int lCounter = 0;
                foreach (DataRow row in lReportSchedulesDAO.GetAllAppointments().Rows)
                {
                    object rawAppointmentData = row["_APPOINTMENTDATA"];

                    if (rawAppointmentData is byte[] == false)
                    {
                        continue;
                    }

                    Appointment appointment = Appointment.FromBytes(rawAppointmentData as byte[]);

                    if (appointment.Recurrence.RangeEndDate < DateTime.Now.AddSeconds(-62))
                    {
                        lReportSchedulesDAO.DeleteAppt(Convert.ToInt32(row["_REPORTSCHEDULEID"]));
                        lCounter++;
                    }
                }

                string message = String.Format("Deleted {0} expired report schedules.", lCounter);

                if (lCounter == 0)
                {
                    message = "There were no expired report schedules to delete.";
                }

                DesktopAlert.ShowDesktopAlert(message);

                //MessageBox.Show(
                //    message,
                //    "Delete report schedules",
                //    MessageBoxButtons.OK,
                //    MessageBoxIcon.Information);

                PopulateGrid();
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Deploy the scanner (Network Configuration)
        /// </summary>
        public void DeployNetwork()
        {
            try
            {
                // Ensure that the scanner name has been defined
                if (_auditScannerDefinition.ScannerName == "")
                {
                    MessageBox.Show("The scanner name is blank - please specify a unique name for this scanner");
                    return;
                }

                // First we need to request the tabs which work with the scanner configuration to save
                // any changes which they may have made but not yet saved.
                ScannerConfigurationTabView generalTabView = WorkItem.Items[Properties.Settings.Default.ScannerConfigurationTabView] as ScannerConfigurationTabView;
                _auditScannerDefinition = generalTabView.UpdateChanges();

                // save the changes so that the auto-loader can pick up the scanner folder
                generalTabView.Save(false);

                // create the scann folders (scanner and data)
                Directory.CreateDirectory(_auditScannerDefinition.DeployPathData);
                Directory.CreateDirectory(_auditScannerDefinition.DeployPathScanner);

                // ...and deploy it
                if (_auditScannerDefinition.Deploy(false))
                {
                    string scannerPath = _auditScannerDefinition.DeployPathScanner;
                    //MessageBox.Show("The Audit Scanner has been deployed to " + _auditScannerDefinition.DeployPathScanner, "Deployment Successful");
                    if (scannerPath.Length > 50)
                    {
                        scannerPath = scannerPath.Substring(0, 22) + "..~.." + scannerPath.Substring(scannerPath.Length - 22, 22);
                    }

                    DesktopAlert.ShowDesktopAlert("The Audit Scanner has been deployed to " + scannerPath);
                }
            }
            catch (Exception ex)
            {
                logger.Error("Error in DeployNetwork.", ex);
                Utility.DisplayApplicationErrorMessage(ex.Message);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Export to PDF
        /// </summary>
        public void ExportToPDF()
        {
            // If there are no rows in the grid then we cannot export
            if (this._currentGrid.Rows.Count == 0)
            {
                MessageBox.Show("There is no data to Export", "Export Error");
            }

            else
            {
                // We need to temporarily set the grid view to 'Resize all columns' in order to get
                // the resultant PDF file formatted correctly.
                AutoFitStyle oldStyle = _currentGrid.DisplayLayout.AutoFitStyle;
                _currentGrid.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns;

                // First browse for the folder / file that we will save
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.ValidateNames = false;
                saveFileDialog.FileName      = "AuditWizardData.pdf";
                saveFileDialog.Filter        = "Adobe Acrobat Document (*.pdf)|*.pdf";

                if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    UltraGridExporter.Export(saveFileDialog.FileName
                                             , ""
                                             , ""
                                             , ""
                                             , _currentGrid
                                             , Infragistics.Documents.Reports.Report.FileFormat.PDF);

                    DesktopAlert.ShowDesktopAlert("Data successfully exported to '" + saveFileDialog.FileName + "'");
                }

                // Populate the old autofit style
                this._currentGrid.DisplayLayout.AutoFitStyle = oldStyle;
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Export to PDF
        /// </summary>
        public void ExportToPDF()
        {
            // If there are no rows in the grid then we cannot export
            if (this.OSDataSet.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("There is no data to Export", "Export Error");
            }

            else
            {
                // We need to temporarily set the grid view to 'Resize all columns' in order to get
                // the resultant PDF file formatted correctly.
                AutoFitStyle oldStyle = OSGridView.DisplayLayout.AutoFitStyle;
                OSGridView.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns;

                // First browse for the folder / file that we will save
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.ValidateNames = false;
                saveFileDialog.FileName      = headerLabel.Text + ".pdf";
                saveFileDialog.Filter        = "Adobe Acrobat Document (*.pdf)|*.pdf";

                if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    UltraGridExporter.Export(saveFileDialog.FileName
                                             , "AuditWizard Applications View : " + OSGridView.Text
                                             , "Generated by AuditWizard from Layton Technology, Inc."
                                             , DataStrings.Disclaimer
                                             , OSGridView
                                             , Infragistics.Documents.Reports.Report.FileFormat.PDF);
                    DesktopAlert.ShowDesktopAlert("Data successfully exported to '" + saveFileDialog.FileName + "'");
                }

                // Populate the old autofit style
                this.OSGridView.DisplayLayout.AutoFitStyle = oldStyle;
            }
        }
        /// <summary>
        /// Export to XPS
        /// </summary>
        public void ExportToXPS()
        {
            // If there are no rows in the grid then we cannot export
            if (this.applicationsDataSet.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("There is no data to Export", "Export Error");
            }

            else
            {
                // First browse for the folder / file that we will save
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.ValidateNames = false;
                saveFileDialog.FileName      = headerLabel.Text + ".xps";
                saveFileDialog.Filter        = "XML Paper Specification (*.xps)|*.xps";

                if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    UltraGridDocumentExporter exporter = new UltraGridDocumentExporter();
                    exporter.Export(applicationsGridView, saveFileDialog.FileName, GridExportFileFormat.XPS);
                    DesktopAlert.ShowDesktopAlert("Data successfully exported to '" + saveFileDialog.FileName + "'");
                }
            }
        }
Exemplo n.º 14
0
 void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     DesktopAlert.ShowDesktopAlert("The selected asset(s) have been re-audited.");
 }
Exemplo n.º 15
0
        private void bnSave_Click(object sender, EventArgs e)
        {
            if (!textBoxSQLString.Text.ToUpper().StartsWith("SELECT"))
            {
                MessageBox.Show(
                    "Only SELECT statements can be executed from this dialog.",
                    "SQL Query",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation);
                return;
            }

            if (tbReportName.Text == "")
            {
                MessageBox.Show(
                    "Please enter a name for the SQL report.",
                    "Save SQL Report",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
                return;
            }

            if (textBoxSQLString.Text.Length == 0)
            {
                MessageBox.Show(
                    "Please enter a SQL string to run against the database.",
                    "Save SQL Report",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
                return;
            }

            List <string> _filterConditions = new List <string>();

            _filterConditions.Add(textBoxSQLString.Text);

            BinaryFormatter bf  = new BinaryFormatter();
            MemoryStream    mem = new MemoryStream();

            bf.Serialize(mem, _filterConditions);
            string lReportData = Convert.ToBase64String(mem.ToArray());

            DataTable lExistingReports = new ReportsDAO().GetReportsByTypeAndName(ReportsDAO.ReportType.SqlReport, tbReportName.Text);

            if (lExistingReports.Rows.Count > 0)
            {
                if (MessageBox.Show(
                        "A SQL report already exists with this name." + Environment.NewLine + Environment.NewLine +
                        "Do you wish to overwrite?",
                        "Save SQL Report",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    new ReportsDAO().Update(Convert.ToInt32(lExistingReports.Rows[0][0]), tbReportName.Text, lReportData);
                }
                else
                {
                    return;
                }
            }
            else
            {
                new ReportsDAO().Insert(tbReportName.Text, ReportsDAO.ReportType.SqlReport, lReportData);
            }

            DesktopAlert.ShowDesktopAlert(String.Format("The SQL report '{0}' has been saved.", tbReportName.Text));
            bnSave.Enabled = false;
            _reportSaved   = true;
        }