コード例 #1
0
        /// <summary>
        /// Add a new asset to the database (or possibly update an existing item)
        /// </summary>
        /// <returns></returns>
        public int Add()
        {
            AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess();

            if (AssetID == 0)
            {
                // Add the asset to the database
                _assetID = lwDataAccess.AssetAdd(this);

                // ...and log this event in the audit trail
                AuditTrailEntry ate = new AuditTrailEntry();
                ate.Date      = DateTime.Now;
                ate.Class     = AuditTrailEntry.CLASS.asset;
                ate.Type      = AuditTrailEntry.TYPE.added;
                ate.Key       = _name;
                ate.AssetID   = _assetID;
                ate.AssetName = _name;
                ate.Username  = System.Environment.UserName;
                lwDataAccess.AuditTrailAdd(ate);
            }
            else
            {
                lwDataAccess.AssetUpdate(this);
            }
            return(0);
        }
コード例 #2
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);
        }
コード例 #3
0
        /// <summary>
        /// Return a list of changes between this object and an old version
        /// For suppliers we really aren't that interested  in changes to these details just adding
        /// and deletion of suppliers
        /// </summary>
        /// <param name="oldObject"></param>
        /// <returns></returns>
        public List <AuditTrailEntry> AuditChanges(Supplier oldObject)
        {
            AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess();

            // Construct the return list
            List <AuditTrailEntry> listChanges = new List <AuditTrailEntry>();

            // Is this a new item or an update to an existing one
            if (SupplierID == 0)
            {
                AuditTrailEntry ate = new AuditTrailEntry();
                ate.Date      = DateTime.Now;
                ate.Class     = AuditTrailEntry.CLASS.supplier;
                ate.Type      = AuditTrailEntry.TYPE.added;
                ate.Key       = _name;
                ate.AssetID   = 0;
                ate.AssetName = "";
                ate.Username  = System.Environment.UserName;
                listChanges.Add(ate);
            }

            // Add all of these changes to the Audit Trail
            foreach (AuditTrailEntry entry in listChanges)
            {
                lwDataAccess.AuditTrailAdd(entry);
            }

            // Return the constructed list
            return(listChanges);
        }
