private void PerformDimse(DicomMessage dimse) { try { Logger.Info("{logId} <- {dicomMessage}", LogID, dimse.ToString(Options.LogDimseDatasets)); if (!DicomMessage.IsRequest(dimse.Type)) { var rsp = dimse as DicomResponse; lock (_lock) { var req = _pending.FirstOrDefault(x => x.MessageID == rsp.RequestMessageID); if (req != null) { rsp.UserState = req.UserState; req.PostResponse(this, rsp); if (rsp.Status.State != DicomState.Pending) _pending.Remove(req); } } return; } if (dimse.Type == DicomCommandField.CStoreRequest) { if (this is IDicomCStoreProvider) { var response = (this as IDicomCStoreProvider).OnCStoreRequest(dimse as DicomCStoreRequest); SendResponse(response); return; } else throw new DicomNetworkException("C-Store SCP not implemented"); } if (dimse.Type == DicomCommandField.CFindRequest) { if (this is IDicomCFindProvider) { var responses = (this as IDicomCFindProvider).OnCFindRequest(dimse as DicomCFindRequest); foreach (var response in responses) SendResponse(response); return; } else throw new DicomNetworkException("C-Find SCP not implemented"); } if (dimse.Type == DicomCommandField.CMoveRequest) { if (this is IDicomCMoveProvider) { var responses = (this as IDicomCMoveProvider).OnCMoveRequest(dimse as DicomCMoveRequest); foreach (var response in responses) SendResponse(response); return; } else throw new DicomNetworkException("C-Move SCP not implemented"); } if (dimse.Type == DicomCommandField.CEchoRequest) { if (this is IDicomCEchoProvider) { var response = (this as IDicomCEchoProvider).OnCEchoRequest(dimse as DicomCEchoRequest); SendResponse(response); return; } else throw new DicomNetworkException("C-Echo SCP not implemented"); } if (dimse.Type == DicomCommandField.NActionRequest || dimse.Type == DicomCommandField.NCreateRequest || dimse.Type == DicomCommandField.NDeleteRequest || dimse.Type == DicomCommandField.NEventReportRequest || dimse.Type == DicomCommandField.NGetRequest || dimse.Type == DicomCommandField.NSetRequest) { if (!(this is IDicomNServiceProvider)) throw new DicomNetworkException("N-Service SCP not implemented"); DicomResponse response = null; if (dimse.Type == DicomCommandField.NActionRequest) response = (this as IDicomNServiceProvider).OnNActionRequest(dimse as DicomNActionRequest); else if (dimse.Type == DicomCommandField.NCreateRequest) response = (this as IDicomNServiceProvider).OnNCreateRequest(dimse as DicomNCreateRequest); else if (dimse.Type == DicomCommandField.NDeleteRequest) response = (this as IDicomNServiceProvider).OnNDeleteRequest(dimse as DicomNDeleteRequest); else if (dimse.Type == DicomCommandField.NEventReportRequest) response = (this as IDicomNServiceProvider).OnNEventReportRequest( dimse as DicomNEventReportRequest); else if (dimse.Type == DicomCommandField.NGetRequest) response = (this as IDicomNServiceProvider).OnNGetRequest(dimse as DicomNGetRequest); else if (dimse.Type == DicomCommandField.NSetRequest) response = (this as IDicomNServiceProvider).OnNSetRequest( dimse as DicomNSetRequest); SendResponse(response); return; } throw new DicomNetworkException("Operation not implemented"); } finally { SendNextMessage(); } }