Cannot submit new Alarm from code

The following code is used by the RuleActionManager in our plugin to directly submit an alarm when a user has configured a rule in the Management Client to execute the action:

EventSource eventSource = new EventSource()
            {
                FQID = sourceEvent.EventHeader.Source.FQID,
                Name = sourceEvent.EventHeader.Source.Name
            };
            EventHeader eventHeader = new EventHeader()
            {
                ID = Guid.NewGuid(),
                Class = "Analytics",
                Type = sourceEvent.EventHeader.Type,
                Timestamp = DateTime.Now,
                Message = sourceEvent.EventHeader.Message,
                Name = sourceEvent.EventHeader.Name,
                Source = eventSource,
                Priority = 1,
                PriorityName = "High"
            };
            Alarm alarm = new Alarm()
            {
                EventHeader = eventHeader,
                StateName = "New",
                State = 1,
                AssignedTo = "Unassigned"
            };
            EnvironmentManager.Instance.Log(
                false,
                "testing",
                "Sending Alarm! Fields are:\nFQID: " + eventHeader.Source.FQID.ToString() +
                "\nName: " + eventHeader.Source.Name.ToString() +
                "\nID: " + eventHeader.ID.ToString() +
                "\nClass: " + eventHeader.Class.ToString() +
                "\nType: " + eventHeader.Type.ToString() +
                "\nTimestamp: " + eventHeader.Timestamp.ToString() +
                "\nMessage: " + eventHeader.Message.ToString() +
                "\nName: " + eventHeader.Name.ToString() +
                "\nPriority: " + eventHeader.Priority.ToString() +
                "\nPriorityName: " + eventHeader.PriorityName.ToString() +
                "\nStateName: " + alarm.StateName.ToString() +
                "\nState: " + alarm.State.ToString() +
                "\nAssignedTo: " + alarm.AssignedTo.ToString());
                
            EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MessageId.Server.NewAlarmCommand) { Data = alarm });

The output of the log statement looks ok to me, and shows that the code is indeed being executed:

2020-04-07 09:31:54.178 UTC-06:00 Info testing Sending Alarm! Fields are:

FQID: Server:XPCORS:desktop-41pbtso Id:80c01a78-2b23-4416-b094-841edbed8225, ObjectId:f1224b31-c337-4f49-8e6d-28fcc77ac5d9, Type:5135ba21-f1dc-4321-806a-6ce2017343c0

Name: AXIS M1065-L Network Camera (192.168.0.20) - Camera 1

ID: f4280f59-ef25-4c16-ba44-a3bdd9d1501e

Class: Analytics

Type: RocGroupRuleHit

Timestamp: 4/7/2020 9:31:54 AM

Message: Home

Name: {508ec948-bc75-49a1-9faf-5c5b89feb4de}

Priority: 1

PriorityName: High

StateName: New

State: 1

AssignedTo: Unassigned

I am running XProtect Corporate 2019 R3 with a test license on my current computer, and have this code working on a separate computer, which is also running XProtect Corporate 2019 R3 with test license. I do not see any errors in the MIP logs or Event Server logs. Could this issue be caused by the fact I am using the same test license on both computers? Again, this code works unchanged on a separate computer running the same XProtect version.

Can you please test unmodified LibraryEventGenerator sample?

https://doc.developer.milestonesys.com/html/index.html?base=samples/libraryeventgenerator_sample.html&tree=tree_search.html?search=library+event+generator

Also, please check if Analytics events setting is enabled. Start Management Client – Tools – Options – Analytics Events tab – Analytics Events – check on Enabled.

The LibraryEventGenerator works. Does that mean this is not a license issue? Analytics Events are enabled on port 9090. I’m able to see all the analytics events our integration is sending using the AlarmList, but I’m still not able to send it alarms from this code.

Hi Rie,

Thanks for your help, but this issue has suddenly disappeared. I have been trying to recreate the problem without luck. Since I still haven’t changed the code, I must have had something misconfigured (maybe the Analytics Events weren’t actually enabled somehow?)