コード例 #4
0
ファイル: DocumentsControl.cs プロジェクト: windygu/AW-master
        /// <summary>
        /// Delete the selected document(s) from the database and if locally linked from the Documents folder
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bnDeleteDocument_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure that you want to remove the specified documents?\n\nDocuments which have been copied to the AuditWizard documents folder will be deleted", "Confirm Remove", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                foreach (UltraListViewItem lvi in lvDocuments.SelectedItems)
                {
                    Document document = lvi.Tag as Document;
                    document.Delete();
                    lvDocuments.Items.Remove(lvi);

                    if (_application != null)
                    {
                        AuditTrailEntry ate = new AuditTrailEntry();
                        ate.Date      = DateTime.Now;
                        ate.Class     = AuditTrailEntry.CLASS.application_changes;
                        ate.Type      = AuditTrailEntry.TYPE.deleted;
                        ate.Key       = _application.Name + "|Documents";
                        ate.AssetID   = 0;
                        ate.AssetName = "";
                        ate.OldValue  = document.Name;
                        ate.Username  = System.Environment.UserName;
                        new AuditTrailDAO().AuditTrailAdd(ate);
                    }
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Called as we click the OK button - save the definition back to the database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bnOK_Click(object sender, EventArgs e)
        {
            if (_installedApplication.Publisher != tbPublisher.Text)
            {
                string          oldPublisherName = _installedApplication.Publisher;
                ApplicationsDAO lwDataAccess     = new ApplicationsDAO();
                lwDataAccess.ApplicationUpdatePublisher(_installedApplication.ApplicationID, tbPublisher.Text);
                _installedApplication.Publisher = tbPublisher.Text;

                AuditTrailEntry ate = new AuditTrailEntry();
                ate.Date      = DateTime.Now;
                ate.Class     = AuditTrailEntry.CLASS.application_changes;
                ate.Type      = AuditTrailEntry.TYPE.changed;
                ate.Key       = _installedApplication.Name + "|Publisher";
                ate.AssetID   = 0;
                ate.AssetName = "";
                ate.OldValue  = oldPublisherName;
                ate.NewValue  = tbPublisher.Text;
                ate.Username  = System.Environment.UserName;
                new AuditTrailDAO().AuditTrailAdd(ate);
            }

            // Save any changes made to the user defined data field values
            SaveUserDefinedData();
        }
コード例 #6
0
ファイル: NotesControl.cs プロジェクト: windygu/AW-master
        private void tbNoteText_Leave(object sender, EventArgs e)
        {
            if (lvExistingNotes.SelectedItems.Count != 1)
            {
                return;
            }

            ListViewItem item         = lvExistingNotes.SelectedItems[0];
            Note         selectedNote = _notes.FindNoteById((int)item.Tag);

            if (selectedNote != null)
            {
                string oldNoteText = selectedNote.Text;
                selectedNote.Text = tbNoteText.Text;
                selectedNote.Update();

                if (_application != null)
                {
                    AuditTrailEntry ate = new AuditTrailEntry();
                    ate.Date      = DateTime.Now;
                    ate.Class     = AuditTrailEntry.CLASS.application_changes;
                    ate.Type      = AuditTrailEntry.TYPE.changed;
                    ate.Key       = _application.Name + "|Notes";
                    ate.AssetID   = 0;
                    ate.AssetName = "";
                    ate.OldValue  = oldNoteText;
                    ate.NewValue  = selectedNote.Text;
                    ate.Username  = Environment.UserName;
                    new AuditTrailDAO().AuditTrailAdd(ate);
                }

                LoadNotes(_scope, _parentID);
            }
        }
コード例 #7
0
ファイル: DocumentsControl.cs プロジェクト: windygu/AW-master
        /// <summary>
        /// Browse for a document to associate with this instance
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bnAddDocument_Click(object sender, EventArgs e)
        {
            FormAddDocument form = new FormAddDocument();

            if (form.ShowDialog() == DialogResult.OK)
            {
                string documentFile = form.DocumentPath;
                string documentName = form.DocumentName;

                if (form.CopyToLocal)
                {
                    string destinationFile = "";
                    try
                    {
                        // Create a hopefully unique name for this document based on the current time
                        destinationFile = Path.Combine(Application.StartupPath, "Documents");

                        Directory.CreateDirectory(destinationFile);

                        string filename = Path.GetFileNameWithoutExtension(documentFile) + "_" + DateTime.Now.Ticks.ToString() + Path.GetExtension(documentFile);
                        destinationFile = destinationFile + @"\" + filename;
                        File.Copy(documentFile, destinationFile);
                        documentFile = destinationFile;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Failed to copy " + documentFile + " to " + destinationFile + "\nThe error was " + ex.Message);
                        return;
                    }
                }

                // Add the document to the database and to the list of documents
                Document newDocument = new Document();
                newDocument.Scope    = _scope;
                newDocument.Name     = documentName;
                newDocument.Path     = documentFile;
                newDocument.ParentID = _parentID;
                //
                newDocument.Add();
                AddDocumentToListView(newDocument);

                _documents.Add(newDocument);

                if (_application != null)
                {
                    AuditTrailEntry ate = new AuditTrailEntry();
                    ate.Date      = DateTime.Now;
                    ate.Class     = AuditTrailEntry.CLASS.application_changes;
                    ate.Type      = AuditTrailEntry.TYPE.added;
                    ate.Key       = _application.Name + "|Documents";
                    ate.AssetID   = 0;
                    ate.AssetName = "";
                    ate.Username  = System.Environment.UserName;
                    ate.NewValue  = newDocument.Name;
                    new AuditTrailDAO().AuditTrailAdd(ate);
                }
            }
        }
コード例 #8
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 });
        }
コード例 #9
0
 /// <summary>
 /// Wrapper around adding an Audit Trail Entry to the list and re-creating the base ATE object
 /// </summary>
 /// <param name="listChanges"></param>
 /// <param name="ate"></param>
 /// <param name="key"></param>
 /// <param name="oldValue"></param>
 /// <param name="newValue"></param>
 /// <returns></returns>
 protected AuditTrailEntry AddChange(List <AuditTrailEntry> listChanges, AuditTrailEntry ate, String key, String oldValue, String newValue)
 {
     ate.Key      = ate.Key + "|" + key;
     ate.OldValue = oldValue;
     ate.NewValue = newValue;
     listChanges.Add(ate);
     ate = BuildATE();
     return(ate);
 }
