NotificationAction Enumeration

Assembly: CodeEffects.Rule.Repository.dll
Namespace: CodeEffects.Rule.Repository.Common

Summary

Specifies what happened in a notification that the Rule Repository raises through the Notify delegate of your configuration: approval requested, declined, or granted, and a rule or source version made live or taken offline.

Syntax

public enum NotificationAction
{
	// Not a notification. Never raised
	Undefined = 0,

	// Approval to put a rule version into production was requested
	ApprovalRequested = 1,

	// A request for approval was declined
	ApprovalDeclined = 2,

	// A rule version was made live
	RuleVersionMadeLive = 3,

	// A rule's live version was taken offline
	RuleVersionTakenOffline = 4,

	// A source version was made live in the repository by a person
	SourceVersionMadeLive = 5,

	// A source object's live version was taken offline by a person
	SourceVersionTakenOffline = 6,

	// A request for approval was approved: the version may go live
	ApprovalGranted = 7
}

Remarks

The repository raises a notification by calling the NotificationDelegate that you set as IRepositoryConfiguration.Notify. The delegate receives a NotificationAction that says what happened and a NotificationData that carries what you need to tell the right people.

The repository keeps no list of who should hear about what. Your application knows its users, their permissions, and how to reach them, so you decide who is told about each action and how. The delegate is called after the change is committed, on the thread of the request. An exception that it throws is ignored.

Member Who you would usually tell Members of NotificationData that apply
ApprovalRequested The users who may approve it, those who hold ActionPermissionType.RuleVersionApproveAndDecline The rule, rule version, and source members
ApprovalDeclined The user who asked Also Reason, when the person who declined said why
ApprovalGranted The user who asked, and those who may make the version live The rule, rule version, and source members
RuleVersionMadeLive Anyone who follows the rule Also ReplacedVersionId, the rule version that was live before, if any
RuleVersionTakenOffline Anyone who follows the rule The rule has no live version now
SourceVersionMadeLive Anyone who follows the source object The rule members are null. ReplacedVersionId is the source version that was live before, if any
SourceVersionTakenOffline Anyone who follows the source object The rule members are null

Approval is requested by a person who cannot make a version live themselves, when they save or later from the version's dialog, and by an AI agent, whose every save requests it. When a person approves and makes a version live in one step, ApprovalGranted is raised first and RuleVersionMadeLive after it.

Do not give Undefined a meaning in your switch: it is never raised. The numeric values are never reused, and new members are added as the repository learns to raise more kinds of notification, so end your switch with a default that ignores what you do not know.

Example

using System;
using CodeEffects.Rule.Repository;
using CodeEffects.Rule.Repository.Common;

var config = new Configuration();

config.Notify = (action, data) =>
{
	switch(action)
	{
		case NotificationAction.ApprovalRequested:
			Console.WriteLine($"Approvers: {data.RuleName} needs approval. {data.Message}");
			break;
		case NotificationAction.ApprovalDeclined:
			Console.WriteLine($"{data.UserName} declined {data.RuleName}: {data.Reason}");
			break;
		case NotificationAction.RuleVersionMadeLive:
			Console.WriteLine($"{data.RuleName} is live; it replaced version {data.ReplacedVersionId}");
			break;
	}
};

Ask on Stack Overflow - Yes, it's still active
Ask in GitHub Discussions

p102

l097 --

l102

p101

×