コード例 #1
0
            public IList <T> Query(T queryCriteria, out LocateFailureInfo[] failures)
            {
                if (queryCriteria == null)
                {
                    const string message = "The argument cannot be null.";
                    Platform.Log(LogLevel.Error, message);
                    throw new FaultException(message);
                }

                var results     = new List <T>();
                var failureList = new List <LocateFailureInfo>();

                try
                {
                    foreach (var priorsServer in ServerDirectory.GetPriorsServers(true))
                    {
                        try
                        {
                            IList <T> r = null;
                            priorsServer.GetService <IStudyRootQuery>(service => r = _query(queryCriteria, service));
                            results.AddRange(r);
                        }
                        catch (Exception e)
                        {
                            QueryFailedFault fault = new QueryFailedFault();
                            fault.Description = String.Format("Failed to query server {0}.", priorsServer.Name);
                            Platform.Log(LogLevel.Error, e, fault.Description);
                            if (_suppressQueryFailureFaults)
                            {
                                failureList.Add(new LocateFailureInfo(fault, fault.Description)
                                {
                                    ServerName = priorsServer.Name, ServerAE = priorsServer.AETitle
                                });
                            }
                            else
                            {
                                throw new FaultException <QueryFailedFault>(fault, fault.Description);
                            }
                        }
                    }
                }
                catch (FaultException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    QueryFailedFault fault = new QueryFailedFault();
                    fault.Description = String.Format("An unexpected error has occurred.");
                    Platform.Log(LogLevel.Error, e, fault.Description);
                    throw new FaultException <QueryFailedFault>(fault, fault.Description);
                }

                failures = failureList.ToArray();
                return(results);
            }
コード例 #2
0
ファイル: IStudyLocator.cs プロジェクト: hksonngan/Xian
 public LocateFailureInfo(QueryFailedFault fault, string faultDescription)
 {
     Fault       = fault;
     Description = faultDescription;
 }
コード例 #3
0
ファイル: StudyLocator.cs プロジェクト: hksonngan/Xian
        private static IList <TIdentifier> Query <TIdentifier, TFindScu>(TIdentifier queryCriteria, TFindScu scu)
            where TIdentifier : Identifier, new()
            where TFindScu : ServerQuery
        {
            if (queryCriteria == null)
            {
                const string message = "The query identifier cannot be null.";
                Platform.Log(LogLevel.Error, message);
                throw new FaultException(message);
            }

            IList <DicomAttributeCollection> scuResults;
            DicomAttributeCollection         criteria;

            try
            {
                criteria = queryCriteria.ToDicomAttributeCollection();
            }
            catch (DicomException e)
            {
                DataValidationFault fault = new DataValidationFault
                {
                    Description =
                        "Failed to convert contract object to DicomAttributeCollection."
                };
                Platform.Log(LogLevel.Error, e, fault.Description);
                throw new FaultException <DataValidationFault>(fault, fault.Description);
            }
            catch (Exception e)
            {
                DataValidationFault fault = new DataValidationFault
                {
                    Description =
                        "Unexpected exception when converting contract object to DicomAttributeCollection."
                };
                Platform.Log(LogLevel.Error, e, fault.Description);
                throw new FaultException <DataValidationFault>(fault, fault.Description);
            }

            try
            {
                scuResults = new List <DicomAttributeCollection>();
                scu.Query(criteria, result => scuResults.Add(result));
            }
            catch (FaultException)
            {
                throw;
            }
            catch (Exception e)
            {
                QueryFailedFault fault = new QueryFailedFault
                {
                    Description = String.Format("An unexpected error has occurred ({0})",
                                                e.Message)
                };
                Platform.Log(LogLevel.Error, e, fault.Description);
                throw new FaultException <QueryFailedFault>(fault, fault.Description);
            }


            List <TIdentifier> results = new List <TIdentifier>();

            foreach (DicomAttributeCollection result in scuResults)
            {
                TIdentifier identifier = Identifier.FromDicomAttributeCollection <TIdentifier>(result);
                if (String.IsNullOrEmpty(identifier.RetrieveAeTitle))
                {
                    identifier.RetrieveAeTitle = scu.Partition.AeTitle;
                }

                results.Add(identifier);
            }

            return(results);
        }