コード例 #10
0
ファイル: Program.cs プロジェクト: theigner/Blobfish
        private static void CreateAuditTrailEntries(ref AnimlDocument document)
        {
            document.AuditTrailEntrySet = new AuditTrailEntrySet();

            Author          author          = new Author("John Doe", UserType.Human);
            AuditTrailEntry auditTrailEntry = new AuditTrailEntry(DateTime.Now, author, Blobfish.Action.Created);

            auditTrailEntry.Comment = "Creation of the AnIML document.";
            document.AuditTrailEntrySet.AuditTrailEntries.Add(auditTrailEntry);
        }
コード例 #11
0
ファイル: NotesControl.cs プロジェクト: windygu/AW-master
        /// <summary>
        /// Delete the currently selected note (after confirmation)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bnDeleteNote_Click(object sender, EventArgs e)
        {
            if (lvExistingNotes.SelectedItems.Count != 1)
            {
                MessageBox.Show("Please select a note from the list.", "Delete Note", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (MessageBox.Show("Are you sure that you want to delete this note?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }

            ListViewItem item         = lvExistingNotes.SelectedItems[0];
            Note         selectedNote = _notes.FindNoteById((int)item.Tag);

            if (selectedNote == null)
            {
                return;
            }

            selectedNote.Delete();

            if (_application != null)
            {
                AuditTrailEntry ate = new AuditTrailEntry();
                ate.Date      = DateTime.Now;
                ate.Class     = AuditTrailEntry.CLASS.application_changes;
                ate.Type      = AuditTrailEntry.TYPE.deleted;
                ate.Key       = _application.Name + "|Notes";
                ate.AssetID   = 0;
                ate.AssetName = "";
                ate.OldValue  = selectedNote.Text;
                ate.Username  = Environment.UserName;
                new AuditTrailDAO().AuditTrailAdd(ate);
            }

            int index = lvExistingNotes.SelectedIndices[0];

            lvExistingNotes.Items.RemoveAt(index);
            tbNoteText.Text = "";

            if (lvExistingNotes.Items.Count > 0)
            {
                lvExistingNotes.Items[0].Selected = true;
            }
            else
            {
                lbNoteDate.Visible   = false;
                lbCharsLeft.Visible  = false;
                lbNotePrompt.Visible = true;
                bnDeleteNote.Enabled = false;
            }
        }
コード例 #12
0
        /// <summary>
        /// Construct a raw Audit Trail Entry and initialize it
        /// </summary>
        /// <returns></returns>
        protected AuditTrailEntry BuildATE()
        {
            AuditTrailEntry ate = new AuditTrailEntry();

            ate.Date      = DateTime.Now;
            ate.Class     = AuditTrailEntry.CLASS.application_changes;
            ate.Type      = AuditTrailEntry.TYPE.changed;
            ate.AssetID   = InstalledOnComputerID;
            ate.AssetName = this.InstalledOnComputer;
            ate.Username  = System.Environment.UserName;

            return(ate);
        }
コード例 #13
0
ファイル: Action.cs プロジェクト: windygu/AW-master
        /// <summary>
        /// Delete the current license from the database
        /// </summary>
        public void Delete()
        {
            // Delete from the database
            AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess();

            lwDataAccess.ActionDelete(this);

            // ...and audit the deletion
            AuditTrailEntry ate = BuildATE();

            ate.Type = AuditTrailEntry.TYPE.deleted;
            lwDataAccess.AuditTrailAdd(ate);
        }
コード例 #14
0
        public static void AddAuditTrailEntry <T>(this IAuditTrailable <T> auditTrailable, AuditTrailContext dbContext) where T : Entity
        {
            var entityEntry = dbContext.Entry(auditTrailable);
            AuditTrailEntry <T> auditTrailEntry;

            if (EntityState.Added == entityEntry.State)
            {
                auditTrailEntry = new AuditTrailEntry <T>
                {
                    Subject   = auditTrailable.GetEntity(),
                    Timestamp = SystemClock.Instance.GetCurrentInstant(),
                    EntryType = AuditTrailEntryType.Insert,
                    FromValue = "",
                    ToValue   = JsonConvert.SerializeObject(entityEntry.Entity, Formatting.Indented, new JsonSerializerSettings {
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                    }),
                };
                auditTrailable.AuditTrailEntries.Add(auditTrailEntry);
                return;
            }

            var changedProperties = entityEntry.Properties.Where(p => p.IsModified).ToList();

            if (changedProperties.Count == 0)
            {
                return;
            }
            var(from, to) = changedProperties.Aggregate((From: "", To: ""), (carry, p) =>
            {
                if (!p.IsModified || p.CurrentValue.GetType() == typeof(ICollection <AuditTrailEntry <T> >))
                {
                    return(carry);
                }

                return($"{carry.From}{Environment.NewLine}{p.Metadata.Name}: {p.OriginalValue}",
                       $"{carry.To}{Environment.NewLine}{p.Metadata.Name}: {p.CurrentValue}");
            });


            auditTrailable.AuditTrailEntries ??= new List <AuditTrailEntry <T> >();
            auditTrailEntry = new AuditTrailEntry <T>
            {
                Subject   = auditTrailable.GetEntity(),
                Timestamp = SystemClock.Instance.GetCurrentInstant(),
                EntryType = entityEntry.State switch
                {
                    EntityState.Added => AuditTrailEntryType.Insert,
                    EntityState.Modified => AuditTrailEntryType.Update,
                    EntityState.Deleted => AuditTrailEntryType.Delete,
                    _ => AuditTrailEntryType.Update,
                },
コード例 #15
0
        /// <summary>
        /// Construct a raw Audit Trail Entry and initialize it
        /// </summary>
        /// <returns></returns>
        protected AuditTrailEntry BuildATE()
        {
            AuditTrailEntry ate = new AuditTrailEntry();

            ate.Date      = DateTime.Now;
            ate.Class     = AuditTrailEntry.CLASS.asset;
            ate.Type      = AuditTrailEntry.TYPE.changed;
            ate.Key       = _name;
            ate.AssetID   = _assetID;
            ate.AssetName = _name;
            ate.Username  = System.Environment.UserName;

            return(ate);
        }
コード例 #16
0
        private AuditTrailEntry CreateAteForAssetNameChange(Asset objAsset)
        {
            AuditTrailEntry ate = new AuditTrailEntry();

            ate.Date      = DateTime.Now;
            ate.Class     = AuditTrailEntry.CLASS.asset;
            ate.Type      = AuditTrailEntry.TYPE.changed;
            ate.Key       = objAsset.Name;
            ate.AssetID   = objAsset.AssetID;
            ate.AssetName = objAsset.Name;;
            ate.Username  = System.Environment.UserName;

            return(ate);
        }
コード例 #17
0
ファイル: WorkflowInstance.cs プロジェクト: yimlu/WorkflowPoc
        public void Submit(string comment)
        {
            AssertOperation(Current, OperationCode.Submit);
            //提交时不进行权限验证,后面可能要加上,某些用户可能不具备提交特定流程的权限
            //AssertPrivilege(Current);

            var action = GetCurrentAction(Current, OperationCode.Submit);

            //判断是否本节点回环
            if (action.Transit.ActivityTemplateId != Current.ActivityTemplate.ActivityTemplateId)
            {
                //非本节点回环,创建下个节点实例
                var nextActivityInstance = NewActivityInstance(action.Transit);

                //标记该Activity已完成
                _originateActivityInstance = Current;
                _originateActivityInstance.MarkFinish();
                //_originateActivityInstance.Tail.MarkFinished();

                //替换当前节点
                Current = nextActivityInstance;
            }

            //相应的创建Action实例
            var actionRecord = new ActionRecord()
            {
                ActivityInstanceId = Current.ActivityInstanceId,
                RequiredRole       = Current.ActivityTemplate.RequiredRole.Id
            };

            Current.AddAction(actionRecord);

            //当前节点替换
            var auditTrail = new AuditTrailEntry()
            {
                IsNew = true
            };

            //添加审核日志
            AuditTrails.Add(auditTrail);

            _isDirty = true;
        }
コード例 #18
0
        /// <summary>
        /// Delete the current license from the database
        /// </summary>
        public void Delete()
        {
            // Delete from the database
            AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess();

            lwDataAccess.SupplierDelete(this);

            // ...and audit the deletion
            AuditTrailEntry ate = new AuditTrailEntry();

            ate.Date      = DateTime.Now;
            ate.Class     = AuditTrailEntry.CLASS.supplier;
            ate.Type      = AuditTrailEntry.TYPE.deleted;
            ate.Key       = _name;
            ate.AssetID   = 0;
            ate.AssetName = "";
            ate.Username  = System.Environment.UserName;
            lwDataAccess.AuditTrailAdd(ate);
        }
コード例 #19
0
        /// <summary>
        /// Delete this asset from the database
        /// </summary>
        /// <returns></returns>
        public int Delete()
        {
            AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess();

            // ...and audit the deletion
            AuditTrailEntry ate = new AuditTrailEntry();

            ate.Date      = DateTime.Now;
            ate.Class     = AuditTrailEntry.CLASS.asset;
            ate.Type      = AuditTrailEntry.TYPE.deleted;
            ate.Key       = _name;
            ate.AssetID   = 0;
            ate.AssetName = "";
            ate.Username  = System.Environment.UserName;
            lwDataAccess.AuditTrailAdd(ate);

            // Delete the asset
            lwDataAccess.AssetDelete(this);
            return(0);
        }
コード例 #20
0
ファイル: SocialController.cs プロジェクト: tyossinsak/Space
        public async Task <HttpStatusCodeResult> Audit(int modelId, string socialName)
        {
            string securityToken = Request.Headers["securityToken"];

            if (string.IsNullOrEmpty(securityToken))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            string phrase = securityToken.Decrypt(EncryptionKey, EncryptionIV);

            if (phrase != Request.Url.Host)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
            }

            var entry = new AuditTrailEntry
            {
                TimeStamp             = DateTime.Now,
                Browser               = Request.Browser.Browser,
                BrowserVersion        = Request.Browser.Version,
                BrowserMajorVersion   = Request.Browser.MajorVersion,
                BrowserIsMobileDevice = Request.Browser.IsMobileDevice,
                BrowserPlatform       = Request.Browser.Platform,
                UrlReferrer           = Request.UrlReferrer?.ToString(),
                UserAgent             = Request.UserAgent,
                UserHostAddress       = Request.UserHostAddress,
                SocialName            = socialName,
                ModelId               = modelId
            };

            using (var db = new DatabaseContext())
            {
                db.AuditTrail.Add(entry);
                await db.SaveChangesAsync();
            }

            await entry.GeolocateIpAddress(new IpInfoGeolocator(GeolocationApiUrl));

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
コード例 #21
0
        /// <summary>
        /// This report will contain information on asset history records dated between the specified start
        /// and end dates
        /// </summary>
        protected void GenerateChangesBetweenReportData()
        {
            // Create a string representation of the publisher filter list passed to us
            // We need to get the entire licensing information at this point
            AuditTrailDAO lwDataAccess = new AuditTrailDAO();
            DataTable     historyTable = lwDataAccess.GetAssetAuditHistory(new Asset(), _startDate, _endDate);

            // For each row in the returned table we need to first see if we need to filter it based on
            // and locations/assets specified
            foreach (DataRow row in historyTable.Rows)
            {
                // Create the object for this History record
                AuditTrailEntry entry = new AuditTrailEntry(row);

                // Check for this being filtered by location/asset
                if (FilterRecord(entry.Location, entry.AssetName))
                {
                    AddChangesRecord(entry);
                }
            }
        }
コード例 #22
0
        /// <summary>
        /// generate the most recent history records for each asset
        /// </summary>
        protected void GenerateMostRecentReportData()
        {
            // Get a complete list of groups and assets and then apply our filters to this list
            LocationsDAO lwDataAccess = new LocationsDAO();

            AssetGroup.GROUPTYPE displayType = AssetGroup.GROUPTYPE.userlocation;
            DataTable            table       = lwDataAccess.GetGroups(new AssetGroup(displayType));
            AssetGroup           assetGroups = new AssetGroup(table.Rows[0], displayType);

            assetGroups.Populate(true, false, true);

            // Now apply the filter to these groups
            assetGroups.ApplyFilters(_selectedGroups, _selectedAssets, _ignoreChildAssets);

            // Now that we have a definitive list of the assets (as objects) which we want to include in the
            // report we could really do with expanding this list so that ALL of the assets are in a single list
            // and not distributed among the publishers
            AssetList listAssets = assetGroups.GetAllAssets();

            // OK - get the last audit trail records for these assets - the last audit date is stored in the
            // Asset object so we don't need to get that again
            foreach (Asset asset in listAssets)
            {
                // Skip any assets not audited yet
                if (asset.LastAudit.Ticks == 0)
                {
                    continue;
                }

                // Get the audit trail records for this asset
                DataTable historyTable = new AuditTrailDAO().GetAssetAuditHistory(asset, asset.LastAudit, DateTime.Now);

                // Add the entries in the data table as ATE records to our DataSet
                foreach (DataRow row in historyTable.Rows)
                {
                    AuditTrailEntry ate = new AuditTrailEntry(row);
                    AddChangesRecord(ate);
                }
            }
        }
コード例 #23
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);
            }
        }
コード例 #24
0
ファイル: NotesControl.cs プロジェクト: windygu/AW-master
        private void AddNewNote(string noteText)
        {
            Note note = new Note {
                ParentID = _parentID, Scope = _scope, Text = noteText
            };

            note.NoteID = new NotesDAO().NoteAdd(note);
            AddNoteToListView(note);
            _notes.Add(note);

            tbNoteText.Text = note.Text;

            lbNoteDate.Visible  = true;
            lbCharsLeft.Visible = true;

            lbNoteDate.Text = String.Format(
                "Last update: {0} by {1}",
                note.DateOfNote.ToString("dd MMM HH:mm"),
                note.User);

            lbCharsLeft.Text = String.Format("{0} chars remaining", 4000 - tbNoteText.Text.Length);

            if (_application != null)
            {
                AuditTrailEntry ate = new AuditTrailEntry();
                ate.Date      = DateTime.Now;
                ate.Class     = AuditTrailEntry.CLASS.application_changes;
                ate.Type      = AuditTrailEntry.TYPE.added;
                ate.Key       = _application.Name + "|Notes";
                ate.AssetID   = 0;
                ate.AssetName = "";
                ate.NewValue  = note.Text;
                ate.Username  = Environment.UserName;
                new AuditTrailDAO().AuditTrailAdd(ate);
            }

            lbNotePrompt.Visible = false;
            bnDeleteNote.Enabled = true;
        }
コード例 #25
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);
                }
            }
        }
