52 lines
3.5 KiB
Markdown
52 lines
3.5 KiB
Markdown
|
|
---
|
||
|
|
source_files:
|
||
|
|
- Common/DTS.Common.DBSyncService/ProjectInstaller.cs
|
||
|
|
- Common/DTS.Common.DBSyncService/Program.cs
|
||
|
|
- Common/DTS.Common.DBSyncService/DBSyncService.Designer.cs
|
||
|
|
- Common/DTS.Common.DBSyncService/DBSyncService.cs
|
||
|
|
- Common/DTS.Common.DBSyncService/ProjectInstaller.Designer.cs
|
||
|
|
generated_at: "2026-04-17T16:02:06.149303+00:00"
|
||
|
|
model: "zai-org/GLM-5-FP8"
|
||
|
|
schema_version: 1
|
||
|
|
sha256: "cb5636bf23f23ea0"
|
||
|
|
---
|
||
|
|
|
||
|
|
# DTS.Common.DBSyncService
|
||
|
|
|
||
|
|
### Purpose
|
||
|
|
This module implements a Windows Service application for database synchronization monitoring. It provides a service infrastructure that can be installed and run as a system service, with configurable monitoring intervals and event logging capabilities. The service supports custom commands for triggering synchronization operations and is designed to run continuously in the background.
|
||
|
|
|
||
|
|
### Public Interface
|
||
|
|
|
||
|
|
**ProjectInstaller** (class)
|
||
|
|
- `ProjectInstaller()` - Constructor that initializes the service installer components. Marked with `[RunInstaller(true)]` for InstallUtil.exe deployment.
|
||
|
|
|
||
|
|
**Program** (static class)
|
||
|
|
- `static void Main()` - Application entry point that creates and runs a `DBSyncService` instance via `ServiceBase.Run()`.
|
||
|
|
|
||
|
|
**DBSyncService** (class, inherits `ServiceBase`)
|
||
|
|
- `DBSyncService()` - Constructor that initializes the event log source, configures logging to `Settings.Default.Service` log, and optionally starts a monitoring timer if `Settings.Default.Monitoring` is enabled.
|
||
|
|
- `void OnTimer(object sender, ElapsedEventArgs args)` - Timer callback that writes "Monitoring the System" to the event log. Contains a TODO comment for monitoring activities.
|
||
|
|
- `protected override void OnStart(string[] args)` - Writes a service started entry to the event log.
|
||
|
|
- `protected override void OnStop()` - Writes a service stopped entry to the event log.
|
||
|
|
- `protected override void OnCustomCommand(int command)` - Handles custom service commands. Supports `SyncDb` (128), `Command2` (129), and `Command3` (130) via the `CustomCommands` enum.
|
||
|
|
- `CustomCommands` (enum) - Defines custom command values: `SyncDb = 128`, `Command2 = 129`, `Command3 = 130`.
|
||
|
|
- `eventLog` (public field, `System.Diagnostics.EventLog`) - Event log instance for writing service entries.
|
||
|
|
|
||
|
|
### Invariants
|
||
|
|
- The event log source must exist before being used; the constructor creates it via `EventLog.CreateEventSource()` if it doesn't exist.
|
||
|
|
- The timer is only created and started if `Settings.Default.Monitoring` is `true`.
|
||
|
|
- Custom commands use values starting at 128 (Windows service custom command convention).
|
||
|
|
- The `ServiceName` in the designer is initially set to "Service1" but is overridden at runtime from `Settings.Default.ServiceName`.
|
||
|
|
|
||
|
|
### Dependencies
|
||
|
|
- **Depends on**: `System.Configuration.Install`, `System.ServiceProcess`, `System.Diagnostics`, `System.Timers`, `DTS.Common.DBSyncService.Properties` (Settings).
|
||
|
|
- **Depended on by**: Not evident from source alone; this is a top-level executable service application.
|
||
|
|
|
||
|
|
### Gotchas
|
||
|
|
- The `OnTimer` method contains only a TODO comment and event log write; actual monitoring logic is not implemented.
|
||
|
|
- The `OnCustomCommand` switch cases are empty—no actual command handling logic exists.
|
||
|
|
- The designer file sets `ServiceName = "Service1"` which is a placeholder; the actual service name comes from settings at runtime.
|
||
|
|
- The timer variable in the constructor is a local variable, not a class field, which could lead to garbage collection issues if the service runs for extended periods (timer could be collected).
|
||
|
|
|
||
|
|
---
|