public void Fire(TableEvent tableEvent, IRequest context) { var oldState = GetOldState(context); try { var triggerType = TriggerInfo.TriggerType; var tableName = tableEvent.Table.TableInfo.TableName; context.Context.OnEvent(new TriggerEvent(triggerType, Name, tableName, tableEvent.EventTime, tableEvent.EventType, tableEvent.OldRowId, tableEvent.NewRow)); var newState = new OldNewTableState(tableName, tableEvent.OldRowId.RowNumber, tableEvent.NewRow, tableEvent.EventTime == TriggerEventTime.Before); SetState(context, newState); using (var block = context.CreateBlock()) { FireTrigger(tableEvent, block); } } catch (TriggerException) { throw; } catch (Exception ex) { throw new TriggerException(String.Format("An unknown error occurred while executing trigger '{0}'.", Name), ex); } finally { SetState(context, oldState); } }
protected override void FireTrigger(TableEvent tableEvent, IBlock context) { var e = new TriggerEvent(TriggerType.Callback, TriggerInfo.TriggerName, tableEvent.Table.TableInfo.TableName, tableEvent.EventTime, tableEvent.EventType, tableEvent.OldRowId, tableEvent.NewRow); context.Context.RegisterEvent(e); }
public void FireTriggers(IRequest context, TableEvent tableEvent) { foreach (var trigger in triggers.Values) { if (trigger.CanFire(tableEvent)) trigger.Fire(tableEvent, context); } }
public void Invoke(IQuery context, TableEvent tableEvent) { var isBefore = (tableEvent.EventType & TriggerEventType.Before) != 0; var transaction = context.Session.Transaction; if (transaction is ITableStateHandler) { var stateHandler = (ITableStateHandler)transaction; var oldState = stateHandler.TableState; var newState = new OldNewTableState(tableEvent.Table.FullName, tableEvent.OldRowId.RowNumber, tableEvent.NewRow, isBefore); stateHandler.SetTableState(newState); try { FireTrigger(context, tableEvent); } finally { stateHandler.SetTableState(oldState); } } else { FireTrigger(context, tableEvent); } }
public static void FireTriggers(this IQuery context, TableEvent tableEvent) { var manager = context.Session.Transaction.GetTriggerManager(); if (manager == null) return; manager.FireTriggers(context, tableEvent); }
protected override void FireTrigger(TableEvent tableEvent, IBlock context) { // TODO: Should pass arguments? try { Body.Execute(new ExecutionContext(context, Body)); } catch (Exception ex) { throw new TriggerException(this, ex); } }
private void NotifyTriggerEvent(IQuery context, TableEvent tableEvent) { var tableName = tableEvent.Table.FullName; var eventType = tableEvent.EventType; var triggerEvent = new TriggerEvent(context.Session, TriggerName, tableName, eventType, tableEvent.OldRowId, tableEvent.NewRow); // TODO: context.RegisterEvent(triggerEvent); }
public bool CanFire(TableEvent tableEvent) { if (!TableName.Equals(tableEvent.Table.TableInfo.TableName)) { return(false); } return(MatchesEvent(tableEvent.EventTime, tableEvent.EventType)); }
public void FireTriggers(IRequest context, TableEvent tableEvent) { foreach (var trigger in triggers.Values) { if (trigger.CanFire(tableEvent)) { trigger.Fire(tableEvent, context); } } }
private void FireTrigger(IQuery context, TableEvent tableEvent) { if (TriggerType == TriggerType.Callback) { NotifyTriggerEvent(context, tableEvent); } else { ExecuteProcedure(context); } }
public static void FireTriggers(this IQuery context, TableEvent tableEvent) { var manager = context.Session.Transaction.GetTriggerManager(); if (manager == null) { return; } manager.FireTriggers(context, tableEvent); }
public static void FireTriggers(this IContext context, IRequest request, TableEvent tableEvent) { var current = context; while (current != null) { if (current is ITriggerScope) { var scope = (ITriggerScope)current; scope.TriggerManager.FireTriggers(request, tableEvent); } current = current.Parent; } }
public bool CanInvoke(TableEvent context) { if ((TriggerInfo.EventType & context.EventType) == 0) { return(false); } var tableName = context.Table.TableInfo.TableName; return(TriggerInfo.TableName == null || TriggerInfo.TableName.Equals(tableName, true)); }
protected override void FireTrigger(TableEvent tableEvent, IBlock context) { var procedure = context.Access().GetObject(DbObjectType.Routine, ProcedureName) as IProcedure; if (procedure == null) throw new TriggerException(String.Format("The procedure '{0}' was not found.", ProcedureName)); var invoke = new Invoke(ProcedureName, Arguments); try { procedure.Execute(new InvokeContext(invoke, procedure, null, null, context)); } catch (Exception ex) { throw new TriggerException(String.Format("Error while invoking '{0}'.",invoke), ex); } }
protected override void FireTrigger(TableEvent tableEvent, IBlock context) { var procedure = context.Access().GetObject(DbObjectType.Routine, ProcedureName) as IProcedure; if (procedure == null) { throw new TriggerException(String.Format("The procedure '{0}' was not found.", ProcedureName)); } var invoke = new Invoke(ProcedureName, Arguments); try { procedure.Execute(new InvokeContext(invoke, procedure, null, null, context)); } catch (Exception ex) { throw new TriggerException(String.Format("Error while invoking '{0}'.", invoke), ex); } }
public void FireTriggers(IQuery context, TableEvent tableEvent) { if (!transaction.TableExists(SystemSchema.TriggerTableName)) { return; } BuildTriggerCache(); foreach (var trigger in triggerCache) { if (trigger.CanInvoke(tableEvent)) { trigger.Invoke(context, tableEvent); } } }
public void FireTriggers(IRequest context, TableEvent tableEvent) { if (!transaction.TableExists(TriggerTableName)) { return; } BuildTriggerCache(); foreach (var trigger in triggerCache) { try { if (trigger.CanFire(tableEvent)) { trigger.Fire(tableEvent, context); } } catch (TriggerException) { throw; } catch (Exception ex) { throw new TriggerException(trigger, ex); } } }
public void FireTriggers(IRequest context, TableEvent tableEvent) { if (!transaction.TableExists(TriggerTableName)) return; BuildTriggerCache(); foreach (var trigger in triggerCache) { try { if (trigger.CanFire(tableEvent)) trigger.Fire(tableEvent, context); } catch(TriggerException) { throw; } catch (Exception ex) { throw new TriggerException(trigger, ex); } } }
public void Invoke(IQuery context, TableEvent tableEvent) { var isBefore = (tableEvent.EventType & TriggerEventType.Before) != 0; var transaction = context.Session.Transaction; if (transaction is ITableStateHandler) { var stateHandler = (ITableStateHandler) transaction; var oldState = stateHandler.TableState; var newState = new OldNewTableState(tableEvent.Table.FullName, tableEvent.OldRowId.RowNumber, tableEvent.NewRow, isBefore); stateHandler.SetTableState(newState); try { FireTrigger(context, tableEvent); } finally { stateHandler.SetTableState(oldState); } } else { FireTrigger(context, tableEvent); } }
protected abstract void FireTrigger(TableEvent tableEvent, IBlock context);
public bool CanInvoke(TableEvent context) { if ((TriggerInfo.EventType & context.EventType) == 0) return false; var tableName = context.Table.TableInfo.TableName; return TriggerInfo.TableName == null || TriggerInfo.TableName.Equals(tableName, true); }
public bool CanFire(TableEvent tableEvent) { return TriggerInfo.CanFire(tableEvent); }
public bool CanFire(TableEvent tableEvent) { return(TriggerInfo.CanFire(tableEvent)); }
public bool CanFire(TableEvent tableEvent) { if (!TableName.Equals(tableEvent.Table.TableInfo.TableName)) return false; return MatchesEvent(tableEvent.EventTime, tableEvent.EventType); }
public void FireTriggers(IQuery context, TableEvent tableEvent) { if (!transaction.TableExists(SystemSchema.TriggerTableName)) return; BuildTriggerCache(); foreach (var trigger in triggerCache) { if (trigger.CanInvoke(tableEvent)) trigger.Invoke(context, tableEvent); } }