ServiceAdministrator Constructor(string,bool)

Summary
Initializes a new instance of the ServiceAdministrator class.
Syntax
C#
C++/CLI
public: 
ServiceAdministrator(  
   String^ BaseDirectory, 
   bool loadAllArchitectures 
) 

Parameters

BaseDirectory
The base directory.

loadAllArchitectures
if set to true load all architectures, false to load only the current architecture.

Remarks

loadAllArchitectures allows you to specify if you want to load 32/64 bit service with a service manager that does not match the service architecture. Setting this property to false will only load DICOM services that correspond to the current architecture. If loadAllArchitectures is set to true and the architectures do not match, you will not be able to edit the server add-ins.

Example
C#
using Leadtools; 
using Leadtools.Dicom.AddIn.Common; 
using Leadtools.Dicom.AddIn.Interfaces; 
 
 
 
AutoResetEvent statusEvent = new AutoResetEvent(false); 
 
public void InstallServiceTest() 
{ 
   ServiceAdministrator admin = new ServiceAdministrator(LEAD_VARS.InstallWin32Dir); 
   ServerSettings settings = new ServerSettings(); 
   DicomService service; 
 
   settings.AETitle = "DICOM_SERVER"; 
   settings.Port = 104; 
   settings.DisplayName = "Sample Dicom Server"; 
   settings.IpAddress = Dns.GetHostEntry(Environment.MachineName).AddressList[0].ToString(); 
   service = admin.InstallService(settings); 
   if (service != null && service.Settings.AETitle == "DICOM_SERVER") 
   { 
      service.Message += new EventHandler<MessageEventArgs>(service_Message); 
      service.StatusChange += new EventHandler(service_StatusChange); 
 
      Console.WriteLine("Base Directory: {0}", admin.BaseDirectory); 
      Console.WriteLine("Server Directory: {0}", service.ServiceDirectory); 
 
      try 
      { 
         AeInfo ae = new AeInfo(); 
 
         // 
         // Start the service 
         // 
         service.Start(); 
         service.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(30)); 
 
         ProcessMessages(); 
 
 
         if (service.IsAdminAvailable) 
         { 
            // 
            // Add AE Title 
            // 
            ae.AETitle = "CLIENT"; 
            ae.Port = 1000; 
            ae.Address = string.Empty; 
            service.SendMessage(MessageNames.AddAeTitle, ae); 
         } 
 
         ProcessMessages(); 
 
         // 
         // Pause the service 
         // 
         service.Pause(); 
         service.WaitForStatus(ServiceControllerStatus.Paused, TimeSpan.FromSeconds(30)); 
 
         ProcessMessages(); 
 
      } 
      finally 
      { 
         if (service.Status != ServiceControllerStatus.Stopped) 
         { 
            // 
            // Stop the service 
            // 
            service.Stop(); 
            service.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(30)); 
         } 
 
         // 
         // UnInstall the service 
         // 
         admin.UnInstallService(service); 
      } 
   } 
} 
 
// 
// Need to process messages so events get called in time.  In a normal windows applications there is no need 
//  to do this extra processing. 
// 
private void ProcessMessages() 
{ 
   while (!statusEvent.WaitOne(0)) 
   { 
      Application.DoEvents(); 
   } 
} 
 
void service_StatusChange(object sender, EventArgs e) 
{ 
   DicomService service = sender as DicomService; 
 
   Console.WriteLine(service.Status); 
   if (service.Status == ServiceControllerStatus.Running || service.Status == ServiceControllerStatus.Stopped || 
      service.Status == ServiceControllerStatus.Paused) 
   { 
      statusEvent.Set(); 
   } 
} 
 
void service_Message(object sender, MessageEventArgs e) 
{ 
   if (e.Message.Message == MessageNames.AddAeTitle) 
   { 
      if (e.Message.Success) 
      { 
         AeInfo ae = e.Message.Data[0] as AeInfo; 
 
         Console.WriteLine("AE Title: {0}", ae.AETitle); 
         Console.WriteLine("IP Address: {0}", ae.Address); 
         Console.WriteLine("Port: {0}", ae.Port); 
      } 
      else 
      { 
         Console.WriteLine("Error Adding AETITLE: {0}", e.Message.Error); 
      } 
   } 
   statusEvent.Set(); 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Dicom.Server.Admin Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.