LaurelBridge.DCF.Examples.PrintSCU Namespace
LAUREL BRIDGE

LaurelBridge.DCF.Examples.PrintSCU Namespace

DICOM Connectivity Framework V3.4
The PrintSCU example demonstrates how to use DCF to implement a print service class user.
Classes

  ClassDescription
Public classProgram
This example demonstrates how to setup a PrintJobDescription, that will serve to define a PrintJob that may be submitted to print to a PrintSCP.
Examples

PrintSCU Sample Code
public class Program
{
    /// <summary>
    /// Main entry point for PrintSCU.
    /// </summary>
    [STAThread]
    public static void Main()
    {
        PrintSCUListener scu = new PrintSCUListener();
        scu.DoPrint(ConfigurePrintJob("ExamplePrint.cfg"));

        if (System.Diagnostics.Debugger.IsAttached)
        {
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey();
        }
    }

    /// <summary>
    /// Reads the print scu configuration from disk. The cfg contains
    /// information about the requested print job, as well as the information
    /// for the association; CalledAETitle, CallingAETitle, Hostname, Port.
    /// </summary>
    private static CFGGroup ConfigurePrintJob(string cfgPath)
    {
        CFGGroup cfg = CFGDB.loadGroupFromFile(cfgPath);
        return cfg;
    }

    /// <summary>
    /// Listener class that, in addition to submitting the print job to the PrintSCP, will
    /// listen for print job status updates sent from the PrintSCP.
    /// </summary>
    private class PrintSCUListener : IPrintClientListener
    {
        private static readonly ILogger Logger = LogManager.GetCurrentClassLogger();

        /// <summary>
        /// Submit the given print job indicated by the input CFGGroup to the PrintSCP. An
        /// association will be requested using the information provided in the input printCfg CFGGroup.
        /// </summary>
        /// <param name="printCfg">The input CFGGroup containing information about the print job to request.</param>
        public void DoPrint(CFGGroup printCfg)
        {
            try
            {
                PrintJobDescription job = new PrintJobDescription(printCfg);

                PrintClient client = new PrintClient();
                PrintJobStatus jobStatus = client.SubmitPrintJob(job, this);
                Logger.InfoFormat("PrintSCU: job status({0})", jobStatus.StatusInfoEx);
            }
            catch (Exception e)
            {
                Logger.Error(e, "PrintSCU: error submitting print job:");
            }
        }

        /// <summary>
        /// Listen for print job status updates sent by the PrintSCP.
        /// </summary>
        /// <param name="printJobStatus">The print job status sent by the SCP.</param>
        public void UpdatePrintJobStatus(PrintJobStatus printJobStatus)
        {
            Logger.InfoFormat("PrintSCU job status({0})", printJobStatus);
        }
    }
}