Exemplo n.º 1
0
 public void AddRequest(DicomRequest request)
 {
     if (_service != null && _service.IsConnected)
         _service.SendRequest(request);
     else
         _requests.Add(request);
 }
Exemplo n.º 2
0
        public void AddFromRequest(DicomRequest request)
        {
            if (request is DicomCStoreRequest)
            {
                var cstore = request as DicomCStoreRequest;
                var pc     = _pc.Values.FirstOrDefault(x => x.AbstractSyntax == request.SOPClassUID && x.AcceptedTransferSyntax == cstore.TransferSyntax);
                if (pc == null)
                {
                    var tx = new List <DicomTransferSyntax>();
                    if (cstore.TransferSyntax != DicomTransferSyntax.ImplicitVRLittleEndian)
                    {
                        tx.Add(cstore.TransferSyntax);
                    }
                    if (cstore.AdditionalTransferSyntaxes != null)
                    {
                        tx.AddRange(cstore.AdditionalTransferSyntaxes);
                    }
                    tx.Add(DicomTransferSyntax.ExplicitVRLittleEndian);
                    tx.Add(DicomTransferSyntax.ImplicitVRLittleEndian);

                    Add(cstore.SOPClassUID, tx.ToArray());
                }
            }
            else
            {
                var pc = _pc.Values.FirstOrDefault(x => x.AbstractSyntax == request.SOPClassUID);
                if (pc == null)
                {
                    Add(request.SOPClassUID, DicomTransferSyntax.ExplicitVRLittleEndian, DicomTransferSyntax.ImplicitVRLittleEndian);
                }
            }
        }
