Exemple #1
0
 protected internal override void PostResponse(DicomService service, DicomResponse response)
 {
     try
     {
         if (OnResponseReceived != null) OnResponseReceived(this, (DicomCEchoResponse)response);
     }
     catch
     {
     }
 }
Exemple #2
0
        private DicomService GetCurrentDicomService( )
        {
            DicomService gatewayService = null;

            if (_gatewaySource.Current != null)
            {
                Gateways.GatewayServerRow gatewayRow = (Gateways.GatewayServerRow)(( DataRowView )_gatewaySource.Current).Row;

                gatewayService = GetGatewayService(gatewayRow);
            }

            return(gatewayService);
        }
Exemple #3
0
        private static void LoadLoggingState(DicomService service)
        {
            LoggingModuleConfigurationManager loggingConfigManager = ServiceLocator.Retrieve <LoggingModuleConfigurationManager> ( );

            if (service != null && loggingConfigManager.IsLoaded)
            {
                ServerState.Instance.LoggingState = loggingConfigManager.GetLoggingState( );
            }
            else
            {
                ServerState.Instance.LoggingState = GetDefaultLoggingState( );
            }
        }
Exemple #4
0
        private string SaveDicomFilesToFilesystem(
            IDicomStudy dicomStudy, string jobProcessingFolder, string studyName, DicomService dicomSource)
        {
            var series = dicomStudy.Series.FirstOrDefault();

            var folderPath = Path.GetFullPath(Path.Combine(jobProcessingFolder, studyName, Dicom));

            dicomSource.SaveSeriesToLocalDisk(series, folderPath);

            CopyDicomFilesToRootFolder(folderPath);

            return(Path.GetFullPath(folderPath));
        }
 /// <summary>
 /// Invoke the event handler upon receiving a N-GET response.
 /// </summary>
 /// <param name="service">Associated DICOM service.</param>
 /// <param name="response">N-GET response.</param>
 protected internal override void PostResponse(DicomService service, DicomResponse response)
 {
     try
     {
         if (OnResponseReceived != null)
         {
             OnResponseReceived(this, (DicomNGetResponse)response);
         }
     }
     catch
     {
     }
 }
Exemple #6
0
        private void CreateConfigurationServices(DicomService service)
        {
            StorageModuleConfigurationManager storageConfigMnager  = new StorageModuleConfigurationManager(false);
            LoggingModuleConfigurationManager loggingConfigManager = new LoggingModuleConfigurationManager(false);

            if (null != service)
            {
                storageConfigMnager.Load(service.ServiceDirectory);
                loggingConfigManager.Load(service.ServiceDirectory);
            }

            ServiceLocator.Register <StorageModuleConfigurationManager> (storageConfigMnager);
            ServiceLocator.Register <LoggingModuleConfigurationManager> (loggingConfigManager);
        }
Exemple #7
0
        public static void GetService(string serviceDirectory, string displayName)
        {
            string dir = serviceDirectory.Replace(displayName, string.Empty);
            ServiceAdministrator _Administrator = new ServiceAdministrator(dir);

            _Administrator.Initialize(new List <string>()
            {
                displayName
            });
            if (_Administrator.Services.ContainsKey(displayName))
            {
                _Service = _Administrator.Services[displayName];
            }
        }
Exemple #8
0
        private int UninstallDicomServers(bool bChecked, bool removeFromBaseDirectoryOnly)
        {
            if (_serviceAdmin == null)
            {
                return(0);
            }

            int nCountRemoved = 0;

            try
            {
                List <DicomAE> servers = new List <DicomAE>();

                foreach (ListViewItem item in listViewServers.Items)
                {
                    bool remove = (!bChecked || (bChecked && item.Checked));
                    if (remove)
                    {
                        DicomService service = null;

                        try
                        {
                            service = _serviceAdmin.Services[item.Text];
                        }
                        catch (Exception e)
                        {
                            ShowError(e.Message);
                        }

                        if (service != null)
                        {
                            ShowMessage("Removing: " + item.Text);
                            if (MyUtils.UninstallOneDicomServer(service, removeFromBaseDirectoryOnly, _serviceAdmin))
                            {
                                servers.Add(new DicomAE(service.Settings.AETitle, service.Settings.IpAddress, service.Settings.Port, service.Settings.ReconnectTimeout, service.Settings.Secure));

                                nCountRemoved++;
                            }
                        }
                    }
                }

                UninstalledServers = servers.ToArray();
            }
            catch (Exception e)
            {
                ShowError(e.Message);
            }
            return(nCountRemoved);
        }
