// Called when a SOP Instance is imported into the local datastore private void OnSopInstanceImported(object sender, ItemEventArgs <ImportedSopInstanceInformation> e) { if (_sopInstanceUidToAeTitle.ContainsKey(e.Item.SopInstanceUid)) { var destinationAeTitle = _sopInstanceUidToAeTitle[e.Item.SopInstanceUid]; var destinationServer = FindAETitle(new ServerTree().RootNode.ServerGroupNode, destinationAeTitle); if (destinationServer == null) { Platform.Log(LogLevel.Error, "Study " + e.Item.SopInstanceUid + " cannot be send to server. Failed to find server infromation for AE Title " + destinationAeTitle + "."); } else { var storageScu = new StorageScu(ServerTree.GetClientAETitle(), destinationServer.AETitle, destinationServer.Host, destinationServer.Port); storageScu.ImageStoreCompleted += OnStoreEachInstanceCompleted; storageScu.AddFile(e.Item.SopInstanceFileName); storageScu.BeginSend(OnAnnotationSendComplete, storageScu); } lock (_mapLock) _sopInstanceUidToAeTitle.Remove(e.Item.SopInstanceUid); } }
public void PublishToServer() { AENavigatorComponent aeNavigator = new AENavigatorComponent(); aeNavigator.IsReadOnly = true; aeNavigator.ShowCheckBoxes = false; aeNavigator.ShowLocalDataStoreNode = false; aeNavigator.ShowTitlebar = false; aeNavigator.ShowTools = false; SimpleComponentContainer dialogContainer = new SimpleComponentContainer(aeNavigator); DialogBoxAction code = this.Host.DesktopWindow.ShowDialogBox(dialogContainer, SR.SelectDestination); if (code != DialogBoxAction.Ok) { return; } if (aeNavigator.SelectedServers == null || aeNavigator.SelectedServers.Servers == null || aeNavigator.SelectedServers.Servers.Count == 0) { return; } if (aeNavigator.SelectedServers.Servers.Count < 1) { return; } BackgroundTask task = new BackgroundTask( delegate { foreach (Server destinationAE in aeNavigator.SelectedServers.Servers) { _studyBuilder.Publish(ServerTree.GetClientAETitle(), destinationAE.AETitle, destinationAE.Host, destinationAE.Port); } }, false); ProgressDialog.Show(task, base.Host.DesktopWindow, true, ProgressBarStyle.Marquee); }
// Note: you may change the name of the 'Apply' method as desired, but be sure to change the // corresponding parameter in the MenuAction and ButtonAction attributes /// <summary> /// Called by the framework when the user clicks the "apply" menu item or toolbar button. /// </summary> public void Apply() { // TODO: add code here to implement the functionality of the tool //|| this.Context.SelectedServerGroup.IsLocalDatastore if (!Enabled || this.Context.SelectedSingleSeries == null) { return; } //Dictionary<ApplicationEntity, List<StudyInformation>> retrieveInformation = new Dictionary<ApplicationEntity, List<StudyInformation>>(); List <string> seriesUIDs = new List <string>(); List <string> studyUIDs = new List <string>(); foreach (SeriesItem item in this.Context.SelectedMultipleSeries) { string foo = item.SeriesInstanceUID; Platform.Log(LogLevel.Info, foo); seriesUIDs.Add(item.SeriesInstanceUID); studyUIDs.Add(item.StudyInstanceUID); } string callingAE = ServerTree.GetClientAETitle(); BackgroundTask task = new BackgroundTask( delegate(IBackgroundTaskContext context) { // Send series level c-move //MyMoveScu moveScu = new MyMoveScu( //DicomMoveManager.MyMoveScu moveScu = new DicomMoveManager.MyMoveScu( MoveScuBase moveScu = new StudyRootMoveScu( callingAE, this.Context.SelectedServer.AETitle, this.Context.SelectedServer.Host, this.Context.SelectedServer.Port, callingAE); // Need to disable this line for the 1.5 version, because the movescu // code only allows one level per movescu request. This may not work with some // PACS moveScu.AddStudyInstanceUid(studyUIDs[0]); foreach (string seriesUID in seriesUIDs) { moveScu.AddSeriesInstanceUid(seriesUID); } moveScu.Move(); //moveScu.updated += delegate(object sender, EventArgs args) //{ // OnMoveUpdate(context, moveScu.completed, moveScu.total, moveScu.movestatus); // //context.ReportProgress(new BackgroundTaskProgress(moveScu.completed / moveScu.total, "Moving Study")); // //OnMoveUpdate(context, moveScu.completed, moveScu.total); //}; // += new EventHandler(OnMoveCompleted); moveScu.Dispose(); //OnMoveCompleted(); }, true); task.Run(); LocalDataStoreActivityMonitorComponentManager.ShowSendReceiveActivityComponent(this.Context.DesktopWindow); // //if (!retrieveInformation.ContainsKey(item.Server)) // // retrieveInformation[item.Server] = new List<StudyInformation>(); // //StudyInformation studyInformation = new StudyInformation(); // //studyInformation.PatientId = item.PatientId; // //studyInformation.PatientsName = item.PatientsName; // //DateTime studyDate; // //DateParser.Parse(item.StudyDate, out studyDate); // //studyInformation.StudyDate = studyDate; // //studyInformation.StudyDescription = item.StudyDescription; // //studyInformation.StudyInstanceUid = item.StudyInstanceUID; // //retrieveInformation[item.Server].Add(studyInformation); }
/// <summary> /// Called by the framework when the user clicks the "apply" menu item or toolbar button. /// </summary> public void SeriesQuery() { string callingAE = ServerTree.GetClientAETitle(); List <SeriesItem> SeriesList = new List <SeriesItem>(); #region remote datastore // If remote data store, need to query server for series level information if (!this.Context.SelectedServerGroup.IsLocalDatastore) { // Loop through all selected servers foreach (Server node in this.Context.SelectedServerGroup.Servers) { DicomAttributeCollection dicomAttributeCollection = new DicomAttributeCollection(); // Query on "Series" Level dicomAttributeCollection[DicomTags.QueryRetrieveLevel].SetStringValue("SERIES"); string studyUID = this.Context.SelectedStudies[0].StudyInstanceUid; dicomAttributeCollection[DicomTags.StudyInstanceUid].SetStringValue(studyUID); dicomAttributeCollection[DicomTags.SeriesDescription].SetNullValue(); dicomAttributeCollection[DicomTags.SeriesInstanceUid].SetNullValue(); dicomAttributeCollection[DicomTags.SeriesNumber].SetNullValue(); dicomAttributeCollection[DicomTags.Modality].SetNullValue(); dicomAttributeCollection[DicomTags.Date].SetNullValue(); dicomAttributeCollection[DicomTags.Time].SetNullValue(); dicomAttributeCollection[DicomTags.RepetitionTime].SetNullValue(); IList <DicomAttributeCollection> resultsList; StudyRootFindScu findScu = new StudyRootFindScu(); List <string> seriesUIDs = new List <string>(); resultsList = findScu.Find( callingAE, node.AETitle, node.Host, node.Port, dicomAttributeCollection); findScu.CloseAssociation(); findScu.Dispose(); foreach (DicomAttributeCollection msg in resultsList) { string text = msg[DicomTags.SeriesInstanceUid]; Platform.Log(LogLevel.Info, text); SeriesItem series = new SeriesItem(); series.SeriesNumber = msg[DicomTags.SeriesNumber]; series.SeriesDescription = msg[DicomTags.SeriesDescription]; series.StudyInstanceUID = msg[DicomTags.StudyInstanceUid]; series.SeriesInstanceUID = msg[DicomTags.SeriesInstanceUid]; series.Modality = msg[DicomTags.Modality]; series.Date = msg[DicomTags.Date]; series.Time = msg[DicomTags.Time]; //series.NumberOfSeriesRelatedInstances = int.Parse(msg[DicomTags.NumberOfSeriesRelatedInstances].ToString()); SeriesList.Add(series); } _component = new SeriesBrowserComponent(SeriesList, node); _shelf = ApplicationComponent.LaunchAsShelf(this.Context.DesktopWindow, _component, "Series Browser", ShelfDisplayHint.DockBottom | ShelfDisplayHint.DockAutoHide); _shelf.Closed += Shelf_Closed; } } #endregion #region Local Datastore // If local datastore, can obtain series information by building study tree else { IImageViewer viewer = new ImageViewerComponent(); StudyTree studyTree = viewer.StudyTree; // Add selected objects studies to study tree foreach (StudyItem selectedstudy in this.Context.SelectedStudies) { string studyUID = selectedstudy.StudyInstanceUid; int numberOfSops = LocalStudyLoader.Start(new StudyLoaderArgs(studyUID, null)); for (int i = 0; i < numberOfSops; ++i) { Sop imageSop = LocalStudyLoader.LoadNextSop(); studyTree.AddSop(imageSop); } } foreach (Patient patient in studyTree.Patients) { foreach (Study study in patient.Studies) { foreach (Series series in study.Series) { SeriesItem seriesitem = new SeriesItem(); seriesitem.SeriesNumber = series.SeriesNumber.ToString(); seriesitem.SeriesDescription = series.SeriesDescription; seriesitem.StudyInstanceUID = study.StudyInstanceUid; seriesitem.SeriesInstanceUID = series.SeriesInstanceUid; seriesitem.Modality = series.Modality; seriesitem.Date = series.SeriesDate; seriesitem.Time = series.SeriesTime; //series.NumberOfSeriesRelatedInstances = int.Parse(msg[DicomTags.NumberOfSeriesRelatedInstances].ToString()); seriesitem.NumberOfSeriesRelatedInstances = series.Sops.Count.ToString(); SeriesList.Add(seriesitem); } _component = new SeriesBrowserComponent(SeriesList, null); _shelf = ApplicationComponent.LaunchAsShelf(this.Context.DesktopWindow, _component, DicomDataFormatHelper.PersonNameFormatter(patient.PatientsName), ShelfDisplayHint.DockBottom | ShelfDisplayHint.DockAutoHide); _shelf.Closed += Shelf_Closed; } } } #endregion }