コード例 #26
0
ファイル: AssetGroup.cs プロジェクト: windygu/AW-master
        /// <summary>
        /// Delete the current location from the database
        /// </summary>
        public bool Delete()
        {
            AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess();

            // As locations are hierarchical we cannot just delete a location without first deleting ALL
            // children and we cannot do that if any of our descendants are still being referenced
            // Get a list of all of our children
            AssetGroupList children = new AssetGroupList(lwDataAccess.GetGroups(this), GroupType);

            // Loop through each child and try and delete them first before we delete ourselves - this actually
            // causes recursion through this deletion function as children may have children and so on...
            foreach (AssetGroup childGroup in children)
            {
                if (!childGroup.Delete())
                {
                    return(false);
                }
            }

            // Only now can we delete ourselves as all of our children have been handled.
            if (lwDataAccess.GroupDelete(this) != 0)
            {
                return(false);
            }

            // ...and audit the deletion
            AuditTrailEntry ate = new AuditTrailEntry();

            ate.Date      = DateTime.Now;
            ate.Class     = AuditTrailEntry.CLASS.location;
            ate.Type      = AuditTrailEntry.TYPE.deleted;
            ate.Key       = _name;
            ate.AssetID   = 0;
            ate.AssetName = "";
            ate.Username  = System.Environment.UserName;
            lwDataAccess.AuditTrailAdd(ate);
            return(true);
        }
