Class DicomService
- Namespace
- FellowOakDicom.Network
- Assembly
- fo-dicom.core.dll
Base class for DICOM network services.
public abstract class DicomService : IDicomServiceRunner, IDisposable- Inheritance
- 
      
      DicomService
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
DicomService(INetworkStream, Encoding, ILogger, DicomServiceDependencies)
Initializes a new instance of the DicomService class.
protected DicomService(INetworkStream stream, Encoding fallbackEncoding, ILogger logger, DicomServiceDependencies dependencies)Parameters
- streamINetworkStream
- Network stream. 
- fallbackEncodingEncoding
- Fallback encoding. 
- loggerILogger
- Logger 
- dependenciesDicomServiceDependencies
- The dependencies of this DICOM service 
Fields
_dimseStream
protected Stream _dimseStreamField Value
_dimseStreamFile
protected IFileReference _dimseStreamFileField Value
_isDisconnectedFlag
protected readonly TaskCompletionSource<bool> _isDisconnectedFlagField Value
Properties
Association
Gets the DICOM association.
public DicomAssociation Association { get; }Property Value
CanStillProcessPDataTF
Gets whether or not the connection can still process P-DATA-TF
public bool CanStillProcessPDataTF { get; }Property Value
DoHandlePDUBytes
Gets or sets an event handler to handle unsupported PDU bytes.
public PDUBytesHandler DoHandlePDUBytes { get; set; }Property Value
IsConnected
Gets whether or not the service is connected.
public bool IsConnected { get; }Property Value
IsSendNextMessageRequired
Gets whether or not SendNextMessage is required, i.e. if any requests still have to be sent and there is no send loop currently running.
public bool IsSendNextMessageRequired { get; }Property Value
IsSendQueueEmpty
Gets whether or not both the message queue and the pending queue is empty.
public bool IsSendQueueEmpty { get; }Property Value
Logger
Gets or sets the logger.
public ILogger Logger { get; set; }Property Value
MaximumPDUsInQueue
Gets or sets the maximum number of PDUs in queue.
public int MaximumPDUsInQueue { get; set; }Property Value
Options
Gets or sets the DICOM service options.
public DicomServiceOptions Options { get; set; }Property Value
UserState
Gets or sets a user state associated with the service.
public object UserState { get; set; }Property Value
Methods
CreateCStoreReceiveStream(DicomFile)
The purpose of this method is to return the Stream that a SopInstance received via CStoreSCP will be written to. This default implementation creates a temporary file and returns a FileStream on top of it. Child classes can override this to write to another stream and avoid the I/O associated with the temporary file if so desired. Beware that some SopInstances can be very large so using a MemoryStream() could cause out of memory situations.
protected virtual void CreateCStoreReceiveStream(DicomFile file)Parameters
- fileDicomFile
- A DicomFile with FileMetaInfo populated. 
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()Dispose(bool)
protected virtual void Dispose(bool disposing)Parameters
- disposingbool
~DicomService()
The finalizer will be called when this instance is not disposed properly.
protected ~DicomService()Remarks
Failing to dispose indicates wrong usage
GetCStoreDicomFile()
The purpose of this method is to create a DicomFile for the SopInstance received via CStoreSCP to pass to the IDicomCStoreProvider.OnCStoreRequest method for processing. This default implementation will return a DicomFile if the stream created by CreateCStoreReceiveStream() is seekable or null if it is not. Child classes that override CreateCStoreReceiveStream may also want override this to return a DicomFile for unseekable streams or to do cleanup related to receiving that specific instance.
protected virtual DicomFile GetCStoreDicomFile()Returns
- DicomFile
- The DicomFile or null if the stream is not seekable. 
OnSendQueueEmptyAsync()
Action to perform when send queue is empty.
protected virtual Task OnSendQueueEmptyAsync()Returns
RunAsync()
Setup long-running operations that the DICOM service manages.
public virtual Task RunAsync()Returns
- Task
- Awaitable task maintaining the long-running operation(s). 
SendAbortAsync(DicomAbortSource, DicomAbortReason)
Send abort request.
protected Task SendAbortAsync(DicomAbortSource source, DicomAbortReason reason)Parameters
- sourceDicomAbortSource
- Abort source. 
- reasonDicomAbortReason
- Abort reason. 
Returns
SendAssociationAcceptAsync(DicomAssociation)
Send association accept response.
protected Task SendAssociationAcceptAsync(DicomAssociation association)Parameters
- associationDicomAssociation
- DICOM association. 
Returns
SendAssociationRejectAsync(DicomRejectResult, DicomRejectSource, DicomRejectReason)
Send association reject response.
protected Task SendAssociationRejectAsync(DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)Parameters
- resultDicomRejectResult
- Rejection result. 
- sourceDicomRejectSource
- Rejection source. 
- reasonDicomRejectReason
- Rejection reason. 
Returns
SendAssociationReleaseRequestAsync()
Send association release request.
protected Task SendAssociationReleaseRequestAsync()Returns
SendAssociationReleaseResponseAsync()
Send association release response.
protected Task SendAssociationReleaseResponseAsync()Returns
SendAssociationRequestAsync(DicomAssociation)
Send association request.
protected Task SendAssociationRequestAsync(DicomAssociation association)Parameters
- associationDicomAssociation
- DICOM association. 
Returns
SendPDUAsync(PDU)
Asynchronously send single PDU.
protected Task SendPDUAsync(PDU pdu)Parameters
- pduPDU
- PDU to send. 
Returns
- Task
- Awaitable task. 
SendRequestAsync(DicomRequest)
Send request from service.
public virtual Task SendRequestAsync(DicomRequest request)Parameters
- requestDicomRequest
- Request to send. 
Returns
SendResponseAsync(DicomResponse)
Send response from service.
protected Task SendResponseAsync(DicomResponse response)Parameters
- responseDicomResponse
- Response to send.