public void TestServiceNodeLocalServices() { Initialize1(); var local = ServerDirectory.GetLocalServer(); Assert.IsTrue(local.IsSupported <IStudyRootQuery>()); Assert.IsNotNull(local.GetService <IStudyRootQuery>()); Assert.IsTrue(local.IsSupported <IStudyStoreQuery>()); Assert.IsNotNull(local.GetService <IStudyStoreQuery>()); Initialize2(); Assert.IsFalse(local.IsSupported <IStudyRootQuery>()); try { var service = local.GetService <IStudyRootQuery>(); Assert.Fail(); } catch (NotSupportedException) { } Assert.IsFalse(local.IsSupported <IStudyStoreQuery>()); try { var service = local.GetService <IStudyStoreQuery>(); Assert.Fail(); } catch (NotSupportedException) { } }
public static List <IDicomServiceNode> ToDicomServiceNodes(this IServerTreeNode serverTreeNode) { Platform.CheckForNullReference(serverTreeNode, "serverTreeNode"); if (serverTreeNode.IsLocalServer) { return new List <IDicomServiceNode> { ServerDirectory.GetLocalServer() } } ; if (serverTreeNode.IsServer) { return new List <IDicomServiceNode> { ((IServerTreeDicomServer)serverTreeNode).ToDicomServiceNode() } } ; var group = (IServerTreeGroup)serverTreeNode; var childServers = new List <IDicomServiceNode>(); childServers.AddRange(group.ChildGroups.SelectMany(g => g.ToDicomServiceNodes())); childServers.AddRange(group.Servers.Cast <IServerTreeDicomServer>().Select(g => g.ToDicomServiceNode())); return(childServers); }
public ImageEntry ToStoreEntry() { var entry = new ImageEntry { Image = new ImageIdentifier(this) { InstanceAvailability = "ONLINE", RetrieveAE = ServerDirectory.GetLocalServer(), SpecificCharacterSet = SpecificCharacterSet }, Data = new ImageEntryData { SourceAETitle = SourceAETitle } }; return(entry); }
internal SeriesEntry ToStoreEntry() { var entry = new SeriesEntry { Series = new SeriesIdentifier(this) { InstanceAvailability = "ONLINE", RetrieveAE = ServerDirectory.GetLocalServer(), SpecificCharacterSet = SpecificCharacterSet }, Data = new SeriesEntryData { ScheduledDeleteTime = GetScheduledDeleteTime(), SourceAETitlesInSeries = SourceAETitlesInSeries } }; return(entry); }
private void InternalVerifyServer() { if (this.NoServersSelected()) { //should never get here because the verify button should be disabled. this.Context.DesktopWindow.ShowMessageBox(SR.MessageNoServersSelected, MessageBoxActions.Ok); return; } try { var localServer = ServerDirectory.GetLocalServer(); var msgText = new StringBuilder(); msgText.AppendFormat(SR.MessageCEchoVerificationPrefix + "\r\n\r\n"); foreach (var server in this.Context.SelectedServers) { using (var scu = new VerificationScu()) { VerificationResult result = scu.Verify(localServer.AETitle, server.AETitle, server.ScpParameters.HostName, server.ScpParameters.Port); if (result == VerificationResult.Success) { msgText.AppendFormat(SR.MessageCEchoVerificationSingleServerResultSuccess + "\r\n", server.Name); } else { msgText.AppendFormat(SR.MessageCEchoVerificationSingleServerResultFail + "\r\n", server.Name); } // must wait for the SCU thread to release the connection properly before disposal, otherwise we might end up aborting the connection instead scu.Join(new TimeSpan(0, 0, 2)); } } msgText.AppendFormat("\r\n"); this.Context.DesktopWindow.ShowMessageBox(msgText.ToString(), MessageBoxActions.Ok); } catch (Exception e) { ExceptionHandler.Report(e, base.Context.DesktopWindow); } }
public StudyEntry ToStoreEntry() { var entry = new StudyEntry { Study = new StudyRootStudyIdentifier(this) { InstanceAvailability = "ONLINE", RetrieveAE = ServerDirectory.GetLocalServer(), SpecificCharacterSet = SpecificCharacterSet }, Data = new StudyEntryData { DeleteTime = DeleteTime, InstitutionNamesInStudy = DicomStringHelper.GetStringArray(InstitutionNamesInStudy), SourceAETitlesInStudy = DicomStringHelper.GetStringArray(SourceAETitlesInStudy), StationNamesInStudy = DicomStringHelper.GetStringArray(StationNamesInStudy), StoreTime = StoreTime } }; return(entry); }
public void TestGetLocalServer() { Initialize1(); var local = ServerDirectory.GetLocalServer(); Assert.AreEqual(SR.LocalServerName, local.Name); Assert.AreEqual("AETITLE", local.AETitle); //default value from DicomServerSettings. Assert.AreEqual("localhost", local.ScpParameters.HostName); Assert.AreEqual(104, local.ScpParameters.Port); Assert.IsTrue(local.IsLocal); var contract = local.ToDataContract(); Assert.AreEqual(SR.LocalServerName, contract.Server.Name); Assert.AreEqual("AETITLE", contract.Server.AETitle); Assert.AreEqual("localhost", contract.Server.ScpParameters.HostName); Assert.AreEqual(104, contract.Server.ScpParameters.Port); DicomServer.DicomServer.UpdateConfiguration(new DicomServerConfiguration { AETitle = "Local2", HostName = "::1", Port = 104 }); local = ServerDirectory.GetLocalServer(); Assert.AreEqual(SR.LocalServerName, local.Name); Assert.AreEqual("Local2", local.AETitle); Assert.AreEqual("::1", local.ScpParameters.HostName); Assert.AreEqual(104, local.ScpParameters.Port); Assert.IsTrue(local.IsLocal); contract = local.ToDataContract(); Assert.AreEqual(SR.LocalServerName, contract.Server.Name); Assert.AreEqual("Local2", contract.Server.AETitle); Assert.AreEqual("::1", contract.Server.ScpParameters.HostName); Assert.AreEqual(104, contract.Server.ScpParameters.Port); }
public override StudyItemList Query(QueryParameters queryParams, IApplicationEntity server) { Platform.CheckForNullReference(queryParams, "queryParams"); //.NET strings are unicode, therefore, so is all the query data. const string utf8 = "ISO_IR 192"; var collection = new DicomAttributeCollection { SpecificCharacterSet = utf8 }; collection[DicomTags.SpecificCharacterSet].SetStringValue(utf8); collection[DicomTags.QueryRetrieveLevel].SetStringValue("STUDY"); collection[DicomTags.PatientId].SetStringValue(queryParams["PatientId"]); collection[DicomTags.AccessionNumber].SetStringValue(queryParams["AccessionNumber"]); collection[DicomTags.PatientsName].SetStringValue(queryParams["PatientsName"]); collection[DicomTags.ReferringPhysiciansName].SetStringValue(queryParams["ReferringPhysiciansName"]); collection[DicomTags.StudyDate].SetStringValue(queryParams["StudyDate"]); collection[DicomTags.StudyTime].SetStringValue(""); collection[DicomTags.StudyDescription].SetStringValue(queryParams["StudyDescription"]); collection[DicomTags.PatientsBirthDate].SetStringValue(""); collection[DicomTags.ModalitiesInStudy].SetStringValue(queryParams["ModalitiesInStudy"]); collection[DicomTags.StudyInstanceUid].SetStringValue(queryParams["StudyInstanceUid"]); collection[DicomTags.NumberOfStudyRelatedInstances].SetStringValue(""); collection[DicomTags.InstanceAvailability].SetEmptyValue(); // must not be included in request collection[DicomTags.PatientSpeciesDescription].SetStringValue(GetString(queryParams, "PatientSpeciesDescription")); var codeValue = GetString(queryParams, "PatientSpeciesCodeSequenceCodeValue"); var codeMeaning = GetString(queryParams, "PatientSpeciesCodeSequenceCodeMeaning"); if (codeValue != null || codeMeaning != null) { var codeSequenceMacro = new CodeSequenceMacro { CodingSchemeDesignator = "", CodeValue = codeValue, CodeMeaning = codeMeaning }; collection[DicomTags.PatientSpeciesCodeSequence].AddSequenceItem(codeSequenceMacro.DicomSequenceItem); } collection[DicomTags.PatientBreedDescription].SetStringValue(GetString(queryParams, "PatientBreedDescription")); codeValue = GetString(queryParams, "PatientBreedCodeSequenceCodeValue"); codeMeaning = GetString(queryParams, "PatientBreedCodeSequenceCodeMeaning"); if (codeValue != null || codeMeaning != null) { var codeSequenceMacro = new CodeSequenceMacro { CodingSchemeDesignator = "", CodeValue = codeValue, CodeMeaning = codeMeaning }; collection[DicomTags.PatientBreedCodeSequence].AddSequenceItem(codeSequenceMacro.DicomSequenceItem); } collection[DicomTags.ResponsiblePerson].SetStringValue(GetString(queryParams, "ResponsiblePerson")); collection[DicomTags.ResponsiblePersonRole].SetStringValue(""); collection[DicomTags.ResponsibleOrganization].SetStringValue(GetString(queryParams, "ResponsibleOrganization")); var localServer = ServerDirectory.GetLocalServer(); var studyItemList = new StudyItemList(); using (var context = new DataAccessContext()) { foreach (DicomAttributeCollection result in context.GetStudyStoreQuery().Query(collection)) { var item = new StudyItem(result[DicomTags.StudyInstanceUid].ToString(), localServer); item.SpecificCharacterSet = result.SpecificCharacterSet; item.PatientId = result[DicomTags.PatientId].ToString(); item.PatientsName = new PersonName(result[DicomTags.PatientsName].ToString()); item.ReferringPhysiciansName = new PersonName(result[DicomTags.ReferringPhysiciansName].GetString(0, "")); item.PatientsBirthDate = result[DicomTags.PatientsBirthDate].ToString(); item.StudyDate = result[DicomTags.StudyDate].ToString(); item.StudyTime = result[DicomTags.StudyTime].ToString(); item.StudyDescription = result[DicomTags.StudyDescription].ToString(); item.ModalitiesInStudy = DicomStringHelper.GetStringArray(result[DicomTags.ModalitiesInStudy].ToString()); item.AccessionNumber = result[DicomTags.AccessionNumber].ToString(); item.NumberOfStudyRelatedInstances = result[DicomTags.NumberOfStudyRelatedInstances].GetInt32(0, 0); item.InstanceAvailability = result[DicomTags.InstanceAvailability].GetString(0, ""); if (String.IsNullOrEmpty(item.InstanceAvailability)) { item.InstanceAvailability = "ONLINE"; } item.PatientSpeciesDescription = result[DicomTags.PatientSpeciesDescription].GetString(0, ""); var patientSpeciesCodeSequence = result[DicomTags.PatientSpeciesCodeSequence]; if (!patientSpeciesCodeSequence.IsNull && patientSpeciesCodeSequence.Count > 0) { var codeSequenceMacro = new CodeSequenceMacro(((DicomSequenceItem[])result[DicomTags.PatientSpeciesCodeSequence].Values)[0]); item.PatientSpeciesCodeSequenceCodingSchemeDesignator = codeSequenceMacro.CodingSchemeDesignator; item.PatientSpeciesCodeSequenceCodeValue = codeSequenceMacro.CodeValue; item.PatientSpeciesCodeSequenceCodeMeaning = codeSequenceMacro.CodeMeaning; } item.PatientBreedDescription = result[DicomTags.PatientBreedDescription].GetString(0, ""); var patientBreedCodeSequence = result[DicomTags.PatientBreedCodeSequence]; if (!patientBreedCodeSequence.IsNull && patientBreedCodeSequence.Count > 0) { var codeSequenceMacro = new CodeSequenceMacro(((DicomSequenceItem[])result[DicomTags.PatientBreedCodeSequence].Values)[0]); item.PatientBreedCodeSequenceCodingSchemeDesignator = codeSequenceMacro.CodingSchemeDesignator; item.PatientBreedCodeSequenceCodeValue = codeSequenceMacro.CodeValue; item.PatientBreedCodeSequenceCodeMeaning = codeSequenceMacro.CodeMeaning; } item.ResponsiblePerson = new PersonName(result[DicomTags.ResponsiblePerson].GetString(0, "")); item.ResponsiblePersonRole = result[DicomTags.ResponsiblePersonRole].GetString(0, ""); item.ResponsibleOrganization = result[DicomTags.ResponsibleOrganization].GetString(0, ""); studyItemList.Add(item); } } AuditHelper.LogQueryIssued(null, null, EventSource.CurrentUser, EventResult.Success, SopClass.StudyRootQueryRetrieveInformationModelFindUid, collection); return(studyItemList); }
private StudyXml RetrieveStudyXml(StudyLoaderArgs studyLoaderArgs) { var headerParams = new HeaderStreamingParameters { StudyInstanceUID = studyLoaderArgs.StudyInstanceUid, ServerAETitle = _serverAe.AETitle, ReferenceID = Guid.NewGuid().ToString(), IgnoreInUse = studyLoaderArgs.Options != null && studyLoaderArgs.Options.IgnoreInUse }; HeaderStreamingServiceClient client = null; try { string uri = String.Format(StreamingSettings.Default.FormatHeaderServiceUri, _serverAe.ScpParameters.HostName, _serverAe.StreamingParameters.HeaderServicePort); client = new HeaderStreamingServiceClient(new Uri(uri)); client.Open(); var studyXml = client.GetStudyXml(ServerDirectory.GetLocalServer().AETitle, headerParams); client.Close(); return(studyXml); } catch (FaultException <StudyIsInUseFault> e) { throw new InUseLoadStudyException(studyLoaderArgs.StudyInstanceUid, e); } catch (FaultException <StudyIsNearlineFault> e) { throw new NearlineLoadStudyException(studyLoaderArgs.StudyInstanceUid, e) { IsStudyBeingRestored = e.Detail.IsStudyBeingRestored }; } catch (FaultException <StudyNotFoundFault> e) { throw new NotFoundLoadStudyException(studyLoaderArgs.StudyInstanceUid, e); } catch (FaultException e) { //TODO: Some versions (pre-Team) of the ImageServer //throw a generic fault when a study is nearline, instead of the more specialized one. string message = e.Message.ToLower(); if (message.Contains("nearline")) { throw new NearlineLoadStudyException(studyLoaderArgs.StudyInstanceUid, e) { IsStudyBeingRestored = true } } ; //assume true in legacy case. throw new LoadStudyException(studyLoaderArgs.StudyInstanceUid, e); } catch (Exception e) { if (client != null) { client.Abort(); } throw new LoadStudyException(studyLoaderArgs.StudyInstanceUid, e); } }
private static IImageViewer LaunchViewer(OpenStudiesRequest request, string primaryStudyInstanceUid) { try { CompleteOpenStudyInfo(request.StudiesToOpen); } catch (Exception ex) { if (request.ReportFaultToUser) { SynchronizationContext.Current.Post(ReportLoadFailures, ex); } throw; } ImageViewerComponent viewer; if (!request.LoadPriors.HasValue || request.LoadPriors.Value) { viewer = new ImageViewerComponent(LayoutManagerCreationParameters.Extended); } else { viewer = new ImageViewerComponent(LayoutManagerCreationParameters.Extended, PriorStudyFinder.Null); } var loadStudyArgs = (from info in request.StudiesToOpen let server = ServerDirectory.GetRemoteServersByAETitle(info.SourceAETitle).FirstOrDefault() ?? ServerDirectory.GetLocalServer() select new LoadStudyArgs(info.StudyInstanceUid, server)).ToList(); try { viewer.LoadStudies(loadStudyArgs); } catch (Exception e) { bool faultThrown = false; try { HandleLoadStudiesException(e, primaryStudyInstanceUid, viewer); } catch { faultThrown = true; viewer.Dispose(); throw; } finally { if (!faultThrown || request.ReportFaultToUser) { SynchronizationContext.Current.Post(ReportLoadFailures, e); } } } ImageViewerComponent.Launch(viewer, new LaunchImageViewerArgs(ViewerLaunchSettings.WindowBehaviour)); return(viewer); }
protected override void AddValueToResult(TDatabaseObject item, DicomAttribute resultAttribute) { resultAttribute.SetString(0, ServerDirectory.GetLocalServer().AETitle); }
/// <summary> /// Registers a number of <see cref="ISopDataSource"/>s with the <see cref="UnitTestStudyLoader"/>. /// </summary> /// <remarks> /// <para>Dispose the returned context to unregister the data sources.</para> /// <para>This method is thread safe.</para> /// </remarks> /// <param name="sopDataSources">The <see cref="ISopDataSource"/>s to be registered.</param> /// <returns>A context object that should be disposed in order to unregister the data sources.</returns> public static UnitTestStudyProviderContext RegisterStudies(IEnumerable <ISopDataSource> sopDataSources) { return(RegisterStudies(ServerDirectory.GetLocalServer(), sopDataSources)); }