示例#1
0
        ///
        /// Disposes the specified disposing.
        ///
        /// if set to true [disposing].
        private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }
            if (disposing)
            {
                // Dispose of other Managed objects,
                // 2500 millisecond timeout
                Abort(2500);
            }

            try
            {
                if (_filestreamHandler != null)
                {
                    _filestreamHandler.CancelStream();
                    _filestreamHandler = null;
                }
            }
            catch (Exception x)
            {
                LogAdapter.Logger.Error("Unexpected exception when calling IDicomFilestreamHandler.CancelStream");
            }

            // FREE UNMANAGED RESOURCES
            _disposed = true;
        }
示例#2
0
        /// <summary>
        /// Method called on a network error.
        /// </summary>
        /// <param name="e">The exception that caused the network error</param>
        /// <param name="closeConnection">Flag telling if the connection should be closed</param>
        protected override void OnNetworkError(Exception e, bool closeConnection)
        {
            try
            {
                if (_filestreamHandler != null)
                {
                    _filestreamHandler.CancelStream();
                    _filestreamHandler = null;
                }
            }
            catch (Exception x)
            {
                LogAdapter.Logger.Error(x, "Unexpected exception when calling IDicomFilestreamHandler.CancelStream");
            }

            try
            {
                if (_handler != null && State != DicomAssociationState.Sta13_AwaitingTransportConnectionClose)
                {
                    _handler.OnNetworkError(this, _assoc as ServerAssociationParameters, e);
                }
            }
            catch (Exception x)
            {
                LogAdapter.Logger.Error(x, "Unexpected exception when calling IDicomServerHandler.OnNetworkError");
            }

            _closedOnError = true;
            if (closeConnection)
            {
                CloseNetwork(Timeout.Infinite);
            }
        }
示例#3
0
        protected override bool OnReceiveFileStream(byte pcid, DicomAttributeCollection command, DicomAttributeCollection dataset, byte[] data, int offset, int count, bool isFirst, bool isLast)
        {
            try
            {
                if (isFirst)
                {
                    _filestreamHandler = _handler.OnStartFilestream(this, _assoc as ServerAssociationParameters, pcid, new DicomMessage(command, dataset));
                }

                if (!_filestreamHandler.SaveStreamData(new DicomMessage(command, dataset), data, offset, count))
                {
                    return(false);
                }

                if (isLast)
                {
                    _filestreamHandler.CompleteStream(this, _assoc as ServerAssociationParameters, pcid,
                                                      new DicomMessage(command, dataset));
                    _filestreamHandler = null;
                }

                return(true);
            }
            catch (Exception e)
            {
                OnUserException(e, "Unexpected exception on OnReceiveFileStream");
                return(false);
            }
        }
示例#4
0
        protected override bool OnReceiveFileStream(byte pcid, DicomDataset command, DicomDataset dataset, byte[] data, int offset, int count, bool encounteredStopTag, bool isFirst, bool isLast)
        {
            try
            {
                if (!encounteredStopTag)
                {
                    // Buffer data until we get to the stop tag so all the attributes expected are filled in.
                    if (_bufferedFilestream == null)
                    {
                        _bufferedFilestream = new MemoryStream();
                    }

                    _bufferedFilestream.Write(data, offset, count);
                    return(true);
                }

                if (isFirst || _bufferedFilestream != null)
                {
                    _filestreamHandler = _handler.OnStartFilestream(this, _assoc as ServerAssociationParameters, pcid, new DicomMessage(command, dataset));
                }

                if (_bufferedFilestream != null)
                {
                    var a = _bufferedFilestream.ToArray();
                    _bufferedFilestream = null;

                    if (!_filestreamHandler.SaveStreamData(new DicomMessage(command, dataset), a, 0, a.Length))
                    {
                        return(false);
                    }
                }

                if (!_filestreamHandler.SaveStreamData(new DicomMessage(command, dataset), data, offset, count))
                {
                    return(false);
                }

                if (isLast)
                {
                    _filestreamHandler.CompleteStream(this, _assoc as ServerAssociationParameters, pcid,
                                                      new DicomMessage(command, dataset));
                    _filestreamHandler = null;
                }

                return(true);
            }
            catch (Exception e)
            {
                OnUserException(e, "Unexpected exception on OnReceiveFileStream");
                return(false);
            }
        }
示例#5
0
        ///
        /// Disposes the specified disposing.
        ///
        /// if set to true [disposing].
        private void Dispose(bool disposing)
        {
            if (_disposed)
                return;
            if (disposing)
            {
                // Dispose of other Managed objects, 
				// 2500 millisecond timeout
                Abort(2500);
            }

			try
			{
				if (_filestreamHandler != null)
				{
					_filestreamHandler.CancelStream();
					_filestreamHandler = null;
				}
			}
			catch (Exception x)
			{
				Platform.Log(LogLevel.Error, x, "Unexpected exception when calling IDicomFilestreamHandler.CancelStream");
			}

            // FREE UNMANAGED RESOURCES
            _disposed = true;
        }
示例#6
0
		protected override bool OnReceiveFileStream(byte pcid, DicomAttributeCollection command, DicomAttributeCollection dataset, byte[] data, int offset, int count, bool isFirst, bool isLast)
		{
			try
			{
				if (isFirst)
					_filestreamHandler = _handler.OnStartFilestream(this, _assoc as ServerAssociationParameters, pcid, new DicomMessage(command, dataset));

				if (!_filestreamHandler.SaveStreamData(new DicomMessage(command, dataset), data, offset, count))
					return false;

				if (isLast)
				{
					_filestreamHandler.CompleteStream(this, _assoc as ServerAssociationParameters, pcid,
					                                  new DicomMessage(command, dataset));
					_filestreamHandler = null;
				}

				return true;
			}
			catch (Exception e)
			{
				OnUserException(e, "Unexpected exception on OnReceiveFileStream");
				return false;
			}
		}
示例#7
0
        /// <summary>
        /// Method called on a network error.
        /// </summary>
        /// <param name="e">The exception that caused the network error</param>
        /// <param name="closeConnection">Flag telling if the connection should be closed</param>
        protected override void OnNetworkError(Exception e, bool closeConnection)
        {
	        try
	        {
				if (_filestreamHandler != null)
				{
					_filestreamHandler.CancelStream();
					_filestreamHandler = null;
				}
	        }
	        catch (Exception x)
	        {
				Platform.Log(LogLevel.Error, x, "Unexpected exception when calling IDicomFilestreamHandler.CancelStream");
			}

            try
            {
                if (_handler != null && State != DicomAssociationState.Sta13_AwaitingTransportConnectionClose)
                    _handler.OnNetworkError(this, _assoc as ServerAssociationParameters, e);
            }
            catch (Exception x) 
            {
				Platform.Log(LogLevel.Error, x, "Unexpected exception when calling IDicomServerHandler.OnNetworkError");
            }

            _closedOnError = true;
            if (closeConnection)
				CloseNetwork(Timeout.Infinite);
        }
示例#8
0
		protected override bool OnReceiveFileStream(byte pcid, DicomAttributeCollection command, DicomAttributeCollection dataset, byte[] data, int offset, int count, bool encounteredStopTag, bool isFirst, bool isLast)
		{
			try
			{
				if (!encounteredStopTag)
				{
					// Buffer data until we get to the stop tag so all the attributes expected are filled in.
					if (_bufferedFilestream == null)
						_bufferedFilestream = new MemoryStream();

					_bufferedFilestream.Write(data, offset, count);
					return true;
				}

				if (isFirst || _bufferedFilestream != null)
					_filestreamHandler = _handler.OnStartFilestream(this, _assoc as ServerAssociationParameters, pcid, new DicomMessage(command, dataset));
				
				if (_bufferedFilestream != null)
				{
					var a = _bufferedFilestream.ToArray();
					_bufferedFilestream = null;

					if (!_filestreamHandler.SaveStreamData(new DicomMessage(command, dataset), a, 0, a.Length))
						return false;
				}

				if (!_filestreamHandler.SaveStreamData(new DicomMessage(command, dataset), data, offset, count))
					return false;

				if (isLast)
				{
					_filestreamHandler.CompleteStream(this, _assoc as ServerAssociationParameters, pcid,
					                                  new DicomMessage(command, dataset));
					_filestreamHandler = null;
				}

				return true;
			}
			catch (Exception e)
			{
				OnUserException(e, "Unexpected exception on OnReceiveFileStream");
				return false;
			}
		}