Exemplo n.º 3
0
 public void AddFromRequest(DicomRequest request)
 {
     if (request is DicomCStoreRequest)
     {
         var cstore = request as DicomCStoreRequest;
         var pc     = _pc.Values.FirstOrDefault(x => x.AbstractSyntax == request.AffectedSOPClassUID && x.AcceptedTransferSyntax == cstore.TransferSyntax);
         if (pc == null)
         {
             if (cstore.TransferSyntax != DicomTransferSyntax.ImplicitVRLittleEndian)
             {
                 Add(cstore.AffectedSOPClassUID, cstore.TransferSyntax, DicomTransferSyntax.ExplicitVRLittleEndian, DicomTransferSyntax.ImplicitVRLittleEndian);
             }
             else
             {
                 Add(cstore.AffectedSOPClassUID, cstore.TransferSyntax);
             }
         }
     }
     else
     {
         var pc = _pc.Values.FirstOrDefault(x => x.AbstractSyntax == request.AffectedSOPClassUID);
         if (pc == null)
         {
             Add(request.AffectedSOPClassUID, DicomTransferSyntax.ExplicitVRLittleEndian, DicomTransferSyntax.ImplicitVRLittleEndian);
         }
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Add DICOM service request.
 /// </summary>
 /// <param name="request">DICOM request.</param>
 public void AddRequest(DicomRequest request)
 {
     lock (this.locker)
     {
         this.requests.Add(request);
     }
 }
Exemplo n.º 5
0
		public void AddRequest(DicomRequest request) {
			if (_service != null && _service.IsConnected) {
				_service.SendRequest(request);
				if (_service._timer != null)
					_service._timer.Change(Timeout.Infinite, Timeout.Infinite);
			} else
				_requests.Add(request);
		}
Exemplo n.º 6
0
 /// <summary>
 /// Add DICOM service request.
 /// </summary>
 /// <param name="request">DICOM request.</param>
 public void AddRequest(DicomRequest request)
 {
     _requests.Enqueue(new StrongBox <DicomRequest>(request));
     if (!_hasRequestsFlag.IsSet)
     {
         _hasRequestsFlag.Set();
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DicomResponse"/> class.
        /// </summary>
        /// <param name="request">
        /// The request initiating the response.
        /// </param>
        /// <param name="status">
        /// Response status.
        /// </param>
        protected DicomResponse(DicomRequest request, DicomStatus status)
        {
            PresentationContext = request.PresentationContext;

            Type             = (DicomCommandField)(0x8000 | (int)request.Type);
            SOPClassUID      = request.SOPClassUID;
            RequestMessageID = request.MessageID;
            Status           = status;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DicomResponse"/> class.
        /// </summary>
        /// <param name="request">
        /// The request initiating the response.
        /// </param>
        /// <param name="status">
        /// Response status.
        /// </param>
        protected DicomResponse(DicomRequest request, DicomStatus status)
        {
            PresentationContext = request.PresentationContext;

            Type = (DicomCommandField)(0x8000 | (int)request.Type);
            SOPClassUID = request.SOPClassUID;
            RequestMessageID = request.MessageID;
            Status = status;
        }
Exemplo n.º 9
0
		public void AddRequest(DicomRequest request) {
			if (_service != null && _service.IsConnected) {
                //zssure:2015-04-14,try to conform whether AddRequest and Send uses the same one client
                LogManager.Default.GetLogger("Dicom.Network").Info("zssure debug at 20150414,the DicomRequest object is {0},DicomServiceUser is{1}", request.GetHashCode(), _service.GetHashCode());
                //zssure:2015-04-14,end
				_service.SendRequest(request);
				if (_service._timer != null)
					_service._timer.Change(Timeout.Infinite, Timeout.Infinite);
			} else
				_requests.Add(request);
		}
Exemplo n.º 10
0
 /// <summary>
 /// Add DICOM service request.
 /// </summary>
 /// <param name="request">DICOM request.</param>
 public void AddRequest(DicomRequest request)
 {
     if (this.service != null && this.service.IsConnected)
     {
         this.service.SendRequest(request);
     }
     else
     {
         this.requests.Add(request);
     }
 }
Exemplo n.º 11
0
 public void AddRequest(DicomRequest request)
 {
     if (_service != null && _service.IsConnected)
     {
         _service.SendRequest(request);
     }
     else
     {
         _requests.Add(request);
     }
 }
Exemplo n.º 12
0
 public void AddRequest(DicomRequest request)
 {
     if (_service != null && _service.IsConnected)
     {
         _service.SendRequest(request);
         if (_service._timer != null)
         {
             _service._timer.Change(Timeout.Infinite, Timeout.Infinite);
         }
     }
     else
     {
         _requests.Add(request);
     }
 }
Exemplo n.º 13
0
 /// <summary>
 /// Add Extended Negotiation obtained from DICOM request.
 /// Note: The extended negotiation will affect all requests that share the same SOP class within an association.
 /// </summary>
 /// <param name="dicomRequest">Request from which extended negotiation info should be obtained.</param>
 public void AddFromRequest(DicomRequest dicomRequest)
 {
     if (dicomRequest is DicomCStoreRequest cStoreRequest)
     {
         if (cStoreRequest.ApplicationInfo != null || cStoreRequest.CommonServiceClassUid != null)
         {
             AddOrUpdate(cStoreRequest.SOPClassUID, cStoreRequest.ApplicationInfo,
                         cStoreRequest.CommonServiceClassUid, cStoreRequest.RelatedGeneralSopClasses?.ToArray());
         }
     }
     else if (dicomRequest.ApplicationInfo != null)
     {
         AddOrUpdate(dicomRequest.SOPClassUID, dicomRequest.ApplicationInfo);
     }
 }
Exemplo n.º 14
0
        public void AddFromRequest(DicomRequest request)
        {
            if (request is DicomCStoreRequest)
            {
                var cstore = request as DicomCStoreRequest;

                var pcs = _pc.Values.Where(x => x.AbstractSyntax == request.SOPClassUID);
                if (cstore.TransferSyntax == DicomTransferSyntax.ImplicitVRLittleEndian)
                {
                    pcs = pcs.Where(x => x.GetTransferSyntaxes().Contains(DicomTransferSyntax.ImplicitVRLittleEndian));
                }
                else
                {
                    pcs = pcs.Where(x => x.AcceptedTransferSyntax == cstore.TransferSyntax);
                }

                var pc = pcs.FirstOrDefault();
                if (pc == null)
                {
                    var tx = new List <DicomTransferSyntax>();
                    if (cstore.TransferSyntax != DicomTransferSyntax.ImplicitVRLittleEndian)
                    {
                        tx.Add(cstore.TransferSyntax);
                    }
                    if (cstore.AdditionalTransferSyntaxes != null)
                    {
                        tx.AddRange(cstore.AdditionalTransferSyntaxes);
                    }
                    tx.Add(DicomTransferSyntax.ExplicitVRLittleEndian);
                    tx.Add(DicomTransferSyntax.ImplicitVRLittleEndian);
                    foreach (var t in tx)
                    {
                        Add(cstore.SOPClassUID, t);
                    }
                }
            }
            else
            {
                var pc = _pc.Values.FirstOrDefault(x => x.AbstractSyntax == request.SOPClassUID);
                if (pc == null)
                {
                    Add(request.SOPClassUID, DicomTransferSyntax.ExplicitVRLittleEndian);
                    Add(request.SOPClassUID, DicomTransferSyntax.ImplicitVRLittleEndian);
                }
            }
        }
Exemplo n.º 15
0
 public void AddRequest(DicomRequest request)
 {
     if (_service != null && _service.IsConnected)
     {
         //zssure:2015-04-14,try to conform whether AddRequest and Send uses the same one client
         LogManager.Default.GetLogger("Dicom.Network").Info("zssure debug at 20150414,the DicomRequest object is {0},DicomServiceUser is{1}", request.GetHashCode(), _service.GetHashCode());
         //zssure:2015-04-14,end
         _service.SendRequest(request);
         if (_service._timer != null)
         {
             _service._timer.Change(Timeout.Infinite, Timeout.Infinite);
         }
     }
     else
     {
         _requests.Add(request);
     }
 }
Exemplo n.º 16
0
 /// <summary>
 /// Send request from service.
 /// </summary>
 /// <param name="request">Request to send.</param>
 public virtual void SendRequest(DicomRequest request)
 {
     SendMessage(request);
 }
Exemplo n.º 17
0
 /// <summary>
 /// Add DICOM service request.
 /// </summary>
 /// <param name="request">DICOM request.</param>
 public void AddRequest(DicomRequest request)
 {
     _requests.Enqueue(request);
     _hasRequestsFlag.Set();
 }
Exemplo n.º 18
0
 public void SendRequest(DicomRequest request)
 {
     SendMessage(request);
 }
Exemplo n.º 19
0
        /// <summary>
        /// Add presentation contexts obtained from DICOM request.
        /// </summary>
        /// <param name="request">Request from which presentation context(s) should be obtained.</param>
        public void AddFromRequest(DicomRequest request)
        {
            if (request is DicomCStoreRequest)
            {
                var cstore = request as DicomCStoreRequest;

                var pcs = _pc.Values.Where(x => x.AbstractSyntax == request.SOPClassUID);
                if (cstore.TransferSyntax == DicomTransferSyntax.ImplicitVRLittleEndian)
                {
                    pcs = pcs.Where(x => x.GetTransferSyntaxes().Contains(DicomTransferSyntax.ImplicitVRLittleEndian));
                }
                else
                {
                    pcs = pcs.Where(x => x.AcceptedTransferSyntax == cstore.TransferSyntax);
                }

                var pc = pcs.FirstOrDefault();
                if (pc == null)
                {
                    var tx = new List <DicomTransferSyntax>();
                    if (cstore.TransferSyntax != DicomTransferSyntax.ImplicitVRLittleEndian)
                    {
                        tx.Add(cstore.TransferSyntax);
                    }
                    if (cstore.AdditionalTransferSyntaxes != null)
                    {
                        tx.AddRange(cstore.AdditionalTransferSyntaxes);
                    }
                    //removed to allow for sending only a compressed transfer syntax if wanted
                    //tx.Add(DicomTransferSyntax.ExplicitVRLittleEndian);
                    //tx.Add(DicomTransferSyntax.ImplicitVRLittleEndian);

                    Add(cstore.SOPClassUID, tx.ToArray());
                }
            }
            else
            {
                if (request.PresentationContext != null)
                {
                    var pc =
                        _pc.Values.FirstOrDefault(
                            x =>
                            x.AbstractSyntax == request.PresentationContext.AbstractSyntax &&
                            request.PresentationContext.GetTransferSyntaxes().All(y => x.GetTransferSyntaxes().Contains(y)));

                    if (pc == null)
                    {
                        var transferSyntaxes = request.PresentationContext.GetTransferSyntaxes().ToArray();
                        if (!transferSyntaxes.Any())
                        {
                            transferSyntaxes = new[] { DicomTransferSyntax.ExplicitVRLittleEndian, DicomTransferSyntax.ImplicitVRLittleEndian }
                        }
                        ;
                        Add(
                            request.PresentationContext.AbstractSyntax,
                            request.PresentationContext.UserRole,
                            request.PresentationContext.ProviderRole,
                            transferSyntaxes);
                    }
                }
                else
                {
                    var pc = _pc.Values.FirstOrDefault(x => x.AbstractSyntax == request.SOPClassUID);
                    if (pc == null)
                    {
                        Add(
                            request.SOPClassUID,
                            DicomTransferSyntax.ExplicitVRLittleEndian,
                            DicomTransferSyntax.ImplicitVRLittleEndian);
                    }
                }
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Add presentation contexts obtained from DICOM request.
        /// </summary>
        /// <param name="request">Request from which presentation context(s) should be obtained.</param>
        public void AddFromRequest(DicomRequest request)
        {
            if (request is DicomCStoreRequest cstore)
            {
                var pcs = _pc.Values
                          .Where(x => x.AbstractSyntax == request.SOPClassUID)
                          .Where(x => x.HasTransferSyntax(cstore.TransferSyntax));

                var pc = pcs.FirstOrDefault();
                if (pc == null)
                {
                    // add a presentation context for the original transfer syntax
                    if (cstore.TransferSyntax != null)
                    {
                        Add(cstore.SOPClassUID, cstore.TransferSyntax);
                    }

                    // then add another presentation context for additional transfersyntaxes, if provided by the user,
                    // and for the mandatory ImplicitVRLittleEndian, if the original file was not implicitLittleEndian
                    var tx = new List <DicomTransferSyntax>();
                    if (cstore.AdditionalTransferSyntaxes != null)
                    {
                        tx.AddRange(cstore.AdditionalTransferSyntaxes);
                    }
                    if (cstore.TransferSyntax != DicomTransferSyntax.ImplicitVRLittleEndian)
                    {
                        tx.Add(DicomTransferSyntax.ImplicitVRLittleEndian);
                    }

                    if (tx.Any())
                    {
                        Add(cstore.SOPClassUID, tx.ToArray());
                    }
                }
            }
            else
            {
                if (request.PresentationContext != null)
                {
                    var pc =
                        _pc.Values.FirstOrDefault(
                            x =>
                            x.AbstractSyntax == request.PresentationContext.AbstractSyntax &&
                            request.PresentationContext.GetTransferSyntaxes().All(y => x.GetTransferSyntaxes().Contains(y)));

                    if (pc == null)
                    {
                        var transferSyntaxes = request.PresentationContext.GetTransferSyntaxes().ToArray();
                        if (!transferSyntaxes.Any())
                        {
                            transferSyntaxes = new[] { DicomTransferSyntax.ImplicitVRLittleEndian }
                        }
                        ;
                        Add(
                            request.PresentationContext.AbstractSyntax,
                            request.PresentationContext.UserRole,
                            request.PresentationContext.ProviderRole,
                            transferSyntaxes);
                    }
                }
                else
                {
                    foreach (var sopclass in MetaSopClasses.GetMetaSopClass(request.SOPClassUID))
                    {
                        var pc = _pc.Values.FirstOrDefault(x => x.AbstractSyntax == sopclass);
                        if (pc == null)
                        {
                            Add(sopclass, DicomTransferSyntax.ImplicitVRLittleEndian);
                        }
                    }
                }
            }
        }
Exemplo n.º 21
0
 /// <summary>
 /// Add DICOM service request.
 /// </summary>
 /// <param name="request">DICOM request.</param>
 public void AddRequest(DicomRequest request)
 {
     if (this.service != null && this.service.IsConnected)
     {
         this.service.SendRequest(request);
     }
     else this.requests.Add(request);
 }
Exemplo n.º 22
0
 /// <summary>
 /// Add DICOM service request.
 /// </summary>
 /// <param name="request">DICOM request.</param>
 public void AddRequest(DicomRequest request)
 {
     lock (this.locker)
     {
         this.requests.Add(request);
     }
 }