NotificationType Enumeration
Assembly: CodeEffects.Rule.Repository.dll
Namespace: CodeEffects.Rule.Repository.Common
Summary
Specifies how the Rule Repository client presents the message of a response: as a confirmation that goes away on its own, as a warning the user can act on, or as an error that shows a control number.
Syntax
public enum NotificationType
{
// The action succeeded; the message says so and disappears on its own
Confirmation = 0,
// An expected refusal the user can act on. No control number is shown
Warning = 1,
// A failure. The control number is shown so the user can quote it to support
Error = 2
}
You meet this enumeration on the NotificationType property of the Response that Context.GetResponse(..) returns, and inside the JSON that RepositoryException.ResponseJson and RepositoryPermissionException.ResponseJson hold. The property is null when the response has nothing to show. In JSON the value is written as the lower-case string confirmation, warning, or error, which is what the client reads.
Confirmation accompanies a request that succeeded and has something to say.
Warning is an expected refusal: a missing permission, a record that someone else changed, or a value that failed validation. It is returned in the response, not thrown, except for a missing permission, which is thrown as a RepositoryPermissionException whose ResponseJson is a warning.
Error is a failure. The response carries the control number of the failure. A host that catches a RepositoryException, logs it, and returns its ResponseJson sends an Error.
This is not the type of the notifications you receive through IRepositoryConfiguration.Notify; those are described by NotificationAction.
Example
using System;
using CodeEffects.Rule.Repository;
using CodeEffects.Rule.Repository.Common;
Request request = Newtonsoft.Json.JsonConvert.DeserializeObject<Request>(requestJson);
Response response = Context.GetResponse(config, dbProvider, request);
if(response.NotificationType == NotificationType.Error)
Console.WriteLine($"Failed, quote {response.ControlNumber} to support");