Example #1
0
        //for delete & restore
        internal bool Add(object recordId, int recordVersionNo, object updatedBy, RecordOperationEnum operation, TableAttribute tableInfo)
        {
            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();

            AuditTrial audit = new AuditTrial
            {
                OperationType   = operation,
                RecordId        = recordId.ToString(),
                RecordVersionNo = recordVersionNo + 1,
                TableName       = tableInfo.Name,
                CreatedBy       = updatedBy
            };

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

            Add(audit);

            return(true);
        }
Example #2
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();

            AuditTrailKeyValue audit = new AuditTrailKeyValue
            {
                OperationType       = operation,
                RecordId            = recordId.ToString(),
                RecordVersionNo     = (recordVersionNo ?? 0) + 1,
                TableName           = entityTableInfo.Name,
                CreatedBy           = updatedBy,
                lstAuditTrailDetail = new List <IAuditTrailDetail>()
                {
                    new AuditTrailKeyValueDetail()
                    {
                        ColumnName = Config.ISACTIVE_COLUMN.Name,
                        ColumnType = (int)DbType.Boolean,
                        OldValue   = (operation == RecordOperationEnum.Delete).ToString(),
                        NewValue   = (!(operation == RecordOperationEnum.Delete)).ToString()
                    }
                }
            };

            return(AddAuditTrail(audit));
        }
Example #3
0
        internal bool Add(EntityBase entity, RecordOperationEnum operation, TableAttribute tableInfo, AuditTrial audit)
        {
            CreateTableIfNotExist();

            audit.OperationType   = operation;
            audit.RecordId        = entity.KeyId.ToString();
            audit.RecordVersionNo = (operation == RecordOperationEnum.Insert ? 1 : entity.VersionNo); //always 1 for new insert
            audit.TableName       = tableInfo.Name;
            audit.Details         = audit.GenerateString();

            audit.KeyId = Add(audit);

            return(true);
        }
Example #4
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();

            audit.OperationType = operation;
            audit.RecordId      = entityTableInfo.GetKeyId(entity).ToString();
            if (!entityTableInfo.NoVersionNo)
            {
                audit.RecordVersionNo = (operation == RecordOperationEnum.Insert ? 1 : entityTableInfo.GetVersionNo(entity)); //always 1 for new insert
            }
            audit.TableName = entityTableInfo.Name;

            return(AddAuditTrail((AuditTrailKeyValue)audit));
        }
Example #5
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);
        }