Leadtools.Medical.Workstation.DataAccessLayer Requires Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
AddDicom Method
See Also  Example
Leadtools.Medical.Workstation.DataAccessLayer Namespace > IWorkstationDataAccessAgent Interface : AddDicom Method



dataset
The DicomDataSet to be inserted.
AETitle
The AE Title of the client performing the insert operation.
referencedFileName
The physical path to the provided dataset file.
thumbImage
The physical path the thumbnail image for the provided dataset.
dataset
The DicomDataSet to be inserted.
AETitle
The AE Title of the client performing the insert operation.
referencedFileName
The physical path to the provided dataset file.
thumbImage
The physical path the thumbnail image for the provided dataset.
Inserts a DicomDataSet into the underlying data store.

Syntax

Visual Basic (Declaration)  
Overridable Function AddDicom( _
   ByVal dataset As DicomDataSet, _
   ByVal AETitle As String, _
   ByVal referencedFileName As String, _
   ByVal thumbImage As String _
) As Boolean
Visual Basic (Usage) Copy Code
Dim instance As IWorkstationDataAccessAgent
Dim dataset As DicomDataSet
Dim AETitle As String
Dim referencedFileName As String
Dim thumbImage As String
Dim value As Boolean
 
value = instance.AddDicom(dataset, AETitle, referencedFileName, thumbImage)
C#  
virtual bool AddDicom( 
   DicomDataSet dataset,
   string AETitle,
   string referencedFileName,
   string thumbImage
)
C++/CLI  
virtual bool AddDicom( 
   DicomDataSet dataset,
   String^ AETitle,
   String^ referencedFileName,
   String^ thumbImage
) 

Parameters

dataset
The DicomDataSet to be inserted.
AETitle
The AE Title of the client performing the insert operation.
referencedFileName
The physical path to the provided dataset file.
thumbImage
The physical path the thumbnail image for the provided dataset.

Return Value

True if the operation succeeded; otherwise it is false.

Example

Visual Basic Copy Code
<Test> _
Public Sub StoreDICOMImages()
  Dim dataSet As DicomDataSet = New DicomDataSet()
  Dim dataSetPath As String = Path.Combine (ImagesPath.Path, "IMAGE1.DIC")

  dataSet.Load (dataSetPath, DicomDataSetLoadFlags.LoadAndClose)

  Dim thumbnailPath As String = GenerateThumbnail (dataSet)

  Dim dataAccessAgent As IWorkstationDataAccessAgent = Nothing
  Try
     'make sure you have configured the application configuration file with a valid
     'SqlCe connection string which have the same connection name 'WorkstationSqlCeConnection'
     dataAccessAgent = DataAccessAgentFactory.Instance.CreateAccessAgent ("WorkstationSqlCeConnection")

     If Nothing Is dataAccessAgent Then
       Console.WriteLine ("You have not configured a valid database connection.")

       Return
     End If
  Catch exception As Exception
     Console.WriteLine(exception.Message," :You have not configured a valid database connection.")

     Return
  End Try

  dataAccessAgent.AddDicom (dataSet, "TEST", dataSetPath,thumbnailPath)

  'perform a wildcard query for all the database information.
  Dim queryResult As DicomInformation = dataAccessAgent.QueryDicomInformation (New FindQuery ())


  If queryResult.Images.Count > 0 Then
     Console.WriteLine (queryResult.Images (0).SOPInstanceUID)

     dataAccessAgent.RemoveDicom (queryResult.Images)
  Else
     Console.WriteLine ("No images found in the database.")
  End If
End Sub

Private Function GenerateThumbnail(ByVal dataset As DicomDataSet) As String
  Dim codec As RasterCodecs = New RasterCodecs()

  Dim imageElement As DicomElement = dataset.FindFirstElement(Nothing, DicomTag.PixelData, False)

  If Not Nothing Is imageElement Then
     Dim rasterImage As RasterImage
     Dim resizeCmd As SizeCommand
     Dim thumbImage As String

     rasterImage = dataset.GetImage(imageElement, 0, 0, RasterByteOrder.Rgb, DicomGetImageFlags.AutoApplyModalityLut Or DicomGetImageFlags.AutoApplyVoiLut)

     If rasterImage.Signed OrElse rasterImage.GrayscaleMode = RasterGrayscaleMode.OrderedInverse Then
       Dim cmgGray As GrayscaleCommand

       cmgGray = New GrayscaleCommand(8)

       cmgGray.Run(rasterImage)
     End If

     resizeCmd = New SizeCommand(64, 64, RasterSizeFlags.None)

     resizeCmd.Run(rasterImage)

     thumbImage = Path.Combine (ImagesPath.Path, "Test.jpg")

     codec.Save(rasterImage, thumbImage, RasterImageFormat.Jpeg, 24)

     Return thumbImage
  Else
     Return Nothing
  End If
End Function
C# Copy Code
public void StoreDICOMImages ( )  

   DicomDataSet dataSet = new DicomDataSet(); 
 
   string dataSetPath = Path.Combine ( ImagesPath.Path, "IMAGE1.DIC" ) ; 
 
   dataSet.Load ( dataSetPath, DicomDataSetLoadFlags.LoadAndClose ) ; 
 
   string thumbnailPath = GenerateThumbnail ( dataSet ) ; 
 
   IWorkstationDataAccessAgent dataAccessAgent = null ; 
   try 
   { 
      //make sure you have configured the application configuration file with a valid  
      //SqlCe connection string which have the same connection name 'WorkstationSqlCeConnection' 
      dataAccessAgent = DataAccessAgentFactory.Instance.CreateAccessAgent ( "WorkstationSqlCeConnection" ) ; 
 
      if ( null == dataAccessAgent ) 
      { 
         Console.WriteLine ( "You have not configured a valid database connection." ) ; 
 
         return ; 
      } 
   } 
   catch ( Exception exception ) 
   { 
      Console.WriteLine( exception.Message," :You have not configured a valid database connection."); 
 
      return ; 
   } 
 
   dataAccessAgent.AddDicom ( dataSet, "TEST", dataSetPath,thumbnailPath ) ; 
 
   //perform a wildcard query for all the database information. 
   DicomInformation queryResult = dataAccessAgent.QueryDicomInformation ( new FindQuery ( ) ) ; 
 
 
   if ( queryResult.Images.Count > 0 )  
   { 
      Console.WriteLine ( queryResult.Images [ 0 ].SOPInstanceUID ) ; 
 
      dataAccessAgent.RemoveDicom ( queryResult.Images ) ; 
   } 
   else 
   { 
      Console.WriteLine ( "No images found in the database." ); 
   } 

 
private string GenerateThumbnail 

   DicomDataSet dataset 
 


   RasterCodecs codec = new RasterCodecs(); 
 
   DicomElement imageElement = dataset.FindFirstElement(null, DicomTag.PixelData, false); 
 
   if (null != imageElement) 
   { 
      RasterImage rasterImage; 
      SizeCommand resizeCmd; 
      string thumbImage; 
 
      rasterImage = dataset.GetImage(imageElement, 
                                       0, 
                                       0, 
                                       RasterByteOrder.Rgb, 
                                       DicomGetImageFlags.AutoApplyModalityLut | DicomGetImageFlags.AutoApplyVoiLut); 
 
      if (rasterImage.Signed || rasterImage.GrayscaleMode == RasterGrayscaleMode.OrderedInverse) 
      { 
         GrayscaleCommand cmgGray; 
 
         cmgGray = new GrayscaleCommand(8); 
 
         cmgGray.Run(rasterImage); 
      } 
 
      resizeCmd = new SizeCommand(64, 64, RasterSizeFlags.None); 
 
      resizeCmd.Run(rasterImage); 
 
      thumbImage = Path.Combine ( ImagesPath.Path, "Test.jpg" ) ; 
 
      codec.Save(rasterImage, thumbImage, RasterImageFormat.Jpeg, 24); 
 
      return thumbImage ; 
   } 
   else 
   { 
      return null ; 
   } 
}

Remarks

Use this method to store DicomDataSet objects into the data store.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also

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