How to trigger an event that is catch by a rule

Hi,

I succeeded in generating Event that appears in Alarm and EventViewer sample from the SDK but I cannot get a rule triggered by this event when the event is triggered by an app.

If I trigger the event from configurator the rule (based on event) is executed and I see in Alarm and event viewer sample . But when the same event is triggered by my app I cannot get this working…

here is the code I use to trigger the event :

EventSource eventSource = new EventSource()

               {

                   FQID = eventItem.FQID,

                   Name = [eventItem.Name](https://eventItem.Name)

               };

               EventHeader eventHeader = new EventHeader()

               {

                   ID = Guid.NewGuid(),

                   Class = "NewEventToRule",

                   Type = "Event",

                   Timestamp = DateTime.Now,

                   Message = "Alarm Obs",

                   Name = " alarm.ObsName",

                   Source = eventSource

               };

               // In this sample the snap shots are being saved. This will make the

               // the build-in AlarmPreview in Smart Client display them in the case where the event result in an alarm.

               //EventSequence eventSequence = new EventSequence();

               //EventData eventData = new EventData()

               //{

               //   EventHeader = eventHeader,

               //   EventSequence = eventSequence

               //};

               //EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MessageId.Server.NewEventCommand) { Data = eventData });

               Alarm alrm = new Alarm()

               {

                   EventHeader = eventHeader,

                   StateName = "In progress",

                   State = 4

                   // Basic user with the name of test in this example

                   // the string to use can be seen in the Smart Client dropdown

                   // Other fields could be filled out, e.g. objectList

               };

               EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MessageId.Server.NewAlarmCommand) { Data = alrm });

AS you can see in comments I tried to generate event as an alarm or not => same behavior…

I tried to do it with a userdefined Event and with an analytics event => same behavior …

can you help ???

Thanks and regards

First of all, it is impossible to configure all rules with SDK in the current version 2019R3.

Good news for you is we are working for being able to configure the rules with SDK, so please keep eye on the release note /news from Milestone.

Hi ok cool but this is not what I am trying to achieve for now…

I want to generate an already existing event from the sdk and the a rule listening to this event can be generated…

As I wrote, when I trigger the event from Milestone configurator my rule is executed but when I trigger the event from an sdk app, the rule is not. Althought I can see the event being triggered in Milestone using Alarm and Event viewer sample connected to the same Milestone server as my app, the rule never executes..

If you want to configure a rule, then you need to trigger an event, not an alarm.

This KB article might be interesting for you to read –

https://developer.milestonesys.com/s/article/Create-an-alarm-from-a-MIP-SDK-based-application