예제 #1
0
        public void Start()
        {
            try
            {
                _AeInfo = _aeAgent.GetAeTitle(_Options.ForwardTo);
                if (_AeInfo != null)
                {
                    IPAddress address = IPAddress.None;

                    if (!IPAddress.TryParse(_AeInfo.Address, out address))
                    {
                        IPHostEntry host = Dns.GetHostEntry(_AeInfo.Address);

                        if (host.AddressList.Length > 0)
                        {
                            address = host.AddressList[0];
                        }
                    }

                    _Scp = new DicomScp(address, _AeInfo.AETitle, _AeInfo.Port);
                    if (_Options.Forward != null)
                    {
                        FixUpJob(_Options.Forward);
                        Scheduler.SubmitJob(_Options.Forward, new Action <Job>(Forward));
                    }

                    if (_Options.Clean != null)
                    {
                        FixUpJob(_Options.Clean);
                        Scheduler.SubmitJob(_Options.Clean, new Action <Job>(Clean));
                    }
                }
            }
            catch { }
        }
예제 #2
0
        public static Patient FindPatient(Control owner, QueryRetrieveScu find, DicomScp scp, string pid)
        {
            PatientRootQueryPatient query = new PatientRootQueryPatient();
            Patient        patient        = null;
            ProgressDialog progress       = new ProgressDialog();

            query.PatientQuery.PatientId = pid;
            Thread thread = new Thread(() =>
            {
                try
                {
                    find.Find <PatientRootQueryPatient, Patient>(scp, query, (p, ds) => patient = p);
                }
                catch (Exception e)
                {
                    ApplicationUtils.ShowException(owner, e);
                }
            });

            progress.ActionThread = thread;
            progress.Title        = "Searching For Patient";
            progress.ProgressInfo = "Looking for patient to merge with.";
            progress.ShowDialog(owner);
            return(patient);
        }
예제 #3
0
        private void StartListeners(ServerPartition part)
        {
            var parms = new DicomScpContext(part);

            //TODO support IPV6
            var scp = new DicomScp <DicomScpContext>(parms, CreateVerify)
            {
                ListenPort = part.Port,
                AeTitle    = part.AeTitle
            };

            if (scp.Start(IPAddress.Any))
            {
                _listenerList.Add(scp);
                LogAdapter.Logger.InfoWithFormat("Start listen on {0} for server partition {1}",
                                                 part.Port, part.Description);
            }
            else
            {
                LogAdapter.Logger.InfoWithFormat("Unable to listen on {0} for server partition {1}",
                                                 part.Port, part.Description);
                LogAdapter.Logger.InfoWithFormat("Unable to listen on {0} for server partition {1}",
                                                 part.Port, part.Description);
            }
        }
예제 #4
0
        private static List <DicomScp> GetScps(string[] aetitles)
        {
            List <DicomScp> scps    = new List <DicomScp>();
            IAETitle        aetitle = ServiceLocator.Retrieve <IAETitle>();

            foreach (string ae in aetitles)
            {
                try
                {
                    AeInfo info = aetitle.GetAeInfo(ae);

                    if (info != null && !string.IsNullOrEmpty(info.Address))
                    {
#if LEADTOOLS_V20_OR_LATER
                        // Update dbo.AeInfo.LastAccessDate to Date.Now
                        info.LastAccessDate = DateTime.Now;
                        aetitle.Update(info.AETitle, info);
#endif

                        DicomScp scp = new DicomScp(ResolveIPAddress(info.Address), ae, info.Port);

                        scps.Add(scp);
                    }
                }
                catch (Exception e)
                {
                    Logger.Global.SystemException(string.Empty, e);
                }
            }
            return(scps);
        }
예제 #5
0
        private void StartPartitionListener(ServerPartition part)
        {
            var parms = new DicomScpContext(part);

            if (DicomSettings.Default.ListenIPV4)
            {
                var ipV4Scp = new DicomScp <DicomScpContext>(parms, AssociationVerifier.Verify,
                                                             AssociationAuditLogger.InstancesTransferredAuditLogger)
                {
                    ListenPort    = part.Port,
                    AeTitle       = part.AeTitle,
                    ListenAddress = IPAddress.Any
                };

                StartScp(ipV4Scp, _listenerList);
            }

            if (DicomSettings.Default.ListenIPV6)
            {
                var ipV6Scp = new DicomScp <DicomScpContext>(parms, AssociationVerifier.Verify,
                                                             AssociationAuditLogger.InstancesTransferredAuditLogger)
                {
                    ListenPort    = part.Port,
                    AeTitle       = part.AeTitle,
                    ListenAddress = IPAddress.IPv6Any
                };
                StartScp(ipV6Scp, _listenerList);
            }
        }
