1. Home
  2. FlexRule Designer
  3. Validation
  4. Notification Message Provider

Notification Message Provider

◷ Reading Time: 2 minutes

As part of rule execution, notification messages can be written in the rule execution context. The list of messages is usually static and can be maintained by multilingual resource document.

While modeling rules, the intelligence-like pop-up will provide an available list of messages if they are registered as resources.

Implementation steps

Implementing an extension allows you to provide a dynamic list from an external data source instead of using Resource documents. To implement the message provider:

  1. Create an application (class library)
  2. Reference FlexRule.Designer.Core
  3. Implement an interface named FlexRule.Designer.Plugins.Notification.INotificationMessageProvider
  4. Register your extension in a rule project

Implementation

Implementation is simple, the INotificationMessageProvide has only one method which returns the list of messages:

[TypeDescription("Provide list of messages from my datasource...")]
public class MessageProvider : INotificationMessageProvider
{
    class Msg : IMessage
    {
        public string Source
        {
            get { return "db.SampleTable1"; }
        }
        public string Culture { get; set; }
        public string Id { get; set; }
        public string Text { get; set; }
    }
    public IEnumerable<IMessage> List(ExtensionContext context)
    {
        // Load the messages from DB... or any other data source...
        return new[]
        {
            new Msg(){Id="a1", Text = "This is a test message from extension"} ,
            new Msg(){Id="a2", Text = "Another text message..."} ,
            new Msg(){Id="a3", Text = "And another one!"} 
        };
    }
}

Registering Extension

  1. Open your rule project file (it has .frpj extension)
  2. Add the following elements for the Extensions section under Designer/ProjectProviders/Extensions. Please note that if Extensions does not exist, add one.
Attributes
  • assembly: name of the assembly that has the extension type. Name should include .dll
  • type: fullname of the type including namespace
Copy

Now you need to copy the assembly into “Bin” folder where the FlexRule Designer is installed.

Validation

During the validation of logic, this provider also will be used to validate the values (messageId) related to a specific condition/action.

Updated on July 5, 2019

Was this article helpful?

Related Articles