User Defined Event Categories

I want to create a user defined Event Category and have the code that creates the plugin assign the category to the event similar to how other events do it with the built in categories. The code below is an example from your demo template: As you can see in the first if statement I am trying to create a “Return To Nomal” category and assign events to it that have an “rtn” in their description so users do not have to do it manually for hundreds of events

private static IEnumerable ConvertToCategories(string eventType, string eventName)

{

if (eventName.ToLowerInvariant().Contains(“rtn”))

{

yield return "Return To Normal";

}

else if (eventName.ToLowerInvariant().Contains(“denied”))

{

yield return ACBuiltInEventTypeCategories.CredentialHolderAccessDenied;

yield return ACBuiltInEventTypeCategories.AccessRequest;

}

else if (eventName.ToLowerInvariant().Contains(“grant”))

{

yield return ACBuiltInEventTypeCategories.CredentialHolderAccessGranted;

}

else if (eventName.ToLowerInvariant().Contains(“error”))

{

yield return ACBuiltInEventTypeCategories.Error;

}

else if (eventName.ToLowerInvariant().Contains(“tampering”))

{

yield return ACBuiltInEventTypeCategories.Alarm;

}

else if (eventName.ToLowerInvariant().Contains(“forced”))

{

yield return ACBuiltInEventTypeCategories.Alarm;

}

else if (eventName.ToLowerInvariant().Contains(“held”))

{

yield return ACBuiltInEventTypeCategories.Alarm;

}

else if (eventName.ToLowerInvariant().Contains(“failure”))

{

yield return ACBuiltInEventTypeCategories.Alarm;

}

else if (eventName.ToLowerInvariant().Contains(“alarm”))

{

yield return ACBuiltInEventTypeCategories.Alarm;

}

}

I am in doubt if you want to share your idea, or you have a question in relation to this?

Yes we have “return to normal” events when an alarm is reset. For example if you get a “forced door” and then it closes we send two events. One the alarm that it is a forced door the other is an event that it has returned to normal. Your built in categories are “hard coded” in your application. You can create custom ones manually in the application and assign events to that category but that is a manual effort on part of the customer. We have many return to normal events which would put a lot of undue work on the customer when I can simply do it in code for them, like your plugin allows for the few built in categories you provide.

Hi John,

If you’d like to create a custom category for the events your plugin, you can take a look at how DoorErrorEvent category is defined. You can see the code in the Constants\Types.cs file in the sample.

When you are using the built-in categories you can just pass the ids for them, but if you want to create a category specific to your plug in you have to define its parameters yourself. This means you need to create an ACCategoryInfo object and pass it as part of the call to GetCategories (in the sample DemoAccessControlPlugin.cs, line 52). Then you can use the ID for that category and pass it to the constructor of the ACEventType.

Just a note, this is a little bit different than the “User Defined Categories”, as those are meant to be defined by the specific user and not in general for the integration.