DicomObjects.NET.8.48 Documentation
DicomObjects Namespace / DicomDataSet Class / MergeBulkData Method
A method which, when passed a URI, returns the associated byte array
If true, then an exception is thrown if any items cannot be found
Example

In This Topic
    MergeBulkData Method
    In This Topic
    Load Bulk data for all attributes, getting data from a method, based on the URI
    Syntax
    'Declaration
     
    
    Public Sub MergeBulkData( _
       ByVal GetData As System.Func(Of Uri,String,HttpContent), _
       ByVal RequireBulkData As System.Boolean _
    ) 
    public void MergeBulkData( 
       System.Func<Uri,string,HttpContent> GetData,
       System.bool RequireBulkData
    )

    Parameters

    GetData
    A method which, when passed a URI, returns the associated byte array
    RequireBulkData
    If true, then an exception is thrown if any items cannot be found
    Remarks
    This method is used to re-assemble data from STOW-RS etc., where some bulk data items have been sent as parts of a multipart message, and the GetData delegate points to a routine which finds the appropriate part of the message.
    Example
    var studyUID = "1.3.46.670589.10.900123.19970114.35056132060.1";
    var seriesUID = "1.3.46.670589.10.900123.19970114.35056132360.3";
    var instanceUID = "1.3.46.670589.10.900123.19970114.3505612064";
                        
    var dwc = new WadoWebClient($"http://localhost:10001/wado");
    dwc.TransferSyntaxes.Clear();
    dwc.TransferSyntaxes.Add(TransferSyntaxes.ExplicitVRLittleEndian);
    var results = dwc.RetrieveMetaData(studyUID, seriesUID, instanceUID);
                        
    DicomDataSet metadata = results.FirstOrDefault();
    bool RequireBulkData = true;
                        
    if (metadata != null)
    {
        metadata.MergeBulkData((uri, contentType) =>
        {
            using (var client = new HttpClient())
            {
                string transferSyntax = TransferSyntaxes.ExplicitVRLittleEndian;
                var request = new HttpRequestMessage(HttpMethod.Get, uri);
                request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/octet-stream")
                {
                    Parameters = { new NameValueHeaderValue("transfer-syntax", transferSyntax) }
                });
                
                var response = client.SendAsync(request).Result;
                response.EnsureSuccessStatusCode();
                
                return new ByteArrayContent(response.Content.ReadAsByteArrayAsync().Result)
                {
                    Headers = { ContentType = new MediaTypeHeaderValue(contentType) }
                };
            }
        }, RequireBulkData);
    }
    var pixelData = results.FirstOrDefault()[Keyword.PixelData].Value; // pixel data retrieved
    Requirements

    Target Platforms: .NET CLR 4.8 or higher

    See Also