private void _comboBox_Server_DropDown(object sender, EventArgs e)
        {
            //Initialize the combobox for server selection to refresh on every open
            List <MyComboBoxItem> li = new List <MyComboBoxItem>();

            li.Add(new MyComboBoxItem(Utility.Constants.ReportSelect_AllServers, 0));

            //Keep the last selection for the user
            string selection = _comboBox_Server.Text;

            if (ultraCombo_Assessment1.SelectedItem != null && ultraCombo_Assessment1.SelectedItem.Tag is Sql.Policy)
            {
                Sql.Policy assessment = (Sql.Policy)ultraCombo_Assessment1.SelectedItem.Tag;

                foreach (Sql.RegisteredServer server in assessment.GetMemberServers())
                {
                    li.Add(new MyComboBoxItem(server.ConnectionName, server.RegisteredServerId));
                }
            }

            _comboBox_Server.DisplayMember = "Label";
            _comboBox_Server.ValueMember   = "Index";
            _comboBox_Server.DataSource    = li;

            //Put the last selection back for the user
            _comboBox_Server.Text = selection;
        }
예제 #2
0
 public void RefreshPolicyInTree(Sql.Policy policy)
 {
     TreeNode[] nodes = m_PolicyTree.Nodes[0].Nodes.Find(policy.PolicyName, false);
     if (nodes.GetLength(0) == 1)
     {
         if (policy.IsAssessment)
         {
             foreach (TreeNode typenode in nodes[0].Nodes)
             {
                 foreach (TreeNode node in typenode.Nodes)
                 {
                     if (node.Tag is Sql.Policy)
                     {
                         if (policy.AssessmentId == ((Sql.Policy)node.Tag).AssessmentId)
                         {
                             m_MainForm.refreshPolicyTreeNode(node);
                             return;
                         }
                     }
                 }
             }
         }
         else
         {
             m_MainForm.refreshPolicyTreeNode(nodes[0]);
         }
     }
 }
예제 #3
0
        public void SetCurrentPolicyAssessment(Sql.Policy assessment)
        {
            m_ExplorerBar.SelectedGroup = m_ExplorerBar.Groups[Utility.Constants.ExplorerBar_GroupKey_Summary];

            // If the policy comes in null then it was deleted and we need to refresh everything
            if (assessment == null || !Sql.Policy.IsPolicyRegistered(assessment.PolicyId) || !assessment.IsAssessmentFound(assessment.AssessmentId))
            {
                m_RefreshPoliciesEvent(0);
            }
            else
            {
                TreeNode selectedNode = null;
                foreach (TreeNode typenode in m_PolicyTree.Nodes[assessment.PolicyName].Nodes)
                {
                    foreach (TreeNode node in typenode.Nodes)
                    {
                        if (node.Name == assessment.AssessmentName)
                        {
                            selectedNode = node;
                            break;
                        }
                    }

                    if (selectedNode != null)
                    {
                        break;
                    }
                }
                m_PolicyTree.SelectedNode = selectedNode;
            }
        }
        public Form_CreateAssessment(Sql.Policy policy)
        {
            InitializeComponent();

            this.Text = TITLEFMT;

            string copytype = policy.IsPolicy ? "policy" : string.Format("{0} {1}", policy.AssessmentStateName.ToLower(), "assessment");

            Description = String.Format(DESCR_GENERAL_FMT, copytype, policy.PolicyAssessmentName);
            DateTime?selectDate = null;

            //_textBox_AssessmentName.Text = string.Format(DEFAULTNAME_FMT, DateTime.Now.ToLongDateString());
            _textBox_Description.Text = policy.AssessmentDescription;
            m_Policy = policy;

            if (policy.IsAssessment)
            {
                _ultraGroupBox_DataSelection.Visible = false;
                selectDate = policy.AssessmentDate.Value;
                _checkBox_BaselineOnly.Checked = policy.UseBaseline;
            }
            else
            {
                _ultraGroupBox_DataSelection.Visible = false; //= true; This is no longer a user selectable option, but will still be filled and used for creation
                if (Program.gController.PolicyTime.HasValue)
                {
                    selectDate = Program.gController.PolicyTime.Value;
                }
                else
                {
                    selectDate = DateTime.Now;
                }
                _checkBox_BaselineOnly.Checked = Program.gController.PolicyUseBaselineSnapshots;
            }

            if (!selectDate.HasValue)
            {
                _checkBox_IncludeTime.Checked = false;
                _dateTimePicker_Time.Value    = DefaultTime;
                _dateTimePicker_Time.Enabled  = false;
            }
            else
            {
                _ultraGroupBox_DataSelection.Enabled = true;
                _dateTimePicker_Date.Value           = new DateTime(selectDate.Value.ToLocalTime().Date.Ticks);

                if (selectDate.Value.ToLocalTime().TimeOfDay.Ticks == DefaultTime.TimeOfDay.Ticks)
                {
                    _checkBox_IncludeTime.Checked = false;
                    _dateTimePicker_Time.Value    = DefaultTime;
                    _dateTimePicker_Time.Enabled  = false;
                }
                else
                {
                    _checkBox_IncludeTime.Checked = true;
                    _dateTimePicker_Time.Value    = selectDate.Value.ToLocalTime();
                }
            }
        }
