←Select platform

IStorageDataAccessAgent4 Interface

Summary

Provides methods for accessing and adding DICOM Instance information.

Syntax
C#
VB
C++
public interface IStorageDataAccessAgent4 : IStorageDataAccessAgent3, IStorageDataAccessAgent2, IStorageDataAccessAgent 
Public Interface IStorageDataAccessAgent4 
   Inherits IStorageDataAccessAgent3, IStorageDataAccessAgent2, IStorageDataAccessAgent 
public: 
   interface class IStorageDataAccessAgent4 abstract : IStorageDataAccessAgent3, IStorageDataAccessAgent2,  
    IStorageDataAccessAgent 
Remarks

The IStorageDataAccessAgent4 interface derives from the IStorageDataAccessAgent3, IStorageDataAccessAgent2, and IStorageDataAccessAgent interfaces. The functionality in the IStorageDataAccessAgent4 interface that is not part of the derived interfaces is related to generating, storing, and deleting DICOM XML and JSON metadata.

Example

This example uses all available metadata operations on the IStorageDataAccessAgent4 interface.

C#
VB
using Leadtools; 
using Leadtools.Dicom; 
using Leadtools.Dicom.Common.Extensions; 
using Leadtools.DicomDemos; 
using Leadtools.Medical.DataAccessLayer; 
using Leadtools.Medical.Storage.DataAccessLayer; 
using Leadtools.Medical.Storage.DataAccessLayer.Configuration; 
 
public static IStorageDataAccessAgent4 GetStorageDataAccessAgent4() 
{ 
   // Before running this sample, follow these steps: 
   // 1. Run CSPacsDatabaseConfigurationDemo.exe to create the databases 
   // 2. Run CSPACSConfigDemo.exe to create the DICOM services 
   // 3. Set 'serviceDirectory' to the DICOM service folder 
   string serviceDirectory = @"C:\LEADTOOLS 21\Bin\Dotnet4\x64\L20_PACS_SCP64"; 
   string productName = "StorageServer"; 
   string serviceName = "L20_PACS_SCP64"; 
   System.Configuration.Configuration configuration = DicomDemoSettingsManager.GetGlobalPacsAddinsConfiguration(serviceDirectory); 
 
   StorageDataAccessConfigurationView view = new StorageDataAccessConfigurationView(configuration, productName, serviceName); 
   IStorageDataAccessAgent4 agent = DataAccessFactory.GetInstance(view).CreateDataAccessAgent<IStorageDataAccessAgent4>(); 
   return agent; 
} 
 
// Stores a DICOM file to the database 
// Stores XML and JSON metadata 
// returns the SOPInstanceUID 
public static string StoreDicomAndMetadataToDatabase(string dicomFileName, IStorageDataAccessAgent4 agent) 
{ 
   DicomDataSet ds = new DicomDataSet(); 
   ds.Load(dicomFileName, DicomDataSetLoadFlags.None); 
   DicomElement element = ds.FindFirstElement(null, DicomTag.SOPInstanceUID, true); 
   string sopInstanceUid = ds.GetStringValue(element, 0); 
   agent.StoreDicom(ds, dicomFileName, "DemoAE", null, true, true, true, true); 
 
   // You can store XML and JSON data with separate calls 
   agent.StoreMetadataXml(ds, sopInstanceUid, DicomDataSetSaveXmlFlags.IgnoreBinaryData, true); 
   agent.StoreMetadataJson(ds, sopInstanceUid, DicomDataSetSaveJsonFlags.IgnoreBinaryData, true); 
 
   // Or you can generate both XML and JSON data with a single method 
   MetadataOptions options = new MetadataOptions(); 
   options.SaveJsonFlags = DicomDataSetSaveJsonFlags.IgnoreBinaryData; 
   options.SaveXmlFlags = DicomDataSetSaveXmlFlags.IgnoreBinaryData; 
   options.StoreJson = true; 
   options.StoreXml = true; 
   agent.StoreMetadata(ds, sopInstanceUid, options, true); 
 
   return sopInstanceUid; 
} 
 
public static void DicomMetadataSample() 
{ 
   IStorageDataAccessAgent4 agent = GetStorageDataAccessAgent4(); 
 
   // Delete all existing metadata 
   agent.DeleteAllMetadataXml(); 
   agent.DeleteAllMetadataJson(); 
 
   // Add two DICOM files, and generate the XML and JSON metadata for each 
   string sopInstanceUid2 = StoreDicomAndMetadataToDatabase(@"C:\LEADTOOLS21\Resources\Images\DICOM\image2.dcm", agent); 
   string sopInstanceUid3 = StoreDicomAndMetadataToDatabase(@"C:\LEADTOOLS21\Resources\Images\DICOM\image3.dcm", agent); 
 
   // Verify the metadata exists for sopInstanceUid2 
   bool exists = agent.ExistsMetadataXml(sopInstanceUid2); 
   Debug.Assert(exists); 
   exists = agent.ExistsMetadataJson(sopInstanceUid2); 
   Debug.Assert(exists); 
 
 
   // Get the total possible XML metadata count -- this is the count of all DICOM instances 
   int xmlMetadataCount = agent.GetCountMetadataXml(MetadataScope.All); 
   Debug.WriteLine("XML MetadataCount: {0}", xmlMetadataCount); 
 
   // Get the existing count of XML metadata records 
   int xmlMetadataExistingCount = agent.GetCountMetadataXml(MetadataScope.Existing); 
   Debug.WriteLine("XML Existing MetadataCount: {0}", xmlMetadataExistingCount); 
 
   // Get the missing count of XML metadata records 
   int xmlMetadataMissingCount = agent.GetCountMetadataXml(MetadataScope.Missing); 
   Debug.WriteLine("XML Missing MetadataCount: {0}", xmlMetadataMissingCount); 
 
   // Get the missing count of JSON metadata records 
   int jsonMetadataMissingCount = agent.GetCountMetadataJson(MetadataScope.Missing); 
   Debug.WriteLine("JSON Missing MetadataCount: {0}", jsonMetadataMissingCount); 
 
   // Delete the metadata for sopInstanceUid2 and sopInstanceUid3 
   List<string> sopList = new List<string>(); 
   sopList.Add(sopInstanceUid2); 
   sopList.Add(sopInstanceUid3); 
 
   agent.DeleteMetadataXml(sopList); 
   agent.DeleteMetadataJson(sopList); 
 
   // Verify the metadata exists no longer exists for sopInstanceUid2 
   exists = agent.ExistsMetadataXml(sopInstanceUid2); 
   Debug.Assert(!exists); 
   exists = agent.ExistsMetadataJson(sopInstanceUid2); 
   Debug.Assert(!exists); 
 
   // Generate metadata for all records in the database 
   agent.GenerateMetadataStarting += Agent_GenerateMetadataStarting; 
   agent.GenerateMetadataUpdate += Agent_GenerateMetadataUpdate; 
   agent.GenerateMetadataCompleted += Agent_GenerateMetadataCompleted; 
   agent.GenerateMetadataXml(DicomDataSetSaveXmlFlags.IgnoreBinaryData, MetadataScope.All); 
   agent.GenerateMetadataJson(DicomDataSetSaveJsonFlags.IgnoreBinaryData, MetadataScope.All); 
 
   // Or you can call a single method to generate all metadata 
   MetadataOptions options = new MetadataOptions(); 
   options.SaveJsonFlags = DicomDataSetSaveJsonFlags.IgnoreBinaryData; 
   options.SaveXmlFlags = DicomDataSetSaveXmlFlags.IgnoreBinaryData; 
   options.StoreJson = true; 
   options.StoreXml = true; 
   agent.GenerateMetadata(options, MetadataScope.All); 
} 
 
private static void Agent_GenerateMetadataCompleted(object sender, GenerateMetadataArgs e) 
{ 
   Debug.WriteLine("GenerateMetadataCompleted {0} of {1}: ", e.CurrentItem + 1, e.TotalCount); 
} 
 
private static void Agent_GenerateMetadataUpdate(object sender, GenerateMetadataArgs e) 
{ 
   // Cancel generating metadata after 5 metadata records have been generated 
   if (e.CurrentItem + 1 == 5) 
   { 
      e.Cancelled = true; 
      Debug.WriteLine("GenerateMetadataUpdate - Cancelled {0} of {1}: ", e.CurrentItem + 1, e.TotalCount); 
   } 
} 
 
private static void Agent_GenerateMetadataStarting(object sender, GenerateMetadataArgs e) 
{ 
   Debug.WriteLine("GenerateMetadataStarting {0} of {1}: ", e.CurrentItem + 1, e.TotalCount); 
} 
Imports Leadtools 
Imports Leadtools.Dicom 
Imports Leadtools.Dicom.Common.Extensions 
Imports Leadtools.DicomDemos 
Imports Leadtools.Medical.DataAccessLayer 
Imports Leadtools.Medical.Storage.DataAccessLayer 
Imports Leadtools.Medical.Storage.DataAccessLayer.Configuration 
 
Public Shared Function GetStorageDataAccessAgent4() As IStorageDataAccessAgent4 
    ' Before running this sample, follow these steps: 
    ' 1. Run CSPacsDatabaseConfigurationDemo.exe to create the databases 
    ' 2. Run CSPACSConfigDemo.exe to create the DICOM services 
    ' 3. Set 'serviceDirectory' to the DICOM service folder 
    Dim serviceDirectory As String = "C:\LEADTOOLS 21\Bin\Dotnet4\x64\L20_PACS_SCP64" 
    Dim productName As String = "StorageServer" 
    Dim serviceName As String = "L20_PACS_SCP64" 
    Dim configuration As System.Configuration.Configuration = DicomDemoSettingsManager.GetGlobalPacsAddinsConfiguration(serviceDirectory) 
 
    Dim view As New StorageDataAccessConfigurationView(configuration, productName, serviceName) 
    Dim agent As IStorageDataAccessAgent4 = DataAccessFactory.GetInstance(view).CreateDataAccessAgent(Of IStorageDataAccessAgent4)() 
    Return agent 
End Function 
 
' Stores a DICOM file to the database 
' Stores XML and JSON metadata 
' returns the SOPInstanceUID 
Public Shared Function StoreDicomAndMetadataToDatabase(ByVal dicomFileName As String, ByVal agent As IStorageDataAccessAgent4) As String 
    Dim ds As New DicomDataSet() 
    ds.Load(dicomFileName, DicomDataSetLoadFlags.None) 
    Dim element As DicomElement = ds.FindFirstElement(Nothing, DicomTag.SOPInstanceUID, True) 
    Dim sopInstanceUid As String = ds.GetStringValue(element, 0) 
    agent.StoreDicom(ds, dicomFileName, "DemoAE", Nothing, True, True, True, True) 
 
    ' You can store XML and JSON data with separate calls 
    agent.StoreMetadataXml(ds, sopInstanceUid, DicomDataSetSaveXmlFlags.IgnoreBinaryData, True) 
    agent.StoreMetadataJson(ds, sopInstanceUid, DicomDataSetSaveJsonFlags.IgnoreBinaryData, True) 
 
    ' Or you can generate both XML and JSON data with a single method 
    Dim options As New MetadataOptions() 
    options.SaveJsonFlags = DicomDataSetSaveJsonFlags.IgnoreBinaryData 
    options.SaveXmlFlags = DicomDataSetSaveXmlFlags.IgnoreBinaryData 
    options.StoreJson = True 
    options.StoreXml = True 
    agent.StoreMetadata(ds, sopInstanceUid, options, True) 
 
    Return sopInstanceUid 
End Function 
 
Public Shared Sub DicomMetadataSample() 
    Dim agent As IStorageDataAccessAgent4 = GetStorageDataAccessAgent4() 
 
    ' Delete all existing metadata 
    agent.DeleteAllMetadataXml() 
    agent.DeleteAllMetadataJson() 
 
    ' Add two DICOM files, and generate the XML and JSON metadata for each 
    Dim sopInstanceUid2 As String = StoreDicomAndMetadataToDatabase("C:\LEADTOOLS21\Resources\Images\DICOM\image2.dcm", agent) 
    Dim sopInstanceUid3 As String = StoreDicomAndMetadataToDatabase("C:\LEADTOOLS21\Resources\Images\DICOM\image3.dcm", agent) 
 
    ' Verify the metadata exists for sopInstanceUid2 
    Dim exists As Boolean = agent.ExistsMetadataXml(sopInstanceUid2) 
    Debug.Assert(exists) 
    exists = agent.ExistsMetadataJson(sopInstanceUid2) 
    Debug.Assert(exists) 
 
 
    ' Get the total possible XML metadata count -- this is the count of all DICOM instances 
    Dim xmlMetadataCount As Integer = agent.GetCountMetadataXml(MetadataScope.All) 
    Debug.WriteLine("XML MetadataCount: {0}", xmlMetadataCount) 
 
    ' Get the existing count of XML metadata records 
    Dim xmlMetadataExistingCount As Integer = agent.GetCountMetadataXml(MetadataScope.Existing) 
    Debug.WriteLine("XML Existing MetadataCount: {0}", xmlMetadataExistingCount) 
 
    ' Get the missing count of XML metadata records 
    Dim xmlMetadataMissingCount As Integer = agent.GetCountMetadataXml(MetadataScope.Missing) 
    Debug.WriteLine("XML Missing MetadataCount: {0}", xmlMetadataMissingCount) 
 
    ' Get the missing count of JSON metadata records 
    Dim jsonMetadataMissingCount As Integer = agent.GetCountMetadataJson(MetadataScope.Missing) 
    Debug.WriteLine("JSON Missing MetadataCount: {0}", jsonMetadataMissingCount) 
 
    ' Delete the metadata for sopInstanceUid2 and sopInstanceUid3 
    Dim sopList As New List(Of String)() 
    sopList.Add(sopInstanceUid2) 
    sopList.Add(sopInstanceUid3) 
 
    agent.DeleteMetadataXml(sopList) 
    agent.DeleteMetadataJson(sopList) 
 
    ' Verify the metadata exists no longer exists for sopInstanceUid2 
    exists = agent.ExistsMetadataXml(sopInstanceUid2) 
    Debug.Assert((Not exists)) 
    exists = agent.ExistsMetadataJson(sopInstanceUid2) 
    Debug.Assert((Not exists)) 
 
    ' Generate metadata for all records in the database 
    AddHandler agent.GenerateMetadataStarting, AddressOf Agent_GenerateMetadataStarting 
    AddHandler agent.GenerateMetadataUpdate, AddressOf Agent_GenerateMetadataUpdate 
    AddHandler agent.GenerateMetadataCompleted, AddressOf Agent_GenerateMetadataCompleted 
    agent.GenerateMetadataXml(DicomDataSetSaveXmlFlags.IgnoreBinaryData, MetadataScope.All) 
    agent.GenerateMetadataJson(DicomDataSetSaveJsonFlags.IgnoreBinaryData, MetadataScope.All) 
 
    ' Or you can call a single method to generate all metadata 
    Dim options As New MetadataOptions() 
    options.SaveJsonFlags = DicomDataSetSaveJsonFlags.IgnoreBinaryData 
    options.SaveXmlFlags = DicomDataSetSaveXmlFlags.IgnoreBinaryData 
    options.StoreJson = True 
    options.StoreXml = True 
    agent.GenerateMetadata(options, MetadataScope.All) 
End Sub 
 
Private Shared Sub Agent_GenerateMetadataCompleted(ByVal sender As Object, ByVal e As GenerateMetadataArgs) 
    Debug.WriteLine("GenerateMetadataCompleted {0} of {1}: ", e.CurrentItem + 1, e.TotalCount) 
End Sub 
 
Private Shared Sub Agent_GenerateMetadataUpdate(ByVal sender As Object, ByVal e As GenerateMetadataArgs) 
    ' Cancel generating metadata after 5 metadata records have been generated 
    If e.CurrentItem + 1 = 5 Then 
        e.Cancelled = True 
        Debug.WriteLine("GenerateMetadataUpdate - Cancelled {0} of {1}: ", e.CurrentItem + 1, e.TotalCount) 
    End If 
End Sub 
 
Private Shared Sub Agent_GenerateMetadataStarting(ByVal sender As Object, ByVal e As GenerateMetadataArgs) 
    Debug.WriteLine("GenerateMetadataStarting {0} of {1}: ", e.CurrentItem + 1, e.TotalCount) 
End Sub 
Requirements
Target Platforms
Help Version 21.0.2021.6.30
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Medical.Storage.DataAccessLayer Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.