workspace sdk services - Genetec/DAP GitHub Wiki
Services provide access to built-in functionality in Security Desk and Config Tool. The Workspace SDK includes services for dialogs, maps, alarms, badges, configuration, and more.
All services implement IService:
public interface IService
{
void Initialize(Workspace workspace);
}Access services through Workspace.Services:
| Method | Description |
|---|---|
Get<T>() |
Get service by interface type |
Get<T>(Guid) |
Get service by interface GUID |
Get<T>(string) |
Get service by unique identifier |
Register(IService) |
Register a custom service |
Register(IService, string) |
Register with unique identifier |
Unregister(IService) |
Unregister a service |
var dialogService = Workspace.Services.Get<IDialogService>();
var mapService = Workspace.Services.Get<IMapService>();Displays standard dialogs for entity selection and position picking.
| Method | Description |
|---|---|
ShowEntityBrowserDialog(EntityTypeCollection, IEnumerable<Guid>, bool, SelectionMode) |
Show entity browser |
ShowEntityBrowserDialog(..., Window) |
Show with owner window |
ShowGeoPositionDialog(GeoCoordinate) |
Show position picker |
var dialog = Workspace.Services.Get<IDialogService>();
var types = new EntityTypeCollection { EntityType.Camera };
var selected = dialog.ShowEntityBrowserDialog(types, null, false, SelectionMode.Single);Executes tasks programmatically.
| Method | Description |
|---|---|
Execute(Guid) |
Execute task by ID, returns success |
Execute(Guid, out Page) |
Execute and return opened page |
ExecuteAsync(Guid, CancellationToken) |
Async execution |
var taskService = Workspace.Services.Get<ITaskService>();
taskService.Execute(myTaskId);Interacts with Security Center maps.
| Member | Description |
|---|---|
DefaultSystemMap |
System default map GUID |
GetDefaultMap() |
Get user's default map |
GetSnapshotAsync(Guid, GeoView, Size, IList<Guid>, TimeSpan) |
Get map snapshot |
RegisterLayer(LayerDescriptor) |
Register custom layer |
UnregisterLayer(LayerDescriptor) |
Unregister layer |
LocateEntityOnMap(Guid, Guid, bool, bool) |
Center map on entity |
LocateEntityOnMapIntoSpecificTile(Guid, Guid, int, int) |
Center in specific tile |
var mapService = Workspace.Services.Get<IMapService>();
mapService.LocateEntityOnMap(mapGuid, entityGuid, showDialog: false, showInTile: true);Registers event extenders for custom event handling.
| Method | Description |
|---|---|
RegisterEventExtender(EventExtender) |
Register extender |
UnregisterEventExtender(EventExtender) |
Unregister extender |
For more information, see About event extenders.
Manages configuration pages in Config Tool.
| Method | Description |
|---|---|
DisplayEntity(Guid) |
Display entity in Config Tool |
DisplayEntityAsync(Guid, CancellationToken) |
Async display |
Register(...) |
Register configuration page |
Unregister(...) |
Unregister configuration page |
For a complete example, see the ConfigPageSample on GitHub.
Controls application lifecycle.
| Method | Description |
|---|---|
IsRunning(ApplicationType) |
Check if application is running |
Start(ApplicationType) |
Start application |
Start(ApplicationType, string) |
Start with arguments |
var shell = Workspace.Services.Get<IShellService>();
if (!shell.IsRunning(ApplicationType.ConfigTool))
{
shell.Start(ApplicationType.ConfigTool);
}Manages alarm operations.
| Member | Description |
|---|---|
Acknowledge(int, Guid, ActionType) |
Acknowledge alarm |
Snooze(int) |
Snooze alarm instance |
Snooze(IEnumerable<int>) |
Snooze multiple alarms |
RetrieveAlarmMonitoringPage(bool) |
Get alarm page |
BeforeAcknowledge |
Event before acknowledgment |
var alarmService = Workspace.Services.Get<IAlarmService>();
alarmService.Acknowledge(instanceId, alarmGuid, ActionType.Acknowledge);Handles badge printing operations.
| Method | Description |
|---|---|
BeginPrint(...) |
Start async print (PrintQueue overload) |
BeginPrint(...) |
Start async print (PrintDialog overload) |
EndPrint(IAsyncResult) |
Complete print operation |
For a complete example, see the BadgePrinterSample on GitHub.
Accesses the Security Desk vault for stored files.
| Member | Description |
|---|---|
VaultPath |
Vault folder path |
VaultFolder |
Vault DirectoryInfo |
GetVaultItemsAsync() |
Get all vault items |
GetVaultVideoItemsAsync() |
Get video items |
GetVaultSnapshopItemsAsync() |
Get snapshot items |
GetVaultFolderItemsAsync() |
Get folder items |
Creates and edits incidents.
| Method | Description |
|---|---|
Create(...) |
Display incident creation dialog |
Edit(...) |
Display incident edit dialog |
Generates reports.
| Method | Description |
|---|---|
CreateReport(Guid, string, FieldsCollection) |
Create report with type GUID, name, and filter fields |
CreateReportAsync(Guid, string, FieldsCollection, CancellationToken) |
Async creation |
var reportService = Workspace.Services.Get<IReportService>();
var fields = new FieldsCollection();
fields.Add("Cameras", new[] { cameraGuid });
var reportPage = reportService.CreateReport(ReportTypes.CameraEvent, "Camera Events", fields);Manages dashboard widget categories.
| Method | Description |
|---|---|
RegisterCategory(Guid, string, int) |
Register category with ID, name, priority |
Controls guard tour functionality.
| Member | Description |
|---|---|
this[Monitor] |
Get guard tour for monitor |
Initialized |
Event when service initializes |
Registers contextual actions for right-click menus.
| Method | Description |
|---|---|
Register(ContextualAction) |
Register action |
Register(ContextualActionGroup) |
Register action group |
Unregister(ContextualAction) |
Unregister action |
Unregister(ContextualActionGroup) |
Unregister group |
For more information, see About contextual actions.
Builds content from input objects.
| Method | Description |
|---|---|
Build(object) |
Build content group |
Build(object, ContentTypes) |
Build with type filter |
Manages background process notifications.
| Member | Description |
|---|---|
Notifications |
Current notifications |
AddProcess(string) |
Add process, returns token |
AddProcess(string, ImageSource) |
Add with icon |
AddProcess(string, ImageSource, Action) |
Add with callback |
EndProcess(Guid, BackgroundProcessResult) |
End process with result |
EndProcess(Guid, BackgroundProcessResult, string) |
End process with result and message |
UpdateProgress(Guid, double) |
Update progress percentage (0.0 to 100.0) |
UpdateProgress(Guid, string) |
Update progress message |
Notify(string) |
Show notification popup |
ClearProcess(Guid) |
Clear specific process |
ClearCompletedProcesses() |
Clear all completed |
GetNotification(Guid) |
Get notification by token |
CollectionChanged |
Event for collection changes |
ProcessStatusChanged |
Event for status changes |
var service = Workspace.Services.Get<IBackgroundProcessNotificationService>();
var token = service.AddProcess("Processing...");
// Do work
service.UpdateProgress(token, 50.0);
// Complete
service.EndProcess(token, BackgroundProcessResult.Success, "Done");For a complete example, see the BackgroundProcessSample on GitHub.
Custom services provide shared functionality across modules. Define a service interface and implementation, then register it with the workspace.
Create an interface that extends IService:
public interface IAnalysisService : IService
{
IList<AnalysisPoint> GetAnalysisData(Guid entityId, DateTime start, DateTime end);
}Implement the interface with the Initialize method:
public sealed class AnalysisService : IAnalysisService
{
public Workspace Workspace { get; private set; }
public void Initialize(Workspace workspace)
{
Workspace = workspace;
}
public IList<AnalysisPoint> GetAnalysisData(Guid entityId, DateTime start, DateTime end)
{
// Implementation using Workspace.Sdk for entity access
var entity = Workspace.Sdk.GetEntity(entityId);
// Return analysis data
}
}Register in your module's Load method:
public class SampleModule : Module
{
private AnalysisService m_analysisService;
public override void Load()
{
m_analysisService = new AnalysisService();
m_analysisService.Initialize(Workspace);
Workspace.Services.Register(m_analysisService);
}
public override void Unload()
{
if (m_analysisService != null)
{
Workspace.Services.Unregister(m_analysisService);
m_analysisService = null;
}
}
}Other modules or components retrieve the service by interface type:
var analysisService = Workspace.Services.Get<IAnalysisService>();
var data = analysisService.GetAnalysisData(cameraId, startTime, endTime);Register with a unique ID when multiple implementations exist:
Workspace.Services.Register(service, "myModule.analysisService");
// Retrieve by ID
var service = Workspace.Services.Get<IAnalysisService>("myModule.analysisService");