public override void OnException(IDeleteRequestHandler handler, Exception exception) { if (exception is SqlException) { SqlExceptionHelper.HandleDeleteForeignKeyException(exception, handler.Context?.Localizer); } }
public override void OnBeforeDelete(IDeleteRequestHandler handler) { if (ReferenceEquals(null, Target) || (Target.Flags & FieldFlags.Updatable) != FieldFlags.Updatable) { return; } var idField = (handler.Row as IIdRow).IdField; var row = rowFactory(); var rowIdField = (row as IIdRow).IdField; var deleteHandler = deleteHandlerFactory(); var deleteList = new List <Int64>(); new SqlQuery() .Dialect(handler.Connection.GetDialect()) .From(row) .Select((Field)rowIdField) .Where(foreignKeyField == idField[handler.Row].Value) .ForEach(handler.Connection, () => { deleteList.Add(rowIdField[row].Value); }); foreach (var id in deleteList) { DeleteDetail(handler.UnitOfWork, id); } }
public override void OnBeforeDelete(IDeleteRequestHandler handler) { if (ReferenceEquals(null, Target) || (Target.Flags & FieldFlags.Updatable) != FieldFlags.Updatable) return; var idField = (handler.Row as IIdRow).IdField; var row = new NoteRow(); var fld = NoteRow.Fields; var deleteList = new List<Int64>(); new SqlQuery() .From(row) .Select(fld.NoteId) .Where( fld.EntityType == handler.Row.Table & fld.EntityId == idField[handler.Row].Value) .ForEach(handler.Connection, () => { deleteList.Add(row.NoteId.Value); }); foreach (var id in deleteList) DeleteNote(handler.UnitOfWork, id); }
public override void OnBeforeDelete(IDeleteRequestHandler handler) { foreach (var info in infoList) { if (!info.Attr.CascadeDelete) { continue; } var thisKey = info.ThisKeyField.AsObject(handler.Row); if (ReferenceEquals(null, thisKey)) { continue; } var oldID = GetExistingID(handler.Connection, info, thisKey); if (oldID == null) { continue; } var deleteHandler = DefaultHandlerFactory.DeleteHandlerFor(info.Attr.RowType); var deleteRequest = DefaultHandlerFactory.DeleteRequestFor(info.Attr.RowType); deleteRequest.EntityId = oldID; deleteHandler.Process(handler.UnitOfWork, deleteRequest); } }
public override void OnBeforeDelete(IDeleteRequestHandler handler) { foreach (var info in infoList) { if (!info.Attr.CascadeDelete) { continue; } var thisKey = info.ThisKeyField.AsObject(handler.Row); if (ReferenceEquals(null, thisKey)) { continue; } var oldID = GetExistingID(handler.Connection, info, thisKey); if (oldID == null) { continue; } info.DeleteHandlerFactory().Process(handler.UnitOfWork, new Services.DeleteRequest { EntityId = oldID }); } }
public override void OnBeforeDelete(IDeleteRequestHandler handler) { if (ReferenceEquals(null, Target) || (Target.Flags & FieldFlags.Updatable) != FieldFlags.Updatable) return; if (!attr.ForceCascadeDelete && ServiceQueryHelper.UseSoftDelete(handler.Row)) return; var row = rowFactory(); var rowIdField = (Field)((row as IIdRow).IdField); var deleteHandler = deleteHandlerFactory(); var deleteList = new List<object>(); new SqlQuery() .Dialect(handler.Connection.GetDialect()) .From(row) .Select((Field)rowIdField) .Where( foreignKeyField == new ValueCriteria(masterKeyField.AsObject(handler.Row)) & queryCriteria) .ForEach(handler.Connection, () => { deleteList.Add(rowIdField.AsObject(row)); }); foreach (var id in deleteList) DeleteDetail(handler.UnitOfWork, id); }
public override void OnBeforeDelete(IDeleteRequestHandler handler) { if (ReferenceEquals(null, Target) || (Target.Flags & FieldFlags.Updatable) != FieldFlags.Updatable) { return; } var idField = (handler.Row as IIdRow).IdField; var row = new NoteRow(); var fld = NoteRow.Fields; var deleteList = new List <Int64>(); new SqlQuery() .From(row) .Select(fld.NoteId) .Where( fld.EntityType == handler.Row.Table & fld.EntityId == idField[handler.Row].Value) .ForEach(handler.Connection, () => { deleteList.Add(row.NoteId.Value); }); foreach (var id in deleteList) { DeleteNote(handler.UnitOfWork, id); } }
public override void OnBeforeDelete(IDeleteRequestHandler handler) { foreach (var info in infoList) { if (!info.Attr.CascadeDelete) { continue; } var thisKey = info.ThisKeyField.AsObject(handler.Row); if (thisKey is null) { continue; } var oldID = GetExistingID(handler.Connection, info, thisKey); if (oldID == null) { continue; } var deleteHandler = handlerFactory.CreateHandler <IDeleteRequestProcessor>(info.Attr.RowType); var deleteRequest = deleteHandler.CreateRequest(); deleteRequest.EntityId = oldID; deleteHandler.Process(handler.UnitOfWork, deleteRequest); } }
public override void OnAudit(IDeleteRequestHandler handler) { if (handler.Row == null || captureLogHandler == null) return; captureLogHandler.LogDelete(handler.UnitOfWork, handler.Row, Authorization.UserId.TryParseID().Value); }
public override void OnBeforeDelete(IDeleteRequestHandler handler) { if (ReferenceEquals(null, Target) || (Target.Flags & FieldFlags.Updatable) != FieldFlags.Updatable) { return; } var idField = (Field)((handler.Row as IIdRow).IdField); var masterId = idField.AsObject(handler.Row); var row = rowFactory(); var rowIdField = (Field)((row as IIdRow).IdField); var deleteHandler = deleteHandlerFactory(); var deleteList = new List <object>(); new SqlQuery() .Dialect(handler.Connection.GetDialect()) .From(row) .Select(rowIdField) .WhereEqual(thisKeyField, masterId) .ForEach(handler.Connection, () => { deleteList.Add(rowIdField.AsObject(row)); }); foreach (var id in deleteList) { DeleteDetail(handler.UnitOfWork, id); } }
public override void OnBeforeDelete(IDeleteRequestHandler handler) { if (ServiceQueryHelper.UseSoftDelete(handler.Row)) { return; } var idField = (Field)((handler.Row as IIdRow).IdField); var localRow = localRowFactory(); var deleteList = new List <object>(); new SqlQuery() .Dialect(handler.Connection.GetDialect()) .From(localRow) .Select(localRowIdField) .Where( foreignKeyField == new ValueCriteria(idField.AsObject(handler.Row))) .ForEach(handler.Connection, () => { deleteList.Add(localRowIdField.AsObject(localRow)); }); foreach (var localId in deleteList) { DeleteLocalRow(handler.UnitOfWork, localId); } }
public override void OnBeforeDelete(IDeleteRequestHandler handler) { if (Target is null || (Target.Flags & FieldFlags.Updatable) != FieldFlags.Updatable) { return; } var idField = (handler.Row as IIdRow).IdField; var row = new NoteRow(); var fld = NoteRow.Fields; var deleteList = new List <long>(); new SqlQuery() .From(row) .Select(fld.NoteId) .Where( fld.EntityType == handler.Row.Table & fld.EntityId == Convert.ToInt64(idField.AsObject(handler.Row), CultureInfo.InvariantCulture)) .ForEach(handler.Connection, () => { deleteList.Add(row.NoteId.Value); }); foreach (var id in deleteList) { DeleteNote(handler.UnitOfWork, id); } }
public override void OnAudit(IDeleteRequestHandler handler) { var auditRequest = GetAuditDeleteRequest(handler); if (auditRequest != null) { AuditLogService.AuditDelete(handler.UnitOfWork.Connection, RowRegistry.GetConnectionKey(handler.Row), auditRequest); } }
public override void OnAudit(IDeleteRequestHandler handler) { if (handler.Row == null || captureLogHandler == null) { return; } captureLogHandler.LogDelete(handler.UnitOfWork, handler.Row, Authorization.UserId.TryParseID().Value); }
public override void OnAudit(IDeleteRequestHandler handler) { var auditRequest = GetAuditDeleteRequest(handler); if (auditRequest != null) { AuditLogService.AuditDelete(handler.UnitOfWork.Connection, handler.Row.GetFields().ConnectionKey, auditRequest); } }
public void OnValidateRequest(IDeleteRequestHandler handler) { var user = (UserDefinition)Authorization.UserDefinition; if (fldTenantId[handler.Row] != user.TenantId) { Authorization.ValidatePermission(PermissionKeys.Tenants); } }
public void OnValidateRequest(IDeleteRequestHandler handler) { var user = (UserDefinition)Authorization.UserDefinition; if (fldIdComercio[handler.Row] != user.Id_Comercio) { Authorization.ValidatePermission( PermissionKeys.Comercio); } }
public override void OnAudit(IDeleteRequestHandler handler) { if (handler.Row == null || captureLogHandler == null) return; Row newRow = null; // if row is not actually deleted, but set to deleted by a flag, log it as if it is an update operation if (handler.Row is IIsActiveDeletedRow) { newRow = handler.Row.Clone(); ((IIsActiveDeletedRow)newRow).IsActiveField[newRow] = -1; } captureLogHandler.Log(handler.UnitOfWork, handler.Row, newRow, Authorization.UserId); }
public override void OnAfterDelete(IDeleteRequestHandler handler) { if (handler.Row is IIsActiveDeletedRow || handler.Row is IDeleteLogRow) return; var field = (StringField)Target; var oldFilesJSON = field[handler.Row].TrimToNull(); var oldFileList = ParseAndValidate(oldFilesJSON, "oldFiles"); var filesToDelete = new FilesToDelete(); UploadHelper.RegisterFilesToDelete(handler.UnitOfWork, filesToDelete); foreach (var file in oldFileList) DeleteOldFile(filesToDelete, file.Filename); }
public override void OnAfterDelete(IDeleteRequestHandler handler) { if (handler.Row is IIsActiveDeletedRow || handler.Row is IDeleteLogRow) { return; } var filename = (StringField)(Target); var oldFilename = filename[handler.Row]; var filesToDelete = new FilesToDelete(); UploadHelper.RegisterFilesToDelete(handler.UnitOfWork, filesToDelete); DeleteOldFile(filesToDelete, oldFilename); }
public override void OnAudit(IDeleteRequestHandler handler) { if (handler.Row == null || captureLogHandler == null) { return; } Row newRow = null; // if row is not actually deleted, but set to deleted by a flag, log it as if it is an update operation if (handler.Row is IIsActiveDeletedRow) { newRow = handler.Row.Clone(); ((IIsActiveDeletedRow)newRow).IsActiveField[newRow] = -1; } captureLogHandler.Log(handler.UnitOfWork, handler.Row, newRow, Authorization.UserId); }
public override void OnAfterDelete(IDeleteRequestHandler handler) { if (ServiceQueryHelper.UseSoftDelete(handler.Row)) { return; } var field = (StringField)Target; var oldFilesJSON = field[handler.Row].TrimToNull(); var oldFileList = ParseAndValidate(oldFilesJSON, "oldFiles"); var filesToDelete = new FilesToDelete(); UploadHelper.RegisterFilesToDelete(handler.UnitOfWork, filesToDelete); foreach (var file in oldFileList) { DeleteOldFile(filesToDelete, file.Filename); } }
protected AuditDeleteRequest GetAuditDeleteRequest(IDeleteRequestHandler handler) { var idField = ((IIdRow)handler.Row).IdField; var auditRequest = new AuditDeleteRequest(handler.Row.Table, idField[handler.Row].Value); var parentIdRow = handler.Row as IParentIdRow; if (parentIdRow != null) { var parentIdField = (Field)parentIdRow.ParentIdField; //EntityType parentEntityType; if (!parentIdField.ForeignTable.IsNullOrEmpty()) //SiteSchema.Instance.TableToType.TryGetValue(parentIdField.ForeignTable, out parentEntityType)) { auditRequest.ParentTypeId = parentIdField.ForeignTable; auditRequest.ParentId = parentIdRow.ParentIdField[handler.Row]; } } return auditRequest; }
protected AuditDeleteRequest GetAuditDeleteRequest(IDeleteRequestHandler handler) { var idField = ((IIdRow)handler.Row).IdField; var auditRequest = new AuditDeleteRequest(handler.Row.Table, idField[handler.Row].Value); var parentIdRow = handler.Row as IParentIdRow; if (parentIdRow != null) { var parentIdField = (Field)parentIdRow.ParentIdField; //EntityType parentEntityType; if (!parentIdField.ForeignTable.IsNullOrEmpty()) //SiteSchema.Instance.TableToType.TryGetValue(parentIdField.ForeignTable, out parentEntityType)) { auditRequest.ParentTypeId = parentIdField.ForeignTable; auditRequest.ParentId = parentIdRow.ParentIdField[handler.Row]; } } return(auditRequest); }
public override void OnAudit(IDeleteRequestHandler handler) { if (handler.Row == null) { return; } IRow newRow = null; // if row is not actually deleted, but set to deleted by a flag, log it as if it is an update operation if (handler.Row is IIsActiveDeletedRow) { newRow = handler.Row.Clone(); ((IIsActiveDeletedRow)newRow).IsActiveField[newRow] = -1; } else if (handler.Row is IIsDeletedRow) { newRow = handler.Row.Clone(); ((IIsDeletedRow)newRow).IsDeletedField[newRow] = true; } Log(handler.UnitOfWork, handler.Row, newRow, handler.Context.User?.GetIdentifier()); }
public override void OnBeforeDelete(IDeleteRequestHandler handler) { if (Target is null || (Target.Flags & FieldFlags.Updatable) != FieldFlags.Updatable) { return; } if (!attr.ForceCascadeDelete && ServiceQueryHelper.UseSoftDelete(handler.Row)) { return; } var idField = handler.Row.IdField; var masterId = idField.AsObject(handler.Row); var row = rowFactory(); var rowIdField = row.IdField; var deleteList = new List <object>(); new SqlQuery() .Dialect(handler.Connection.GetDialect()) .From(row) .Select(rowIdField) .Where( thisKeyField == new ValueCriteria(masterId) & queryCriteria) .ForEach(handler.Connection, () => { deleteList.Add(rowIdField.AsObject(row)); }); foreach (var id in deleteList) { DeleteDetail(handler.UnitOfWork, id); } }
public override void OnBeforeDelete(IDeleteRequestHandler handler) { if (ReferenceEquals(null, Target) || (Target.Flags & FieldFlags.Updatable) != FieldFlags.Updatable) { return; } if (handler.Row is IIsActiveDeletedRow) { return; } var idField = (Field)((handler.Row as IIdRow).IdField); var row = rowFactory(); var rowIdField = (Field)((row as IIdRow).IdField); var deleteHandler = deleteHandlerFactory(); var deleteList = new List <object>(); new SqlQuery(handler.Connection.GetDialect()) .From(row) .Select((Field)rowIdField) .Where( foreignKeyField == new ValueCriteria(idField.AsObject(handler.Row)) & filterCriteriaT0) .ForEach(handler.Connection, () => { deleteList.Add(rowIdField.AsObject(row)); }); foreach (var id in deleteList) { DeleteDetail(handler.UnitOfWork, id); } }
public void OnPrepareQuery(IDeleteRequestHandler handler, SqlQuery query) { }
public void OnBeforeDelete(IDeleteRequestHandler handler) { }
public void OnAudit(IDeleteRequestHandler handler) { InsertNewLog(handler.Row, null, AuditActionType.Delete); }
public void OnAfterDelete(IDeleteRequestHandler handler) { }
public virtual void OnReturn(IDeleteRequestHandler handler) { }
public override void OnBeforeDelete(IDeleteRequestHandler handler) { if (ReferenceEquals(null, Target) || (Target.Flags & FieldFlags.Updatable) != FieldFlags.Updatable) return; if (handler.Row is IIsActiveDeletedRow) return; var idField = (Field)((handler.Row as IIdRow).IdField); var masterId = idField.AsObject(handler.Row); var row = rowFactory(); var rowIdField = (Field)((row as IIdRow).IdField); var deleteHandler = deleteHandlerFactory(); var deleteList = new List<object>(); new SqlQuery() .Dialect(handler.Connection.GetDialect()) .From(row) .Select(rowIdField) .Where( thisKeyField == new ValueCriteria(masterId) & filterCriteriaT0) .ForEach(handler.Connection, () => { deleteList.Add(rowIdField.AsObject(row)); }); foreach (var id in deleteList) DeleteDetail(handler.UnitOfWork, id); }
public virtual void OnAudit(IDeleteRequestHandler handler) { }
public static DeleteRequest CreateRequest(this IDeleteRequestHandler handler) { return((DeleteRequest)Activator.CreateInstance(handler.GetRequestType())); }
public virtual void OnBeforeDelete(IDeleteRequestHandler handler) { }
public void OnValidateRequest(IDeleteRequestHandler handler) { var user = (UserDefinition)Authorization.UserDefinition; if (fldTenantId[handler.Row] != user.TenantId) Authorization.ValidatePermission(PermissionKeys.Tenants); }
public virtual void OnAfterDelete(IDeleteRequestHandler handler) { }
public virtual void OnValidateRequest(IDeleteRequestHandler handler) { }
public void OnReturn(IDeleteRequestHandler handler) { }
public override void OnBeforeDelete(IDeleteRequestHandler handler) { if (ReferenceEquals(null, Target) || (Target.Flags & FieldFlags.Updatable) != FieldFlags.Updatable) return; var idField = (handler.Row as IIdRow).IdField; var row = rowFactory(); var rowIdField = (row as IIdRow).IdField; var deleteHandler = deleteHandlerFactory(); var deleteList = new List<Int64>(); new SqlQuery() .From(row) .Select((Field)rowIdField) .Where(foreignKeyField == idField[handler.Row].Value) .ForEach(handler.Connection, () => { deleteList.Add(rowIdField[row].Value); }); foreach (var id in deleteList) DeleteDetail(handler.UnitOfWork, id); }
public void OnValidateRequest(IDeleteRequestHandler handler) { }
public override void OnAudit(IDeleteRequestHandler handler) { var auditRequest = GetAuditDeleteRequest(handler); if (auditRequest != null) AuditLogService.AuditDelete(handler.UnitOfWork.Connection, RowRegistry.GetConnectionKey(handler.Row), auditRequest); }
public override void OnBeforeDelete(IDeleteRequestHandler handler) { foreach (var info in infoList) { if (!info.Attr.CascadeDelete) continue; var thisKey = info.ThisKeyField.AsObject(handler.Row); if (ReferenceEquals(null, thisKey)) continue; var oldID = GetExistingID(handler.Connection, info, thisKey); if (oldID == null) continue; info.DeleteHandlerFactory().Process(handler.UnitOfWork, new Services.DeleteRequest { EntityId = oldID }); } }
public override void OnAfterDelete(IDeleteRequestHandler handler) { if (handler.Row is IIsActiveDeletedRow || handler.Row is IDeleteLogRow) return; var filename = (StringField)(Target); var oldFilename = filename[handler.Row]; var filesToDelete = new FilesToDelete(); UploadHelper.RegisterFilesToDelete(handler.UnitOfWork, filesToDelete); DeleteOldFile(filesToDelete, oldFilename); }
public void OnAudit(IDeleteRequestHandler handler) { }
public virtual void OnPrepareQuery(IDeleteRequestHandler handler, SqlQuery query) { }