Пример #1
0
 protected override void OnClose(DicomExceptionCode error, DicomNet net)
 {
     _mainForm.LogText("Server Closed Connection", string.Empty);
     base.OnClose(error, net);
 }
Пример #2
0
 protected override void OnClose(DicomExceptionCode error, DicomNet net)
 {
     base.OnClose(error, net);
 }
Пример #3
0
        public override DicomDirInsertFileCommand OnInsertFile(string fileName, DicomDataSet ds, DicomDirInsertFileStatus status, DicomExceptionCode code)
        {
            if (MainForm.cancel)
            {
                SetStatus("Cancelled");
                return(DicomDirInsertFileCommand.Stop);
            }
            if (status == DicomDirInsertFileStatus.PreAdd)
            {
                // About to add the DICOM file
                if (ds.InformationClass == DicomClassType.BasicDirectory)
                {
                    return(DicomDirInsertFileCommand.Skip);
                }
                SetStatus(string.Format("Status: Adding the file \"{0}\"", fileName));
            }
            else if (status == DicomDirInsertFileStatus.Success)
            {
                // The DICOM file has been added successfully
                m_nAddedDicomFilesCount++;
            }
            else // Failure
            {
                DialogResult dlgRes = MessageBox.Show("Invalid File Id: " + fileName + "\n Do you want to skip this file and continue?", "Error", MessageBoxButtons.YesNo);
                if (dlgRes == DialogResult.Yes)
                {
                    return(DicomDirInsertFileCommand.Skip);
                }
                else
                {
                    return(DicomDirInsertFileCommand.Stop);
                }
            }

            Application.DoEvents();
            return(DicomDirInsertFileCommand.Continue);
        }
Пример #4
0
        /// <summary>
        /// moveservice方法的处理函数
        /// </summary>
        public void MoveSeriesProcess()
        {
            DicomExceptionCode ret = DicomExceptionCode.Success;

            using (CFindSCP scp = new CFindSCP())
            {
                dsCollection.Clear();
                scp.cfind                     = this;
                scp.dsCollection              = dsCollection;
                scp.ImplementationClass       = ImplementationClass;
                scp.ImplementationVersionName = ImplementationVersionName;
                ret = scp.Listen(clientPort, 1, ipType);
                if (ret != DicomExceptionCode.Success)
                {
                    InvokeStatusEvent(StatusType.Error, ret);
                    Terminate();
                    return;
                }

                using (DicomDataSet ds = new DicomDataSet())
                {
                    ds.Initialize(DicomClassType.Undefined, DicomDataSetInitializeType.ExplicitVRLittleEndian);

                    Utils.SetTag(ds, DemoDicomTags.QueryRetrieveLevel, "SERIES");
                    Utils.SetTag(ds, DemoDicomTags.StudyInstanceUID, studyInstance);
                    Utils.SetTag(ds, DemoDicomTags.SeriesInstanceUID, seriesInstance);
                    //Utils.SetTag(ds, DemoDicomTags.PatientID, patientID);

                    byte pid;
                    pid = Association.FindAbstract(DicomUidType.StudyRootQueryMove);
                    if (pid == 0)
                    {
                        pid = Association.FindAbstract(DicomUidType.PatientRootQueryMove);
                        Utils.SetTag(ds, DemoDicomTags.PatientID, patientID);
                    }

                    InvokeStatusEvent(StatusType.SendCMoveRequest, DicomExceptionCode.Success);

                    try
                    {
                        string UidType = Association.GetAbstract(pid);
                        SendCMoveRequest(pid, MessageId++, UidType,
                                         DicomCommandPriorityType.Medium, Association.Calling, ds);
                    }
                    catch (DicomException de)
                    {
                        InvokeStatusEvent(StatusType.Error, de.Code);
                        SendReleaseRequest();
                        if (!Wait()) // Allows Messages to occur
                        {
                            InvokeStatusEvent(StatusType.Timeout, DicomExceptionCode.Success);
                            Terminate();
                        }
                        scp.Close();
                        return;
                    }
                }

                if (!Wait())
                {
                    //
                    // Connection timed out
                    //
                    scp.Close();
                    InvokeStatusEvent(StatusType.Timeout, DicomExceptionCode.Success);
                    Terminate();
                }

                InvokeStatusEvent(StatusType.SendReleaseRequest, DicomExceptionCode.Success);
                SendReleaseRequest();

                if (!Wait())
                {
                    scp.Close();
                    InvokeStatusEvent(StatusType.Timeout, DicomExceptionCode.Success);
                    Terminate();
                }

                scp.Close();
                MoveCompleteEventArgs e = new MoveCompleteEventArgs();

                e._Datasets = dsCollection;
                OnMoveComplete(e);

                foreach (DicomDataSet resultDs in dsCollection)
                {
                    resultDs.Dispose();
                }

                dsCollection.Clear();
            }
        }
