How a-h-software-house-inc/accesscontroladaptersample works
Project Type & Purpose
• Type: A headless Windows‐service HTTP adapter (C#/.NET) that bridges a 3rd-party AccessControl system (emulated) with a Video Management System (VMS).
• Purpose: Polls the AccessControl system, caches data, implements the IAccessControlAdapter interface to expose REST endpoints, and pushes event notifications back into the VMS integration.
High-Level Components
a. External Access Control System (SimpleAccessControlEmulator)
b. Data Acquisition & Caching
• AccessControlDataUpdater (poller)
• AccessControlDataCache (in‐memory store)
c. Adapter Core
• IAccessControlAdapter interface + AccessControlAdapter implementation
• Domain models: AccessControlData/*, AdapterData/*
d. HTTP Server Layer
• HttpServer
• HttpRequestHandlers
e. Notifications Subsystem
• NotificationsManager (INotificationsManager)
f. Configuration & Logging
• appsettings.json / AccessControlAdapterSettings.json
• Logging.cs
g. Service Host & Deployment
• Program.cs (bootstraps HTTP server, DI, logging)
• Windows Service wrapper (sc.exe install)
Interactions & Data Flows
1. On startup (Program.cs):
– Read configuration → initialize Logging, Settings, DI container.
– Start HttpServer (listening on configured HTTP/HTTPS ports).
– Start DataUpdater polling loop.
– Initialize NotificationsManager.
2. DataUpdater polls External AccessControl Emulator via host/port → maps raw AccessControlData.* → updates AccessControlDataCache.
3. VMS (client) sends HTTP requests to the Adapter’s REST API endpoints (GetItems, GetUsers, GetEvents, etc.).
– HttpServer routes to HttpRequestHandlers → calls methods on AccessControlAdapter → reads from DataCache / executes actions via Adapter logic → returns JSON responses (using AdapterData.* DTOs).
4. When events occur (poller loops detect new events), FireAccessControlEvents is invoked → pushes notifications via NotificationsManager back to the VMS (e.g., via HTTP callback or push subscription).
5. ExecuteSystemAction / ExecuteItemAction methods on the adapter invoke commands back to the AccessControl system (through DataUpdater or direct API calls), returning success/failure.
Architectural Patterns & Principles
• Layered architecture:
– Data Layer (poller + cache)
– Adapter/Service Layer (business logic implementing IAccessControlAdapter)
– Presentation/API Layer (HTTP server + handlers)
– Notifications Layer
• Dependency Injection for loose coupling (Program.cs).
• Configuration externalized via JSON files.
• Interface‐based design (IAccessControlAdapter, INotificationsManager).
• Separation of concerns: polling vs. request‐serving vs. event‐pushing.
Checklist
[ ] Main external systems (VMS, AccessControl Emulator)
[ ] DataUpdater & DataCache
[ ] AccessControlAdapter core (interface + implementation)
[ ] HTTP Server & Handlers
[ ] NotificationsManager
[ ] Configuration files & logging subsystem
[ ] Clear component labels and port numbers where applicable