I have a plugin whose Background part is running in the Event Server. And has a Management Client UI too.
On server startup, I want to check whether a user-defined and an alarm definition exists or not (based on name, guid etc)…and if they don’t I want to create them automatically from within the plugin in such a way that the new alarm definition is triggered whenever the user-defined event is triggered.
Right now I have:
ServerId sid = EnvironmentManager.Instance.CurrentSite.ServerId;
Item i = new Item(sid, sid.Id, new Guid("a6b60fbc-879b-4d8d-a339-2c2e4a47b3f2"), "My User-defined Event", FolderType.No, Kind.InputEvent);
// a6b60fbc-879b-4d8d-a339-2c2e4a47b3f2 is a fresh generated Guid
Configuration.Instance.SaveItemConfiguration(CalipsaMilestonePluginDefinition.CalipsaMilestonePluginPluginId, i);
This doesn’t crash but it doesn’t work either, which is expected since I don’t have much of an idea how to create new items
I’ve looked at the ConfigApi sample code, though not too deeply, and I could be wrong but I think it requires a token-based login first.
I was wondering if this could be done from within a plugin integration without any login_,_ say, the code runs in the Management Client or in the background in Event Server.
Using the following code I was able to make one change, unintended of course. It renamed the site.
It is possible to use ConfigAPI Client code for creating a User-defined or Analytics Event from within the plugin. It is easy to use the strongly typed classes. Try this snippet of code:
private void createUserDefEvent()
{
var ms = new ManagementServer(EnvironmentManager.Instance.CurrentSite);
var udefolder = ms.UserDefinedEventFolder;
udefolder.AddUserDefinedEvent("testingWithConfig");
}