예제 #6
0
        private void StartAlternateAeTitleListener(ServerPartition part, ServerPartitionAlternateAeTitle alternateAe)
        {
            var context = new DicomScpContext(part)
            {
                AlternateAeTitle = alternateAe
            };

            if (DicomSettings.Default.ListenIPV4)
            {
                var ipV4Scp = new DicomScp <DicomScpContext>(context, AssociationVerifier.Verify,
                                                             AssociationAuditLogger.InstancesTransferredAuditLogger)
                {
                    ListenPort    = alternateAe.Port,
                    AeTitle       = alternateAe.AeTitle,
                    ListenAddress = IPAddress.Any
                };
                StartScp(ipV4Scp, _alternateAeListenerList);
            }

            if (DicomSettings.Default.ListenIPV6)
            {
                var ipV6Scp = new DicomScp <DicomScpContext>(context, AssociationVerifier.Verify,
                                                             AssociationAuditLogger.InstancesTransferredAuditLogger)
                {
                    ListenPort    = alternateAe.Port,
                    AeTitle       = alternateAe.AeTitle,
                    ListenAddress = IPAddress.IPv6Any
                };

                StartScp(ipV6Scp, _alternateAeListenerList);
            }
        }
예제 #7
0
        public void MovePatient(DicomScp scp, string aetitle, string patientID)
        {
            DicomServer server = ServiceLocator.Retrieve <DicomServer>();

            using (DicomDataSet ds = new DicomDataSet(server.TemporaryDirectory))
            {
                try
                {
                    Connect(scp);
                    if (_Accepted)
                    {
                        ds.Initialize(DicomClassType.Undefined, DicomDataSetInitializeFlags.ExplicitVR | DicomDataSetInitializeFlags.LittleEndian);
                        ds.InsertElementAndSetValue(DicomTag.QueryRetrieveLevel, "PATIENT");
                        ds.InsertElementAndSetValue(DicomTag.PatientID, patientID);

                        SendPatientMove(ds, aetitle);
                    }
                }
                finally
                {
                    if (IsConnected())
                    {
                        OnBeforeClose();
                        Close();
                        OnAfterClose();
                    }
                }
            }
        }
예제 #8
0
        public DicomCommandStatusType SendUpdate(DicomScp scp, DicomDataSet ds, int action)
        {
            DicomCommandStatusType status = DicomCommandStatusType.Reserved4;

            status = _Scu.SendUpdate(scp, ds, action, PatientUpdaterConstants.UID.PatientUpdateInstance);
            return(status);
        }
예제 #9
0
        public static Job route_dataset_with_retry_to_at(DicomDS wrapper, string aetitle, string ipAddress, int port, DateTimeOffset time, int numRetries, int retryTimeout)
        {
            try
            {
                if (!string.IsNullOrEmpty(ipAddress))
                {
                    DicomScp scp = new DicomScp(IPAddress.Parse(ipAddress), aetitle, port);
                    Job      job = new Job()
                    {
                        Loops = 1
                    };

                    job.StartTime = time;
                    Module.Scheduler.SubmitJob(job, (j) => Store(wrapper, new List <DicomScp>()
                    {
                        scp
                    }, numRetries, retryTimeout));
                    Logger.Global.SystemMessage(LogType.Information, "Dataset will be stored to server {0} at {1}".FormatWith(aetitle, job.StartTime.ToString("MM/dd/yyyy - hh:mm:ss tt")), "");
                    return(job);
                }
            }
            catch (Exception e)
            {
                Logger.Global.SystemException(string.Empty, e);
            }
            return(null);
        }
예제 #10
0
        private void SendUpdate(AutoUpdateItem item)
        {
            AeInfo[] aes = _AccessAgent.GetRelatedAeTitles(item.SourceAE, UPDATE_RELATION);
            DicomScp scp = null;

            if (aes == null || aes.Length == 0)
            {
                return;
            }

            foreach (AeInfo ae in aes)
            {
                using (UpdateProcessor processor = new UpdateProcessor(Module.Options.UseCustomAE ? Module.Options.AutoUpdateAE : item.ClientAE))
                {
                    try
                    {
                        DicomCommandStatusType status = DicomCommandStatusType.Reserved4;

                        if (processor.Scu.IsConnected())
                        {
                            processor.Scu.CloseForced(true);
                        }
                        scp    = new DicomScp(IPAddress.Parse(ae.Address), ae.AETitle, ae.Port);
                        status = processor.SendUpdate(scp, item.Dicom, item.Action);
                        if (status != DicomCommandStatusType.Success)
                        {
                            if (status != DicomCommandStatusType.MissingAttribute && status != DicomCommandStatusType.AttributeOutOfRange)
                            {
                                AddRetry(scp, item, ae.Address);
                            }
                        }
                    }
                    catch (ClientAssociationException ce)
                    {
                        string message = string.Format("[Auto Update] Failed to establish association with server: {0}.  Adding {1} action to update retry queue.", ce.Reason,
                                                       AutoRetryProcessor.Actions[item.Action]);

                        UpdateProcessor.LogEvent(LogType.Error, MessageDirection.None, message, DicomCommandType.Undefined, null, processor.Scu, null);
                        AddRetry(scp, item, ae.Address);
                    }
                    catch (DicomException de)
                    {
                        string message = string.Format("[Auto Update] Error: {0}. Adding {1} action to update retry queue.", de.Message, AutoRetryProcessor.Actions[item.Action]);

                        UpdateProcessor.LogEvent(LogType.Error, MessageDirection.Input, message, DicomCommandType.Undefined, null, processor.Scu, null);
                        AddRetry(scp, item, ae.Address);
                    }
                    catch (Exception e)
                    {
                        string message = "[Auto Update] " + e.Message;

                        Logger.Global.Log(string.Empty, string.Empty, -1, string.Empty, string.Empty, -1, DicomCommandType.Undefined,
                                          DateTime.Now, LogType.Error, MessageDirection.None, message, null, null);
                    }
                    finally
                    {
                    }
                }
            }
        }
예제 #11
0
 public static void AddRetry(DicomScp scp, AutoUpdateItem item, string ae)
 {
     if (Module.RetryProcessor != null)
     {
         Module.RetryProcessor.AddRetry(scp, item, ae);
     }
 }
예제 #12
0
        public DicomServer()
        {
            _aeTitle = string.Empty;
            _host = string.Empty;
            _port = 104;

            _context = new DicomServerContext();
            _scp = new DicomScp<IDicomServerContext>(_context, AssociationVerifier.VerifyAssociation);
        }
예제 #13
0
        public DicomServer(DicomServerConfiguration serverConfiguration)
        {
            _aeTitle = serverConfiguration.AETitle;
            _host    = serverConfiguration.HostName;
            _port    = serverConfiguration.Port;

            _context = new DicomServerContext(this);
            _scp     = new DicomScp <IDicomServerContext>(_context, AssociationVerifier.VerifyAssociation);
        }
예제 #14
0
파일: DicomServer.cs 프로젝트: nhannd/Xian
		public DicomServer(DicomServerConfiguration serverConfiguration)
		{
			_aeTitle = serverConfiguration.AETitle;
            _host = serverConfiguration.HostName;
			_port = serverConfiguration.Port;

			_context = new DicomServerContext(this);
			_scp = new DicomScp<IDicomServerContext>(_context, AssociationVerifier.VerifyAssociation);
		}
예제 #15
0
        public DicomCommandStatusType SendNActionRequest <TQuery>(DicomScp Scp, TQuery Query, int action, string instance)
        {
            DicomDataSet ds = null;

            if (Scp == null)
            {
                throw new ArgumentNullException("Scp");
            }

            if (Query == null)
            {
                throw new ArgumentNullException("Query");
            }

            _ErrorMessage = string.Empty;
            try
            {
                _CurrentInstance = GetFindAttribute(Query);
                if (_CurrentInstance == null)
                {
                    throw new InvalidOperationException();
                }

                ds = GetDataset(Query, null);
                Connect(Scp);
                if (parameters.Result == null)
                {
                    SendNAction(ds, action, instance);
                }
                else
                {
                    throw new ClientAssociationException(parameters.Reason);
                }
            }
            catch (Exception e)
            {
                _ErrorMessage = e.Message;
                _Status       = DicomCommandStatusType.Failure;
            }
            finally
            {
                if (IsConnected())
                {
                    Close();
                }
                if (ds != null)
                {
                    ds.Dispose();
                    ds = null;
                }
            }

            return(_Status);
        }
예제 #16
0
        public MoveWorker(DicomScp server, List <string> aetitles, MoveInfo moveInfo)
        {
            _Server   = server;
            _MoveInfo = moveInfo;
            if (aetitles != null && aetitles.Count > 0)
            {
                _AeTitles.AddRange(aetitles);
            }

            DoWork += new DoWorkEventHandler(MoveWorker_DoWork);
        }
예제 #17
0
        public void SendDownloadRequest(object param,
                                        string clientAE,
                                        string clientAddress,
                                        int clientPort,
                                        string storageServerAE,
                                        string storageServerAddress,
                                        int storageServerPort)
        {
            #region LOG
            {
                string message = @"Image Download - Download Request";
                Logger.Global.Log(storageServerAE, clientAddress, clientPort,
                                  clientAE, storageServerAddress, storageServerPort, DicomCommandType.CMove,
                                  DateTime.Now, LogType.Error, MessageDirection.None, message, null, null);

                Logger.Global.Log(string.Empty, string.Empty, -1, string.Empty, string.Empty, -1, DicomCommandType.Undefined, DateTime.Now,
                                  LogType.Information, MessageDirection.None, message, null, null);
            }
            #endregion

            try
            {
                AETitle     = clientAE;
                HostAddress = IPAddress.Parse(clientAddress);
                HostPort    = clientPort;

                DicomScp scp = new DicomScp(IPAddress.Parse(storageServerAddress), storageServerAE, storageServerPort);

                //Use this overload to do a connect and association at the same time and receive the AfterConnect/AfterAssociate events. the other Connect are the low-level which means you have to do a different procedure
                Connect(scp);

                if (null == Association)
                {
                    throw new Exception("Association rejected");
                }


                SendDownloadRequest(param);
            }
            catch (Exception e)
            {
                Logger.Global.Log(string.Empty, string.Empty, -1, string.Empty, string.Empty, -1, DicomCommandType.Undefined, DateTime.Now,
                                  LogType.Information, MessageDirection.None, e.Message, null, null);

                throw;
            }
            finally
            {
                if (IsConnected())
                {
                    Close();
                }
            }
        }
예제 #18
0
        public DicomScp CreateServerObject()
        {
            DicomScp _server = new DicomScp();

            _server.AETitle     = ServerAE;
            _server.Port        = ServerPort;
            _server.PeerAddress = IPAddress.Parse(ServerIP);
            _server.Timeout     = ServerTimeout;

            return(_server);
        }
예제 #19
0
        protected override DicomAssociate BuildAssociation(DicomScp scp)
        {
            DicomAssociate associate = base.BuildAssociation(scp);
            byte           pid       = associate.FindAbstract(DicomUidType.PatientRootQueryMove);

            if (pid != 0)
            {
                associate.SetExtendedData(pid, new byte[] { 1 });
            }
            return(associate);
        }
예제 #20
0
        private static void Move(MoveInfo info, params string[] aetitles)
        {
            if (aetitles.Length > 0)
            {
                DicomServer server = ServiceLocator.Retrieve <DicomServer>();
                DicomScp    scp    = new DicomScp(IPAddress.Parse(server.HostAddress), server.AETitle, server.Port);
                MoveWorker  mw     = new MoveWorker(scp, aetitles.ToList(), info);

                mw.RunWorkerAsync();
            }
        }
예제 #21
0
        public EditPatientDialog(NActionScu naction, QueryRetrieveScu find, DicomScp scp, Patient patient)
        {
            InitializeComponent();
            _Patient = patient;
            _naction = naction;
            _find    = find;
            _scp     = scp;

            errorProvider = new ErrorProvider(this);
            errorProvider.SetIconAlignment(textBoxLastname, ErrorIconAlignment.TopLeft);
            errorProvider.SetIconAlignment(textBoxId, ErrorIconAlignment.TopLeft);
        }
예제 #22
0
 public void RunThread(DicomScp scp, IForwardDataAccessAgent forwardAgent)
 {
     // int threadId = Thread.CurrentThread.ManagedThreadId;
     try
     {
         // Logger.Global.SystemMessage(LogType.Information, string.Format("[Forwarder] [{0:X8}] +++ InternalRunThread starting", threadId), _ServerAE);
         InternalRunThread(scp, forwardAgent);
     }
     finally
     {
         // Logger.Global.SystemMessage(LogType.Information, string.Format("[Forwarder]  [{0:X8}] --- InternalRunThread ending", threadId), _ServerAE);
     }
 }
        private void __SearchStudies_RetrieveSeries(object sender, StoreSeriesEventArgs e)
        {
            try
            {
                PopulateState(e.Study, e.Series);

                if (!__QueueManager.Visible)
                {
                    __QueueManager.Show(View.DisplayContainer);
                }

                DicomScp                 scp;
                string                   patientID;
                string                   description;
                PacsRetrieveClient       client;
                RetrieveQueueItemCommand retrieveCommand;


                scp = new DicomScp( );

                scp.AETitle     = e.Server.AETitle;
                scp.PeerAddress = Utils.ResolveIPAddress(e.Server.Address);
                scp.Port        = e.Server.Port;
                scp.Timeout     = e.Server.Timeout;
                scp.Secure      = e.Server.Secure;

                patientID = e.Study.IsPatientIDNull( ) ? string.Empty : e.Study.PatientID;

                description = string.Format(SeriesInfo,
                                            e.Study.IsPatientNameNull( ) ? string.Empty : e.Study.PatientName,
                                            patientID,
                                            e.Series.IsSeriesNumberNull( ) ? string.Empty : e.Series.SeriesNumber,
                                            e.Series.IsModalityNull( ) ? string.Empty : e.Series.Modality);


                client = DicomClientFactory.CreatePacsRetrieveClient(scp);

                retrieveCommand = new RetrieveQueueItemCommand(new SeriesInformation(patientID,
                                                                                     e.Study.StudyInstanceUID,
                                                                                     e.Series.SeriesInstanceUID,
                                                                                     description),
                                                               client);


                __QueueManager.AddCommand(retrieveCommand);
            }
            catch (Exception exception)
            {
                ThreadSafeMessager.ShowError(exception.Message);
            }
        }
        private MediaCreationManagementScu CreateMediaScu( )
        {
            DicomScp scp;
            MediaCreationManagementScu scu;


            scp = new DicomScp(Utils.ResolveIPAddress(__View.SelectedServer.Address),
                               __View.SelectedServer.AETitle,
                               __View.SelectedServer.Port);

            scu = new MediaCreationManagementScu(ConfigurationData.WorkstationClient.AETitle, scp);

            return(scu);
        }
예제 #25
0
        private static void Move(MoveInfo info, int retries, int retryTimeout, params string[] aetitles)
        {
            if (aetitles.Length > 0)
            {
                DicomServer server = ServiceLocator.Retrieve <DicomServer>();
                DicomScp    scp    = new DicomScp(IPAddress.Parse(server.HostAddress), server.AETitle, server.Port);
                MoveWorker  mw     = new MoveWorker(scp, aetitles.ToList(), info);

                mw.NumberOfRetries = retries;
                mw.Timeout         = retryTimeout;
                mw.EnableRetry     = true;
                mw.RunWorkerAsync();
            }
        }
예제 #26
0
        static public void MergePatient(Dicom.Common.DataTypes.PatientUpdater.MergePatient data, string aeTitle)
        {
            var aeSrv   = HL7ServerPatientUpdate.DicomServer.AETitle;
            var ipSrv   = HL7ServerPatientUpdate.DicomServer.HostAddress;
            var portSrv = HL7ServerPatientUpdate.DicomServer.Port;
            var scp     = new DicomScp(IPAddress.Parse(ipSrv), aeSrv, portSrv);
            var scu     = new PatientUpdaterScu(null);

            scu.AETitle = aeTitle;
            var status = scu.MergePatient(scp, data);

            if (status != DicomCommandStatusType.Success)
            {
                throw new Exception(status.ToString());
            }
        }
예제 #27
0
        public void Run(DicomScp scp, IForwardDataAccessAgent forwardAgent)
        {
            if (_serviceShuttingDown)
            {
                return;
            }

            AeInfoExtended aeInfoExtended = Module._aeManagementAgent.GetAeTitle(scp.AETitle);

            if (aeInfoExtended != null)
            {
                _useTls = aeInfoExtended.ClientPortUsage == ClientPortUsageType.Secure || ((aeInfoExtended.ClientPortUsage == ClientPortUsageType.SameAsServer) && (Module._Server.Secure));
            }

            Thread thread = new Thread(() => RunThread(scp, forwardAgent));

            thread.Start();
        }
예제 #28
0
 public EditSeriesDialog(NActionScu naction, QueryRetrieveScu find, DicomScp scp, string studyInstanceUID,
                         PatientUpdaterSeries series, Patient patient)
 {
     InitializeComponent();
     _Series           = series;
     _Patient          = patient;
     _naction          = naction;
     _scp              = scp;
     _find             = find;
     _StudyInstanceUID = studyInstanceUID;
     InitializeModalities();
     try
     {
         radioButtonMoveSeriesToExistingPatient.Visible = ConfigurationManager.AppSettings["AllowSeriesMove"] == null ? false : bool.Parse(ConfigurationManager.AppSettings["AllowSeriesMove"]);
     }
     catch
     {
         radioButtonMoveSeriesToExistingPatient.Visible = false;
     }
 }
예제 #29
0
        private void StartScp(DicomScp <DicomScpContext> listener, List <DicomScp <DicomScpContext> > list)
        {
            if (listener.Start())
            {
                list.Add(listener);
                var helper = new ApplicationActivityAuditHelper(
                    ServerPlatform.AuditSource,
                    EventIdentificationContentsEventOutcomeIndicator.Success,
                    ApplicationActivityType.ApplicationStarted,
                    new AuditProcessActiveParticipant(listener.AeTitle));
                ServerAuditHelper.LogAuditMessage(helper);
            }
            else
            {
                var helper = new ApplicationActivityAuditHelper(
                    ServerPlatform.AuditSource,
                    EventIdentificationContentsEventOutcomeIndicator.MajorFailureActionMadeUnavailable,
                    ApplicationActivityType.ApplicationStarted,
                    new AuditProcessActiveParticipant(listener.AeTitle));
                ServerAuditHelper.LogAuditMessage(helper);

                Platform.Log(LogLevel.Error, "Unable to add {1} SCP handler for server partition {0}",
                             listener.Context.Partition.Description,
                             listener.ListenAddress.AddressFamily == AddressFamily.InterNetworkV6
                                 ? "IPv6"
                                 : "IPv4");
                Platform.Log(LogLevel.Error,
                             "Partition {0} will not accept IPv6 incoming DICOM associations.",
                             listener.Context.Partition.Description);

                ServerPlatform.Alert(AlertCategory.Application, AlertLevel.Critical, "DICOM Listener",
                                     AlertTypeCodes.UnableToStart, null, TimeSpan.Zero,
                                     "Unable to start {2} DICOM listener on {0} : {1}",
                                     listener.AeTitle, listener.ListenPort,
                                     listener.ListenAddress.AddressFamily == AddressFamily.InterNetworkV6
                                         ? "IPv6"
                                         : "IPv4");
            }
        }
예제 #30
0
        public T[] DoFind(DicomDataSet query)
        {
            using (QueryRetrieveScu find = CreateQueryRetrieveClient())
            {
                __CurrentFind = find;

                RegisterEvents(find);

                try
                {
                    DicomScp scp = new DicomScp( );

                    scp.AETitle     = ScpInfo.AETitle;
                    scp.Port        = ScpInfo.Port;
                    scp.PeerAddress = IPAddress.Parse(ScpInfo.Address);

                    Matches = new List <T>();

                    find.EnableDebugLog = false;

                    find.Find(scp, query);

                    return(Matches.ToArray( ));
                }
                catch (Exception exception)
                {
                    System.Diagnostics.Debug.Assert(false, exception.Message);

                    throw;
                }
                finally
                {
                    __CurrentFind = null;

                    UnregisterEvents(find);
                }
            }
        }
예제 #31
0
        private void VerifyButton_Click(object sender, EventArgs e)
        {
            DicomScp scp = new DicomScp();
            PatientUpdaterConnection scu = new PatientUpdaterConnection();

            scp.AETitle     = _textBoxServerAE.Text;
            scp.PeerAddress = ResolveIPAddress(_textBoxServerIP.Text);
            scp.Port        = Convert.ToInt32(_textBoxServerPort.Text);
            scu.AETitle     = _textBoxClientAE.Text;
            try
            {
                bool   ret     = scu.Verify(scp);
                string scpInfo = scp.PeerAddress.ToString() + " (" + scp.Port.ToString() + ")";

                if (!scu.Rejected)
                {
                    if (ret)
                    {
                        TaskDialogHelper.ShowMessageBox(this, "Successful Verification", "Verified " + scp.AETitle, string.Empty,
                                                        scpInfo, TaskDialogStandardButtons.Ok, TaskDialogStandardIcon.Information, null);
                    }
                    else
                    {
                        TaskDialogHelper.ShowMessageBox(this, "Failed Verification", "Unable to verify " + scp.AETitle, string.Empty,
                                                        scpInfo, TaskDialogStandardButtons.Ok, TaskDialogStandardIcon.Error, null);
                    }
                }
                else
                {
                    TaskDialogHelper.ShowMessageBox(this, "Failed Verification", "Unable to verify " + scp.AETitle, scu.Reason,
                                                    scpInfo, TaskDialogStandardButtons.Ok, TaskDialogStandardIcon.Error, null);
                }
            }
            catch (Exception ex)
            {
                ApplicationUtils.ShowException(this, ex);
            }
        }
예제 #32
0
        public string VerifyConnection(PACSConnection server, ClientConnection client)
        {
            AeInfo scpInfo = GetScp(server);

            using (StoreScu scu = new StoreScu())
            {
                DicomScp scp = new DicomScp(IPAddress.Parse(scpInfo.Address), scpInfo.AETitle, scpInfo.Port);

                scu.AETitle = client.AETitle;
                try
                {
                    if (scu.Verify(scp))
                    {
                        return(string.Empty);
                    }
                }
                catch (Exception exception)
                {
                    return(exception.Message);
                }
            }
            return(string.Empty);
        }
예제 #33
0
        private void StartListeners(ServerPartition part)
        {
            var parms = new DicomScpContext(part);

            //TODO support IPV6
            var scp = new DicomScp<DicomScpContext>(parms, AssociationVerifier.Verify)
            {
                ListenPort = part.Port,
                AeTitle = part.AeTitle
            };

            if (scp.Start(IPAddress.Any))
            {
                _listenerList.Add(scp);
                Platform.Log(LogLevel.Info, "Start listen on {0} for server partition {1}",
                    part.Port, part.Description);
            }
            else
            {
                Platform.Log(LogLevel.Error, "Unable to listen on {0} for server partition {1}",
                    part.Port, part.Description);
                Platform.Log(LogLevel.Error, "Partition {0} will not accept any DICOM associations", part.Description);
            }
        }
예제 #34
0
	    private void StartScp(DicomScp<DicomScpContext> listener, List<DicomScp<DicomScpContext>> list)
        {
            if (listener.Start())
            {
                list.Add(listener);
                var helper = new ApplicationActivityAuditHelper(
                                        ServerPlatform.AuditSource,
                                        EventIdentificationContentsEventOutcomeIndicator.Success,
                                        ApplicationActivityType.ApplicationStarted,
                                        new AuditProcessActiveParticipant(listener.AeTitle));
                ServerAuditHelper.LogAuditMessage(helper);
            }
            else
            {
                var helper = new ApplicationActivityAuditHelper(
                    ServerPlatform.AuditSource,
                    EventIdentificationContentsEventOutcomeIndicator.MajorFailureActionMadeUnavailable,
                    ApplicationActivityType.ApplicationStarted,
                    new AuditProcessActiveParticipant(listener.AeTitle));
                ServerAuditHelper.LogAuditMessage(helper);

                Platform.Log(LogLevel.Error, "Unable to add {1} SCP handler for server partition {0}",
                             listener.Context.Partition.Description,
                             listener.ListenAddress.AddressFamily == AddressFamily.InterNetworkV6
                                 ? "IPv6"
                                 : "IPv4");
                Platform.Log(LogLevel.Error,
                             "Partition {0} will not accept IPv6 incoming DICOM associations.",
                             listener.Context.Partition.Description);

                ServerPlatform.Alert(AlertCategory.Application, AlertLevel.Critical, "DICOM Listener",
                                     AlertTypeCodes.UnableToStart, null, TimeSpan.Zero,
                                     "Unable to start {2} DICOM listener on {0} : {1}",
                                     listener.AeTitle, listener.ListenPort,
                                     listener.ListenAddress.AddressFamily == AddressFamily.InterNetworkV6
                                         ? "IPv6"
                                         : "IPv4");
            }
        }
예제 #35
0
	    private void StartPartitionListener(ServerPartition part)
	    {
			var parms = new DicomScpContext(part);

	        if (DicomSettings.Default.ListenIPV4)
	        {
	            var ipV4Scp = new DicomScp<DicomScpContext>(parms, AssociationVerifier.Verify,
	                                                        AssociationAuditLogger.InstancesTransferredAuditLogger)
	                {
	                    ListenPort = part.Port,
	                    AeTitle = part.AeTitle,
	                    ListenAddress = IPAddress.Any
	                };

	            StartScp(ipV4Scp, _listenerList);
	        }

	        if (DicomSettings.Default.ListenIPV6)
	        {
	            var ipV6Scp = new DicomScp<DicomScpContext>(parms, AssociationVerifier.Verify,
	                                                        AssociationAuditLogger.InstancesTransferredAuditLogger)
	                {
	                    ListenPort = part.Port,
	                    AeTitle = part.AeTitle,
	                    ListenAddress = IPAddress.IPv6Any
	                };
	            StartScp(ipV6Scp, _listenerList);
	        }
	    }
