Files
DP44/enriched-qwen3-coder-next/Common/DTS.Common.Service.md
2026-04-17 14:55:32 -04:00

5.7 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
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
2026-04-16T14:18:10.918818+00:00 zai-org/GLM-5-FP8 1 c2781b46f4b0859d

Documentation: DTS.Common.Service

1. Purpose

This module implements a Windows Service application framework for DTS (Diversified Technical Systems). It provides a template service (DTSService) that can be installed as a Windows Service, supports optional timer-based monitoring, writes operational events to the Windows Event Log, and handles custom service commands. The module exists to provide a reusable service infrastructure with installation support via InstallUtil.exe.


2. Public Interface

Classes

ProjectInstaller

Signature: public partial class ProjectInstaller : System.Configuration.Install.Installer

Description: Installer class for deploying the Windows Service. Marked with [RunInstaller(true)] attribute to enable installation via InstallUtil.exe. Configures the service to run under the LocalSystem account with automatic start type.

Constructor:

  • ProjectInstaller() — Calls InitializeComponent() to set up installers.

DTSService

Signature: public partial class DTSService : ServiceBase

Description: The main Windows Service implementation. Handles service lifecycle events (start/stop), optional timer-based monitoring, event logging, and custom command processing.

Constructor:

  • DTSService() — Initializes the service by calling InitializeComponent(), configures the event log source (creating it if it doesn't exist), and optionally starts a monitoring timer if Settings.Default.Monitoring is enabled.

Public Methods:

  • void OnTimer(object sender, ElapsedEventArgs args) — Timer callback that writes a monitoring message to the event log. Intended to be extended with actual monitoring activities.

  • protected override void OnStart(string[] args) — Called when the service starts; writes an informational entry to the event log.

  • protected override void OnStop() — Called when the service stops; writes an informational entry to the event log.

  • protected override void OnCustomCommand(int command) — Handles custom service commands. Supports commands 128, 129, and 130 (defined in CustomCommands enum). Currently has empty implementation for all commands.

Public Fields:

  • public System.Diagnostics.EventLog eventLog — Event log instance for writing service events.

Public Enum:

  • public enum CustomCommands — Defines custom command identifiers:
    • Command1 = 128
    • Command2 = 129
    • Command3 = 130

Program

Signature: static class Program

Description: Application entry point that creates and runs the DTSService instance.

Methods:

  • static void Main() — Entry point. Instantiates DTSService and passes it to ServiceBase.Run().

3. Invariants

  1. Event Source Existence: The event log source (Settings.Default.ServiceName) will be created if it does not exist before the service attempts to write to it.

  2. Timer Initialization: The monitoring timer is only created and started when Settings.Default.Monitoring is true.

  3. Timer Interval: The timer interval is determined by Settings.Default.Interval (default noted as 60 seconds in comments).

  4. Service Account: The service always installs to run under the LocalSystem account with null username and password.

  5. Service Start Type: The service is configured for Automatic start type upon installation.

  6. Custom Command Range: Custom commands use values 128-130, which fall within the valid range for custom service commands (128-255).


4. Dependencies

This module depends on:

  • System.ComponentModel — For IContainer and component support
  • System.ServiceProcess — For ServiceBase, ServiceInstaller, ServiceProcessInstaller
  • System.Diagnostics — For EventLog functionality
  • System.Timers — For Timer and ElapsedEventArgs
  • System.Configuration.Install — For Installer base class
  • DTS.Common.Service.Properties — For Settings class (referenced but not provided in source)

What depends on this module:

  • Unclear from source alone — The module appears to be a base/common service template, but no consumers are visible in the provided files.

5. Gotchas

  1. Service Name Inconsistency: The designer file (DTSService.Designer.cs) sets this.ServiceName = "Service1", which is a placeholder default. The actual service name is configured via Settings.Default.ServiceName at runtime and "DTSService" in the installer. This discrepancy could cause confusion.

  2. Timer Garbage Collection Risk: In DTSService() constructor, the Timer instance is declared as a local variable (var timer = new Timer...), not a class field. If the timer is not rooted elsewhere, it could be eligible for garbage collection, causing monitoring to silently stop.

  3. Empty Custom Command Implementations: All three custom command cases in OnCustomCommand have empty bodies. This is likely placeholder code awaiting implementation.

  4. TODO Placeholder in OnTimer: The OnTimer method contains a // TODO: Insert monitoring activities here. comment, indicating incomplete implementation.

  5. ReSharper Directive: The file DTSService.cs includes // ReSharper disable InconsistentNaming, suggesting naming convention inconsistencies were suppressed rather than resolved (likely related to "DTSService" naming pattern).