Relatude Help

Transaction plugins and jobs

TransactionPlugin<T>() registers a NodeTransactionPlugin, created with the application's services. A write reaches it in one of two forms, and a rule about values must check both: the whole node (OnBeforeNodeAction: an insert, an update, an upsert), or some of its properties (OnBeforePropertyAction). The CMS interface saves the second way, sending only what changed.

public sealed class EventPagePlugin : NodeTransactionPlugin<IEventPage> {
    public override void OnBeforeNodeAction(NodeKey key, NodeOperation operation, Transaction transaction,
            NodeHelper<IEventPage> helper) {
        if (operation is NodeOperation.DeleteOrFail or NodeOperation.DeleteIfExists
            or NodeOperation.ReIndex or NodeOperation.ChangeType) return;     // no values to check
        var e = helper.GetNode();
        …
    }

    public override void OnBeforePropertyAction(NodeKey key, Guid[] propertyIds, NodePropertyOperation operation,
            object[]? values, Transaction transaction, PropertyHelper<IEventPage> helper) {
        var startsId = helper.GetPropertyId(e => e.StartsUtc);         // values[i] goes to propertyIds[i]
        var stored = helper.GetNodes([key.Guid]).FirstOrDefault();     // the other values, as stored
        …
    }
}

Job(name, description, run) registers a job, which an administrator schedules or runs by hand in the admin UI (Tasks › Scheduler). run gets the CmsModuleContext and a JobContext, whose Report(text) says what the run did. While the module is not active, a run does nothing and reports why.