Initializes a new instance of the
DbQueryClient class.
Syntax
Example
Visual Basic | Copy Code |
---|
Public Sub DatabaseQueryLocal()
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 client As DbQueryClient = New DbQueryClient(clientInfo, dataAccess)
client.EnableLog = True
client.LogFileName = Path.Combine(LEAD_VARS.ImagesDir, "DicomLog.txt")
PerformClientQuery(client)
End Sub
Public Sub PerformClientQuery(ByVal client As QueryClient)
Dim studiesQuery As FindQuery = New FindQuery()
Dim studies As DicomDataSet() = client.FindStudies(studiesQuery)
If studies.Length > 0 Then
Dim study As DicomDataSet = studies(0)
Dim seriesQuery As FindQuery = New FindQuery()
seriesQuery.StudyInstanceUID = study.GetValue(Of String)(DicomTag.StudyInstanceUID, String.Empty)
Dim series As DicomDataSet() = client.FindSeries(seriesQuery)
For Each seriesDS As DicomDataSet In series
Dim imagesQuery As FindQuery = New FindQuery()
imagesQuery.SeriesInstanceUID = seriesDS.GetValue(Of String)(DicomTag.SeriesInstanceUID, String.Empty)
Dim images As DicomDataSet() = client.FindImages(imagesQuery)
For Each instance As DicomDataSet In images
Console.WriteLine("SOPInstanceUID: {0}", instance.GetValue(Of String)(DicomTag.SOPInstanceUID, String.Empty))
Console.WriteLine("SeriesInstanceUID: {0}", instance.GetValue(Of String)(DicomTag.SeriesInstanceUID, String.Empty))
Console.WriteLine("StudyInstanceUID: {0}", instance.GetValue(Of String)(DicomTag.StudyInstanceUID, String.Empty))
Next instance
Next seriesDS
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 DatabaseQueryLocal()
{
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 client = new DbQueryClient(clientInfo, dataAccess);
client.EnableLog = true;
client.LogFileName = Path.Combine(LEAD_VARS.ImagesDir, "DicomLog.txt");
PerformClientQuery ( client ) ;
}
public void PerformClientQuery(QueryClient client)
{
FindQuery studiesQuery = new FindQuery();
DicomDataSet[] studies = client.FindStudies(studiesQuery);
if (studies.Length > 0)
{
DicomDataSet study = studies[0];
FindQuery seriesQuery = new FindQuery();
seriesQuery.StudyInstanceUID = study.GetValue <string> ( DicomTag.StudyInstanceUID, string.Empty ) ;
DicomDataSet [] series = client.FindSeries(seriesQuery);
foreach (DicomDataSet seriesDS in series )
{
FindQuery imagesQuery = new FindQuery();
imagesQuery.SeriesInstanceUID = seriesDS.GetValue <string> ( DicomTag.SeriesInstanceUID, string.Empty);
DicomDataSet[] images = client.FindImages(imagesQuery);
foreach (DicomDataSet instance in images)
{
Console.WriteLine("SOPInstanceUID: {0}", instance.GetValue <string> ( DicomTag.SOPInstanceUID, string.Empty));
Console.WriteLine("SeriesInstanceUID: {0}", instance.GetValue <string> ( DicomTag.SeriesInstanceUID, string.Empty));
Console.WriteLine("StudyInstanceUID: {0}", instance.GetValue <string> ( DicomTag.StudyInstanceUID, string.Empty));
}
}
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
} |
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