protected override void ProcessFile(Model.WorkQueueUid queueUid, DicomFile file, ClearCanvas.Dicom.Utilities.Xml.StudyXml stream, bool compare) { Platform.CheckFalse(compare, "compare"); SopInstanceProcessor processor = new SopInstanceProcessor(Context); FileInfo fileInfo = new FileInfo(file.Filename); long fileSize = fileInfo.Length; processor.InstanceStats.FileSize = (ulong)fileSize; string sopInstanceUid = file.DataSet[DicomTags.SopInstanceUid].GetString(0, "File:" + fileInfo.Name); processor.InstanceStats.Description = sopInstanceUid; if (Study != null) { StudyComparer comparer = new StudyComparer(); DifferenceCollection list = comparer.Compare(file, Study, ServerPartition.GetComparisonOptions()); if (list != null && list.Count > 0) { Platform.Log(LogLevel.Warn, "Dicom file contains information inconsistent with the study in the system"); } } string groupID = ServerHelper.GetUidGroup(file, StorageLocation.ServerPartition, WorkQueueItem.InsertTime); processor.ProcessFile(groupID, file, stream, false, false, null, null); Statistics.StudyInstanceUid = StorageLocation.StudyInstanceUid; if (String.IsNullOrEmpty(processor.Modality) == false) Statistics.Modality = processor.Modality; // Update the statistics Statistics.NumInstances++; }
public void OnReceiveRequestMessage(DicomServer server, ServerAssociationParameters association, byte presentationID, ClearCanvas.Dicom.DicomMessage message) { foreach (byte pcid in association.GetPresentationContextIDs()) { DicomPresContext context = association.GetPresentationContext(pcid); if (context.Result == DicomPresContextResult.Accept) { if (context.AbstractSyntax == SopClass.StudyRootQueryRetrieveInformationModelFind) { DicomMessage response = new DicomMessage(); response.DataSet[DicomTags.StudyInstanceUid].SetStringValue("1.2.3"); response.DataSet[DicomTags.PatientId].SetStringValue("1"); response.DataSet[DicomTags.PatientsName].SetStringValue("test"); response.DataSet[DicomTags.StudyId].SetStringValue("1"); response.DataSet[DicomTags.StudyDescription].SetStringValue("dummy"); server.SendCFindResponse(presentationID, message.MessageId, response, DicomStatuses.Pending); DicomMessage finalResponse = new DicomMessage(); server.SendCFindResponse(presentationID, message.MessageId, finalResponse, DicomStatuses.Success); } else if (context.AbstractSyntax == SopClass.VerificationSopClass) { server.SendCEchoResponse(presentationID, message.MessageId, DicomStatuses.Success); } } } }
protected override void OnExecute(CommandProcessor theProcessor, ClearCanvas.Enterprise.Core.IUpdateContext updateContext) { IDeleteSeries broker = updateContext.GetBroker<IDeleteSeries>(); DeleteSeriesParameters criteria = new DeleteSeriesParameters(); criteria.StudyStorageKey = _location.Key; criteria.SeriesInstanceUid = _series.SeriesInstanceUid; if (!broker.Execute(criteria)) throw new ApplicationException("Error occurred when calling DeleteSeries"); }
protected override void OnParentPresentationImageChanged(ClearCanvas.ImageViewer.IPresentationImage oldParentPresentationImage, ClearCanvas.ImageViewer.IPresentationImage newParentPresentationImage) { base.OnParentPresentationImageChanged(oldParentPresentationImage, newParentPresentationImage); // Update callout text and calculations // Interestingly, before overwrite, update only required for newly created annotations' graphics //if (SynchronizationContext.Current == null) this.Update(); }
public SendOperationInfo(WorkItemData reference, ushort messageId, byte presentationId, ClearCanvas.Dicom.Network.DicomServer server) { PresentationId = presentationId; Server = server; WorkItemData = reference; MessageId = messageId; SubOperations = 0; Complete = false; FailedSopInstanceUids = new List<string>(); }
public override void OnReceiveResponseMessage(DicomClient client, ClientAssociationParameters association, byte presentationID, ClearCanvas.Dicom.DicomMessage message) { base.OnReceiveResponseMessage(client, association, presentationID, message); if (message.Status.Status == DicomState.Warning) { DicomStatus status = DicomStatuses.LookupQueryRetrieve(message.Status.Code); _errorDescriptionDetails = String.Format("Remote server returned a warning status ({0}: {1}).", RemoteAE, status.Description); } }
public override IActionSet GetExportedActions(string site, ClearCanvas.ImageViewer.InputManagement.IMouseInformation mouseInformation) { IResourceResolver resolver = new ResourceResolver(GetType(), true); var @namespace = GetType().FullName; var hideAction = new MenuAction(@namespace + ":toggle", new ActionPath(site + "/MenuSetMarkupColorForUser", resolver), ClickActionFlags.None, resolver); hideAction.Label = "Set User Markup Color"; hideAction.Persistent = true; hideAction.SetClickHandler(OpenAimMarkupColorOptions); IActionSet actions = new ActionSet(new IAction[] { hideAction }); var other = base.GetExportedActions(site, mouseInformation); if (other != null) actions = actions.Union(other); return actions; }
private void LoadImage() { BitmapImage bmi = new BitmapImage(); bmi.BeginInit(); bmi.CacheOption = BitmapCacheOption.OnLoad; bmi.Rotation = this.Rotation; bmi.UriSource = new Uri(FilePath, UriKind.Relative); bmi.EndInit(); ImageSource = bmi; OnPropertyChanged("ImageSource"); ClearCanvas?.Invoke(); if (bmi.Height > bmi.Width) { #pragma warning disable CS0219 // The variable 'ans' is assigned but its value is never used string ans = "Is Landscape"; #pragma warning restore CS0219 // The variable 'ans' is assigned but its value is never used } }
internal DialogBoxAction Show(string message, string title, ClearCanvas.Common.MessageBoxActions buttons, IWin32Window owner) { #if !MONO // Ticket #7285: messages boxes should not be obscured by the splashscreen // If no splash screen is being displayed, this is effectively a no-op. SplashScreenManager.DismissSplashScreen(owner as Form); #endif title = string.IsNullOrEmpty(title) ? Application.Name : string.Format("{0} - {1}", Application.Name, title); using (var hook = new CommonDialogHook()) { var mbButtons = _buttonMap[(int) buttons]; // The OK-only message box has a single button whose control ID is actually "Cancel" if (mbButtons == MessageBoxButtons.OK) hook.ButtonCaptions[2] = SR.ButtonOk; var dr = System.Windows.Forms.MessageBox.Show(owner, message, title, mbButtons); return (DialogBoxAction) _resultMap[dr]; } }
public DialogBoxAction Show(string message, ClearCanvas.Common.MessageBoxActions buttons) { return Show(message, null, buttons, null); }
public override bool OnReceiveRequest(ClearCanvas.Dicom.Network.DicomServer server, ServerAssociationParameters association, byte presentationID, DicomMessage message) { server.SendCEchoResponse(presentationID, message.MessageId, DicomStatuses.Success); return true; }
private void OnReceiveMoveSeriesRequest(ClearCanvas.Dicom.Network.DicomServer server, byte presentationID, DicomMessage message, IDicomServiceNode remoteAEInfo) { string studyInstanceUid = message.DataSet[DicomTags.StudyInstanceUid].GetString(0, ""); var seriesUids = (string[])message.DataSet[DicomTags.SeriesInstanceUid].Values; lock (_syncLock) { int subOperations = 0; using (var context = new DataAccessContext()) { var results = context.GetStudyStoreQuery().SeriesQuery(new SeriesIdentifier { StudyInstanceUid = studyInstanceUid, }); foreach (SeriesIdentifier series in results) { foreach (string seriesUid in seriesUids) if (series.SeriesInstanceUid.Equals(seriesUid) && series.NumberOfSeriesRelatedInstances.HasValue) { subOperations += series.NumberOfSeriesRelatedInstances.Value; break; } } var s = context.GetStudyStoreQuery().StudyQuery(new StudyRootStudyIdentifier {StudyInstanceUid = studyInstanceUid}); var identifier = CollectionUtils.FirstElement(s); var client = new DicomSendBridge(); client.SendSeries(remoteAEInfo, identifier, seriesUids, WorkItemPriorityEnum.High); _sendOperations.Add(new SendOperationInfo(client.WorkItem, message.MessageId, presentationID, server) { SubOperations = subOperations }); } } }
public override bool OnReceiveRequest(ClearCanvas.Dicom.Network.DicomServer server, ServerAssociationParameters association, byte presentationID, DicomMessage message) { String level = message.DataSet[DicomTags.QueryRetrieveLevel].GetString(0, "").Trim(); var extendedConfiguration = Common.DicomServer.DicomServer.GetExtendedConfiguration(); var queryResponsesInUtf8 = extendedConfiguration.QueryResponsesInUtf8; if (message.AffectedSopClassUid.Equals(SopClass.StudyRootQueryRetrieveInformationModelFindUid)) { try { using (var context = new DataAccessContext()) { IEnumerable<DicomAttributeCollection> results = context.GetStudyStoreQuery().Query(message.DataSet); foreach (DicomAttributeCollection result in results) { const string utf8 = "ISO_IR 192"; if (queryResponsesInUtf8) ChangeCharacterSet(result, utf8); var response = new DicomMessage(null, result); //Add these to each response. message.DataSet[DicomTags.RetrieveAeTitle].SetStringValue(Context.AETitle); message.DataSet[DicomTags.InstanceAvailability].SetStringValue("ONLINE"); response.DataSet[DicomTags.QueryRetrieveLevel].SetStringValue(level); server.SendCFindResponse(presentationID, message.MessageId, response, DicomStatuses.Pending); } } } catch (Exception e) { Platform.Log(LogLevel.Error, e, "Unexpected exception when processing FIND request."); try { var errorResponse = new DicomMessage(); server.SendCFindResponse(presentationID, message.MessageId, errorResponse, DicomStatuses.QueryRetrieveUnableToProcess); return true; } finally { AuditHelper.LogQueryReceived(association.CallingAE, GetRemoteHostName(association), EventResult.SeriousFailure, message.AffectedSopClassUid, message.DataSet); } } try { var finalResponse = new DicomMessage(); server.SendCFindResponse(presentationID, message.MessageId, finalResponse, DicomStatuses.Success); AuditHelper.LogQueryReceived(association.CallingAE, GetRemoteHostName(association), EventResult.Success, message.AffectedSopClassUid, message.DataSet); return true; } catch { AuditHelper.LogQueryReceived(association.CallingAE, GetRemoteHostName(association), EventResult.SeriousFailure, message.AffectedSopClassUid, message.DataSet); throw; } } try { Platform.Log(LogLevel.Error, "Unexpected Study Root Query/Retrieve level: {0}", level); server.SendCFindResponse(presentationID, message.MessageId, new DicomMessage(), DicomStatuses.QueryRetrieveIdentifierDoesNotMatchSOPClass); return true; } finally { AuditHelper.LogQueryReceived(association.CallingAE, GetRemoteHostName(association), EventResult.SeriousFailure, message.AffectedSopClassUid, message.DataSet); } }
/// <summary> /// Creates the <see cref="KeyboardAction"/> represented by this attribute. /// </summary> /// <param name="actionID">The logical action ID.</param> /// <param name="path">The action path.</param> /// <param name="flags">Flags that specify the click behaviour of the action.</param> /// <param name="resolver">The object used to resolve the action path and icons.</param> protected override ClickAction CreateAction(string actionID, ActionPath path, ClickActionFlags flags, ClearCanvas.Common.Utilities.IResourceResolver resolver) { return new KeyboardAction(actionID, path, flags, resolver); }
public override bool OnReceiveRequest(ClearCanvas.Dicom.Network.DicomServer server, ServerAssociationParameters association, byte presentationID, DicomMessage message) { string studyInstanceUid; string seriesInstanceUid; DicomUid sopInstanceUid; bool ok = message.DataSet[DicomTags.SopInstanceUid].TryGetUid(0, out sopInstanceUid); if (ok) ok = message.DataSet[DicomTags.SeriesInstanceUid].TryGetString(0, out seriesInstanceUid); if (ok) ok = message.DataSet[DicomTags.StudyInstanceUid].TryGetString(0, out studyInstanceUid); if (!ok) { Platform.Log(LogLevel.Error, "Unable to retrieve UIDs from request message, sending failure status."); server.SendCStoreResponse(presentationID, message.MessageId, sopInstanceUid.UID, DicomStatuses.ProcessingFailure); return true; } if (_importContext == null) { LoadImportContext(association); } var importer = new ImportFilesUtility(_importContext); var result = importer.Import(message,BadFileBehaviourEnum.Ignore, FileImportBehaviourEnum.Save); if (result.Successful) { if (!String.IsNullOrEmpty(result.AccessionNumber)) Platform.Log(LogLevel.Info, "Received SOP Instance {0} from {1} to {2} (A#:{3} StudyUid:{4})", result.SopInstanceUid, association.CallingAE, association.CalledAE, result.AccessionNumber, result.StudyInstanceUid); else Platform.Log(LogLevel.Info, "Received SOP Instance {0} from {1} to {2} (StudyUid:{3})", result.SopInstanceUid, association.CallingAE, association.CalledAE, result.StudyInstanceUid); server.SendCStoreResponse(presentationID, message.MessageId, message.AffectedSopInstanceUid, result.DicomStatus); } else { if (result.DicomStatus==DicomStatuses.ProcessingFailure) Platform.Log(LogLevel.Error, "Failure importing sop: {0}", result.ErrorMessage); //OnReceiveError(message, result.ErrorMessage, association.CallingAE); server.SendCStoreResponse(presentationID, message.MessageId, message.AffectedSopInstanceUid, result.DicomStatus, result.ErrorMessage); } return true; }
private void OnReceiveMoveStudiesRequest(ClearCanvas.Dicom.Network.DicomServer server, byte presentationID, DicomMessage message, IDicomServiceNode remoteAEInfo) { IEnumerable<string> studyUids = (string[])message.DataSet[DicomTags.StudyInstanceUid].Values; foreach (string studyUid in studyUids) { lock (_syncLock) { int subOperations = 0; using (var context = new DataAccessContext()) { var s = context.GetStudyStoreQuery().StudyQuery(new StudyRootStudyIdentifier {StudyInstanceUid = studyUid}); var identifier = CollectionUtils.FirstElement(s); if (identifier.NumberOfStudyRelatedInstances.HasValue) subOperations = identifier.NumberOfStudyRelatedInstances.Value; var client = new DicomSendBridge(); client.SendStudy(remoteAEInfo, identifier, WorkItemPriorityEnum.High); _sendOperations.Add(new SendOperationInfo(client.WorkItem, message.MessageId, presentationID, server) { SubOperations = subOperations }); } } } }
public void OnReceiveResponseMessage(DicomServer server, ServerAssociationParameters association, byte presentationID, ClearCanvas.Dicom.DicomMessage message) { server.SendAssociateAbort(DicomAbortSource.ServiceUser, DicomAbortReason.UnexpectedPDU); }
private void OnReceiveMoveImageRequest(ClearCanvas.Dicom.Network.DicomServer server, byte presentationID, DicomMessage message, IDicomServiceNode remoteAEInfo) { string studyInstanceUid = message.DataSet[DicomTags.StudyInstanceUid].GetString(0, string.Empty); string seriesInstanceUid = message.DataSet[DicomTags.SeriesInstanceUid].GetString(0, string.Empty); var sopInstanceUids = (string[])message.DataSet[DicomTags.SopInstanceUid].Values; lock (_syncLock) { using (var context = new DataAccessContext()) { var s = context.GetStudyStoreQuery().StudyQuery(new StudyRootStudyIdentifier {StudyInstanceUid = studyInstanceUid}); var identifier = CollectionUtils.FirstElement(s); var client = new DicomSendBridge(); client.SendSops(remoteAEInfo, identifier, seriesInstanceUid, sopInstanceUids, WorkItemPriorityEnum.High); _sendOperations.Add(new SendOperationInfo(client.WorkItem, message.MessageId, presentationID, server) { SubOperations = sopInstanceUids.Length }); } } }
public override bool OnReceiveRequest(ClearCanvas.Dicom.Network.DicomServer server, ServerAssociationParameters association, byte presentationID, DicomMessage message) { string studyInstanceUid; string seriesInstanceUid; DicomUid sopInstanceUid; bool ok = message.DataSet[DicomTags.SopInstanceUid].TryGetUid(0, out sopInstanceUid); if (ok) ok = message.DataSet[DicomTags.SeriesInstanceUid].TryGetString(0, out seriesInstanceUid); if (ok) ok = message.DataSet[DicomTags.StudyInstanceUid].TryGetString(0, out studyInstanceUid); if (!ok) { Platform.Log(LogLevel.Error, "Unable to retrieve UIDs from request message, sending failure status."); server.SendCStoreResponse(presentationID, message.MessageId, sopInstanceUid.UID, DicomStatuses.ProcessingFailure); return true; } if (_importContext == null) { _importContext = new DicomReceiveImportContext(association.CallingAE, GetRemoteHostName(association), StudyStore.GetConfiguration(), EventSource.CurrentProcess); // Publish new WorkItems as they're added to the context lock (_importContext.StudyWorkItemsSyncLock) { _importContext.StudyWorkItems.ItemAdded += delegate(object sender, DictionaryEventArgs<string,WorkItem> args) { Platform.GetService( (IWorkItemActivityMonitorService service) => service.Publish(new WorkItemPublishRequest { Item = WorkItemDataHelper .FromWorkItem( args.Item) })); var auditedInstances = new AuditedInstances(); var request = args.Item.Request as DicomReceiveRequest; if (request != null) { auditedInstances.AddInstance(request.Patient.PatientId, request.Patient.PatientsName, request.Study.StudyInstanceUid); } AuditHelper.LogReceivedInstances( association.CallingAE, GetRemoteHostName(association), auditedInstances, EventSource.CurrentProcess, EventResult.Success, EventReceiptAction.ActionUnknown); } ; _importContext.StudyWorkItems.ItemChanged += (sender, args) => Platform.GetService( (IWorkItemActivityMonitorService service) => service.Publish(new WorkItemPublishRequest {Item = WorkItemDataHelper.FromWorkItem(args.Item)})); } } var importer = new ImportFilesUtility(_importContext); var result = importer.Import(message,BadFileBehaviourEnum.Ignore, FileImportBehaviourEnum.Save); if (result.Successful) { if (!String.IsNullOrEmpty(result.AccessionNumber)) Platform.Log(LogLevel.Info, "Received SOP Instance {0} from {1} to {2} (A#:{3} StudyUid:{4})", result.SopInstanceUid, association.CallingAE, association.CalledAE, result.AccessionNumber, result.StudyInstanceUid); else Platform.Log(LogLevel.Info, "Received SOP Instance {0} from {1} to {2} (StudyUid:{3})", result.SopInstanceUid, association.CallingAE, association.CalledAE, result.StudyInstanceUid); server.SendCStoreResponse(presentationID, message.MessageId, message.AffectedSopInstanceUid, result.DicomStatus); } else { if (result.DicomStatus==DicomStatuses.ProcessingFailure) Platform.Log(LogLevel.Error, "Failure importing sop: {0}", result.ErrorMessage); //OnReceiveError(message, result.ErrorMessage, association.CallingAE); server.SendCStoreResponse(presentationID, message.MessageId, message.AffectedSopInstanceUid, result.DicomStatus, result.ErrorMessage); } return true; }
public override bool OnReceiveRequest(ClearCanvas.Dicom.Network.DicomServer server, ServerAssociationParameters association, byte presentationID, DicomMessage message) { //// Check for a Cancel message, and cancel the SCU. if (message.CommandField == DicomCommandField.CCancelRequest) { OnReceiveCancelRequest(message); return true; } // TODO (CR Jun 2012): Log when there's more than 1. var remoteAE = ServerDirectory.GetRemoteServersByAETitle(message.MoveDestination).FirstOrDefault(); if (remoteAE == null) { server.SendCMoveResponse(presentationID, message.MessageId, new DicomMessage(), DicomStatuses.QueryRetrieveMoveDestinationUnknown); return true; } String level = message.DataSet[DicomTags.QueryRetrieveLevel].GetString(0, string.Empty); try { if (level.Equals("STUDY")) { OnReceiveMoveStudiesRequest(server, presentationID, message, remoteAE); } else if (level.Equals("SERIES")) { OnReceiveMoveSeriesRequest(server, presentationID, message, remoteAE); } else if (level.Equals("IMAGE")) { OnReceiveMoveImageRequest(server, presentationID, message, remoteAE); } else { Platform.Log(LogLevel.Error, "Unexpected Study Root Move Query/Retrieve level: {0}", level); server.SendCMoveResponse(presentationID, message.MessageId, new DicomMessage(), DicomStatuses.QueryRetrieveIdentifierDoesNotMatchSOPClass); return true; } } catch(Exception e) { Platform.Log(LogLevel.Error, e, "Unexpected exception when processing C-MOVE-RQ"); try { server.SendCMoveResponse(presentationID, message.MessageId, new DicomMessage(), DicomStatuses.QueryRetrieveUnableToProcess, e.Message); } catch (Exception ex) { Platform.Log(LogLevel.Error, ex, "Unable to send final C-MOVE-RSP message on association from {0} to {1}", association.CallingAE, association.CalledAE); } } return true; }
public void FireEvent(ClearCanvas.Web.Common.Event e) { _eventSent.Add(e); }