예제 #5
0
        public PolicyAssessment(Sql.Policy policyIn)
        {
            Debug.Assert(policyIn != null, "Policy Assessment called with null Policy");

            m_Policy = policyIn;
            m_Server = null;
            m_Name   = m_Policy.PolicyAssessmentName;
        }
예제 #6
0
        public Main_SecuritySummary(Sql.Policy policyIn)
        {
            Debug.Assert(policyIn != null, "Security Summary called with null Policy");

            m_Policy = policyIn;
            m_Server = null;
            m_Name   = m_Policy.PolicyName;
        }
예제 #7
0
        public ReportCard(Sql.Policy policyIn, bool useBaselineIn, DateTime?selectionDateIn)
        {
            Debug.Assert(policyIn != null, "Report Card called with null Policy");

            m_Policy        = policyIn;
            m_Name          = m_Policy.PolicyName;
            m_UseBaseline   = useBaselineIn;
            m_SelectionDate = selectionDateIn;
        }
예제 #8
0
        public Main_SecuritySummary(Sql.Policy policyIn, Views.View_Main_SecuritySummary.SecurityView showTabIn)
        {
            Debug.Assert(policyIn != null, "Security Summary called with null Policy");

            m_Policy       = policyIn;
            m_Server       = null;
            m_Name         = m_Policy.PolicyName;
            m_SecurityView = showTabIn;
        }
예제 #9
0
        public PolicyAssessment(Sql.Policy policyIn, Views.View_PolicyAssessment.AssessmentView showTabIn)
        {
            Debug.Assert(policyIn != null, "Security Summary called with null Policy");

            m_Policy         = policyIn;
            m_Server         = null;
            m_Name           = m_Policy.PolicyAssessmentName;
            m_AssessmentView = showTabIn;
        }
예제 #10
0
        public SqlServerSettings(Sql.Policy policyIn, bool useBaselineIn, DateTime?selectionDateIn)
        {
            Debug.Assert(policyIn != null, "Sql Server Settings called with null Policy");

            m_Policy        = policyIn;
            m_UseBaseline   = useBaselineIn;
            m_SelectionDate = selectionDateIn;

            m_Name = m_Policy.PolicyName;
        }
예제 #11
0
        public ReportCard(Sql.Policy policyIn, bool useBaselineIn, DateTime?selectionDateIn, Sql.RegisteredServer serverIn)
        {
            Debug.Assert(policyIn != null, "Report Card called with null Policy");

            m_Policy        = policyIn;
            m_Server        = serverIn;
            m_Name          = string.Format("{0}::{1}", m_Policy.PolicyName, m_Server == null ? null : m_Server.ConnectionName);
            m_UseBaseline   = useBaselineIn;
            m_SelectionDate = selectionDateIn;
        }
