/// <summary>Creates a new, empty AuditDataMessageRelatedEntity object.</summary> /// <returns>A new, empty AuditDataMessageRelatedEntity object.</returns> public override IEntity Create() { IEntity toReturn = new AuditDataMessageRelatedEntity(); // __LLBLGENPRO_USER_CODE_REGION_START CreateNewAuditDataMessageRelated // __LLBLGENPRO_USER_CODE_REGION_END return(toReturn); }
/// <summary> /// Audits the alternation of a message by the specified user /// </summary> /// <param name="userID">User ID.</param> /// <param name="messageID">Message ID.</param> /// <returns></returns> public static bool AuditAlteredMessage(int userID, int messageID) { AuditDataMessageRelatedEntity toLog = new AuditDataMessageRelatedEntity(); toLog.AuditActionID = (int)AuditActions.AuditAlteredMessage; toLog.UserID = userID; toLog.AuditedOn = DateTime.Now; toLog.MessageID = messageID; return(toLog.Save()); }
/// <summary> /// Audits the alternation of a message by the specified user /// </summary> /// <param name="userId">User ID.</param> /// <param name="messageId">Message ID.</param> /// <returns></returns> public static async Task <bool> AuditAlteredMessageAsync(int userId, int messageId) { using (var adapter = new DataAccessAdapter()) { var toLog = new AuditDataMessageRelatedEntity { AuditActionID = (int)AuditActions.AuditAlteredMessage, UserID = userId, AuditedOn = DateTime.Now, MessageID = messageId }; return(await adapter.SaveEntityAsync(toLog).ConfigureAwait(false)); } }
/// <summary> /// Audits the approval of an attachment. We'll log the approval of an attachment with the messageid, as attachments are stored related to a message. /// </summary> /// <param name="userID">The user ID.</param> /// <param name="attachmentID">The attachment ID.</param> public static bool AuditApproveAttachment(int userID, int attachmentID) { AuditDataMessageRelatedEntity toLog = new AuditDataMessageRelatedEntity(); AttachmentCollection collection = new AttachmentCollection(); // use a scalar query to obtain the message id so we don't have to pull it completely in memory. An attachment can be big in size so we don't want to // read the entity to just read the messageid. We could use excluding fields to avoid the actual attachment data, but this query is really simple. // this query will return 1 value directly from the DB, so it won't read all attachments first into memory. int messageID = (int)collection.GetScalar(AttachmentFieldIndex.MessageID, null, AggregateFunction.None, (AttachmentFields.AttachmentID == attachmentID)); toLog.AuditActionID = (int)AuditActions.AuditApproveAttachment; toLog.UserID = userID; toLog.MessageID = messageID; toLog.AuditedOn = DateTime.Now; return(toLog.Save()); }
private void rptAudits_ItemDataBound(object sender, RepeaterItemEventArgs e) { switch (e.Item.ItemType) { case ListItemType.AlternatingItem: case ListItemType.Item: AuditDataCoreEntity auditCore = (AuditDataCoreEntity)e.Item.DataItem; Label lblAuditAction = (Label)e.Item.FindControl("lblAuditAction"); lblAuditAction.Text = ((AuditActions)auditCore.AuditActionID).ToString(); Label lblAuditDateTime = (Label)e.Item.FindControl("lblAuditDateTime"); lblAuditDateTime.Text = auditCore.AuditedOn.ToString("dd-MMM-yyyy HH:mm:ss"); HyperLink infoLink = (HyperLink)e.Item.FindControl("lnkAdditionalInfoLink"); switch ((AuditActions)auditCore.AuditActionID) { case AuditActions.AuditNewMessage: case AuditActions.AuditAlteredMessage: case AuditActions.AuditApproveAttachment: AuditDataMessageRelatedEntity auditMessageData = auditCore as AuditDataMessageRelatedEntity; if (auditMessageData != null) { // convert the link into a link to the message in question. infoLink.Visible = true; infoLink.NavigateUrl = "../GotoMessage.aspx?ThreadID=" + auditMessageData.Message.ThreadID + "&MessageID=" + auditMessageData.MessageID; infoLink.Text = "Message in thread: '" + auditMessageData.Message.Thread.Subject + "'"; } break; case AuditActions.AuditEditMemo: case AuditActions.AuditNewThread: AuditDataThreadRelatedEntity auditThreadData = auditCore as AuditDataThreadRelatedEntity; if (auditThreadData != null) { infoLink.Visible = true; infoLink.NavigateUrl = "../Messages.aspx?ThreadID=" + auditThreadData.ThreadID; infoLink.Text = "Thread: '" + auditThreadData.Thread.Subject + "'"; } break; case AuditActions.AuditLogin: break; } break; } }
/// <summary> /// Audits the approval of an attachment. We'll log the approval of an attachment with the messageid, as attachments are stored related to a message. /// </summary> /// <param name="userId">The user ID.</param> /// <param name="attachmentId">The attachment ID.</param> public static async Task <bool> AuditApproveAttachmentAsync(int userId, int attachmentId) { using (var adapter = new DataAccessAdapter()) { // use a scalar query to obtain the message id so we don't have to pull it completely in memory. An attachment can be big in size so we don't want to // read the entity to just read the messageid. We could use excluding fields to avoid the actual attachment data, but this query is really simple. // this query will return 1 value directly from the DB, so it won't read all attachments first into memory. var q = new QueryFactory().Attachment.Where(AttachmentFields.AttachmentID.Equal(attachmentId)).Select(AttachmentFields.MessageID); var messageID = await adapter.FetchScalarAsync <int>(q); var toLog = new AuditDataMessageRelatedEntity { AuditActionID = (int)AuditActions.AuditApproveAttachment, UserID = userId, MessageID = messageID, AuditedOn = DateTime.Now }; var toReturn = await adapter.SaveEntityAsync(toLog).ConfigureAwait(false); return(toReturn); } }