Add the following .NET System DLL:
System.Core (.NET 3.5 dll)[C#]
using Leadtools.Dicom;
using Leadtools.Dicom.AddIn;
using Leadtools.Dicom.AddIn.Interfaces;
using Leadtools.Dicom.AddIn.Attributes;
using Microsoft.Practices.Unity;
[C#]
public class StorageCommitAddIn : IProcessNAction
{
}
[C#]
[DicomAddInAttribute("Storage Commit AddIn", "1.0.0.0", Description = "Implements Storage Commitment", Author = "")]
public class StorageCommitAddIn : IProcessNAction
{
}
[C#]
public class StorageCommitAddIn : IProcessNAction
{
public DicomCommandStatusType OnNAction(DicomClient Client, byte PresentationId, int MessageID, string AffectedClass, string Instance, int Action, DicomDataSet Request, DicomDataSet Response)
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
#region IProcessBreak Members
public void Break(BreakType type)
{
throw new Exception("The method or operation is not implemented.");
}
}
[C#]
[PresentationContext(DicomUidType.StorageCommitmentPushModelClass, DicomUidType.ImplicitVRLittleEndian)]
public DicomCommandStatusType OnNAction(DicomClient Client, byte PresentationId, int MessageID, string AffectedClass, string Instance, int Action, DicomDataSet Request, DicomDataSet Response)
{
throw new Exception("The method or operation is not implemented.");
}
[C#]
private IDicomRequest _DicomRequest;
/// <summary>
/// Allows the user to send a DICOM request from an addin.
/// </summary>
/// <value>The dicom request.</value>
[Dependency]
public IDicomRequest DicomRequest
{
set
{
_DicomRequest = value;
}
}
private IAETitle _AeTitle;
/// <summary>
/// Let's get the AE title information.
/// </summary>
/// <value>The AE title.</value>
[Dependency]
public IAETitle AeTitle
{
set
{
_AeTitle = value;
}
}
The above code uses the Microsoft Unity Dependency injection to get registered interfaces that implement features required by our addin. For instance, the IDicomRequest interface is implemented by the Leadtools.Dicom.Server.exe.
[C#]
[PresentationContext(DicomUidType.StorageCommitmentPushModelClass, DicomUidType.ImplicitVRLittleEndian)]
public DicomCommandStatusType OnNAction(DicomClient Client, byte PresentationId, int MessageID, string AffectedClass, string Instance, int Action, DicomDataSet Request, DicomDataSet Response)
{
DicomDataSet ds = new DicomDataSet(Client.Server.TemporaryDirectory);
// Copy the dataset. We will be using it in a thread so we need to copy
// it so will be available in the thread.
ds.Copy(Request, null, null);
// Process the commit on a separate thread. This will allow us to immediately
// return a notification to the client informing that we have received the
// message.
result = AsyncHelper.Execute(delegate()
{
DicomDataSet commitDS = new DicomDataSet(Client.Server.TemporaryDirectory);
PresentationContext pc = new PresentationContext();
DicomRequest request = new DicomRequest(Client);
// At this point we would process the storage commit and build a response
// dataset. For a complete example of this refer to the sample storage commit
// add-in that ships with the LEADTOOLS PACS Framework.
// Prepare to send our response back to the requesting client
pc.AbstractSyntax = DicomUidType.StorageCommitmentPushModelClass;
pc.TransferSyntaxes.Add(DicomUidType.ImplicitVRLittleEndian);
request.PresentationContexts.Add(pc);
request.RequireMessagePump = true;
request.ReceiveNReportResponse += new ReceiveNReportResponseDelegate(request_ReceiveNReportResponse);
request.ConnectType = ConnectType.Conditional;
_DicomRequest.SendNReportRequest(request, PresentationId, 1000, DicomUidType.StorageCommitmentPushModelClass,
DicomUidType.StorageCommitmentPushModelInstance,1, commitDS);
});
Response = null;
return DicomCommandStatusType.Success;
}
void request_ReceiveNReportResponse(DicomRequest request, byte presentationID, int messageID, string affectedClass, string instance, DicomCommandStatusType status, int dicomEvent, DicomDataSet dataSet)
{
// The LEADTOOLS PACS Framework provides a default implementation.
}
[C#]
private AsyncResult result = null;
public void Break(BreakType type)
{
// Stop the commit process if we received a request
// to stop processing
if(result != null && !result.IsCompleted)
result.Cancel();
}