Micro Focus Content Manager SDK 9.4
HP.HPTRIM.SDK.DownloadNotifier Class Reference

The DownloadNotifier class provides a streaming interface to document transfers from the workgroup server to the SDK application. During document transfers from the workgroup server to the SDK application, the OnChunkAvailable event is called, to provide real-time notifications of the bytes that are being transferred. This allows the SDK application to access the bytes of the document, before the document has been transferred in its entirety, and is particularly useful for streaming documents onwards from the SDK application to a subsequent receiver. More...

Inheritance diagram for HP.HPTRIM.SDK.DownloadNotifier:
HP.HPTRIM.SDK.DownloadNotifierBase

Public Member Functions

 DownloadNotifier (Database db, long chunkSize=1024 *1024, long startingPosition=0, long endingPosition=-1)
 Creates a DownloadNotifier instance. More...
 
delegate void OnChunkAvailableEventHandler (byte[] chunk, long chunkPos, long chunkLen, bool lastChunk)
 OnChunkAvailableEventHandler is the delegate type of the event that that is fired when new data is available. More...
 
- Public Member Functions inherited from HP.HPTRIM.SDK.DownloadNotifierBase
void Dispose ()
 
 DownloadNotifierBase (Database db)
 
 DownloadNotifierBase (Database db, long startingPosition, long endingPosition)
 
 DownloadNotifierBase (Database db, long startingPosition)
 
delegate void SwigDelegateDownloadNotifierBase_0 (global::System.IntPtr args)
 

Events

OnChunkAvailableEventHandler OnChunkAvailable
 OnChunkAvailable is the event that is fired for each new chunk in a document transfer. More...
 

Detailed Description

The DownloadNotifier class provides a streaming interface to document transfers from the workgroup server to the SDK application. During document transfers from the workgroup server to the SDK application, the OnChunkAvailable event is called, to provide real-time notifications of the bytes that are being transferred. This allows the SDK application to access the bytes of the document, before the document has been transferred in its entirety, and is particularly useful for streaming documents onwards from the SDK application to a subsequent receiver.

DownloadNotifier provides a unified streaming interface for documents, regardless of whether the document is already present in the local document cache or not. In the case of a document residing in the local document cache, all bytes will be notified immediately.

The following is a simple example of how to use DownloadNotifier.

private void Notifier_OnChunkAvailable(byte[] chunk, long chunkPos, long chunkLen, bool lastChunk)
{
    // ...
}

Record rec = new Record(db, "Some Record");
int chunkSize = 5000;
int startingPosition = 0;
int endingPosition = -1;
using (DownloadNotifier notifier = new DownloadNotifier(db, chunkSize, startingPosition, endingPosition))
{
    notifier.OnChunkAvailable += Notifier_OnChunkAvailable;
    string downloadTo = "C:\\Some Record.doc";
    rec.GetDocument(downloadTo, false, "", "");
}

Constructor & Destructor Documentation

HP.HPTRIM.SDK.DownloadNotifier.DownloadNotifier ( Database  db,
long  chunkSize = 1024*1024,
long  startingPosition = 0,
long  endingPosition = -1 
)

Creates a DownloadNotifier instance.

Parameters
dbDatabase connection
chunkSizeChunk size. Notifications will not exceed the chunk size.
startingPositionStarting positon. Notifications will begin at the starting position in the document.
endingPositionEnding position. Notifications will end at the ending position in the document. An ending position of -1 indicates that notifications are requested up to the end of the document.

Member Function Documentation

delegate void HP.HPTRIM.SDK.DownloadNotifier.OnChunkAvailableEventHandler ( byte[]  chunk,
long  chunkPos,
long  chunkLen,
bool  lastChunk 
)

OnChunkAvailableEventHandler is the delegate type of the event that that is fired when new data is available.

Parameters
chunkChunk. Array of bytes from the document.
chunkPosChunk position. The position in the document where the chunk starts.
chunkLenChunk length.
lastChunkWhether this notification is for the last chunk in the notification stream.

Event Documentation

OnChunkAvailableEventHandler HP.HPTRIM.SDK.DownloadNotifier.OnChunkAvailable

OnChunkAvailable is the event that is fired for each new chunk in a document transfer.