예제 #12
0
        public PolicySummary(Sql.Policy policyIn, bool useBaselineIn, DateTime?selectionDateIn)
        {
            Debug.Assert(policyIn != null, "Policy Summary called with null Policy");

            m_Policy        = policyIn;
            m_UseBaseline   = useBaselineIn;
            m_SelectionDate = selectionDateIn;

            m_Name = m_Policy.PolicyName;
        }
예제 #13
0
        public TreeNode AddAssessmentToPolicy(TreeNode PolicyNode, Sql.Policy Assessment)
        {
            TreeNode assessmentnode = new TreeNode(Assessment.AssessmentName);

            assessmentnode.Name                   = Assessment.AssessmentName;
            assessmentnode.ImageIndex             =
                assessmentnode.SelectedImageIndex = Assessment.FindingIconIndex;
            assessmentnode.Tag = Assessment;

            TreeNode[] nodes = PolicyNode.Nodes.Find(Utility.Policy.AssessmentState.DisplayName(Assessment.AssessmentState), false);
            TreeNode   typenode;

            if (nodes.Length > 0)
            {
                typenode = nodes[0];

                //Add the found assessment to the list in order by assessmentid or in the last position
                int nodeIdx = typenode.Nodes.Count;

                foreach (TreeNode node in typenode.Nodes)
                {
                    if (node.Tag != null && node.Tag.GetType() == typeof(Sql.Policy))
                    {
                        // make sure it isn't already in the tree
                        if (((Sql.Policy)node.Tag).AssessmentId == Assessment.AssessmentId)
                        {
                            return(node);
                        }
                        else if (((Sql.Policy)node.Tag).AssessmentId < Assessment.AssessmentId)
                        {
                            nodeIdx = node.Index;
                            break;
                        }
                    }
                    else
                    {
                        nodeIdx = node.Index;
                        break;
                    }
                }
                typenode.Nodes.Insert(nodeIdx, assessmentnode);
            }
            else
            {
                typenode            = new TreeNode(Utility.Policy.AssessmentState.DisplayName(Assessment.AssessmentState));
                typenode.Name       = typenode.Text;
                typenode.ImageIndex = AppIcons.AppImageIndex16(AppIcons.Enum.Folder);
                typenode.Nodes.Add(assessmentnode);
                PolicyNode.Nodes.Add(typenode);
            }
            typenode.Expand();

            return(assessmentnode);
        }
예제 #14
0
        public Main_SecuritySummary(Sql.Policy policyIn, Sql.RegisteredServer serverIn)
        {
            Debug.Assert(policyIn != null, "Security Summary called with null Policy");
            Debug.Assert(serverIn != null, "Security Summary called with null Server");

            m_Policy = policyIn;
            m_Server = serverIn;
            m_Name   = string.Format("{0}::{1}", m_Policy.PolicyName, m_Server.ConnectionName);

            Program.gController.SetCurrentPolicy(m_Policy);
        }
예제 #15
0
        public PolicyAssessment(Sql.Policy policyIn, Sql.RegisteredServer serverIn)
        {
            Debug.Assert(policyIn != null, "Policy Assessment called with null Policy");
            Debug.Assert(serverIn != null, "Policy Assessment called with null Server");

            m_Policy = policyIn;
            m_Server = serverIn;
            m_Name   = string.Format("{0}::{1}", m_Policy.PolicyAssessmentName, m_Server.ConnectionName);

            Program.gController.SetCurrentPolicyAssessment(m_Policy);
        }
예제 #16
0
        public PolicySummary(Sql.Policy policyIn)
        {
            Debug.Assert(policyIn != null, "Policy Summary called with null Policy");
            Debug.Assert(policyIn.IsAssessment, "Policy Summary called with Policy that should be Assessment");

            m_Policy        = policyIn;
            m_UseBaseline   = m_Policy.UseBaseline;
            m_SelectionDate = m_Policy.AssessmentDate;

            m_Name = m_Policy.PolicyAssessmentName;
        }