예제 #36
0
		private void StartListeners(ServerPartition part)
		{
			DicomScpContext parms =
				new DicomScpContext(part);

			if (DicomSettings.Default.ListenIPV4)
			{
				DicomScp<DicomScpContext> ipV4Scp = new DicomScp<DicomScpContext>(parms, AssociationVerifier.Verify, AssociationAuditLogger.InstancesTransferredAuditLogger);

				ipV4Scp.ListenPort = part.Port;
				ipV4Scp.AeTitle = part.AeTitle;

				if (ipV4Scp.Start(IPAddress.Any))
				{
					_listenerList.Add(ipV4Scp);
					ApplicationActivityAuditHelper helper = new ApplicationActivityAuditHelper(
											ServerPlatform.AuditSource, 
											EventIdentificationContentsEventOutcomeIndicator.Success, 
											ApplicationActivityType.ApplicationStarted, 
											new AuditProcessActiveParticipant(ipV4Scp.AeTitle));
					ServerPlatform.LogAuditMessage(helper);
				}
				else
				{
					ApplicationActivityAuditHelper helper = new ApplicationActivityAuditHelper(
											ServerPlatform.AuditSource,
											EventIdentificationContentsEventOutcomeIndicator.MajorFailureActionMadeUnavailable,
											ApplicationActivityType.ApplicationStarted,
											new AuditProcessActiveParticipant(ipV4Scp.AeTitle));
					ServerPlatform.LogAuditMessage(helper);
					Platform.Log(LogLevel.Error, "Unable to add IPv4 SCP handler for server partition {0}",
								 part.Description);
					Platform.Log(LogLevel.Error,
								 "Partition {0} will not accept IPv4 incoming DICOM associations.",
								 part.Description);
					ServerPlatform.Alert(AlertCategory.Application, AlertLevel.Critical, "DICOM Listener",
                                         AlertTypeCodes.UnableToStart, null, TimeSpan.Zero, "Unable to start IPv4 DICOM listener on {0} : {1}",
					                     ipV4Scp.AeTitle, ipV4Scp.ListenPort);
				}
			}

			if (DicomSettings.Default.ListenIPV6)
			{
				DicomScp<DicomScpContext> ipV6Scp = new DicomScp<DicomScpContext>(parms, AssociationVerifier.Verify, AssociationAuditLogger.InstancesTransferredAuditLogger);

				ipV6Scp.ListenPort = part.Port;
				ipV6Scp.AeTitle = part.AeTitle;

				if (ipV6Scp.Start(IPAddress.IPv6Any))
				{
					_listenerList.Add(ipV6Scp);
					ApplicationActivityAuditHelper helper = new ApplicationActivityAuditHelper(
											ServerPlatform.AuditSource,
											EventIdentificationContentsEventOutcomeIndicator.Success,
											ApplicationActivityType.ApplicationStarted,
											new AuditProcessActiveParticipant(ipV6Scp.AeTitle));
					ServerPlatform.LogAuditMessage(helper);
				}
				else
				{
					ApplicationActivityAuditHelper helper = new ApplicationActivityAuditHelper(
						ServerPlatform.AuditSource,
						EventIdentificationContentsEventOutcomeIndicator.MajorFailureActionMadeUnavailable,
						ApplicationActivityType.ApplicationStarted,
						new AuditProcessActiveParticipant(ipV6Scp.AeTitle));
					ServerPlatform.LogAuditMessage(helper);

					Platform.Log(LogLevel.Error, "Unable to add IPv6 SCP handler for server partition {0}",
								 part.Description);
					Platform.Log(LogLevel.Error,
								 "Partition {0} will not accept IPv6 incoming DICOM associations.",
								 part.Description);
					ServerPlatform.Alert(AlertCategory.Application, AlertLevel.Critical, "DICOM Listener",
                                         AlertTypeCodes.UnableToStart, null, TimeSpan.Zero, "Unable to start IPv6 DICOM listener on {0} : {1}",
										 ipV6Scp.AeTitle, ipV6Scp.ListenPort);
				}
			}
		}
예제 #37
0
	    private void StartAlternateAeTitleListener(ServerPartition part, ServerPartitionAlternateAeTitle alternateAe)
	    {
	        var context = new DicomScpContext(part)
	            {
	                AlternateAeTitle = alternateAe
	            };

	        if (DicomSettings.Default.ListenIPV4)
	        {
	            var ipV4Scp = new DicomScp<DicomScpContext>(context, AssociationVerifier.Verify,
	                                                        AssociationAuditLogger.InstancesTransferredAuditLogger)
	                {
	                    ListenPort = alternateAe.Port,
	                    AeTitle = alternateAe.AeTitle,
	                    ListenAddress = IPAddress.Any
	                };
	            StartScp(ipV4Scp, _alternateAeListenerList);
			}

	        if (DicomSettings.Default.ListenIPV6)
	        {
	            var ipV6Scp = new DicomScp<DicomScpContext>(context, AssociationVerifier.Verify,
	                                                        AssociationAuditLogger.InstancesTransferredAuditLogger)
	                {
	                    ListenPort = alternateAe.Port,
	                    AeTitle = alternateAe.AeTitle,
	                    ListenAddress = IPAddress.IPv6Any
	                };

	            StartScp(ipV6Scp, _alternateAeListenerList);
	        }
		}