コード例 #1
0
ファイル: HistoryTabView.cs プロジェクト: windygu/AW-master
        /// <summary>
        /// Display
        /// =======
        ///
        /// Displays the audit history for this asset within this tab view.
        ///
        /// </summary>
        /// <param name="displayNode">UltraTreeNode holding the asset for which history is to be displayed</param>
        public void Display(UltraTreeNode displayedNode)
        {
            _displayedNode = displayedNode;
            Asset displayedAsset = _displayedNode.Tag as Asset;

            //	Call BeginUpdate to prevent drawing while we are populating the control
            this.historyGridView.BeginUpdate();
            this.Cursor = Cursors.WaitCursor;

            // Delete all entries from the current data set being displayed
            historyDataSet.Tables[0].Rows.Clear();

            // Recover the asset audit history records for this asset
            AuditTrailDAO lwDataAccess = new AuditTrailDAO();
            DataTable     historyTable = lwDataAccess.GetAssetAuditHistory(displayedAsset, new DateTime(0), new DateTime(0));

            // Add the entries in the data table as ATE records to our DataSet
            foreach (DataRow row in historyTable.Rows)
            {
                AuditTrailEntry ate = new AuditTrailEntry(row);
                historyDataSet.Tables[0].Rows.Add(new object[] { ate, ate.Date, ate.GetTypeDescription(), ate.Username });
            }

            //	Restore the cursor
            this.Cursor = Cursors.Default;

            //	Call EndUpdate to resume drawing operations
            this.historyGridView.EndUpdate(true);
        }
コード例 #2
0
        /// <summary>
        /// Add an Audit Trail Entry to the data set associated with the grid
        /// </summary>
        /// <param name="ate"></param>
        protected void AddAuditTrailEntry(AuditTrailEntry ate)
        {
            // Get any filter dates
            DateTime startDate = _auditTrailFilterEventArgs.StartDate.Date;
            DateTime endDate   = _auditTrailFilterEventArgs.EndDate.Date.AddDays(1);

            // ...and check date in range first
            if (ate.Date < startDate.Date || ate.Date > endDate.Date)
            {
                return;
            }

            // Check the entry type against what we are expecting to add and reject if invalid
            if ((_auditTrailFilterEventArgs.RequiredClass != AuditTrailEntry.CLASS.all) &&
                (ate.Class != _auditTrailFilterEventArgs.RequiredClass))
            {
                return;
            }

            // Some items modified may be delimited by '|'.  Split these here
            // For Application Property Changes these will be in the form
            //	APPLICATION | PROPERTY
            //
            // For license changes this will be in the form
            //	APPLICATION | LICENSE TYPE | PROPERTY
            String keyValue1 = "";
            String keyValue2 = "";
            String keyValue3 = "";

            String[] keyParts = ate.Key.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            if (keyParts.Length > 0)
            {
                keyValue1 = keyParts[0];
            }
            if (keyParts.Length > 1)
            {
                keyValue2 = keyParts[1];
            }
            if (keyParts.Length > 2)
            {
                keyValue3 = keyParts[2];
            }


            // OK this record has survived all filters so add it
            _listDisplayedRows.Add(ate);
            auditTrailDataSet.Tables[0].Rows.Add(new object[]
                                                 { ate,
                                                   ate.Date.ToString("yyyy-MM-dd HH:mm"),
                                                   ate.AssetName,
                                                   ate.Username,
                                                   ate.GetTypeDescription(),
                                                   keyValue1,
                                                   (keyValue3 == "") ? ate.OldValue : keyValue3 + " : " + ate.OldValue,
                                                   ate.NewValue,
                                                   keyValue2 });
        }
コード例 #3
0
ファイル: HistoryTabView.cs プロジェクト: windygu/AW-master
        private void historyGridView_InitializeRow(object sender, InitializeRowEventArgs e)
        {
            // Get the application object being displayed - this is always a tree node in this view
            AuditTrailEntry ate = e.Row.Cells["DataObject"].Value as AuditTrailEntry;

            // The icon displayed will depend on the type of entry - we can have
            //		application installs/uninstalls
            //		audited data changes
            //		audit/reaudit
            if (ate.Class == AuditTrailEntry.CLASS.application_installs)
            {
                e.Row.Cells["Operation"].Appearance.Image = Properties.Resources.application_16;
            }

            else if (ate.Class == AuditTrailEntry.CLASS.audited || ate.Class == AuditTrailEntry.CLASS.reaudited)
            {
                e.Row.Cells["Operation"].Appearance.Image = Properties.Resources.computer16;
            }

            else
            {
                // Recover the Description
                string description = ate.GetTypeDescription();

                // Strip off everything after the last colon (if any)
                int delimiter = description.LastIndexOf(':');
                if (delimiter != -1)
                {
                    description = description.Substring(0, delimiter);
                }

                // Now check this against the database to see if we can find an icon for it
                IconMapping iconMapping = _iconMappings.GetIconMapping(description);
                if (iconMapping != null)
                {
                    e.Row.Cells["Operation"].Appearance.Image = IconMapping.LoadIcon(iconMapping.Icon, IconMapping.Iconsize.Small);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// This function is called to add an audit trail entry to the DataSet
        /// </summary>
        /// <param name="thisApplication"></param>
        protected void AddChangesRecord(AuditTrailEntry record)
        {
            // Get the Table from the DataSet
            DataTable historyTable = _reportDataSet.Tables["History"];

            // Add the row to the data set
            try
            {
                historyTable.Rows.Add(new object[]
                                      { record
                                        , record.Location
                                        , record.AssetName
                                        , record.Date.ToShortDateString()
                                        , 0                                                                             // Days not applicable to this report
                                        , record.ClassString
                                        , record.GetTypeDescription() });
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }