The StoreSCU example demonstrates how to use the DCF to construct and use the low level store SCU class LaurelBridge.DCF.Dicom.Store.StoreSCU.
Classes
Class | Description | |
---|---|---|
![]() | Program |
Basic store service class user example which should be run with StoreSCPCallback.
|
Examples
StoreSCU Sample Code
public class Program { private static StoreScuOptions _options; /// <summary> /// Main entry point for StoreSCU. /// </summary> /// <param name="args">Command line args.</param> [STAThread] public static void Main(string[] args) { try { _options = new StoreScuOptions(args); new Program(); // and we're done } catch (Exception e) { Console.WriteLine("Exception caught during execution: {0}{1}Please verify the Store Server is up and running.", e, Environment.NewLine); } if (System.Diagnostics.Debugger.IsAttached) { Console.Write("Press any key to continue . . . "); Console.ReadKey(); } } /// <summary> /// The class submits C-Store requests using the StoreSCU class. /// </summary> public Program() { DicomDataSet dds; string sopClass; string transferSyntax; // Note that this contrived example reads the entire DicomDataSet, including the pixel data, into memory. // In a more real world scenario, the user of the StoreSCU class would either: // a) already know what the SOP class and transfer syntax would be (for example, a modality). // b) discover this information by some other means, such as reading external records which stated the information // (for example, see the DoCMoveOnThread method in the SampleVNAQuerySCP.cs file in the SampleVNA example for // how a Query SCP might persist/discover this information for populating the RequestedPresentationContext objects). using (DicomFileInput dfi = new DicomFileInput(_options.InputPath)) { dds = dfi.ReadDataSet(); dds.ExpandStreamingModeData(true); sopClass = dds.GetElementStringValue(Tags.SOPClassUID); transferSyntax = dfi.FileMetaInformation.TransferSyntaxUid; } AssociationInfo ainfo = new AssociationInfo(); ainfo.CalledPresentationAddress = _options.RemoteHost + ":" + _options.RemotePort; ainfo.CalledTitle = _options.CalledAETitle; ainfo.CallingTitle = _options.CallingAETitle; ainfo.AddRequestedPresentationContext(new RequestedPresentationContext(0, sopClass, transferSyntax)); Dicom.Store.StoreSCU scu = new Dicom.Store.StoreSCU(ainfo); scu.RequestAssociation(); CStoreResponse response = scu.CStore(dds, 5); Console.WriteLine(response); scu.ReleaseAssociation(); } } /// <summary> /// A simple StoreScuOptions class that returns the default value unless overridden on the command line. /// </summary> /// <remarks> /// <para> /// The order of items on the command line, and their defaults are as follows: /// <list type="table"> /// <item> /// <term>InputPath</term> /// <description>mr-knee.dcm</description> /// </item> /// <item> /// <term>CalledHost</term> /// <description>localhost</description> /// </item> /// <item> /// <term>CalledPort</term> /// <description>104</description> /// </item> /// <item> /// <term>CalledAETitle</term> /// <description>SCP</description> /// </item> /// <item> /// <term>CallingAETitle</term> /// <description>SCU</description> /// </item> /// </list> /// </para> /// </remarks> internal sealed class StoreScuOptions { private readonly List<string> _commandArgs; /// <summary> /// Constructor. /// </summary> /// <param name="commandArgs">the command line options</param> public StoreScuOptions(string[] commandArgs) { _commandArgs = commandArgs == null ? new List<string>() : new List<string>(commandArgs); } /// <summary> /// Get specified input path or default. /// </summary> public string InputPath { get { return _commandArgs.Count < 1 ? "mr-knee.dcm" : _commandArgs[0]; } } /// <summary> /// Get specified remote host address or default. /// </summary> public string RemoteHost { get { return _commandArgs.Count < 2 ? "localhost" : _commandArgs[1]; } } /// <summary> /// Get specified remote port or default. /// </summary> public string RemotePort { get { return _commandArgs.Count < 3 ? "104" : _commandArgs[2]; } } /// <summary> /// Get specified calling ae title or default. /// </summary> public string CallingAETitle { get { return _commandArgs.Count < 4 ? "SCU" : _commandArgs[3]; } } /// <summary> /// Get specified called ae title or default. /// </summary> public string CalledAETitle { get { return _commandArgs.Count < 5 ? "SCP" : _commandArgs[4]; } } }