コード例 #1
0
ファイル: SecurityManager.cs プロジェクト: priaonehaha/HnD
        /// <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());
        }
コード例 #2
0
ファイル: SecurityManager.cs プロジェクト: priaonehaha/HnD
        /// <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();
        }