コード例 #27
0
        private void backgroundWorker_ImportHistoryLine(string[] fields)
        {
            // Does the Asset exist?
            Asset newAsset = new Asset();

            newAsset.Name = fields[0];
            //
            AssetDAO lwDataAccess = new AssetDAO();

            newAsset.AssetID = lwDataAccess.AssetFind(newAsset);

            // If the asset exists then add the history record for it
            if (newAsset.AssetID != 0)
            {
                // Create an Audit Trail Entry record based on the data passed in to us.
                try
                {
                    AuditTrailDAO auditTrailDAO = new AuditTrailDAO();

                    AuditTrailEntry ate = new AuditTrailEntry();
                    //ate.Date = DateTime.ParseExact(fields[1], "yyyy-MM-dd HH:mm:ss", null);
                    ate.Date      = Convert.ToDateTime(fields[1]);
                    ate.Class     = AuditTrailEntry.CLASS.asset;
                    ate.AssetID   = newAsset.AssetID;
                    ate.AssetName = newAsset.Name;
                    ate.Type      = AuditTrailEntry.TranslateV7Type((AuditTrailEntry.V7_HIST_OPS)Convert.ToInt32(fields[2]));
                    ate.Key       = fields[3];
                    ate.OldValue  = fields[4];
                    ate.NewValue  = fields[5];
                    ate.Username  = fields[6];
                    auditTrailDAO.AuditTrailAdd(ate);
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                }
            }
        }
