LEADTOOLS Medical (Leadtools.Medical.Workstation.Client assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.30
StoreClient Class
See Also  Members  
Leadtools.Medical.Workstation.Client Namespace : StoreClient Class



Performs DICOM Store operations against DICOM servers.

Object Model

StoreClient Class

Syntax

Visual Basic (Declaration) 
Public Class StoreClient 
Visual Basic (Usage)Copy Code
Dim instance As StoreClient
C# 
public class StoreClient 
C++/CLI 
public ref class StoreClient 

Example

Visual BasicCopy Code
Public Sub StoreDicom()
         Leadtools.Examples.Support.Unlock()

         Dim clientInfo As AeInfo = New AeInfo()

         clientInfo.Address = Dns.GetHostName() 'local machine
         clientInfo.AETitle = "TEST_CLIENT"
         clientInfo.Port = 1000

         Dim dataAccess As Medical.Storage.DataAccessLayer.IStorageDataAccessAgent

         Dim fromConfiguration As Boolean

         fromConfiguration = False
         If (fromConfiguration) Then

            'Make sure that the Sotrage Data Access is configured before creating an instance.
            dataAccess = DataAccessFactory.GetInstance(New StorageDataAccessConfigurationView()).CreateDataAccessAgent(Of IStorageDataAccessAgent)()
         Else

            Dim connectionString As String = "Data Source=local;Initial Catalog=DicomStorage;Integrated Security=True;User ID=;Password=;Pooling=True"
            'or you can directly create the data access object which works with your database
            dataAccess = New StorageSqlDbDataAccessAgent(connectionString)
         End If


         'Make sure that the FindAddIn is configured properly before using this class.
         Dim queryClient As DbQueryClient = New DbQueryClient(clientInfo, dataAccess)

         queryClient.EnableLog = True
         queryClient.LogFileName = Path.Combine(LEAD_VARS.ImagesDir, "DicomLog.txt")

         Dim series As DicomDataSet() = queryClient.FindSeries(New FindQuery())

         If series.Length > 0 Then
            Dim scpInfo As DicomScp = New DicomScp()

            scpInfo.AETitle = "LEAD_SERVER"
            scpInfo.Port = 104
            scpInfo.Timeout = 30

            Dim addressFound As Boolean
            Dim addresses As IPAddress()

            addressFound = False
            addresses = Dns.GetHostAddresses(Dns.GetHostName())

            For Each address As IPAddress In addresses
               'we need to get an IP V4, won't work with IP V6
               If address.AddressFamily = System.Net.Sockets.AddressFamily.InterNetwork Then
                  addressFound = True

                  scpInfo.PeerAddress = address

                  Exit For
               End If
            Next address

            If (Not addressFound) Then
               Throw New ArgumentException("Couldn't resolve a valid host Address. Address must conform to IP version 4")
            End If

            Dim client As StoreClient = New StoreClient(clientInfo, scpInfo, Compression.Native, dataAccess)

            client.EnableLog = True
            client.LogFileName = Path.Combine(LEAD_VARS.ImagesDir, "DicomLog.txt")

            client.StoreSeries(series(0).GetValue(Of String)(DicomTag.StudyInstanceUID, String.Empty), series(0).GetValue(Of String)(DicomTag.SeriesInstanceUID, String.Empty))

            Console.WriteLine("Series {0} has been stored successfully.", series(0).GetValue(Of String)(DicomTag.SeriesInstanceUID, String.Empty))
         End If
      End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
C#Copy Code
public void StoreDicom()
      {
         Leadtools.Examples.Support.Unlock();

         AeInfo clientInfo = new AeInfo();

         clientInfo.Address = Dns.GetHostName(); //local machine
         clientInfo.AETitle = "TEST_CLIENT";
         clientInfo.Port = 1000;

         IStorageDataAccessAgent dataAccess = null;
         bool fromConfiguration = false;

         if (fromConfiguration)
         {
            //Make sure that the Sotrage Data Access is configured before creating an instance.
            dataAccess = DataAccessFactory.GetInstance(new StorageDataAccessConfigurationView()).CreateDataAccessAgent<IStorageDataAccessAgent>();
         }
         else
         {
            string connectionString = @"Data Source=local;Initial Catalog=DicomStorage;Integrated Security=True;User ID=;Password=;Pooling=True";
            //or you can directly create the data access object which works with your database
            dataAccess = new StorageSqlDbDataAccessAgent(connectionString);
         }

         DbQueryClient queryClient = new DbQueryClient(clientInfo, dataAccess);

         queryClient.EnableLog = true;
         queryClient.LogFileName = Path.Combine(LEAD_VARS.ImagesDir, "DicomLog.txt");

         DicomDataSet[] series = queryClient.FindSeries(new FindQuery());

         if ( series.Length > 0 )
         {
            DicomScp scpInfo = new DicomScp();

            scpInfo.AETitle = "LEAD_SERVER";
            scpInfo.Port = 104;
            scpInfo.Timeout = 30;

            bool addressFound;
            IPAddress [] addresses ;

            addressFound = false;
            addresses = Dns.GetHostAddresses ( Dns.GetHostName ( ) ) ;

            foreach (IPAddress address in addresses)
            {
               //we need to get an IP V4, won't work with IP V6
               if (address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
               {
                  addressFound = true;

                  scpInfo.PeerAddress = address;

                  break;
               }
            }

            if (!addressFound)
            {
               throw new ArgumentException("Couldn't resolve a valid host Address. Address must conform to IP version 4");
            }

            StoreClient client = new StoreClient(clientInfo, scpInfo, Compression.Native, dataAccess);

            client.EnableLog = true ;
            client.LogFileName = Path.Combine(LEAD_VARS.ImagesDir, "DicomLog.txt");

            client.StoreSeries ( series [ 0 ].GetValue <string> ( DicomTag.StudyInstanceUID, string.Empty ), 
                                 series [ 0 ].GetValue <string> ( DicomTag.SeriesInstanceUID, string.Empty ) ) ;

            Console.WriteLine ( "Series {0} has been stored successfully.", series [ 0 ].GetValue <string> ( DicomTag.SeriesInstanceUID, string.Empty ) ) ;
         }
      }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}

Remarks

This class uses the Leadtools.Dicom.Scu.StoreScu class to perform DICOM communication with remote servers.

Inheritance Hierarchy

System.Object
   Leadtools.Medical.Workstation.Client.StoreClient

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

See Also

Leadtools.Medical.Workstation.Client requires a Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features