The scenario I am trying to cover is the following: from our plug-in (running in the Management client) I have to trigger user-defined event which will trigger email notification and alarm (if they are configured by the administrator). Everything works fine - the event is triggered, email notification/alarm working perfectly except one thing - data sent with the message is just ignored. Trigger event code:
// eventItem (Item) is user-defined event selected using ItemPicker form
// Have tried with generic event - same result
EventSource eventSource = new EventSource()
{
FQID = eventItem.FQID,
Name = eventItem.Name
};
EventHeader eventHeader = new EventHeader()
{
ID = Guid.NewGuid(),
Timestamp = DateTime.Now.AddMonths(-1),
Message = "Text message goes here",
Name = eventItem.Name,
Source = eventSource,
Priority = 2,
PriorityName = "Medium"
};
// Have tried using EventData class instead of BaseEvent - same result
BaseEvent baseEvent = new BaseEvent
{
EventHeader = eventHeader
};
// Have tried using MessageId.Server.NewEventCommand - event not triggered
Message msg = new Message(MessageId.Control.TriggerCommand, baseEvent);
// When SendMessage desination FQID param is not passed event not triggered
Collection<object> response = EnvironmentManager.Instance.SendMessage(msg, eventItem.FQID, null);
I am monitoring events using EventListener sample and see the data field (EventHeader especially) has other (maybe default) properties different than the one sent by me. Note: when using MessageId.Server.NewEventCommand from the plug-in the event is not triggered, but when try this one from LibraryEventGenerator component sample (standalone application) event is fired (see it in the EventListener and data passed by me is correct) but email notification and alarm both are not triggered.
So the question:
How can I trigger event and send custom data (like message, timestamp etc.)
If first can be done how to configure email notification and alarm definition to use these custom data properties
I have explored AnalyticsEventTriggerViaLibrary as you recommended. You are right - notification is sent even NewEventCommand is used in the sample. But stll I think this will not be very usefull to me. When creating rule which will be triggered by Analytics event I should select device (camera) related to this rule, but this is not my case. When using User-defined event in the rule it is not neccessary to attach any devices. So, let me explain clearly my case:
In our solution we have a service (actually a set of services) running on the Recording server machine. Now I am developing a Background plug-in which will run in the Event server and talking with our service on the Recording server machine. Then I would like to send some reports from our service (on the Recording server) using Milestone notifications mechanism - the best solution of course is just to trigger a Milestone event. Then this event trigger may send email notifications or alarms (if configured of course). So working solution for me will be to have ability to send just single message with the event trigger and this message to be included in the email notification and alarm if possible. Also I think I cannot use Analytics event - they are tightly coupled with cameras (devices). Untill find better solution we have decided still to use events but in order to receive meaningfull information user have to configure (create) the following:
User-defined events for each of the Recording servers for each of our reports.
Then separate notification profile, rule and alarm definition for each of the previously created events with appropriate meaningfull messages.
Unfortunately, it is impossible to trigger a user-defined event with added information and have the information picked up by a rule, this functionality is not supported.