예제 #17
0
        public static void ShowSnapshots(Sql.Policy policy, bool useBaseline, DateTime selectDate)
        {
            bool updated = false;
            // Create the form.
            Form_PolicySnapshots form = new Form_PolicySnapshots(policy, useBaseline, selectDate);

            if (form.LoadSnapshots())
            {
                form.ShowDialog();
            }
        }
예제 #18
0
        public PolicySummary(Sql.Policy policyIn, bool useBaselineIn, DateTime?selectionDateIn, Sql.RegisteredServer serverIn)
        {
            Debug.Assert(policyIn != null, "Policy Summary called with null Policy");
            Debug.Assert(serverIn != null, "Policy Summary called with null Server");

            m_Policy        = policyIn;
            m_UseBaseline   = useBaselineIn;
            m_SelectionDate = selectionDateIn;
            m_Server        = serverIn;

            m_Name = string.Format("{0}::{1}", m_Policy.PolicyName, m_Server.ConnectionName);
        }
예제 #19
0
        public PolicySummary(Sql.Policy policyIn, Sql.RegisteredServer serverIn)
        {
            Debug.Assert(policyIn != null, "Policy Summary called with null Policy");
            Debug.Assert(policyIn.IsAssessment, "Policy Summary called with Policy that should be Assessment");

            m_Policy        = policyIn;
            m_UseBaseline   = m_Policy.UseBaseline;
            m_SelectionDate = m_Policy.AssessmentDate;
            m_Server        = serverIn;

            m_Name = string.Format("{0}::{1}", m_Policy.PolicyAssessmentName, m_Server.ConnectionName);
        }
예제 #20
0
        public PolicyUsers(Sql.Policy policyIn, bool useBaselineIn, DateTime?selectionDateIn, Sql.RegisteredServer serverIn)
        {
            Debug.Assert(policyIn != null, "Policy Users called with null Policy");
            Debug.Assert(serverIn != null, "Policy Users called with null Server");

            m_Policy        = policyIn;
            m_UseBaseline   = useBaselineIn;
            m_SelectionDate = selectionDateIn;
            m_Server        = serverIn;

            m_Name = m_Server.ConnectionName;
        }
예제 #21
0
        public void SetCurrentPolicy(Sql.Policy policy)
        {
            m_ExplorerBar.SelectedGroup = m_ExplorerBar.Groups[Utility.Constants.ExplorerBar_GroupKey_Summary];

            // If the policy comes in null then it was deleted and we need to refresh everything
            if (policy == null || !Sql.Policy.IsPolicyRegistered(policy.PolicyId))
            {
                m_RefreshPoliciesEvent(0);
            }
            else
            {
                m_PolicyTree.SelectedNode = m_PolicyTree.Nodes[policy.PolicyName];
            }
        }
예제 #22
0
        public Form_PolicySnapshots(Sql.Policy policy, bool useBaseline, DateTime selectDate)
        {
            InitializeComponent();

            m_Policy      = policy;
            m_UseBaseline = useBaseline;
            m_SelectDate  = selectDate;

            _toolStripButton_ColumnChooser.Image = AppIcons.AppImage16(AppIcons.Enum.GridFieldChooser);
            _toolStripButton_GroupBy.Image       = AppIcons.AppImage16(AppIcons.Enum.GridGroupBy);
            _toolStripButton_Save.Image          = AppIcons.AppImage16(AppIcons.Enum.GridSaveToExcel);
            _toolStripButton_Print.Image         = AppIcons.AppImage16(AppIcons.Enum.Print);

            // load value lists for grid display
            m_statusValueList.Key          = "statusValueList";
            m_statusValueList.DisplayStyle = ValueListDisplayStyle.DisplayText;
            _grid.DisplayLayout.ValueLists.Add(m_statusValueList);

            ValueListItem listItem;

            m_statusValueList.ValueListItems.Clear();
            listItem = new ValueListItem("S", "Successful");
            m_statusValueList.ValueListItems.Add(listItem);
            listItem = new ValueListItem("W", "Warnings");
            m_statusValueList.ValueListItems.Add(listItem);
            listItem = new ValueListItem("E", "Errors");
            m_statusValueList.ValueListItems.Add(listItem);
            listItem = new ValueListItem("I", "In Progress");
            m_statusValueList.ValueListItems.Add(listItem);

            m_baselineValueList.Key          = "baselineValueList";
            m_baselineValueList.DisplayStyle = ValueListDisplayStyle.DisplayText;
            _grid.DisplayLayout.ValueLists.Add(m_baselineValueList);

            m_baselineValueList.ValueListItems.Clear();
            listItem = new ValueListItem("Y", "Yes");
            m_baselineValueList.ValueListItems.Add(listItem);
            listItem = new ValueListItem("N", "No");
            m_baselineValueList.ValueListItems.Add(listItem);
            listItem = new ValueListItem(DBNull.Value, "No");
            m_baselineValueList.ValueListItems.Add(listItem);

            _grid.DrawFilter = new Utility.HideFocusRectangleDrawFilter();
            _grid.DisplayLayout.GroupByBox.Hidden = Utility.Constants.InitialState_GroupByBoxHidden;

            this.Description = string.Format(DescriptionDisplay,
                                             m_UseBaseline ? @"baseline " : string.Empty,
                                             m_SelectDate.ToLocalTime().ToString(Constants.DATETIME_FORMAT));
        }
        /// <summary>
        /// Show selection criteria for audit data and return the selection
        /// </summary>
        /// <param name="policy">the policy or assessment object to copy when creating the new assessment</param>
        /// <returns>the assessmentid of the new assessment, otherwise 0</returns>
        public static int Process(Sql.Policy policy)
        {
            int newAssessmentId = 0;

            // Create the form.
            Form_CreateAssessment form = new Form_CreateAssessment(policy);

            if (DialogResult.OK == form.ShowDialog())
            {
                newAssessmentId = Sql.Policy.CreateAssessment(policy.PolicyId, policy.AssessmentId, form.AssessmentName, form.AssessmentDescription, form.SelectDate, form.UseBaseline);
                Program.gController.SignalRefreshPoliciesEvent(policy.PolicyId);
            }

            return(newAssessmentId);
        }
예제 #24
0
        protected void showCompare()
        {
            try
            {
                Sql.Repository.AssessmentList aList = m_policy.Assessments.FindByState(Utility.Policy.AssessmentState.Current);

                Sql.Policy p = aList[0];

                Program.gController.ShowCompareDialog(m_policy.PolicyId, p.AssessmentId, m_server);
            }
            catch (Exception ex)
            {
                logX.loggerX.Error("Error - Unable to load the assessment from the Policy from the Repository", ex);
                MsgBox.ShowError(Utility.ErrorMsgs.CantGetAssessments, ex.Message);
            }
        }
        private string GetDisplayNameForAssessmentInCombo(Sql.Policy p)
        {
            string displayName = string.Empty;

            if (p.IsPolicy)
            {
                string displayFmt = "as of {0}{1}";
                displayName =
                    string.Format(displayFmt,
                                  Program.gController.PolicyTime.HasValue ? Program.gController.PolicyTime.Value.ToLocalTime().ToString(Utility.Constants.DATETIME_FORMAT) : "Now",
                                  Program.gController.PolicyUseBaselineSnapshots ? " (using Baseline)" : string.Empty);
            }
            else
            {
                displayName = p.AssessmentName;
            }
            return(displayName);
        }