Пример #5
0
        protected override void OnAccept(DicomExceptionCode error)
        {
            Client client = null;

            if (error == DicomExceptionCode.Success)
            {
                if (IsSecure)
                {
                    client = new Client(this, false);
                    if (client != null)
                    {
                        //Require and verify a client certificate.
                        //Support SSL version 3 or TLS Version 1 for the handshake.
                        //Use trusted certificate authority file to verify the client certificate
                        //Verify the client certificate chain to a maximum depth of 2.
                        DicomOpenSslContextCreationSettings settings = new DicomOpenSslContextCreationSettings(DicomSslMethodType.SslV23,
                                                                                                               _certificationAuthoritiesFileName,
                                                                                                               DicomOpenSslVerificationFlags.Peer |
                                                                                                               DicomOpenSslVerificationFlags.FailIfNoPeerCertificate,
                                                                                                               2,
                                                                                                               DicomOpenSslOptionsFlags.NoSslV2 |
                                                                                                               DicomOpenSslOptionsFlags.AllBugWorkarounds);
#if !LEADTOOLS_V20_OR_LATER
                        client.Initialize(null, DicomNetSecurityeMode.Tls, settings);
#else
                        client.Initialize(null, DicomNetSecurityMode.Tls, settings);
#endif // #if !LEADTOOLS_V20_OR_LATER

                        client.SetTlsCipherSuiteByIndex(0, DicomTlsCipherSuiteType.DheRsaWithDesCbcSha);
                        client.SetTlsCipherSuiteByIndex(1, DicomTlsCipherSuiteType.DheRsaWith3DesEdeCbcSha);
                        client.SetTlsCipherSuiteByIndex(2, DicomTlsCipherSuiteType.DheRsaAes256Sha);

#if LEADTOOLS_V20_OR_LATER
                        // TLS 1.0
                        client.SetTlsCipherSuiteByIndex(3, DicomTlsCipherSuiteType.RsaWithAes128CbcSha);
                        client.SetTlsCipherSuiteByIndex(4, DicomTlsCipherSuiteType.RsaWith3DesEdeCbcSha);

                        // TLS 1.2
                        client.SetTlsCipherSuiteByIndex(5, DicomTlsCipherSuiteType.DheRsaWithAes128GcmSha256);
                        client.SetTlsCipherSuiteByIndex(6, DicomTlsCipherSuiteType.EcdheRsaWithAes128GcmSha256);
                        client.SetTlsCipherSuiteByIndex(7, DicomTlsCipherSuiteType.DheRsaWithAes256GcmSha384);
                        client.SetTlsCipherSuiteByIndex(8, DicomTlsCipherSuiteType.EcdheRsaWithAes256GcmSha384);
#endif // #if LEADTOOLS_V20_OR_LATER

                        client.SetTlsClientCertificate(_serverPEM, DicomTlsCertificateType.Pem, null);
                    }
                }
                else
                {
                    client = new Client(this);
                }

                try
                {
                    Accept(client);
                }
                catch (Exception ex)
                {
                    mf.Log("Connect", string.Format("Connection rejected : {0}", ex.Message));
                    client.Close();
                    return;
                }

                if (!Clients.ContainsKey(client.PeerAddress + "_" + client.PeerPort))
                {
                    Clients.Add(client.PeerAddress + "_" + client.PeerPort, client);
                }
                else
                {
                    mf.Log("Connect", "Connection rejected.  IP already connected: " + client.PeerAddress);
                    client.Close();
                    return;
                }

                if (Clients.Count > _Peers)
                {
                    mf.Log("Connect", "Connection rejected. Max connections reached");
                    client.Close();
                    return;
                }

                if (_Verify)
                {
                    if (!usersDB.FindUser(client.PeerAddress))
                    {
                        Clients.Remove(client.PeerAddress + "_" + client.PeerPort);
                        client.Close();
                        mf.Log("Connect", "Connection rejected.  Unknown User: "******"Connect", "Accepted");
            }
        }