init
This commit is contained in:
90
enriched-partialglm/Common/DTS.Common.Service.md
Normal file
90
enriched-partialglm/Common/DTS.Common.Service.md
Normal file
@@ -0,0 +1,90 @@
|
||||
---
|
||||
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-16T11:37:04.449162+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "c2781b46f4b0859d"
|
||||
---
|
||||
|
||||
# DTS.Common.Service Module Documentation
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module provides a Windows Service infrastructure for DTS (Diversified Technical Systems) applications. It implements a standard Windows Service that can be installed, started, stopped, and controlled via the Windows Service Control Manager. The service includes built-in event logging capabilities and an optional monitoring feature that executes periodic tasks on a configurable timer interval. It serves as a base service framework that can be extended with custom monitoring activities and custom commands.
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `Program` (static class)
|
||||
Entry point for the service application.
|
||||
|
||||
| Member | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| `Main` | `static void Main()` | Creates a new `DTSService` instance and executes it via `ServiceBase.Run()`. This is the application entry point. |
|
||||
|
||||
### `DTSService` (class, inherits `ServiceBase`)
|
||||
The primary Windows Service implementation.
|
||||
|
||||
| Member | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| `DTSService()` | `public DTSService()` | Constructor. Initializes the event log source (creating it if it doesn't exist), configures the event log from settings, and optionally starts a monitoring timer if `Settings.Default.Monitoring` is enabled. |
|
||||
| `OnTimer` | `public void OnTimer(object sender, ElapsedEventArgs args)` | Timer callback that writes an informational entry "Monitoring the System" to the event log. Intended to be extended with monitoring activities. |
|
||||
| `OnStart` | `protected override void OnStart(string[] args)` | Called when the service starts. Writes a start message to the event log using `Settings.Default.ServiceName`. |
|
||||
| `OnStop` | `protected override void OnStop()` | Called when the service stops. Writes a stop message to the event log using `Settings.Default.ServiceName`. |
|
||||
| `OnCustomCommand` | `protected override void OnCustomCommand(int command)` | Handles custom service commands. Dispatches to switch statement based on `CustomCommands` enum values. |
|
||||
| `CustomCommands` | `public enum CustomCommands` | Defines custom command values: `Command1 = 128`, `Command2 = 129`, `Command3 = 130`. |
|
||||
| `eventLog` | `public System.Diagnostics.EventLog eventLog` | Public field providing access to the event log component. Defined in `DTSService.Designer.cs`. |
|
||||
|
||||
### `ProjectInstaller` (class, inherits `System.Configuration.Install.Installer`)
|
||||
Handles installation of the Windows Service via InstallUtil.exe.
|
||||
|
||||
| Member | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| `ProjectInstaller()` | `public ProjectInstaller()` | Constructor. Calls `InitializeComponent()` to configure service installers. |
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **Event Source Existence**: The event source specified by `Settings.Default.ServiceName` must exist before logging; the constructor creates it if missing via `EventLog.CreateEventSource()`.
|
||||
- **Event Log Configuration**: The event log name is determined by `Settings.Default.Service`, and the source by `Settings.Default.ServiceName`.
|
||||
- **Timer Interval**: When monitoring is enabled, the timer interval is set from `Settings.Default.Interval` (comment indicates default is 60 seconds).
|
||||
- **Service Account**: The service is configured to run under `ServiceAccount.LocalSystem` with no explicit username or password.
|
||||
- **Service Start Type**: The service is configured for `ServiceStartMode.Automatic`.
|
||||
- **Installation Identity**: The installer sets `ServiceName = "DTSService"`, `DisplayName = "DTS Common Service"`, and `Description = "Diversified Technical Systems Common Service"`.
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### This module depends on:
|
||||
- `System.ComponentModel` - For `IContainer` and component support
|
||||
- `System.ServiceProcess` - For `ServiceBase`, `ServiceInstaller`, `ServiceProcessInstaller`
|
||||
- `System.Diagnostics` - For `EventLog` and `EventLogEntryType`
|
||||
- `System.Timers` - For `Timer` and `ElapsedEventArgs`
|
||||
- `DTS.Common.Service.Properties` - For `Settings` class providing configuration values (`ServiceName`, `Service`, `Monitoring`, `Interval`)
|
||||
|
||||
### What depends on this module:
|
||||
- Not determinable from the provided source files alone. This appears to be a foundational service module intended to be extended or referenced by other DTS components.
|
||||
|
||||
---
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
1. **Timer Started in Constructor**: The monitoring timer is started in the `DTSService` constructor, not in `OnStart()`. This means the timer begins before the service is officially in a "running" state.
|
||||
|
||||
2. **Timer Not Stored as Field**: The `Timer` instance in the constructor is a local variable, not a class field. This could potentially allow garbage collection of the timer, though the event subscription may keep it alive. This is a potential reliability issue.
|
||||
|
||||
3. **Designer ServiceName Mismatch**: In `DTSService.Designer.cs`, `InitializeComponent()` sets `this.ServiceName = "Service1"`, but the actual service name is configured via `Settings.Default.ServiceName`. The designer value appears to be a placeholder that gets overridden.
|
||||
|
||||
4. **Empty Custom Command Implementations**: The `OnCustomCommand` method defines three custom commands (`Command1`, `Command2`, `Command3`) but all switch cases are empty. This is placeholder functionality.
|
||||
|
||||
5. **TODO in Production Code**: The `OnTimer` method contains a `// TODO: Insert monitoring activities here.` comment, indicating incomplete implementation.
|
||||
|
||||
6. **Monitoring Conditional**: If `Settings.Default.Monitoring` is `false`, the timer is never created, and `OnTimer` will never be called. The service will only log start/stop events.
|
||||
Reference in New Issue
Block a user