예제 #26
0
        public void SetCurrentPolicyServer(string server)
        {
            m_ExplorerBar.SelectedGroup = m_ExplorerBar.Groups[Utility.Constants.ExplorerBar_GroupKey_Summary];

            // If the policy comes in null then it was deleted and we need to refresh everything
            if (m_PolicyTree.Nodes[0].Tag is Sql.Policy)
            {
                Sql.Policy policy = (Sql.Policy)m_PolicyTree.Nodes[0].Tag;
                if (policy == null || !Sql.Policy.IsPolicyRegistered(policy.PolicyId))
                {
                    m_RefreshPoliciesEvent(0);
                }
                else
                {
                    m_PolicyServerTree.Focus();
                    m_PolicyServerTree.SelectedNode = m_PolicyServerTree.Nodes[0].Nodes[server];
                }
            }
        }
        /// <summary>
        /// Show selection criteria for audit data and apply the selection to the policy
        /// </summary>
        /// <param name="policy">the policy or assessment object to refresh assessment data on</param>
        /// <returns>true if the selection was applied, otherwise 0</returns>
        public static bool Process(Sql.Policy policy)
        {
            bool updated = false;
            // Create the form.
            Form_RefreshAuditData form = new Form_RefreshAuditData(policy);

            if (DialogResult.OK == form.ShowDialog())
            {
                policy.AssessmentDate = form.SelectDate;
                policy.UseBaseline    = form.UseBaseline;

                if (policy.SavePolicyToRepository(Program.gController.Repository.ConnectionString))
                {
                    updated = true;
                    Program.gController.SignalRefreshPoliciesEvent(policy.PolicyId);
                }
            }

            return(updated);
        }
        private void _button_OK_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            if (string.IsNullOrEmpty(_textBox_AssessmentName.Text.Trim()))
            {
                MsgBox.ShowError(ERRORTITLE_CREATE,
                                 ERRORMSGNAMEEMPTY);
                DialogResult = DialogResult.None;

                Cursor = Cursors.Default;
                return;
            }
            else
            {
                Sql.Policy policy = Program.gController.Repository.Policies.Find(m_Policy.PolicyId);
                if (policy != null)
                {
                    if (policy.HasAssessment(_textBox_AssessmentName.Text))
                    {
                        MsgBox.ShowError(ERRORTITLE_CREATE,
                                         string.Format(ERRORMSGDUPLICATENAME, _textBox_AssessmentName.Text, m_Policy.PolicyName));
                        DialogResult = DialogResult.None;

                        Cursor = Cursors.Default;
                        return;
                    }
                }
            }

            m_UseBaseline = _checkBox_BaselineOnly.Checked;
            if (_checkBox_IncludeTime.Checked)
            {
                m_SelectDate = _dateTimePicker_Date.Value.Date + _dateTimePicker_Time.Value.TimeOfDay;
            }
            else
            {
                m_SelectDate = _dateTimePicker_Date.Value.Date + new TimeSpan(DefaultTime.TimeOfDay.Ticks);
            }
            m_SelectDate = m_SelectDate.Value.ToUniversalTime();
        }
        public Form_RefreshAuditData(Sql.Policy policy)
        {
            InitializeComponent();

            //Icon = AppIcons.AppImage16(AppIcons.Enum.Policy);
            this.Text = TITLEFMT;

            Description = DESCR_GENERAL_FMT;

            DateTime?selectDate = null;

            m_Policy   = policy;
            selectDate = m_Policy.AssessmentDate;
            _checkBox_BaselineOnly.Checked = m_Policy.UseBaseline;

            if (!selectDate.HasValue)
            {
                _checkBox_IncludeTime.Checked = false;
                _dateTimePicker_Time.Value    = DefaultTime;
                _dateTimePicker_Time.Enabled  = false;
            }
            else
            {
                _dateTimePicker_Date.Value = new DateTime(selectDate.Value.ToLocalTime().Date.Ticks);

                if (selectDate.Value.ToLocalTime().TimeOfDay.Ticks == DefaultTime.TimeOfDay.Ticks)
                {
                    _checkBox_IncludeTime.Checked = false;
                    _dateTimePicker_Time.Value    = DefaultTime;
                    _dateTimePicker_Time.Enabled  = false;
                }
                else
                {
                    _checkBox_IncludeTime.Checked = true;
                    _dateTimePicker_Time.Value    = selectDate.Value.ToLocalTime();
                }
            }
        }
예제 #30
0
 public PolicySummary()
 {
     m_Policy = null;
     m_Server = null;
     m_Name   = "No Policy Selected";
 }