コード例 #1
0
        /// <summary>
        /// Add record to AuditTrail. Delete or Recover action on a Table
        /// </summary>
        /// <param name="recordId">RecordId which was modified</param>
        /// <param name="recordVersionNo">Record Version o</param>
        /// <param name="updatedBy">Modified By</param>
        /// <param name="operation">Delete or Recover operation</param>
        /// <returns>true if success, False if fail</returns>
        public bool Add(object recordId, int?recordVersionNo, object updatedBy, RecordOperationEnum operation)
        {
            if (operation != RecordOperationEnum.Delete && operation != RecordOperationEnum.Recover)
            {
                throw new InvalidOperationException("Invalid call to this method. This method shall be call for Delete and Recover operation only.");
            }

            CreateTableIfNotExist();

            AuditTrail audit = new AuditTrail
            {
                OperationType   = operation,
                RecordId        = recordId.ToString(),
                RecordVersionNo = (recordVersionNo ?? 0) + 1,
                TableName       = entityTableInfo.Name,
                CreatedBy       = updatedBy
            };

            audit.AppendDetail(Config.ISACTIVE_COLUMN.Name, !(operation == RecordOperationEnum.Delete), DbType.Boolean, (operation == RecordOperationEnum.Delete));
            audit.Details = audit.GenerateString();

            Add(audit);

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Add record to AuditTrail. Insert or Update action on a Table
        /// </summary>
        /// <param name="entity">Entity which was modified</param>
        /// <param name="operation">Insert or Update operation</param>
        /// <param name="audit">Audit Trail object of type IAuditTrail</param>
        /// <returns>true if success, False if fail</returns>
        public bool Add(Entity entity, RecordOperationEnum operation, IAuditTrail audit)
        {
            CreateTableIfNotExist();

            AuditTrail auditTrail = (AuditTrail)audit;

            auditTrail.OperationType = operation;
            //Remove EntityBase 12-Apr-19
            auditTrail.RecordId = entityTableInfo.GetKeyId(entity).ToString();
            //Remove EntityBase 12-Apr-19
            if (!entityTableInfo.NoVersionNo)
            {
                auditTrail.RecordVersionNo = (operation == RecordOperationEnum.Insert ? 1 : entityTableInfo.GetVersionNo(entity)); //always 1 for new insert
            }
            auditTrail.TableName    = entityTableInfo.Name;
            auditTrail.Details      = auditTrail.GenerateString();
            auditTrail.AuditTrailId = (long)Add(auditTrail);

            return(true);
        }