コード例 #28
0
        /// <summary>
        /// Return a list of changes between this object and an old version
        /// </summary>
        /// <param name="oldObject"></param>
        /// <returns></returns>
        public List <AuditTrailEntry> ListChanges(ApplicationInstance oldObject)
        {
            // Construct the return list
            List <AuditTrailEntry> listChanges = new List <AuditTrailEntry>();

            // The Publisher, Application Name, Version and Installed Asset must not change
            // as these are basic properties of the application instance.
            // Build a blank AuditTrailEntry
            AuditTrailEntry ate = BuildATE();

            if (this.Serial.ProductId != oldObject.Serial.ProductId)
            {
                ate = AddChange(listChanges, ate, "Serial Number", oldObject.Serial.ProductId, Serial.ProductId);
            }

            // CD Key
            if (this.Serial.CdKey != oldObject.Serial.CdKey)
            {
                ate = AddChange(listChanges, ate, "CD Key", oldObject.Serial.CdKey, Serial.CdKey);
            }

            // Return the constructed list
            return(listChanges);
        }
コード例 #29
0
        public void Execute(AuditTrailEntryCreatedEvent @event, IDbContext unitOfWork)
        {
            if (@event == null)
            {
                throw new ArgumentNullException("event");
            }
            if (unitOfWork == null)
            {
                throw new ArgumentNullException("unitOfWork");
            }

            var auditTrailEntry = new AuditTrailEntry
            {
                Id          = @event.EntityId,
                SubjectId   = @event.SubjectId,
                UserId      = @event.UserId,
                Summary     = @event.Summary,
                Timestamp   = @event.Timestamp,
                SubjectName = @event.SubjectName,
                UserName    = @event.UserName
            };

            unitOfWork.AuditTrailEntries.Add(auditTrailEntry);
        }
