Here is the description of SDK issues we were faced with and possible solutions by SDK extension.
The problem we are trying to solve: we need to pull out all the roles with users belonging to these roles and permissions to read data from cameras for these roles.
But for this we are forced, using the Milestone Platform SDK, to call the “ChangeSecurityPermissions” method for each role and for each camera. In our case, the end-user has about 100 roles and 200 cameras, resulting in 100*200=20000 requests to the Milestone server.
While performing this task, the server returns the error: “Timeout expired. The timeout period elapsed before obtaining a connection from the pool”. This may have occurred because all pooled connections were in use and the max pool size was reached. It looks like the pool of connections to the SQL Server database is being depleted.
Therefore, to reduce the load on the Milestone database, we are forced to call this method the first time a user logs into our system. But this greatly complicates the logic, incl. synchronization of permissions, and does not guarantee stability (when several users do this at the same time), etc. And even in this implementation, we’re from time-to-time getting the same error.
So, we propose to extend Milestone SDK with the next methods/classes (naming, arguments, and response are conditional):
GetUserPermissions (userId, permission type) → list of cameras with permissions [{“camera1”:[“permission1”, “permissionN”]}]
Optional, but very desirable:
GetRolePermissions (roleId, permission type) → list of cameras with permissions [{“camera1”:[“permission1”, “permissionN”]}]
permission type = Read (for example)
GetAllRolesPermissions (permission type) → list of roles with its’ cameras with permissions [{“role” : [{“camera”:[“permission1”, “permissionN”]}]}
Class/Method name (arguments) → response
Probably with the implementation of some kind of pagination for 2, 3 points for large systems.