Exemplo n.º 1
0
 public string DeleteChanges(EntityRecord entityRecord, IDictionary<string, object> existingRecord)
 {
     var display = entityRecord.ToString();
     var joinedKeyValue = "#" + entityRecord.JoinedKeysValues;
     if (display != joinedKeyValue)
     {
         display += " ({0})".Fill(joinedKeyValue);
     }
     return "Deleted " + display;
 }
Exemplo n.º 2
0
 public string CreateChanges(EntityRecord entityRecord)
 {
     var display = entityRecord.ToString();
     var joinedKeyValue = "#" + entityRecord.JoinedKeysValues;
     if (display != joinedKeyValue)
     {
         display += " ({0})".Fill(joinedKeyValue);
     }
     return "Created " + display;
 }
Exemplo n.º 3
0
        public string DeleteChanges(EntityRecord entityRecord, IDictionary <string, object> existingRecord)
        {
            var display        = entityRecord.ToString();
            var joinedKeyValue = "#" + entityRecord.JoinedKeysValues;

            if (display != joinedKeyValue)
            {
                display += " ({0})".Fill(joinedKeyValue);
            }
            return("Deleted " + display);
        }
Exemplo n.º 4
0
        public string CreateChanges(EntityRecord entityRecord)
        {
            var display        = entityRecord.ToString();
            var joinedKeyValue = "#" + entityRecord.JoinedKeysValues;

            if (display != joinedKeyValue)
            {
                display += " ({0})".Fill(joinedKeyValue);
            }
            return("Created " + display);
        }
Exemplo n.º 5
0
        private void AccessDenied(AccessType accessType, EntityRecord record, EntityMemberInfo member = null)
        {
            if (!MustThrowOnDenied(accessType))
            {
                return;
            }
            var msg = StringHelper.SafeFormat("Actions(s) [{0}] denied for record {1}, user {2}",
                                              accessType, record.ToString(), Context.User);

            if (member != null)
            {
                msg += "(Property " + member.MemberName + ")";
            }
            var authEx = new AuthorizationException(msg, record.EntityInfo.EntityType, accessType, true, record.UserPermissions, this);

            throw authEx;
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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;
        }