Gets or sets a value that represents the index of the metadata record that has just been generated.
public int CurrentItem {get; set;} public:property Int32 CurrentItem{Int32 get()void set(Int32 value)}
A value that represents the index of the metadata record that has just been generated.
The GenerateMetadataXml and GenerateMetadataJson classes both generate metadata, and fire the following events:
These events all have the GenerateMetadataArgs class as a parameter.
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 folderstring 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 SOPInstanceUIDpublic 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 callsagent.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 methodMetadataOptions 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 metadataagent.DeleteAllMetadataXml();agent.DeleteAllMetadataJson();// Add two DICOM files, and generate the XML and JSON metadata for eachstring 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 sopInstanceUid2bool 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 instancesint xmlMetadataCount = agent.GetCountMetadataXml(MetadataScope.All);Debug.WriteLine("XML MetadataCount: {0}", xmlMetadataCount);// Get the existing count of XML metadata recordsint xmlMetadataExistingCount = agent.GetCountMetadataXml(MetadataScope.Existing);Debug.WriteLine("XML Existing MetadataCount: {0}", xmlMetadataExistingCount);// Get the missing count of XML metadata recordsint xmlMetadataMissingCount = agent.GetCountMetadataXml(MetadataScope.Missing);Debug.WriteLine("XML Missing MetadataCount: {0}", xmlMetadataMissingCount);// Get the missing count of JSON metadata recordsint jsonMetadataMissingCount = agent.GetCountMetadataJson(MetadataScope.Missing);Debug.WriteLine("JSON Missing MetadataCount: {0}", jsonMetadataMissingCount);// Delete the metadata for sopInstanceUid2 and sopInstanceUid3List<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 sopInstanceUid2exists = agent.ExistsMetadataXml(sopInstanceUid2);Debug.Assert(!exists);exists = agent.ExistsMetadataJson(sopInstanceUid2);Debug.Assert(!exists);// Generate metadata for all records in the databaseagent.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 metadataMetadataOptions 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 generatedif (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
