Gets or sets the total count of possible metadata records.
public int TotalCount {get; set;}
public:
property Int32 TotalCount
{
Int32 get()
void set(Int32 value)
}
The total count of possible metadata records
The TotalCount is equal to the number of DICOM instances stored in the Instance database table. This is the case because there can be one XML metadata record (or one JSON metadata record) for each DICOM instance.
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:\LEADTOOLS22\Bin\Dotnet4\x64\L22_PACS_SCP64";
string productName = "StorageServer";
string serviceName = "L22_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:\LEADTOOLS22\Resources\Images\DICOM\image2.dcm", agent);
string sopInstanceUid3 = StoreDicomAndMetadataToDatabase(@"C:\LEADTOOLS22\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);
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document