init
This commit is contained in:
52
docs/ai/Common/DTS.Common.Service.md
Normal file
52
docs/ai/Common/DTS.Common.Service.md
Normal file
@@ -0,0 +1,52 @@
|
||||
---
|
||||
source_files:
|
||||
- Common/DTS.Common.Service/ProjectInstaller.cs
|
||||
- Common/DTS.Common.Service/Program.cs
|
||||
- Common/DTS.Common.Service/DTSService.Designer.cs
|
||||
- Common/DTS.Common.Service/DTSService.cs
|
||||
- Common/DTS.Common.Service/ProjectInstaller.Designer.cs
|
||||
generated_at: "2026-04-17T16:02:06.149898+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "c917bed8fd5b39aa"
|
||||
---
|
||||
|
||||
# DTS.Common.Service
|
||||
|
||||
### Purpose
|
||||
This module implements a generic Windows Service application template for DTS (Diversified Technical Systems) common services. It provides a reusable service infrastructure with event logging, configurable monitoring via timers, and support for custom commands. The service is configured to run under the LocalSystem account with automatic startup.
|
||||
|
||||
### 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 `DTSService` instance via `ServiceBase.Run()`.
|
||||
|
||||
**DTSService** (class, inherits `ServiceBase`)
|
||||
- `DTSService()` - Constructor that initializes the event log source, configures logging, and optionally starts a monitoring timer if `Settings.Default.Monitoring` is enabled with interval from `Settings.Default.Interval`.
|
||||
- `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 `Command1` (128), `Command2` (129), and `Command3` (130) via the `CustomCommands` enum.
|
||||
- `CustomCommands` (enum) - Defines custom command values: `Command1 = 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 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.
|
||||
- The service is installed with `ServiceAccount.LocalSystem`, `ServiceStartMode.Automatic`, and `ServiceName = "DTSService"`.
|
||||
|
||||
### Dependencies
|
||||
- **Depends on**: `System.Configuration.Install`, `System.ServiceProcess`, `System.Diagnostics`, `System.Timers`, `DTS.Common.Service.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 timer variable in the constructor is a local variable, not a class field, which could lead to garbage collection issues.
|
||||
- The designer file comment references "CPUService" but the actual class is `DTSService`, suggesting copy-paste history.
|
||||
|
||||
---
|
||||
Reference in New Issue
Block a user