void IDicomServerHandler.OnReceiveRequestMessage(DicomServer server, ServerAssociationParameters association, byte presentationId, DicomMessage message) { Task.Factory.StartNew(delegate { try { IDicomScp <TContext> scp = _extensionList[presentationId]; bool ok = scp.OnReceiveRequest(server, association, presentationId, message); if (!ok) { LogAdapter.Logger.Error("Unexpected error processing message of type {0}. Aborting association.", message.SopClass.Name); server.SendAssociateAbort(DicomAbortSource.ServiceProvider, DicomAbortReason.NotSpecified); } else if (_complete != null) { // Only save C-STORE-RQ messages if (message.CommandField == DicomCommandField.CStoreRequest) { _instances.Add(new StorageInstance(message)); } } } catch (Exception x) { LogAdapter.Logger.Error("Unexpected exception in OnReceiveImageLevelQuery."); server.SendAssociateAbort(DicomAbortSource.ServiceProvider, DicomAbortReason.NotSpecified); } }); }
public void OnReceiveRequestMessage(DicomServer server, ServerAssociationParameters association, byte presentationID, DicomMessage message) { if (_type == TestTypes.SendMR) { var testSet = new DicomAttributeCollection(); _test.SetupMR(testSet); bool same = testSet.Equals(message.DataSet); string studyId = message.DataSet[DicomTags.StudyId].GetString(0, ""); Assert.AreEqual(studyId, "1933"); DicomUid sopInstanceUid; bool ok = message.DataSet[DicomTags.SopInstanceUid].TryGetUid(0, out sopInstanceUid); if (!ok) { server.SendAssociateAbort(DicomAbortSource.ServiceUser, DicomAbortReason.NotSpecified); return; } server.SendCStoreResponse(presentationID, message.MessageId, sopInstanceUid.UID, DicomStatuses.Success); } else if (_type == TestTypes.Receive) { DicomUid sopInstanceUid; bool ok = message.DataSet[DicomTags.SopInstanceUid].TryGetUid(0, out sopInstanceUid); if (!ok) { server.SendAssociateAbort(DicomAbortSource.ServiceUser, DicomAbortReason.InvalidPDUParameter); return; } MessagesReceived.Add(message); server.SendCStoreResponse(presentationID, message.MessageId, sopInstanceUid.UID, DicomStatuses.Success); } else { Platform.Log(LogLevel.Error, "Unexpected test type mode"); server.SendAssociateAbort(DicomAbortSource.ServiceUser, DicomAbortReason.InvalidPDUParameter); } }
void IDicomServerHandler.OnReceiveRequestMessage(DicomServer server, ServerAssociationParameters association, byte presentationID, DicomMessage message) { _sessionDebug.SetAssociationDumpString(association); _sessionDebug._request = message.Dump(); #region Cancel request if (message.CommandField == DicomCommandField.CCancelRequest) { Logger.LogInfo("Received CANCEL-RQ message from {0}.", association.CallingAE); _cancelReceived = true; return; } #endregion #region CEcho request if (message.CommandField == DicomCommandField.CEchoRequest) { server.SendCEchoResponse(presentationID, message.MessageId, DicomStatuses.Success); Logger.LogInfo("Received ECHO-RQ message from {0}.", association.CallingAE); return; } #endregion #region MWL C-FIND request if (message.CommandField == DicomCommandField.CFindRequest) { Logger.LogInfo("Message Dumped :\n" + message.Dump("", DicomDumpOptions.KeepGroupLengthElements)); String level = message.DataSet[DicomTags.QueryRetrieveLevel].GetString(0, string.Empty); _cancelReceived = false; if (message.AffectedSopClassUid.Equals(SopClass.ModalityWorklistInformationModelFindUid)) { OnReceiveMWLQuery(server, presentationID, message); } else { // Not supported message type, send a failure status. server.SendCFindResponse(presentationID, message.MessageId, new DicomMessage(), DicomStatuses.QueryRetrieveIdentifierDoesNotMatchSOPClass); } return; } #endregion //ignore all unsupported request server.SendAssociateAbort(DicomAbortSource.ServiceProvider, DicomAbortReason.UnexpectedPDU); Logger.LogInfo("Unexpected Command. Send Associate Abort message from server to {0}.", association.CallingAE); return; }
void IDicomServerHandler.OnReceiveRequestMessage(DicomServer server, ServerAssociationParameters association, byte presentationID, DicomMessage message) { IDicomScp <TContext> scp = _extensionList[presentationID]; bool ok = scp.OnReceiveRequest(server, association, presentationID, message); if (!ok) { Platform.Log(LogLevel.Error, "Unexpected error processing message of type {0}. Aborting association.", message.SopClass.Name); server.SendAssociateAbort(DicomAbortSource.ServiceProvider, DicomAbortReason.NotSpecified); } else if (_complete != null) { // Only save C-STORE-RQ messages if (message.CommandField == DicomCommandField.CStoreRequest) { _instances.Add(new StorageInstance(message)); } } }
void IDicomServerHandler.OnReceiveResponseMessage(DicomServer server, ServerAssociationParameters association, byte presentationID, DicomMessage message) { Platform.Log(LogLevel.Error, "Unexpectedly received response mess on server."); server.SendAssociateAbort(DicomAbortSource.ServiceUser, DicomAbortReason.UnrecognizedPDU); }
void IDicomServerHandler.OnReceiveResponseMessage(DicomServer server, ServerAssociationParameters association, byte presentationID, DicomMessage message) { Platform.Log(LogLevel.Error, "Unexpectedly received OnReceiveResponseMessage callback from {0} to {1}. Aborting association.", association.CallingAE, association.CalledAE); server.SendAssociateAbort(DicomAbortSource.ServiceUser, DicomAbortReason.UnexpectedPDU); }
public void OnReceiveResponseMessage(DicomServer server, ServerAssociationParameters association, byte presentationID, ClearCanvas.Dicom.DicomMessage message) { server.SendAssociateAbort(DicomAbortSource.ServiceUser, DicomAbortReason.UnexpectedPDU); }
void IDicomServerHandler.OnReceiveResponseMessage(DicomServer server, ServerAssociationParameters association, byte presentationID, DicomMessage message) { Logger.LogError("Unexpectedly received response mess on server."); server.SendAssociateAbort(DicomAbortSource.ServiceUser, DicomAbortReason.UnrecognizedPDU); _sessionDebug.DumpSession(); }
void IDicomServerHandler.OnReceiveResponseMessage(DicomServer server, ServerAssociationParameters association, byte presentationID, DicomMessage message) { Platform.Log(LogLevel.Info, string.Format("Unexpectedly received response mess on server.")); server.SendAssociateAbort(DicomAbortSource.ServiceUser, DicomAbortReason.UnrecognizedPDU); //_sessionDebug.DumpSession(); }
public void OnReceiveResponseMessage(DicomServer server, ServerAssociationParameters association, byte presentationID, DicomMessage message) { server.SendAssociateAbort(DicomAbortSource.ServiceUser, DicomAbortReason.NotSpecified); Assert.Fail("Unexpected OnReceiveResponseMessage"); }
void IDicomServerHandler.OnReceiveRequestMessage(DicomServer server, ServerAssociationParameters association, byte presentationID, DicomMessage message) { _sessionDebug.SetAssociationDumpString(association); _sessionDebug._request = message.Dump(); #region CEcho request if (message.CommandField == DicomCommandField.CEchoRequest) { server.SendCEchoResponse(presentationID, message.MessageId, DicomStatuses.Success); Logger.LogInfo("Received ECHO-RQ message from {0}.", association.CallingAE); return; } #endregion #region MPPS NCreate Request if (message.CommandField == DicomCommandField.NCreateRequest) { // june -1st-2009 : // Unlike the "ModalityWorklistIod" class, the 'partially' implemented ModalityPerformedProcedureStepIod class could // be usefull here. ModalityPerformedProcedureStepIod mppsIod = new ModalityPerformedProcedureStepIod(message.DataSet); Logger.LogInfo("Message Dumped :\n" + message.Dump("", DicomDumpOptions.KeepGroupLengthElements)); // checking message for error and anomalies bool anomalyExist = CheckNCreateDataSetConformance(server, association, presentationID, mppsIod, true); if (anomalyExist) { server.SendNCreateResponse(presentationID, message.MessageId, new DicomMessage(), DicomStatuses.InvalidAttributeValue); Logger.LogError("Sending Invalid Attributes Response."); return; } // wrong status if (mppsIod.PerformedProcedureStepInformation.PerformedProcedureStepStatus != ClearCanvas.Dicom.Iod.Modules.PerformedProcedureStepStatus.InProgress) { server.SendNCreateResponse(presentationID, message.MessageId, new DicomMessage(), DicomStatuses.InvalidAttributeValue); Logger.LogError("Recieved N-Create Request with bad status."); return; } // pps already in cache (duplicated step) string cacheKeyId = message.AffectedSopInstanceUid; bool alreadyCached; MPPSScp.CacheMppsEntity(association, cacheKeyId, mppsIod, out alreadyCached); if (alreadyCached) { server.SendNCreateResponse(presentationID, message.MessageId, new DicomMessage(), DicomStatuses.DuplicateSOPInstance); Logger.LogError("Recieved duplicated N-Create Request."); return; } if (!ProcessNCreateRequest(server, presentationID, message)) { server.SendNCreateResponse(presentationID, message.MessageId, new DicomMessage(), DicomStatuses.ProcessingFailure); Logger.LogError("Sending Processing due to NCreate request Failure."); return; } server.SendNCreateResponse(presentationID, message.MessageId, new DicomMessage(), DicomStatuses.Success); return; } #endregion #region MPPS NSet Request if (message.CommandField == DicomCommandField.NSetRequest) { // june -1st-2009 : // Unlike the "ModalityWorklistIod" class, the ModalityPerformedProcedureStepIod is fully implemented // we can use it here. ModalityPerformedProcedureStepIod mppsIod = new ModalityPerformedProcedureStepIod(message.DataSet); Logger.LogInfo("Message Dumped :\n" + message.Dump("", DicomDumpOptions.KeepGroupLengthElements)); // check if pps already in cache (duplicated step) string cacheKeyId = message.RequestedSopInstanceUid; if (!IsMppsEntitycached(cacheKeyId)) { server.SendNCreateResponse(presentationID, message.MessageId, new DicomMessage(), DicomStatuses.NoSuchObjectInstance); Logger.LogError("Received Unknown NSset SOP."); return; } // status diffrent from in progress if (mppsIod.PerformedProcedureStepInformation.PerformedProcedureStepStatus == ClearCanvas.Dicom.Iod.Modules.PerformedProcedureStepStatus.InProgress) { server.SendNSetResponse(presentationID, message.MessageId, new DicomMessage(), DicomStatuses.InvalidAttributeValue); Logger.LogError("Recieved N-Set Request with In Progress status."); RemoveMppsEntityFromCache(cacheKeyId); return; } // checking the received mppsiod against cached one ModalityPerformedProcedureStepIod cachedMppsIod = GetCachedMppsIod(cacheKeyId); //assuming cachedMppsIod not null. bool anomaly = CheckNSetDataSetConformance(server, association, presentationID, cachedMppsIod, mppsIod, true); if (anomaly) { server.SendNSetResponse(presentationID, message.MessageId, new DicomMessage(), DicomStatuses.InvalidAttributeValue); Logger.LogError("Sending Failure Response."); RemoveMppsEntityFromCache(cacheKeyId); return; } string studyInstanceUID = mppsIod. PerformedProcedureStepRelationship. DicomAttributeProvider[DicomTags.StudyInstanceUid]. GetString(0, ""); XmlElement performedSeriesSQ = GenerateXmlForPerformedSeriesSQ(message, studyInstanceUID); bool success = true; if (mppsIod.PerformedProcedureStepInformation.PerformedProcedureStepStatus == ClearCanvas.Dicom.Iod.Modules.PerformedProcedureStepStatus.Completed) { success = ProcessNSetRequestForCompleted(server, presentationID, message, performedSeriesSQ); } if (mppsIod.PerformedProcedureStepInformation.PerformedProcedureStepStatus == ClearCanvas.Dicom.Iod.Modules.PerformedProcedureStepStatus.Discontinued) { success = ProcessNSetRequestForDiscontinued(server, presentationID, message, performedSeriesSQ); } if (success) { server.SendNSetResponse(presentationID, message.MessageId, new DicomMessage(), DicomStatuses.Success); } else { server.SendNSetResponse(presentationID, message.MessageId, new DicomMessage(), DicomStatuses.ProcessingFailure); } MPPSScp.RemoveMppsEntityFromCache(cacheKeyId); return; } #endregion //ignore all unsupported request server.SendAssociateAbort(DicomAbortSource.ServiceProvider, DicomAbortReason.UnexpectedPDU); Logger.LogInfo("Unexpected Command. Send Associate Abort message from server to {0}.", association.CallingAE); return; }