Ejemplo n.º 1
0
        private DbCommand CreateChangeCommand(
            EntityRecord entityRecord,
            EntityChangeType changeType,
            string keyValue,
            Func <string> changeDescriber = null)
        {
            if (changeType == EntityChangeType.Insert)
            {
                entityRecord.SetKeyValue(keyValue);
            }

            var cmd = DB.CreateCommand(_admin.ConnectionStringName);

            var changeEntity        = _admin.ChangeEntity;
            var table               = changeEntity.Table;
            var entityNameColumn    = changeEntity["EntityName"].Column;
            var entityKeyColumn     = changeEntity["EntityKey"].Column;
            var changeTypeColumn    = changeEntity["ChangeType"].Column;
            var recordDisplayColumn = changeEntity["RecordDisplayName"].Column;
            var descriptionColumn   = changeEntity["Description"].Column;
            var changedOnColumn     = changeEntity["ChangedOn"].Column;
            var changedByColumn     = changeEntity["ChangedBy"].Column;

            var sql =
                $@"INSERT INTO {table} ({entityNameColumn}, {entityKeyColumn}, {changeTypeColumn}, {recordDisplayColumn}, {descriptionColumn}, {changedOnColumn}, {changedByColumn})
VALUES (@0,@1,@2,@3,@4,@5,@6);";

            cmd.AddParam(entityRecord.Entity.Name);
            cmd.AddParam(keyValue);
            cmd.AddParam(changeType);
            cmd.AddParam(entityRecord.ToString());
            cmd.AddParam(changeDescriber == null ? null : changeDescriber());
            cmd.AddParam(DateTime.UtcNow);
            cmd.AddParam(_user.CurrentUserName());

            cmd.CommandText = sql;

            return(cmd);
        }
Ejemplo n.º 2
0
        private DbCommand CreateChangeCommand(
            EntityRecord entityRecord,
            EntityChangeType changeType,
            string keyValue,
            Func<string> changeDescriber = null)
        {
            if(changeType == EntityChangeType.Insert)
            {
                entityRecord.SetKeyValue(keyValue);
            }

            var cmd = DB.CreateCommand(_admin.ConnectionStringName);

            var changeEntity = _admin.ChangeEntity;
            var table = changeEntity.Table;
            var entityNameColumn = changeEntity["EntityName"].Column;
            var entityKeyColumn = changeEntity["EntityKey"].Column;
            var changeTypeColumn = changeEntity["ChangeType"].Column;
            var recordDisplayColumn = changeEntity["RecordDisplayName"].Column;
            var descriptionColumn = changeEntity["Description"].Column;
            var changedOnColumn = changeEntity["ChangedOn"].Column;
            var changedByColumn = changeEntity["ChangedBy"].Column;

            var sql =
$@"INSERT INTO {table} ({entityNameColumn}, {entityKeyColumn}, {changeTypeColumn}, {recordDisplayColumn}, {descriptionColumn}, {changedOnColumn}, {changedByColumn})
VALUES (@0,@1,@2,@3,@4,@5,@6);";

            cmd.AddParam(entityRecord.Entity.Name);
            cmd.AddParam(keyValue);
            cmd.AddParam(changeType);
            cmd.AddParam(entityRecord.ToString());
            cmd.AddParam(changeDescriber == null ? null : changeDescriber());
            cmd.AddParam(DateTime.UtcNow);
            cmd.AddParam(_user.CurrentUserName());

            cmd.CommandText = sql;

            return cmd;
        }