Exemple #9
0
        void _serverControlStrip_StopAllServers(object sender, EventArgs e)
        {
            Gateways gateways = (Gateways)_gatewaySource.DataSource;

            foreach (Gateways.GatewayServerRow gateway in gateways.GatewayServer)
            {
                DicomService service = GetGatewayService(gateway);

                if (null != service && service.Status != ServiceControllerStatus.Stopped)
                {
                    service.Stop( );
                }
            }
        }
 internal override void PostResponse(DicomService service, DicomResponse response)
 {
     try
     {
         if (OnResponseReceived != null)
         {
             OnResponseReceived(this, (DicomCMoveResponse)response);
         }
     }
     catch (System.Exception ex)
     {
         Log.LogManager.GetLogger("Dicom.Network").Error("", ex.Message, ex.Source, ex.StackTrace);
     }
 }
Exemple #11
0
        void _serverControlStrip_StopServer(object sender, EventArgs e)
        {
            DicomService gatewayService = null;

            gatewayService = GetCurrentDicomService( );

            if (gatewayService != null)
            {
                if (gatewayService.Status != ServiceControllerStatus.Stopped)
                {
                    gatewayService.Stop( );
                }
            }
        }
Exemple #12
0
        static public bool UninstallOneDicomServer(DicomService service, bool removeFromBaseDirectoryOnly, ServiceAdministrator serviceAdmin)
        {
            bool success = false;

            try
            {
                if (service != null)
                {
                    if (removeFromBaseDirectoryOnly)
                    {
                        string serviceDir = Path.GetFullPath(service.ServiceDirectory).ToLower();

                        if (!serviceDir.Contains(Program._baseDir.ToLower( )))
                        {
                            return(false);
                        }
                    }

                    // If this fails to stop the service, we can still proceed to delete it
                    // In this case, the service was marked as 'disabled', marked for deleted, and will be deleted on reboot
                    // (or if the service is stopped, it will be automatically deleted)
                    StopOneDicomServer(service);

                    success = true;
                    string serviceDirectory = service.ServiceDirectory;
                    serviceAdmin.SafeUnInstallService(service);

                    // To remove the service directory and files, uncomment the code below
                    if (success)
                    {
                        try
                        {
                            RemoveOneDicomServerFiles(serviceDirectory);
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.Assert(false, e.ToString());
                success = false;
            }
            return(success);
        }
Exemple #13
0
        static public bool InitializeDatabase(DicomService service, out string errorString)
        {
            bool success = true;

            errorString = string.Empty;

            string       ConnectionString = "Data Source='" + service.ServiceDirectory + "Dicom.sdf'";
            string       ImageDirectory   = service.ServiceDirectory + @"Images\";
            DicomDataSet ds = new DicomDataSet();

            if (!File.Exists(service.ServiceDirectory + @"Dicom.sdf"))
            {
                string fullname = GetResourceFullName(@"Dicom.sdf");
                Stream stream   = Assembly.GetExecutingAssembly().GetManifestResourceStream(fullname);

                if (stream != null)
                {
                    FileStream fs   = new FileStream(service.ServiceDirectory + "Dicom.sdf", FileMode.CreateNew);
                    byte[]     data = new byte[stream.Length];

                    stream.Read(data, 0, (int)stream.Length);
                    fs.Write(data, 0, (int)stream.Length);
                    fs.Close();

                    SqlCeUtils.UpgradeDatabase(ConnectionString);
                }
            }

            try
            {
                for (int i = 1; i <= 5; i++)
                {
                    string fullname = GetResourceFullName(string.Format("{0}.dcm", i));
                    Stream stream   = Assembly.GetExecutingAssembly().GetManifestResourceStream(fullname);

                    LoadDicomDataSetFromStream(ds, stream, DicomDataSetFlags.None);
                    DB.Insert(DateTime.Now, ConnectionString, ImageDirectory, string.Empty, ds);
                }
            }
            catch (Exception ex)
            {
                success     = false;
                errorString = ex.Message;
                throw ex;
            }
            return(success);
        }
Exemple #14
0
        static public bool WriteAeTitlesXml(DicomService service)
        {
            try
            {
                if (_aeTitles != null)
                {
                    _aeTitles.AcceptChanges( );

                    _aeTitles.WriteXml(service.ServiceDirectory + "aetitles.xml");
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #15
0
        /// <summary>
        /// Checks each study against all 'Series Selection Criteria' and returns only one that matches it and throws exception if more than one study is returned
        /// </summary>
        /// <param name="studies">List of dicom Study details</param>
        /// <param name="criteria">Series Selection Criteria</param>
        /// <param name="referenceStudyIndex">In process of finding matching studies, this parameter is used to filter in studies done only before this index.
        /// e.g. There is a list of studies and a only studies prior to study indexed 3 is desired. This parameter can be set to 3.
        /// In order to filter all studies this parameter to be set to -1</param>
        /// <param name="localNode"></param>
        /// <param name="sourceNode"></param>
        /// <returns></returns>
        private IDicomStudy FindStudyMatchingCriteria(
            IEnumerable <IDicomStudy> allStudies,
            IEnumerable <SeriesSelectionCriteria> seriesSelectionCriteria,
            int referenceStudyIndex,
            DicomService dicomSource)
        {
            _log.Info($"ssc.c: {seriesSelectionCriteria.Count()}");
            var studiesMatchingDateCriteria = GetStudiesMatchingDateCriteria(allStudies, seriesSelectionCriteria, referenceStudyIndex);

            _log.Info($"ssc.c: {seriesSelectionCriteria.Count()}");
            var studiesMatchingStudyDetails = GetStudiesMatchingStudyDetails(studiesMatchingDateCriteria, seriesSelectionCriteria);

            _log.Info($"ssc.c: {seriesSelectionCriteria.Count()}");
            var studiesContainingMatchingSeries = GetStudiesContainingMatchingSeries(studiesMatchingStudyDetails, seriesSelectionCriteria, dicomSource);

            var matchedStudies = GetStudiesMatchingOtherCriteria(studiesContainingMatchingSeries, seriesSelectionCriteria).ToList();

            return(matchedStudies.FirstOrDefault());
        }
Exemple #16
0
        public void UpdateUI( )
        {
            _syncContext.Send(new SendOrPostCallback(delegate(object state) {
                _serverControlStrip.CanStart    = _serverControlStrip.CanStop = (_view.SelectedRow != null) && ServerState.Instance.ServiceAdmin != null;
                _serverControlStrip.CanStartAll = _serverControlStrip.CanStopAll = _gatewaySource.Count > 0 && ServerState.Instance.ServiceAdmin != null;

                if (null != _view.SelectedRow && _gatewaySource.Current != null)
                {
                    GatewayServer server = (GatewayServer)((Gateways.GatewayServerRow)(( DataRowView )_gatewaySource.Current).Row).GatewayServer;

                    if (null != ServerState.Instance.ServiceAdmin &&
                        ServerState.Instance.ServiceAdmin.Services.ContainsKey(server.ServiceName))
                    {
                        DicomService service = ServerState.Instance.ServiceAdmin.Services [server.ServiceName];


                        _serverControlStrip.CanStart = service.Status != ServiceControllerStatus.Running;
                        _serverControlStrip.CanStop  = service.Status != ServiceControllerStatus.Stopped;
                    }
                }
            }), null);
        }
Exemple #17
0
        /// <summary>
        /// Creates a DicomService object given a source AET (which should be in the config file)
        /// </summary>
        /// <param name="sourceAet"></param>
        /// <returns></returns>
        private DicomService CreateDicomSource(string sourceAet)
        {
            var        capiConfig  = CapiConfig.GetConfig();
            var        localNode   = capiConfig.DicomConfig.LocalNode;
            var        remoteNodes = capiConfig.DicomConfig.RemoteNodes;
            IDicomNode sourceNode;

            if (remoteNodes.Count == 0)
            {
                _log.Error("No remote nodes found in config file.");
                throw new Exception("No remote nodes found in config file.");
            }

            try
            {
                sourceNode = remoteNodes
                             .Single(n => n.AeTitle.Equals(sourceAet, StringComparison.InvariantCultureIgnoreCase));
            }
            catch (Exception ex)
            {
                var errorMessage =
                    $"Source node AET [{sourceAet}] in Recipe was not found in config file list of remote nodes";
                _log.Error(errorMessage, ex);
                throw new Exception(errorMessage);
            }

            try
            {
                var dicomSource = new DicomService(localNode, sourceNode);
                dicomSource.CheckRemoteNodeAvailability();
                return(dicomSource);
            }
            catch (Exception ex)
            {
                _log.Error($"Local Node AET [{localNode.AeTitle}] cannot reach" +
                           $"Source Node AET [{sourceAet}]", ex);
                throw;
            }
        }
        public DicomRequestAttrs Extract(DicomService service, DicomCStoreRequest request)
        {
            var acqDate         = request.Dataset.Get(DicomTag.AcquisitionDate, string.Empty);
            var acqDateTime     = request.Dataset.Get(DicomTag.AcquisitionDateTime, string.Empty);
            var acqTime         = request.Dataset.Get(DicomTag.AcquisitionTime, string.Empty);
            var acquisitionDate = buildAcquisitionDateTime(acqDate, acqTime);

            return(new DicomRequestAttrs()
            {
                CalledAE = service.Association.CalledAE,
                AcquisitionDateTime = acquisitionDate,
                Modality = request.Dataset.Get(DicomTag.Modality, string.Empty),
                PatientName = request.Dataset.Get(DicomTag.PatientName, string.Empty),
                Priority = request.Priority.ToString(),
                RemoteHostIP = service.Association.RemoteHost,
                SeriesInstanceUID = request.Dataset.Get(DicomTag.SeriesInstanceUID, string.Empty),
                SOPInstanceUID = request.Dataset.Get(DicomTag.SOPInstanceUID, string.Empty),
                StudyDescription = request.Dataset.Get(DicomTag.StudyDescription, string.Empty),
                StudyInstanceUID = request.Dataset.Get(DicomTag.StudyInstanceUID, string.Empty),
                SeriesCount = request.Dataset.Get(DicomTag.NumberOfStudyRelatedSeries, 1),
                ImageCount = request.Dataset.Get(DicomTag.NumberOfSeriesRelatedInstances, 1)
            });
        }
Exemple #19
0
        static void Main(string[] args)
        {
            if (args.Any(s=> s == "/console"))
            {
                var dicomService = new DicomService();
                dicomService.isRunningOnConsole = true;
                dicomService.Start(args);

                Console.ReadLine();

                dicomService.Stop();
            }
            else
            {
                ServiceBase[] ServicesToRun;

                ServicesToRun = new ServiceBase[]
                                    {
                                        new DicomService()
                                    };
                ServiceBase.Run(ServicesToRun);

            }
        }
Exemple #20
0
 /// <summary>
 /// Creates or updates a DICOM Service resource with the specified parameters.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group that contains the service instance.
 /// </param>
 /// <param name='workspaceName'>
 /// The name of workspace resource.
 /// </param>
 /// <param name='dicomServiceName'>
 /// The name of DICOM Service resource.
 /// </param>
 /// <param name='dicomservice'>
 /// The parameters for creating or updating a Dicom Service resource.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <DicomService> BeginCreateOrUpdateAsync(this IDicomServicesOperations operations, string resourceGroupName, string workspaceName, string dicomServiceName, DicomService dicomservice, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, workspaceName, dicomServiceName, dicomservice, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Exemple #21
0
 public StudiesController(DicomService dicomService)
 {
     m_DicomService = dicomService;
 }
Exemple #22
0
        private string GetReferenceSeriesForRegistration(Job job, IEnumerable <IDicomStudy> allStudiesForPatient, DicomService dicomSource)
        {
            var studiesForPatient = allStudiesForPatient.ToList();

            if (string.IsNullOrEmpty(job.Attempt.ReferenceSeries))
            {
                job.Attempt.ReferenceSeries = FindReferenceSeriesInPreviousJobs(job.Attempt.PatientId);
            }

            if (string.IsNullOrEmpty(job.Attempt.ReferenceSeries))
            {
                return(string.Empty);
            }

            var studyId  = job.GetStudyIdFromReferenceSeries();
            var seriesId = job.GetSeriesIdFromReferenceSeries();
            var study    = studiesForPatient.FirstOrDefault(s => s.StudyInstanceUid == studyId);

            if (study == null)
            {
                _log.Error($"Failed to find reference study to register series against StudyInstanceUid: [{studyId}]");
                return(string.Empty);
            }
            var allSeries      = dicomSource.GetSeriesForStudy(study.StudyInstanceUid);
            var matchingSeries = allSeries.FirstOrDefault(s => s.SeriesInstanceUid == seriesId);

            if (matchingSeries == null)
            {
                _log.Error($"Failed to find reference study with matching series to register series against StudyInstanceUid: [{studyId}] SeriesInstanceUid: [{seriesId}]");
                return(string.Empty);
            }
            study.Series.Add(matchingSeries);
            _log.Info("Saving reference series to disk...");
            string referenceFolderPath;

            try
            {
                referenceFolderPath = SaveDicomFilesToFilesystem(study, job.ProcessingFolder, Reference, dicomSource);
            }
            catch (Exception ex)
            {
                _log.Error("Failed to save reference series dicom files to disk.", ex);
                throw;
            }
            return(referenceFolderPath);
        }
Exemple #23
0
 /// <summary>
 /// Creates or updates a DICOM Service resource with the specified parameters.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group that contains the service instance.
 /// </param>
 /// <param name='workspaceName'>
 /// The name of workspace resource.
 /// </param>
 /// <param name='dicomServiceName'>
 /// The name of DICOM Service resource.
 /// </param>
 /// <param name='dicomservice'>
 /// The parameters for creating or updating a Dicom Service resource.
 /// </param>
 public static DicomService BeginCreateOrUpdate(this IDicomServicesOperations operations, string resourceGroupName, string workspaceName, string dicomServiceName, DicomService dicomservice)
 {
     return(operations.BeginCreateOrUpdateAsync(resourceGroupName, workspaceName, dicomServiceName, dicomservice).GetAwaiter().GetResult());
 }
Exemple #24
0
        static public bool SafeUnInstallService(this ServiceAdministrator serviceAdmin, DicomService service)
        {
            bool success = true;

            if (service != null)
            {
                try
                {
                    serviceAdmin.UnInstallService(service);
                }
                catch (Exception)
                {
                    success = false;
                }
            }
            return(success);
        }
Exemple #25
0
        private IDicomStudy GetCurrentDicomStudy(Recipe recipe, List <IDicomStudy> allStudiesForPatient, DicomService dicomSource)
        {
            _log.Info($"ssc.c: {recipe.CurrentSeriesCriteria.Count()}");
            var currentDicomStudy =
                string.IsNullOrEmpty(recipe.CurrentAccession)
                ? FindStudyMatchingCriteria(allStudiesForPatient, recipe.CurrentSeriesCriteria, -1, dicomSource)
                : FindStudyMatchingAccession(allStudiesForPatient, recipe.CurrentSeriesCriteria, recipe.CurrentAccession);

            currentDicomStudy = AddMatchingSeriesToStudy(currentDicomStudy, recipe.CurrentSeriesCriteria, dicomSource);

            return(currentDicomStudy);
        }
 public WorkstationServiceEventArgs ( string serviceName, DicomService service ) 
 {
    ServiceName = serviceName ;
    Service     = service ;
 }
Exemple #27
0
        private IDicomStudy GetPriorDicomStudy(
            Recipe recipe, int studyFixedIndex, IEnumerable <IDicomStudy> allStudiesForPatient, DicomService dicomSource)
        {
            var floatingSeriesBundle =
                string.IsNullOrEmpty(recipe.PriorAccession)
                    ? FindStudyMatchingCriteria(allStudiesForPatient, recipe.PriorSeriesCriteria, studyFixedIndex, dicomSource)
                    : FindStudyMatchingAccession(allStudiesForPatient, recipe.PriorSeriesCriteria, recipe.PriorAccession);

            if (floatingSeriesBundle != null)
            {
                floatingSeriesBundle = AddMatchingSeriesToStudy(floatingSeriesBundle, recipe.PriorSeriesCriteria, dicomSource);
            }

            return(floatingSeriesBundle);
        }
 public static DicomServiceTesterResult Test(DicomService dicomService, out string errorMessage)
 {
     return(SendDicomServiceMessage(dicomService, StorageAddinMessage.CanAccessDatabase, out errorMessage));
 }
Exemple #29
0
        static public void CopyAddIns(List <List <string> > addins, DicomService service, string addinsFolderName)
        {
            if (addins == null)
            {
                return;
            }

            string destDir = Path.Combine(service.ServiceDirectory, addinsFolderName);

            if (!Directory.Exists(destDir))
            {
                Directory.CreateDirectory(destDir);
            }

            foreach (List <string> addinPathList in addins)
            {
                bool successfulCopy = false;

                foreach (string addin in addinPathList)
                {
                    FileInfo f       = new FileInfo(addin);
                    string   newFile = Path.Combine(destDir, f.Name);

                    if (!File.Exists(addin))
                    {
                        continue;
                    }

                    try
                    {
                        if (!File.Exists(newFile))
                        {
                            File.Copy(addin, newFile, true);
                        }
                        successfulCopy = true;
                        break;
                    }
                    catch (IOException e)
                    {
                        int hResult = Marshal.GetHRForException(e);
                        //
                        // If the addin is being used by another process we will not report and
                        // error.
                        //
                        if (!e.Message.Contains("being used by another process") && (uint)hResult != ERROR_SHARING_VIOLATION)
                        {
                            throw e;
                        }
                        successfulCopy = true;
                    }
                }

                if (successfulCopy == false)
                {
                    string errorMessage;

                    if (addinPathList.Count > 1)
                    {
                        errorMessage = "At least one file must exist: " + string.Join(",", addinPathList.ToArray());
                    }
                    else
                    {
                        errorMessage = "File missing: " + string.Join(",", addinPathList.ToArray());
                    }
                    throw new FileNotFoundException(errorMessage);
                }
            }
        }
 public static DicomServiceTesterResult CrashDicomServer(DicomService dicomService, out string errorMessage)
 {
     return(SendDicomServiceMessage(dicomService, MessageNames.CrashDicomServer, out errorMessage));
 }
 public static DicomServiceTesterResult GarbageCollectDicomServer(DicomService dicomService, out string errorMessage)
 {
     return(SendDicomServiceMessage(dicomService, MessageNames.GarbageCollectDicomServer, out errorMessage));
 }
        public static DicomServiceTesterResult SendDicomServiceMessage(DicomService dicomService, string dicomServiceMessageGuid, out string errorMessage)
        {
            DicomServiceTesterResult result = DicomServiceTesterResult.Success;

            errorMessage = string.Empty;

            _serverService = dicomService;
            if (_serverService == null)
            {
                result = DicomServiceTesterResult.ErrorServiceIsNull;
            }
            else if (_serverService.Status != ServiceControllerStatus.Running)
            {
                result = DicomServiceTesterResult.ErrorServiceNotRunning;
            }
            else
            {
                _serverService.Message -= new EventHandler <MessageEventArgs>(_storageServerService_Message);
                _serverService.Message += new EventHandler <MessageEventArgs>(_storageServerService_Message);
                _serviceMessageReturned = false;
                _autoResetEvent.Reset();

                bool exceptionError = false;
                try
                {
                    _serverService.SendMessage(dicomServiceMessageGuid); // StorageAddinMessage.CrashDicomServer
                }
                catch (Exception ex)
                {
                    if (string.Compare("Service must be running", ex.Message, true) == 0)
                    {
                        result = DicomServiceTesterResult.ErrorServiceNotRunning;
                    }
                    else
                    {
                        result       = DicomServiceTesterResult.ErrorServiceCannotAccessDatabase;
                        errorMessage = ex.Message;
                    }
                    exceptionError = true;
                }

                if (exceptionError)
                {
                    return(result);
                }

                _autoResetEvent.WaitOne(WaitMilliseconds);
                if (_serviceMessageReturned)
                {
                    if (_serviceMessage.Success)
                    {
                        result = DicomServiceTesterResult.Success;
                    }
                    else
                    {
                        errorMessage = _serviceMessage.Data[0] as string;
                        result       = DicomServiceTesterResult.ErrorServiceCannotAccessDatabase;
                    }
                }
                else
                {
                    result = DicomServiceTesterResult.ErrorServiceNotResponding;
                }
            }
            return(result);
        }