Пример #1
0
        private void loadPolicyMetrics()
        {
            //string err_section = "Security Summary Information";
            try
            {
                if (m_importing)
                {
                    m_metrics = m_policy.GetExistingPolicyMetrics(Program.gController.Repository.ConnectionString);
                }
                else
                {
                    m_metrics = m_policy.GetPolicyMetrics(Program.gController.Repository.ConnectionString);
                }

                if (m_metrics != null)
                {
                    m_InternalUpdate = true;

                    //save the current grid settings to restore after importing.
                    GridSettings settings = GridSettings.GetSettings(ultraGridPolicyMetrics);

                    ultraGridPolicyMetrics.DataSource = m_metrics;
                    updateVulnerabilityLayout();
                    ultraGridPolicyMetrics.ActiveRow = null;
                    ultraGridPolicyMetrics.Selected.Rows.Clear();

                    //restore the saved grid settings so it appears the same to the user
                    settings.ApplySettingsToGrid(ultraGridPolicyMetrics);

                    m_InternalUpdate = false;
                    UltraGridRow[] rows = ultraGridPolicyMetrics.Rows.GetAllNonGroupByRows();
                    if (rows.GetLength(0) > 0)
                    {
                        ultraGridPolicyMetrics.Selected.Rows.Add(rows[0]);
                        rows[0].Activate();
                    }
                }
            }
            catch (Exception ex)
            {
                logX.loggerX.Error("Error loading PolicyMetrics", ex);
            }

            UpdateEnabledCount();
        }
Пример #2
0
        private void button_ResetToDefaults_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            m_metrics = PolicyMetric.GetPolicyMetrics(Program.gController.Repository.ConnectionString, 0, 0);

            foreach (PolicyMetric m in m_metrics)
            {
                m.SetMetricChanged();
            }

            if (m_metrics != null)
            {
                //save the current grid settings to restore after importing.
                GridSettings settings = GridSettings.GetSettings(ultraGridPolicyMetrics);

                ultraGridPolicyMetrics.DataSource = m_metrics;
                updateVulnerabilityLayout();
                m_InternalUpdate = true;
                ultraGridPolicyMetrics.Selected.Rows.Clear();

                //restore the saved grid settings so it appears the same to the user
                settings.ApplySettingsToGrid(ultraGridPolicyMetrics);

                m_InternalUpdate = false;
                UltraGridRow[] rows = ultraGridPolicyMetrics.Rows.GetAllNonGroupByRows();
                if (rows.GetLength(0) > 0)
                {
                    ultraGridPolicyMetrics.Selected.Rows.Add(rows[0]);
                    rows[0].Activate();
                }
            }

            UpdateEnabledCount();

            Cursor = Cursors.Default;
        }
Пример #3
0
        private void loadDataSource()
        {
            logX.loggerX.Info("Retrieve Policy Report Card");

            try
            {
                _textBox_Description.Text = DisplayNoLog;

                // Open connection to repository and query permissions.
                using (SqlConnection connection = new SqlConnection(Program.gController.Repository.ConnectionString))
                {
                    // Open the connection.
                    connection.Open();

                    // Setup parameters for all queries
                    SqlParameter paramPolicyId     = new SqlParameter(ParamPolicyId, m_policy.PolicyId);
                    SqlParameter paramAssessmentId = new SqlParameter(ParamAssessmentId, m_policy.AssessmentId);

                    // Get Change Log
                    SqlCommand cmd = new SqlCommand(QueryGetChangeLog, connection);
                    cmd.CommandType    = CommandType.Text;
                    cmd.CommandTimeout = SQLCommandTimeout.GetSQLCommandTimeoutFromRegistry();

                    cmd.Parameters.Add(paramPolicyId);
                    cmd.Parameters.Add(paramAssessmentId);

                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    DataSet        ds = new DataSet();
                    da.Fill(ds);

                    m_ChangeLogTable = ds.Tables[0];

                    // fix the time by converting to local for display
                    foreach (DataRow row in m_ChangeLogTable.Rows)
                    {
                        row[colChangedDate] = ((DateTime)row[colChangedDate]).ToLocalTime();
                    }

                    m_ChangeLogTable.DefaultView.Sort = colChangedDate;

                    _grid_ChangeLog.SuspendLayout();

                    // Save the user configuration of the grid to restore it after setting the datasource again
                    Utility.GridSettings gridSettings = GridSettings.GetSettings(_grid_ChangeLog);

                    _label_ChangeLog.Text =
                        string.Format(HeaderDisplay,
                                      m_ChangeLogTable.DefaultView.Count,
                                      m_ChangeLogTable.DefaultView.Count == 1 ? @"y" : @"ies");

                    _grid_ChangeLog.SetDataBinding(m_ChangeLogTable.DefaultView, null);

                    // Reapply the user's settings after rebuilding the grid
                    GridSettings.ApplySettingsToGrid(gridSettings, _grid_ChangeLog);

                    if (!m_Initialized)
                    {
                        foreach (UltraGridColumn col in _grid_ChangeLog.DisplayLayout.Bands[0].Columns)
                        {
                            //if (col.Key != colSeverityCode)
                            {
                                col.PerformAutoResize(PerformAutoSizeType.AllRowsInBand, true);
                            }
                        }
                        _grid_ChangeLog.DisplayLayout.Bands[0].SortedColumns.Add(colChangedDate, true, false);

                        m_Initialized = true;
                    }



                    _grid_ChangeLog.ResumeLayout();
                }
            }
            catch (Exception ex)
            {
                logX.loggerX.Error(@"Error - Unable to retrieve policy change log", ex);
                MsgBox.ShowError(string.Format(ErrorMsgs.CantGetPolicyInfoMsg, "Policy Change Log"),
                                 ErrorMsgs.ErrorProcessPolicyInfo,
                                 ex);
                initDataSources();

                _grid_ChangeLog.ResumeLayout();
            }
        }