LAUREL BRIDGE

LaurelBridge.DCFExamples.StoreSCU Namespace

DICOM Connectivity Framework V3.4
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

  ClassDescription
Public classOptions
Command line options class for parsing user options for StoreSCU.
Public classProgram
Basic store service class user example which should be run with StoreSCPCallback.
Remarks

Supported OS Platforms:

  • Windows - .Net Framework 4.7.2 64-bit and 32-bit
  • Windows - .Net Core 2.1 64-bit and 32-bit
  • Linux - .Net Core 2.1 64-bit

Examples

StoreSCU Sample Code
public class Program
{
    /// <summary>
    /// Main entry point for StoreSCU.
    /// </summary>
    /// <param name="args">Command line args.</param>
    [STAThread]
    public static void Main(string[] args)
    {
        try
        {
            Options options;
            if (!Options.TryParse(args, out options))
            {
                throw new ArgumentException("bad command line parameters");
            }
            new Program(options);
            // and we're done
        }
        catch (AssociationRejectedException e)
        {
            Console.WriteLine("StoreSCU: {0}{1}{2}", e, Environment.NewLine, e.Pdu);
            Environment.ExitCode = 2;
        }
        catch (Exception e)
        {
            Console.WriteLine("StoreSCU: Exception caught during execution: {0}{1}Please verify the Store Server is up and running.", e,
                Environment.NewLine);
            Environment.ExitCode = 1;
        }
        finally
        {
            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>
    /// <param name="options">Parsed command line options class.</param>
    public Program(Options options)
    {
        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));

        DCF.Dicom.Store.StoreSCU scu = new DCF.Dicom.Store.StoreSCU(ainfo);
        scu.RequestAssociation();
        CStoreResponse response = scu.CStore(dds, 5);
        Console.WriteLine(response);
        scu.ReleaseAssociation();
    }
}