예제 #1
0
        private void OnReceiveCStoreRequest(object sender, CStoreRequestReceivedEventArgs request)
        {
            try
            {
                if (__CurrentRequest != null && __MovedInstances != null)
                {
                    if (CanMoveCStoreRequest(request))
                    {
                        GatewaySession.Log(__Client, DicomCommandType.CMove, LogType.Debug, MessageDirection.Output, null,
                                           "[Gateway] Sending C-Move response to client \"" + __ClientAE + "\"");

                        lock ( _storeLock )
                        {
                            OnMoveDataSet(request.RequestDataSet);


                            GatewaySession.Log(__Client, DicomCommandType.CMove, LogType.Debug, MessageDirection.Output, null,
                                               "[Gateway] C-Move response sent successfully to client \"" + __ClientAE + "\"");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                GatewaySession.Log(__Client, DicomCommandType.CMove, LogType.Error, MessageDirection.Output, null,
                                   "[Gateway] Failed to send C-Move response to client \"" + __ClientAE + "\"\n"
                                   + ex.Message);

                __CurrentStatus = DicomCommandStatusType.Failure;
            }
        }
예제 #2
0
        private bool CanMoveCStoreRequest(CStoreRequestReceivedEventArgs request)
        {
            lock ( _instancesListLock )
            {
                string storeSopInstanceUID = request.SopInstanceUID;


                if (__MovedInstances.Contains(storeSopInstanceUID))
                {
                    return(false);
                }

                if (!String.IsNullOrEmpty(__CurrentRequest.PatientId))
                {
                    string patientID = request.RequestDataSet.GetValue <string> (DicomTag.PatientID, string.Empty);

                    if (string.Compare(patientID, __CurrentRequest.PatientId) != 0)
                    {
                        return(false);
                    }
                }

                if (__CurrentRequest.StudyInstanceUID.Count > 0)
                {
                    bool found = false;

                    foreach (string studyInstanceUID in __CurrentRequest.StudyInstanceUID)
                    {
                        string storeStudyInstanceUID = request.RequestDataSet.GetValue <string> (DicomTag.StudyInstanceUID, string.Empty);

                        if (string.Compare(storeStudyInstanceUID, studyInstanceUID) == 0)
                        {
                            found = true;

                            break;
                        }
                    }

                    if (!found)
                    {
                        return(false);
                    }
                }

                if (__CurrentRequest.SeriesInstanceUID.Count > 0)
                {
                    bool found = false;

                    foreach (string seriesInstanceUID in __CurrentRequest.SeriesInstanceUID)
                    {
                        string storeSeriesInstanceUID = request.RequestDataSet.GetValue <string> (DicomTag.SeriesInstanceUID, string.Empty);

                        if (string.Compare(storeSeriesInstanceUID, seriesInstanceUID) == 0)
                        {
                            found = true;

                            break;
                        }
                    }

                    if (!found)
                    {
                        return(false);
                    }
                }

                if (__CurrentRequest.SopInstanceUID.Count > 0)
                {
                    bool found = false;

                    foreach (string sopInstanceUID in __CurrentRequest.SopInstanceUID)
                    {
                        if (string.Compare(storeSopInstanceUID, sopInstanceUID) == 0)
                        {
                            found = true;

                            break;
                        }
                    }

                    if (!found)
                    {
                        return(false);
                    }
                }

                __MovedInstances.Add(storeSopInstanceUID);
            }

            return(true);
        }