This class is created once for all Items of a specific Kind and is responsible for getting and saving configuration for all Items of that Kind
This class is also responsible for creating, filling and saving UserControl and relevant fields changed by the user in the administrators.
Normally there will be one ItemManager for each ItemNode.
If the Items being managed are stored on another server, then this class can utilize the Init() and Close() methods to setup sessions to the remote server in anticipation of calls to GetItems().
EventServer and Items on MAP
This class is also involved in defining ContextMenu on the SmartClient MAP, because the plug-in executing in the Event Server, are providing the Smart Client MAP ViewItem with all relevant plug-ins and their definitions.
As the Event Server uses authorization for Items, the ItemNode needs to define the SecurityActions relevant for the items being managed by the ItemManager. A minimum of two SecurityActions must always be defined for the Items to be available in the Smart Client.
Item Selection in the Administrators
Selection of an Item can happen via mouse click on the TreeView.
The user action will result in the following sequences of events:
a) ItemManager is accessed through the ItemNode
b) The GenerateUserControl() is called to allow ItemManager to create the User Control, setup the ConfigurationChangedByUserEvent, and return the UserControl to the caller.
c) The caller will add the UserControl to its relevant panel and set userControl.Dock = DockStyle.Fill to fill available area.
d) Existing configuration is fetched by calling the ItemManager.GetItem(FQID)
e) The ItemManager.FillUserControl(item) method is called to let the ItemManager populate the UserControl.
When de-selecting an item, the ItemManager.FillUserControl(null) is called to let the ItemManager clear the UserControl. The parent UserControl will also have Enabled=false; set shortly after this call.
Note: A ItemManager.ClearUserControl() is now defined - this is used when no items are selected to let the implementation clear all fields and disable the entire form.
Item edit and update
After an Item is selected or created, the system needs to know if any updates have been done by the administrator.
Ensure the ConfigurationChangedByUserHandler is called whenever the administrator changes something on the UI.
This will allow the administration application to enable Save and Apply buttons as appropriate.
When the administrator presses a Save or Apply button, the ValidateAndSaveUserControl is called to let the ItemManager and the underlying UserControl validate the entered values. If fields are valid the method returns true.
TreeView name change
On the TreeView itself, it is possible to press F2 and edit the name directly. In this case the updated name is passed to the ItemManager via the SetItemName(name) method.
The ItemManager should save the new name immediately.
More...
Classes | |
| struct | ItemSummaryHeader |
| A structure which describes a column header in a summary pane. More... | |
Public Types | |
| enum | AdminTabBehaviour { Group , Individual } |
| Describe how user selection of different tabs should be handled. More... | |
Public Member Functions | |
| virtual void | ClearUserControl () |
| Clear all user entries on the UserControl. | |
| virtual void | Close () |
| The Close() method is called when the user selected to log off or exit the application. After this call there may be a new session starting, in which case the Init() method is called again. If this happens please take notice the it might be towards another server, so no caching of anything should happened after the call to the Close() method. | |
| void | ConfigurationChangedByUserHandler (object sender, EventArgs e) |
| The UserControl needs to indicate when the user have changed any field, and should call this event handler every time. The MIP environment will ensure that save or apply buttons are enabled. | |
| virtual Item | CreateItem (Item parentItem, FQID suggestedFQID) |
| Create a new item. Insert default values. The parentFQID can be null, when a top level node is created (e.g. no parent) The new fqid should be filled with ServerID, ParentId, ObjectId or ObjectIdString and Kind. When storing the configuration on the Milestone server, the following code can be used: | |
| virtual Item | CreateItem (Item parentItem, FQID suggestedFQID, UserControl addUserControl) |
| Create a new item. Insert values as user has entered on the AddUserControl. The parentFQID can be null, when a top level node is created (e.g. no parent) The new fqid should be filled with ServerID, ParentId, ObjectId or ObjectIdString and Kind. | |
| virtual void | DeleteItem (Item item) |
| When an administrator selects the context menu Delete item, or press the DEL key, a confirmation dialog is displayed and upon administrator confirms this method is called. | |
| virtual void | FillUserControl () |
| This overloaded method is used when no Items are selected, e.g. for summary pages. | |
| virtual void | FillUserControl (Item item) |
| Fill the UserControl with the content of the Item or the data it represent. When the ItemNode.ItemsAllowed == ItemsAllowed.One, the item in this call will often be null, as the ItemManager itself will be in control of the single item. When the ItemNode.ItemsAllowed == ItemsAllowed.None, the item in this call will always be null, as the system does not know what kind of information the plugin like to display. | |
| virtual UserControl | GenerateAddUserControl (Item parentItem, FQID suggestedFQID) |
| Create a UserControl to be used for adding a new item. Just fill the user control with default content, but do NOT add it to your configuration yet. Implementation of this method will determine the flow of calls for creating new Items. When implemented, this UserControl is showed to the user, and upon OK pressed the ValidateAddUserControl is called for the plug-in to validate the entry, and a OK response will result in closing the form containing the AddUserControl and a call the the Create() method including the AddUserControl. If not implementing this method, the Create() method WITHOUT the AddUserControl parameter is called, and a default Item is then created, stored (where ever this ItemManager stores it configuration), and displayed in the TreeView. Last step is that the new item node is selected and the ItemManager.FillUserControl is called to fill the large configuration form. | |
| virtual UserControl | GenerateAlarmPreviewUserControl (FQID fqid, object alarmOrBaseEvent) |
| Deprecated! Use PluginDefinition.GenerateAlarmPreviewWpfUserControl() instead. | |
| virtual UserControl | GenerateDetailUserControl () |
| Generate the UserControl for configuring the Kind of item that this ItemManager manages. Overwrite it with your own implementation returning your own UserControl derived object. | |
| virtual List< DetailedUserControl > | GenerateDetailUserControlList () |
| Generate a list of extra UserControls for configuring more pages of information this ItemManager manages. | |
| virtual ItemNodeUserControl | GenerateOverviewUserControl () |
| A user control to display when the administrator clicks on the treeNode. This can be a help page or a status over of the configuration. | |
| virtual Dictionary< string, string > | GetConfigurationReportProperties (Item item) |
| Gets the configuration properties of an item. These properties are used for configuration reporting within the administration environment. Override this method to provide custom properties for the MIP plug-in configuration report. | |
| virtual Collection< ContextMenuItem > | GetContextMenu (Item item=null) |
| List of contextmenu items to be displayed in the administrator. | |
| virtual Item | GetItem (FQID fqid) |
| Returns the Item defined by the FQID. Will return null if not found. | |
| virtual String | GetItemName () |
| Get the name of the current Item. | |
| virtual List< Item > | GetItems () |
| Returns a list of all Items on top level (e.g. no parents) | |
| virtual List< Item > | GetItems (Item parentItem) |
| Returns a list of all Items of the Kind this ItemManager manages. When no parentItem is provided, this ItemManager should be managing a server configuration. | |
| virtual string | GetItemStatusDetails (Item item) |
| Overloaded method when using default language ("en-US"). Please make sure to implement the GetItemStatusDetails with 2 parameters, as that method is the one being called most of the time. | |
| virtual string | GetItemStatusDetails (Item item, string language) |
| Can return an XML string with status details to be displayed via a ContextMenu on the Smart Client Map ViewItem. The return value is null if no status is available, or an XML string like: | |
| virtual List< object > | GetItemSummary (Item item) |
| Allows an integration to define the values to be presented in one row of a summary pane Called by the admin client when it is about to display one row of a summary pane To be re-implemented in each integration's Integrationname_ItemManager. | |
| virtual List< ItemSummaryHeader > | GetItemSummaryHeaders () |
| Allows an integration to define the columns in a summary pane. This includes name, value type and read-only flag. The columns will be ordered as indexed in this list, the first index being 0. Called by the admin client when it is about to display a summary pane To be re-implemented in each integration's Integrationname_ItemManager. | |
| virtual Collection< EventGroup > | GetKnownEventGroups (CultureInfo culture) |
| Return all the Event Groups this Kind of Item can deliver to the Event Server. The list is used to group the Event Types. This method should always support at least the en-US culture. | |
| virtual Collection< String > | GetKnownEventTypes () |
| Deprecated - see GetKnownEventTypes(CultureInfo culture). | |
| virtual Collection< EventType > | GetKnownEventTypes (CultureInfo culture) |
| Return all the Event Types this Kind of Item can deliver to the Event Server. This list is used for configuring alarms. This method should always support at least the en-US culture, which is the expected culture of incoming events. | |
| virtual Collection< StateGroup > | GetKnownStateGroups (CultureInfo culture) |
| Return all state groups defined by this plugin. | |
| virtual OperationalState | GetOperationalState (Item item) |
| Return the operational state of a specific Item. This is used by the Event Server. | |
| virtual Dictionary< String, string > | GetTranslationDictionary (CultureInfo culture) |
| Returns a Dictionary used for fine tuning specific translations. This method is optional and does not have to be implemented or may return null. The current use is for these translations: | |
| virtual void | Init () |
| The Init method is called when the Environment is up and running, and the Configuration.Instance can be used for getting specific Items from the Milestone servers, as well as calling the GetConfiguration() methods. | |
| virtual bool | IsContextMenuValid (string command) |
| Just before a context menu is displayed, each line on the context menu is checked for it should be enabled or disabled. This method is called with the following command (If allowed by the ItemNode definition) "ADD" - for the "Add new ..." "DELETE" - for the "Delete ..." "RENAME" - for rename If your plugin has the configuration stored on another server, and management is not possible via the ItemManager, then this method can be used to disable all ContextMenu actions. When this method is not implemented, the default value returned is true. | |
| ItemManager () | |
| Construction of the ItemManager does not need any parameters. | |
| void | PopConfigurationChangedEventHandler () |
| Reserved for internal use. | |
| void | PushConfigurationChangedEventHandler () |
| Reserved for internal use. | |
| virtual void | ReleaseUserControl () |
| This call is issued when the itemManager needs to remove any event registration or dispose of specific objects as the UserControl is no longer being used. | |
| virtual void | SetItemName (String name) |
| Set the name on current Item, used by TreeView edit via F2. | |
| virtual bool | ValidateAddUserControl (UserControl addUserControl) |
| Validate the content of the AddUserControl generated by this class's GenerateAddUserControl. | |
| virtual bool | ValidateAndSaveItemSummary (Item item, List< object > allValues, List< int > changedIndices, out int errIndex) |
| Validate the updated values from a row in a summary pane. Called by the admin client when the end user applies all changes to one row in the summary pane To be re-implemented in each integration's Integrationname_ItemManager External configuration should be saved during this call. If any entry error exists, the errIndex should be filled, and either an error message can be displayed or a ValidateAndSaveMIPException can be thrown. | |
| virtual bool | ValidateAndSaveUserControl () |
| Validate the user entry, and return true for OK. External configuration should be saved during this call. If any entry error exists, the field in error should get focus, and an error message should be displayed to the user or a ValidateAndSaveMIPException should be thrown. | |
Properties | |
| Item | CurrentItem [get, set] |
| The Item currently being displayed and worked on. | |
| virtual bool | DisableUserControlWhenNoItemIsSelected [get] |
| Override this in your ItemManager and return false if your Items' UserControl does not want to be disabled when no item is selected. | |
| bool | ExcludePersonalDataFromConfigReport [get, set] |
| Specify whether to exclude personal DataFrom Config Report. | |
| virtual int | SummaryUpdateInterval [get, set] |
| If the summary panel needs to be updated, set this property to the number of seconds inbetween updates. | |
| virtual AdminTabBehaviour | TabBehaviour [get, set] |
| Describe how user selection of different tabs should be handled. AdminTabBehaviour | |
Events | |
| EventHandler | ConfigurationChangedByUser |
| An event that needs to fired when the user changes something on the UserControl that requires a save at some point. | |
This class is created once for all Items of a specific Kind and is responsible for getting and saving configuration for all Items of that Kind
This class is also responsible for creating, filling and saving UserControl and relevant fields changed by the user in the administrators.
Normally there will be one ItemManager for each ItemNode.
If the Items being managed are stored on another server, then this class can utilize the Init() and Close() methods to setup sessions to the remote server in anticipation of calls to GetItems().
EventServer and Items on MAP
This class is also involved in defining ContextMenu on the SmartClient MAP, because the plug-in executing in the Event Server, are providing the Smart Client MAP ViewItem with all relevant plug-ins and their definitions.
As the Event Server uses authorization for Items, the ItemNode needs to define the SecurityActions relevant for the items being managed by the ItemManager. A minimum of two SecurityActions must always be defined for the Items to be available in the Smart Client.
Item Selection in the Administrators
Selection of an Item can happen via mouse click on the TreeView.
The user action will result in the following sequences of events:
a) ItemManager is accessed through the ItemNode
b) The GenerateUserControl() is called to allow ItemManager to create the User Control, setup the ConfigurationChangedByUserEvent, and return the UserControl to the caller.
c) The caller will add the UserControl to its relevant panel and set userControl.Dock = DockStyle.Fill to fill available area.
d) Existing configuration is fetched by calling the ItemManager.GetItem(FQID)
e) The ItemManager.FillUserControl(item) method is called to let the ItemManager populate the UserControl.
When de-selecting an item, the ItemManager.FillUserControl(null) is called to let the ItemManager clear the UserControl. The parent UserControl will also have Enabled=false; set shortly after this call.
Note: A ItemManager.ClearUserControl() is now defined - this is used when no items are selected to let the implementation clear all fields and disable the entire form.
Item edit and update
After an Item is selected or created, the system needs to know if any updates have been done by the administrator.
Ensure the ConfigurationChangedByUserHandler is called whenever the administrator changes something on the UI.
This will allow the administration application to enable Save and Apply buttons as appropriate.
When the administrator presses a Save or Apply button, the ValidateAndSaveUserControl is called to let the ItemManager and the underlying UserControl validate the entered values. If fields are valid the method returns true.
TreeView name change
On the TreeView itself, it is possible to press F2 and edit the name directly. In this case the updated name is passed to the ItemManager via the SetItemName(name) method.
The ItemManager should save the new name immediately.
Describe how user selection of different tabs should be handled.
| Enumerator | |
|---|---|
| Group | This is default implementation for MIPSDK 4.0 - all tabs are called when new tabs are selected, e.g. FillUserControl is called at start of new tab selection, and ValidateAndSave are called on every new tab de-selection. |
| Individual | The FillUserControl is only called once, and 3 new methods are used to understand whar UserControl are currently displayed:
The Selected() method is call on every tab that is selected. |
|
inline |
Construction of the ItemManager does not need any parameters.
|
inlinevirtual |
Clear all user entries on the UserControl.
|
inlinevirtual |
The Close() method is called when the user selected to log off or exit the application.
After this call there may be a new session starting, in which case the Init() method is called again. If this happens please take notice the it might be towards another server, so no caching of anything should happened after the call to the Close() method.
|
inline |
The UserControl needs to indicate when the user have changed any field, and should call this event handler every time. The MIP environment will ensure that save or apply buttons are enabled.
| sender | |
| e |
|
inlinevirtual |
Create a new item. Insert default values.
The parentFQID can be null, when a top level node is created (e.g. no parent)
The new fqid should be filled with ServerID, ParentId, ObjectId or ObjectIdString and Kind.
When storing the configuration on the Milestone server, the following code can be used:
| parentItem | Identifies the configuration parent to the new item. |
| suggestedFQID | A pre-generated fqid with above fields filled. The ObjectId or ObjectIdString can be overridden. |
|
inlinevirtual |
Create a new item. Insert values as user has entered on the AddUserControl.
The parentFQID can be null, when a top level node is created (e.g. no parent) The new fqid should be filled with ServerID, ParentId, ObjectId or ObjectIdString and Kind.
| parentItem | Identifies the configuration parent to the new item. |
| suggestedFQID | A pre-generated fqid with above fields filled. The ObjectId or ObjectIdString can be overridden. |
| addUserControl | A filled user control returned by the GeneratedAddUserControl method after it has been displayed and edited by the user |
|
inlinevirtual |
When an administrator selects the context menu Delete item, or press the DEL key, a confirmation dialog is displayed and upon administrator confirms this method is called.
| item | The Item to delete |
|
inlinevirtual |
This overloaded method is used when no Items are selected, e.g. for summary pages.
Supported from MIP v4.5
When not implemented, it will call the FillUserControl(null) and ignore any NullReferenceExceptions
|
inlinevirtual |
Fill the UserControl with the content of the Item or the data it represent.
When the ItemNode.ItemsAllowed == ItemsAllowed.One, the item in this call will often be null, as the ItemManager itself will be in control of the single item.
When the ItemNode.ItemsAllowed == ItemsAllowed.None, the item in this call will always be null, as the system does not know what kind of information the plugin like to display.
| item | The Item to work with |
|
inlinevirtual |
Create a UserControl to be used for adding a new item.
Just fill the user control with default content, but do NOT add it to your configuration yet.
Implementation of this method will determine the flow of calls for creating new Items.
When implemented, this UserControl is showed to the user, and upon OK pressed the ValidateAddUserControl is called for the plug-in to validate the entry, and a OK response will result in closing the form containing the AddUserControl and a call the the Create() method including the AddUserControl.
If not implementing this method, the Create() method WITHOUT the AddUserControl parameter is called, and a default Item is then created, stored (where ever this ItemManager stores it configuration), and displayed in the TreeView.
Last step is that the new item node is selected and the ItemManager.FillUserControl is called to fill the large configuration form.
|
inlinevirtual |
Deprecated! Use PluginDefinition.GenerateAlarmPreviewWpfUserControl() instead.
For displaying detail information about an Alarm or an Event, this method can be implemented to return a UserControl to be displayed when the user selects an Alarm in the alarm list, or a Event in the event list, in the Smart Client.
The returned UserControl will be placed together with other relevant information like CameraViewItem's within the AlarmPreview ViewItem.
Note: the alarmOrBaseEvent need to be checked for type and type casted accordingly, e.g. to Alarm, BaseEvent or AnalyticsEvent.
|
inlinevirtual |
Generate the UserControl for configuring the Kind of item that this ItemManager manages.
Overwrite it with your own implementation returning your own UserControl derived object.
|
inlinevirtual |
Generate a list of extra UserControls for configuring more pages of information this ItemManager manages.
Note that this method will only be called if GenerateDetailUserControl returns null, so you will need to overwrite it with an implementation returning null for this method to be utilized.
The ItemManager needs to keep track of all the UserControls it generates, e.g. passing on the ItemManager class to each DetailedUserControl or implement relevant events for understanding when the user changes the UI and when the ItemManager need to update the content.
|
inlinevirtual |
A user control to display when the administrator clicks on the treeNode. This can be a help page or a status over of the configuration.
|
inlinevirtual |
Gets the configuration properties of an item. These properties are used for configuration reporting within the administration environment. Override this method to provide custom properties for the MIP plug-in configuration report.
| item | The item. |
|
inlinevirtual |
List of contextmenu items to be displayed in the administrator.
When the item parameter is null, the administrator right clicked on the type node, while when the item contains a specific item, the administrator right clicked on an individual item. This also reflects the hierarchy of the ItemNode's - when the administrator clicks on an ItemNode that does not have any parent ItemNode - the item will be null; while when the administrator clicks on an item (or its type) that has a parent ItemNode - the Item will be filled with the specific parent Item.
This method needs to return immediately - no remote communication should be required.
| item | The item the contextmenu will be shown for |
|
inlinevirtual |
Get the name of the current Item.
|
inlinevirtual |
Returns a list of all Items on top level (e.g. no parents)
Returns a list of all Items of the Kind this ItemManager manages. When no parentItem is provided, this ItemManager should be managing a server configuration.
| parentItem | The parent owning the items. |
|
inlinevirtual |
Overloaded method when using default language ("en-US").
Please make sure to implement the GetItemStatusDetails with 2 parameters, as that method is the one being called most of the time.
| item |
|
inlinevirtual |
Can return an XML string with status details to be displayed via a ContextMenu on the Smart Client Map ViewItem. The return value is null if no status is available, or an XML string like:
The valid 'detail' types are:
| item | |
| language | The language the Smart Client is using. The detailname and content should be translated to defined language. |
|
inlinevirtual |
Allows an integration to define the values to be presented in one row of a summary pane Called by the admin client when it is about to display one row of a summary pane To be re-implemented in each integration's Integrationname_ItemManager.
| item | The Item which the pane is to display in a row |
|
inlinevirtual |
Allows an integration to define the columns in a summary pane. This includes name, value type and read-only flag. The columns will be ordered as indexed in this list, the first index being 0. Called by the admin client when it is about to display a summary pane To be re-implemented in each integration's Integrationname_ItemManager.
|
inlinevirtual |
Return all the Event Groups this Kind of Item can deliver to the Event Server. The list is used to group the Event Types. This method should always support at least the en-US culture.
| culture | The requested culture in which the group names should be returned |
|
inlinevirtual |
Deprecated - see GetKnownEventTypes(CultureInfo culture).
|
inlinevirtual |
Return all the Event Types this Kind of Item can deliver to the Event Server. This list is used for configuring alarms. This method should always support at least the en-US culture, which is the expected culture of incoming events.
| culture | The requested culture in which the event type messages should be returned |
|
inlinevirtual |
Return all state groups defined by this plugin.
The state group is used to understand which events are modifying a given state.
| culture | The requested culture in which the group names should be returned |
|
inlinevirtual |
Return the operational state of a specific Item. This is used by the Event Server.
| item |
|
inlinevirtual |
Returns a Dictionary used for fine tuning specific translations.
This method is optional and does not have to be implemented or may return null.
The current use is for these translations:
| culture |
|
inlinevirtual |
The Init method is called when the Environment is up and running, and the Configuration.Instance can be used for getting specific Items from the Milestone servers, as well as calling the GetConfiguration() methods.
|
inlinevirtual |
Just before a context menu is displayed, each line on the context menu is checked for it should be enabled or disabled. This method is called with the following command (If allowed by the ItemNode definition)
"ADD" - for the "Add new ..."
"DELETE" - for the "Delete ..."
"RENAME" - for rename
If your plugin has the configuration stored on another server, and management is not possible via the ItemManager, then this method can be used to disable all ContextMenu actions.
When this method is not implemented, the default value returned is true.
| command |
|
inline |
Reserved for internal use.
|
inline |
Reserved for internal use.
|
inlinevirtual |
This call is issued when the itemManager needs to remove any event registration or dispose of specific objects as the UserControl is no longer being used.
|
inlinevirtual |
Set the name on current Item, used by TreeView edit via F2.
| name |
|
inlinevirtual |
Validate the content of the AddUserControl generated by this class's GenerateAddUserControl.
| addUserControl |
|
inlinevirtual |
Validate the updated values from a row in a summary pane.
Called by the admin client when the end user applies all changes to one row in the summary pane To be re-implemented in each integration's Integrationname_ItemManager
External configuration should be saved during this call.
If any entry error exists, the errIndex should be filled, and either an error message can be displayed or a ValidateAndSaveMIPException can be thrown.
| ValidateAndSaveMIPException | Can be thrown to provide a more specific error message. |
| item | The item for which one or more of its property values has been changed |
| allValues | A list of values, changed as well as unaltered ones. |
| changedIndices | A list of 0-based indexes for those values which were changed. |
| errIndex | Returns the 0-based index of the most critical field, which has an invalid value. Returns -1 for no invalid fields. |
|
inlinevirtual |
Validate the user entry, and return true for OK.
External configuration should be saved during this call.
If any entry error exists, the field in error should get focus, and an error message should be displayed to the user or a ValidateAndSaveMIPException should be thrown.
| ValidateAndSaveMIPException | Can be thrown to provide a more specific error message. |
|
getset |
The Item currently being displayed and worked on.
|
get |
Override this in your ItemManager and return false if your Items' UserControl does not want to be disabled when no item is selected.
|
getset |
Specify whether to exclude personal DataFrom Config Report.
|
getset |
If the summary panel needs to be updated, set this property to the number of seconds inbetween updates.
When set to 0, updates are disabled.
|
getset |
Describe how user selection of different tabs should be handled. AdminTabBehaviour
| EventHandler VideoOS.Platform.Admin.ItemManager.ConfigurationChangedByUser |
An event that needs to fired when the user changes something on the UserControl that requires a save at some point.