コード例 #30
0
        /// <summary>
        /// Return a list of changes between this object and an old version
        /// </summary>
        /// <param name="oldObject"></param>
        /// <returns></returns>
        public void AuditChanges(Asset oldObject)
        {
            AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess();

            // Construct the return list
            List <AuditTrailEntry> listChanges = new List <AuditTrailEntry>();

            // The following fields are auditable for an Asset
            //
            //	Stock Status
            //	Category
            //  Type
            //	Make
            //	Model
            //	Serial
            //	Supplier
            //
            // Build a blank AuditTrailEntry
            AuditTrailEntry ate = BuildATE();

            // We only audit changes made for existing assets so ignore if we weren't passed an original
            if (oldObject != null)
            {
                // Stock Status
                if (_stockStatus != oldObject._stockStatus)
                {
                    AddChange(listChanges, ate, "Stock Status", Asset.GetStockStatusText(oldObject._stockStatus), Asset.GetStockStatusText(_stockStatus));
                }

                // Asset Category / Tuype is the same thing
                if (_assetTypeID != oldObject._assetTypeID)
                {
                    AddChange(listChanges, ate, "Asset Type", oldObject.TypeAsString, this.TypeAsString);
                }

                // Make
                if (_make != oldObject._make)
                {
                    AddChange(listChanges, ate, "Make", oldObject._make, this._make);
                }

                // Model
                if (_model != oldObject._model)
                {
                    AddChange(listChanges, ate, "Model", oldObject._model, this._model);
                }

                // Serial
                if (_serial != oldObject._serial)
                {
                    AddChange(listChanges, ate, "Serial Number", oldObject._serial, this._serial);
                }


                // Add all of these changes to the Audit Trail
                foreach (AuditTrailEntry entry in listChanges)
                {
                    lwDataAccess.AuditTrailAdd(entry);
                }
            }

            // Return the constructed list
            return;
        }