I could implement the C-Echo, C-Find SCP, MPPS (N-Create and N-Set) SCP and C-Store SCP services. Now I am trying to implement Storage Commitment service. In this, I received the NActionRequest from the Emulator and could return the NActionResponse for the same. Now I am stuck with how to send NEventReportRequest to the Modality Emulator. Below is the code for the same (C-Store SCP class) :
( I am including the 'Storage' operation and 'Storage Commitment' operation both in a single class ) :
public class CStoreSCP : DicomService, IDicomServiceProvider, IDicomCStoreProvider, IDicomCEchoProvider, IDicomNServiceProvider
{
private static DicomTransferSyntax[] AcceptedTransferSyntaxes = new DicomTransferSyntax[] {
DicomTransferSyntax.ExplicitVRLittleEndian,
DicomTransferSyntax.ExplicitVRBigEndian,
DicomTransferSyntax.ImplicitVRLittleEndian
};
private static DicomTransferSyntax[] AcceptedImageTransferSyntaxes = new DicomTransferSyntax[] {
// Lossless
DicomTransferSyntax.JPEGLSLossless,
DicomTransferSyntax.JPEG2000Lossless,
DicomTransferSyntax.JPEGProcess14SV1,
DicomTransferSyntax.JPEGProcess14,
DicomTransferSyntax.RLELossless,
// Lossy
DicomTransferSyntax.JPEGLSNearLossless,
DicomTransferSyntax.JPEG2000Lossy,
DicomTransferSyntax.JPEGProcess1,
DicomTransferSyntax.JPEGProcess2_4,
// Uncompressed
DicomTransferSyntax.ExplicitVRLittleEndian,
DicomTransferSyntax.ExplicitVRBigEndian,
DicomTransferSyntax.ImplicitVRLittleEndian
};
public CStoreSCP(Stream stream, Logger log)
: base(stream, log)
{
}
public void OnReceiveAssociationRequest(DicomAssociation association)
{
if (association.CalledAE != Constants.AETitle)
{
SendAssociationReject(DicomRejectResult.Permanent, DicomRejectSource.ServiceUser, DicomRejectReason.CalledAENotRecognized);
return;
}
foreach (var pc in association.PresentationContexts)
{
if (pc.AbstractSyntax == DicomUID.Verification)
pc.AcceptTransferSyntaxes(AcceptedTransferSyntaxes);
else if (pc.AbstractSyntax.StorageCategory != DicomStorageCategory.None)
pc.AcceptTransferSyntaxes(AcceptedImageTransferSyntaxes);
}
SendAssociationAccept(association);
}
public void OnReceiveAssociationReleaseRequest()
{
SendAssociationReleaseResponse();
}
public void OnReceiveAbort(DicomAbortSource source, DicomAbortReason reason)
{
throw new NotImplementedException();
}
public void OnConnectionClosed(int errorCode)
{
}
public DicomCStoreResponse OnCStoreRequest(DicomCStoreRequest request)
{
var studyUid = request.Dataset.Get<string>(DicomTag.StudyInstanceUID);
var instUid = request.SOPInstanceUID.UID;
var path = Path.GetFullPath(Program.StoragePath);
path = Path.Combine(path, studyUid);
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
path = Path.Combine(path, instUid) + ".dcm";
request.File.Save(path);
return new DicomCStoreResponse(request, DicomStatus.Success);
}
public void OnCStoreRequestException(string tempFileName, Exception e)
{
// let library handle logging and error response
}
public DicomCEchoResponse OnCEchoRequest(DicomCEchoRequest request)
{
return new DicomCEchoResponse(request, DicomStatus.Success);
}
public DicomNActionResponse OnNActionRequest(DicomNActionRequest request)
{
/* Just wrote this code for sending NEventReportRequest, but didn't get expected result, hence commented */
// DicomNEventReportRequest nEventReportReq = new DicomNEventReportRequest(request.SOPClassUID, request.SOPInstanceUID, 1);
// nEventReportReq.OnResponseReceived += new DicomNEventReportRequest.ResponseDelegate(NEventReportResponseReceivedMethod);
// SendRequest(nEventReportReq);
//code for sending NActionResponse to Modality Emulator
DicomNActionResponse dicomNActionResp = new DicomNActionResponse(request, DicomStatus.Success);
return dicomNActionResp;
}
public void NEventReportResponseReceivedMethod(DicomNEventReportRequest request, DicomNEventReportResponse response)
{
//just to print if NEventReportResponse object is received from the Modality to the PACS
ConsoleLogger.Instance.Log(LogLevel.Info, response.SOPInstanceUID.ToString(), new object[] { });
}
public DicomNCreateResponse OnNCreateRequest(DicomNCreateRequest request)
{
throw new NotImplementedException();
}
public DicomNDeleteResponse OnNDeleteRequest(DicomNDeleteRequest request)
{
throw new NotImplementedException();
}
public DicomNEventReportResponse OnNEventReportRequest(DicomNEventReportRequest request)
{
throw new NotImplementedException();
}
public DicomNGetResponse OnNGetRequest(DicomNGetRequest request)
{
throw new NotImplementedException();
}
public DicomNSetResponse OnNSetRequest(DicomNSetRequest request)
{
throw new NotImplementedException();
}
}
I would be grateful is somebody guides me in this issue.
Thank You.