Example #1
0
        protected override void OnStart(string[] args)
        {
            clearServices();

            storeServer = new DicomServer<CStoreScp>(Properties.Settings.Default.Port);
            (new ImportService()).Start();
        }
Example #2
0
        public Listener(int port = 5000)
        {
            this.port = port;

            //use the designated DICOM port as the default
            server = new DicomServer<DicomCStoreProvider>(port, null, null, ConsoleLogger.Instance);

        }
Example #3
0
 static void Main(string[] args)
 {
     DicomServer<FindSCP> cfindServer = new DicomServer<FindSCP>(104);
     DicomServer<FindSCP> cfindServer2 = new DicomServer<FindSCP>(1110);
     DicomServer<FindSCP> cfindServer3 = new DicomServer<FindSCP>(1111);
     Console.WriteLine("Press <return> to end...");
     Console.ReadKey();
 }
Example #4
0
        private static void Main(string[] args)
        {
            // preload dictionary to prevent timeouts
            var dict = DicomDictionary.Default;

            // start DICOM server on port 104
            var server = new DicomServer<CStoreSCP>(104);

            // end process
            Console.WriteLine("Press <return> to end...");
            Console.ReadLine();
        }
        public void ServerStart()
        {
            var dicomServer = new DicomServer();
            dicomServer.ArchiveDir = "c:\\";
            dicomServer.Port = 105;
            dicomServer.Policy = new AcceptorPolicyService().AcceptorPolicy;

            dicomServer.Start();
            while(!dicomServer.IsStarted)
            {
                Thread.Sleep(0);
            }
            dicomServer.Stop();
        }
Example #6
0
        public void Constructor_EstablishTwoWithSamePort_ShouldYieldAccessibleException()
        {
            var port = Ports.GetNext();

            var server1 = new DicomServer<DicomCEchoProvider>(port);
            while (!server1.IsListening) Thread.Sleep(10);
            var server2 = new DicomServer<DicomCEchoProvider>(port);
            Thread.Sleep(500);  // Allow for server2 to attempt listening

            Assert.True(server1.IsListening);
            Assert.Null(server1.Exception);

            Assert.False(server2.IsListening);
            Assert.IsType<SocketException>(server2.Exception);
        }
Example #7
0
		private void StopServerAsync(object nothing)
		{
			lock (_syncLock)
			{
				DicomServer server = _server;
				_server = null;

				if (server != null)
				{
					Trace.WriteLine("Stopping Dicom server.");
					server.Stop();
				}

				_serviceState = ServiceStateEnum.Stopped;
				OnServerStopped();
			}
		}
Example #8
0
        public void Stop_IsListening_TrueUntilStopRequested()
        {
            var port = Ports.GetNext();

            var server = new DicomServer<DicomCEchoProvider>(port);
            while (!server.IsListening) Thread.Sleep(10);

            for (var i = 0; i < 10; ++i)
            {
                Thread.Sleep(500);
                Assert.True(server.IsListening);
            }

            server.Stop();
            Thread.Sleep(500);

            Assert.False(server.IsListening);
        }
Example #9
0
        private void clearServices()
        {
            if (storeServer != null)
            {
                try
                {
                    storeServer.Dispose();
                }
                catch
                {
                }
                storeServer = null;
            }

            while (BackgroundService.Services.Count>0)
            {
                BackgroundService.Services[0].Dispose();
            }
        }
Example #10
0
        static void Main(string[] args)
        {
            // initialize NLog logging
            var config = new LoggingConfiguration();

            var target = new ColoredConsoleTarget();
            target.Layout = "${message}";
            config.AddTarget("Console", target);
            config.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Info, target));

            LogManager.Configuration = config;

            // preload dictionary to prevent timeouts
            var dict = DicomDictionary.Default;

            // start DICOM server on port 104
            var server = new DicomServer<CStoreSCP>(104);

            // end process
            Console.WriteLine("Press <return> to end...");
            Console.ReadLine();
        }
		private void StartServerAsync(object nothing)
		{
			DicomServerConfiguration serverConfiguration;
            lock (_syncLock)
            {
                serverConfiguration = Common.DicomServer.DicomServer.GetConfiguration();
				_restart = false;
			}

			DicomServer server = null;

			try
			{
				Trace.WriteLine("Starting Dicom server.");

				server = new DicomServer(serverConfiguration);
				server.Start();
			}
			catch (Exception e)
			{
				Platform.Log(LogLevel.Error, e, "Failed to start dicom server ({0}/{1}:{2}",
				             serverConfiguration.HostName, serverConfiguration.AETitle, serverConfiguration.Port);

				server = null;
			}
			finally
			{
				lock (_syncLock)
				{
					//the server may be null here, we are just reflecting the state based on the method calls.
					_server = server;
					_serviceState = ServiceStateEnum.Started;
					OnServerStarted();
				}
			}
		}
Example #12
0
 public void Refresh()
 {
     _dicomServerConfiguration = DicomServer.GetConfiguration();
     _storageConfiguration     = StudyStore.GetConfiguration();
 }
Example #13
0
 private StorageScp(DicomServer server, ServerAssociationParameters assoc)
 {
     _statsRecorder = new AssociationStatisticsRecorder(server);
 }
Example #14
0
 protected static DicomServerConfiguration GetServerConfiguration()
 {
     return(DicomServer.GetConfiguration());
 }
Example #15
0
        private void Anonymize(IBackgroundTaskContext context)
        {
            //TODO (Marmot) This probably should be its own WorkItem type and have it done in the background there.
            var study = (StudyTableItem)context.UserState;
            var anonymizedInstances = new AuditedInstances();

            try
            {
                context.ReportProgress(new BackgroundTaskProgress(0, SR.MessageAnonymizingStudy));

                var loader       = study.Server.GetService <IStudyLoader>();
                int numberOfSops = loader.Start(new StudyLoaderArgs(study.StudyInstanceUid, null, null));
                if (numberOfSops <= 0)
                {
                    return;
                }

                var anonymizer = new DicomAnonymizer {
                    StudyDataPrototype = _component.AnonymizedData, KeepPrivateTags = _component.KeepPrivateTags
                };

                if (_component.PreserveSeriesData)
                {
                    //The default anonymizer removes the series data, so we just clone the original.
                    anonymizer.AnonymizeSeriesDataDelegate = original => original.Clone();
                }

                // Setup the ImportFilesUtility to perform the import
                var configuration = DicomServer.GetConfiguration();

                // setup auditing information
                var result = EventResult.Success;

                string patientsSex = null;

                for (int i = 0; i < numberOfSops; ++i)
                {
                    using (var sop = loader.LoadNextSop())
                    {
                        if (sop != null &&
                            (_component.KeepReportsAndAttachments || !IsReportOrAttachmentSopClass(sop.SopClassUid)))
                        {
                            //preserve the patient sex.
                            if (patientsSex == null)
                            {
                                anonymizer.StudyDataPrototype.PatientsSex = patientsSex = sop.PatientsSex ?? "";
                            }

                            var localSopDataSource = sop.DataSource as ILocalSopDataSource;
                            if (localSopDataSource != null)
                            {
                                string    filename = string.Format("{0}.dcm", i);
                                DicomFile file     = (localSopDataSource).File;

                                // make sure we anonymize a new instance, not the same instance that the Sop cache holds!!
                                file = new DicomFile(filename, file.MetaInfo.Copy(), file.DataSet.Copy());
                                anonymizer.Anonymize(file);

                                // TODO (CR Jun 2012): Importing each file separately?
                                Platform.GetService((IPublishFiles w) => w.PublishLocal(new List <DicomFile> {
                                    file
                                }));

                                string studyInstanceUid = file.DataSet[DicomTags.StudyInstanceUid].ToString();
                                string patientId        = file.DataSet[DicomTags.PatientId].ToString();
                                string patientsName     = file.DataSet[DicomTags.PatientsName].ToString();
                                anonymizedInstances.AddInstance(patientId, patientsName, studyInstanceUid);

                                var progressPercent = (int)Math.Floor((i + 1) / (float)numberOfSops * 100);
                                var progressMessage = String.Format(SR.MessageAnonymizingStudy, file.MediaStorageSopInstanceUid);
                                context.ReportProgress(new BackgroundTaskProgress(progressPercent, progressMessage));
                            }
                        }
                    }
                }

                AuditHelper.LogCreateInstances(new[] { configuration.AETitle }, anonymizedInstances, EventSource.CurrentUser, result);

                context.Complete();
            }
            catch (Exception e)
            {
                AuditHelper.LogCreateInstances(new[] { string.Empty }, anonymizedInstances, EventSource.CurrentUser, EventResult.MajorFailure);
                context.Error(e);
            }
        }
Example #16
0
        static void Main(string[] args)
        {
            ZSCMoveSCP.OnZSCMoveRequest = (request) =>
            {
                List<DicomDataset> dataset = new List<DicomDataset>();
                for (int i = 0; i < 3; ++i)
                {
                    DicomDataset dt = new DicomDataset();
                    dt.Add(DicomTag.StudyInstanceUID, "12");
                    dt.Add(DicomTag.SOPInstanceUID, i.ToString());
                    dataset.Add(dt);

                }
                return dataset;
            };
            var cmoveScp = new DicomServer<ZSCMoveSCP>(12345);
            Console.ReadLine();

        }
Example #17
0
 public IDicomFilestreamHandler OnStartFilestream(DicomServer server, ServerAssociationParameters association,
                                                  byte presentationId, DicomMessage message)
 {
     // Should not be called bcause OnReceiveDimseCommand isn't doing anything
     throw new NotImplementedException();
 }
Example #18
0
 void IDicomServerHandler.OnReceiveAssociateRequest(DicomServer server, ServerAssociationParameters association)
 {
     server.SendAssociateAccept(association);
 }
Example #19
0
 void IDicomServerHandler.OnDimseTimeout(DicomServer server, ServerAssociationParameters association)
 {
     // Annoying log
     //Platform.Log(LogLevel.Info, "Unexpected timeout waiting for activity on association from {0} to {1}.", association.CallingAE, association.CalledAE);
 }
Example #20
0
        private void Retry(Job <StoreFailure> job, StoreFailure storeFailure)
        {
            int         count     = storeFailure.Scps.Count;
            DicomServer dcmServer = ServiceLocator.Retrieve <DicomServer>();

            foreach (ResendServer server in storeFailure.Scps.ToList())
            {
                string lastStatus = string.Empty;
                bool   success;
                string aetitle = !string.IsNullOrEmpty(server.AETitle) ? server.AETitle : dcmServer.AETitle;

                server.Scp.PeerAddress = IPAddress.Parse(server.IPAddress);
                success = Store(aetitle, server.Scp, storeFailure.Dataset, ref lastStatus);

                server.RetryCount--;
                //
                // If the store operation failed and we do not have not exhausted our retry count we
                // will try to send this dataset again later
                //
                if (!success && server.RetryCount > 0)
                {
                    string retryMessage = server.RetryCount > 0 ? string.Format("are {0} retries", server.RetryCount) : "is only 1 retry";
                    string message      = string.Format("[Rules] Failed to successfully store dataset to {0}. There {1} left.", server.Scp.AETitle, retryMessage);

                    Logger.Global.SystemMessage(LogType.Error, message, string.Empty);
                }
                else
                {
                    //
                    // If the dataset is not successfully store we need to save the info so that it can be manually sent to
                    // its destination.
                    //
                    if (!success)
                    {
                        try
                        {
                            string message = string.Format("[Rules] Failed to successfully store dataset to {0} after {1} retries. Dataset will be added to manual resend queue", server.Scp.AETitle, NumberOfRetries);

                            Logger.Global.SystemMessage(LogType.Error, message, string.Empty);
                        }
                        catch (Exception e)
                        {
                            Logger.Global.SystemException(string.Empty, e);
                        }
                    }
                    else
                    {
                        storeFailure.Scps.Remove(server);
                    }
                }
            }

            //
            // Some items still failed so we need to resubmit
            //
            if (storeFailure.Scps.Count > 0)
            {
                int itemsToRetry = (from scp in storeFailure.Scps
                                    where scp.RetryCount > 0
                                    select scp).Count();


                if (itemsToRetry > 0)
                {
                    Job <StoreFailure> retryJob = new Job <StoreFailure>()
                    {
                        Loops = 1, Data = storeFailure
                    };

                    retryJob.StartTime = Timeout.Milliseconds().FromNow();
                    Module.Scheduler.SubmitJob <StoreFailure>(retryJob, Retry);
                }
                else
                {
                    storeFailure.Save();
                }
            }
        }
Example #21
0
 public virtual IDicomFilestreamHandler OnStartFilestream(DicomServer server, ServerAssociationParameters association,
                                                          byte presentationId, DicomMessage message)
 {
     return(null);
 }
Example #22
0
        public static bool Store(string serverAE, DicomScp scp, DicomDataSet ds, ref string lastStatus)
        {
            StoreScu    store  = new StoreScu();
            DicomServer server = ServiceLocator.Retrieve <DicomServer>();

            bool success = false;

            store.AETitle                 = serverAE;
            store.BeforeConnect          += new BeforeConnectDelegate(store_BeforeConnect);
            store.AfterConnect           += new AfterConnectDelegate(store_AfterConnect);
            store.BeforeAssociateRequest += new BeforeAssociationRequestDelegate(store_BeforeAssociateRequest);
            store.AfterAssociateRequest  += new AfterAssociateRequestDelegate(store_AfterAssociateRequest);
            store.BeforeCStore           += new BeforeCStoreDelegate(store_BeforeCStore);
            store.AfterCStore            += new AfterCStoreDelegate(store_AfterCStore);
            store.BeforeReleaseRequest   += new EventHandler(store_BeforeReleaseRequest);
            store.AfterReleaseRequest    += new EventHandler(store_AfterReleaseRequest);

            try
            {
                scp.Timeout = server.ClientTimeout;
                store.Store(scp, ds);
                if (store.Rejected)
                {
                    lastStatus = store.RejectReason;
                }
                else
                {
                    if (store.Status != DicomCommandStatusType.Success)
                    {
                        lastStatus = store.Status.ToString();
                    }
                    else
                    {
                        success = true;
                    }
                }
            }
            catch (Exception e)
            {
                if (e is ClientAssociationException)
                {
                    ClientAssociationException ce = e as ClientAssociationException;
                    string message = string.Format("[Rules] Failed to establish association with server: {0}.", ce.Reason);

                    Utils.LogEvent(LogType.Error, MessageDirection.None, message, DicomCommandType.Undefined, null, store, null);
                    lastStatus = message;
                }
                if (e is DicomException)
                {
                    DicomException de      = e as DicomException;
                    string         message = string.Format("[Rules] Error: {0}.", de.Message);

                    Utils.LogEvent(LogType.Error, MessageDirection.Input, message, DicomCommandType.Undefined, null, store, null);
                    lastStatus = de.Code.ToString();
                }
                else
                {
                    string message = "[Rules] " + 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);
                    lastStatus = e.Message;
                }
            }
            finally
            {
                store.BeforeConnect          -= new BeforeConnectDelegate(store_BeforeConnect);
                store.AfterConnect           -= new AfterConnectDelegate(store_AfterConnect);
                store.BeforeAssociateRequest -= new BeforeAssociationRequestDelegate(store_BeforeAssociateRequest);
                store.AfterAssociateRequest  -= new AfterAssociateRequestDelegate(store_AfterAssociateRequest);
                store.BeforeCStore           -= new BeforeCStoreDelegate(store_BeforeCStore);
                store.AfterCStore            -= new AfterCStoreDelegate(store_AfterCStore);
                store.BeforeReleaseRequest   -= new EventHandler(store_BeforeReleaseRequest);
                store.AfterReleaseRequest    -= new EventHandler(store_AfterReleaseRequest);
                ds = null;
            }
            return(success);
        }
Example #23
0
 public static void Start(int port, string aet)
 {
     Printer = new Printer(aet);
     _server = DicomServer.Create <PrintService>(port);
 }
Example #24
0
        /// <summary>
        ///     Main routine for processing C-MOVE-RQ messages.  Called by the <see cref="DicomScp{TContext}" /> component.
        /// </summary>
        /// <param name="server"></param>
        /// <param name="association"></param>
        /// <param name="presentationID"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public override bool OnReceiveRequest(DicomServer server, ServerAssociationParameters association,
                                              byte presentationID, DicomMessage message)
        {
            var    finalResponseSent = false;
            string errorComment;

            try
            {
                // check for a Cancel Message, and cance the scu
                if (message.CommandField == DicomCommandField.CCancelRequest)
                {
                    if (_theScu != null)
                    {
                        _theScu.Cancel();
                    }

                    return(true);
                }

                var level = message.DataSet[DicomTags.QueryRetrieveLevel].GetString(0, string.Empty);

                var remoteAe = message.MoveDestination.Trim();

                // load remote device for move information
                var device = IoC.Get <IDeviceManager>().LookupDevice(Partition, remoteAe);

                if (device == null)
                {
                    errorComment = string.Format(
                        "Unknown move destination \"{0}\", failing C-MOVE-RQ from {1} to {2}",
                        remoteAe, association.CallingAE, association.CalledAE);
                    Platform.Log(LogLevel.Error, errorComment);
                    server.SendCMoveResponse(presentationID, message.MessageId, new DicomMessage(),
                                             DicomStatuses.QueryRetrieveMoveDestinationUnknown, errorComment);
                    finalResponseSent = true;
                    return(true);
                }

                //If the remote node is a DHCP node, use its IP address from the connection information, else
                // use what is configured.Always use the configured port.
                if (device.Dhcp && association.CallingAE.Equals(remoteAe))
                {
                    device.Hostname = association.RemoteEndPoint.Address.ToString();
                }

                // now setup the storage scu component
                _theScu = new PacsStorageScu(Partition, device, association.CallingAE, message.MessageId);

                bool bOnline;

                if (level.Equals("PATIENT"))
                {
                    bOnline = GetSopListForPatient(message, out errorComment);
                }
                else if (level.Equals("STUDY"))
                {
                    bOnline = GetSopListForStudy(message, out errorComment);
                }
                else if (level.Equals("SERIES"))
                {
                    bOnline = GetSopListForSeries(message, out errorComment);
                }
                else if (level.Equals("IMAGE"))
                {
                    bOnline = GetSopListForInstance(message, out errorComment);
                }
                else
                {
                    errorComment = string.Format("Unexpected Study Root Move Query/Retrieve level: {0}", level);
                    Platform.Log(LogLevel.Error, errorComment);

                    server.SendCMoveResponse(presentationID, message.MessageId, new DicomMessage(),
                                             DicomStatuses.QueryRetrieveIdentifierDoesNotMatchSOPClass,
                                             errorComment);
                    finalResponseSent = true;
                    return(true);
                }

                // Could not find an online/readable location for the requested objects to move.
                // Note that if the C-MOVE-RQ included a list of study instance uids, and some
                // were online and some offline, we don't fail now (ie, the check on the Count)
                if (!bOnline || _theScu.StorageInstanceList.Count == 0)
                {
                    Platform.Log(LogLevel.Error, "Unable to find online storage location for C-MOVE-RQ: {0}",
                                 errorComment);

                    server.SendCMoveResponse(presentationID, message.MessageId, new DicomMessage(),
                                             DicomStatuses.QueryRetrieveUnableToPerformSuboperations,
                                             string.IsNullOrEmpty(errorComment) ? string.Empty : errorComment);
                    finalResponseSent = true;
                    _theScu.Dispose();
                    _theScu = null;
                    return(true);
                }

                _theScu.ImageStoreCompleted += delegate(object sender, StorageInstance instance)
                {
                    var         scu = (StorageScu)sender;
                    var         msg = new DicomMessage();
                    DicomStatus status;

                    if (instance.SendStatus.Status == DicomState.Failure)
                    {
                        errorComment =
                            string.IsNullOrEmpty(instance.ExtendedFailureDescription)
                                ? instance.SendStatus.ToString()
                                : instance.ExtendedFailureDescription;
                    }

                    if (scu.RemainingSubOperations == 0)
                    {
                        foreach (var sop in _theScu.StorageInstanceList)
                        {
                            if ((sop.SendStatus.Status != DicomState.Success) &&
                                (sop.SendStatus.Status != DicomState.Warning))
                            {
                                msg.DataSet[DicomTags.FailedSopInstanceUidList].AppendString(sop.SopInstanceUid);
                            }
                        }
                        if (scu.Status == ScuOperationStatus.Canceled)
                        {
                            status = DicomStatuses.Cancel;
                        }
                        else if (scu.Status == ScuOperationStatus.ConnectFailed)
                        {
                            status = DicomStatuses.QueryRetrieveMoveDestinationUnknown;
                        }
                        else if (scu.FailureSubOperations > 0)
                        {
                            status = DicomStatuses.QueryRetrieveSubOpsOneOrMoreFailures;
                        }
                        else if (!bOnline)
                        {
                            status = DicomStatuses.QueryRetrieveUnableToPerformSuboperations;
                        }
                        else
                        {
                            status = DicomStatuses.Success;
                        }
                    }
                    else
                    {
                        status = DicomStatuses.Pending;

                        if (scu.RemainingSubOperations % 5 != 0)
                        {
                            return;
                        }
                        // Only send a RSP every 5 to reduce network load
                    }

                    server.SendCMoveResponse(presentationID, message.MessageId,
                                             msg, status,
                                             (ushort)scu.SuccessSubOperations,
                                             (ushort)scu.RemainingSubOperations,
                                             (ushort)scu.FailureSubOperations,
                                             (ushort)scu.WarningSubOperations,
                                             status == DicomStatuses.QueryRetrieveSubOpsOneOrMoreFailures
                            ? errorComment
                            : string.Empty);


                    if (scu.RemainingSubOperations == 0)
                    {
                        finalResponseSent = true;
                    }
                };

                _theScu.BeginSend(
                    delegate(IAsyncResult ar)
                {
                    if (_theScu != null)
                    {
                        if (!finalResponseSent)
                        {
                            var msg = new DicomMessage();
                            server.SendCMoveResponse(presentationID, message.MessageId,
                                                     msg, DicomStatuses.QueryRetrieveSubOpsOneOrMoreFailures,
                                                     (ushort)_theScu.SuccessSubOperations,
                                                     0,
                                                     (ushort)
                                                     (_theScu.FailureSubOperations +
                                                      _theScu.RemainingSubOperations),
                                                     (ushort)_theScu.WarningSubOperations, errorComment);
                            finalResponseSent = true;
                        }

                        _theScu.EndSend(ar);
                        _theScu.Dispose();
                        _theScu = null;
                    }
                },
                    _theScu);

                return(true);
            }
            catch (Exception e)
            {
                Platform.Log(LogLevel.Error, e, "Unexpected exception when processing C-MOVE-RQ");
                if (finalResponseSent == false)
                {
                    try
                    {
                        server.SendCMoveResponse(presentationID, message.MessageId, new DicomMessage(),
                                                 DicomStatuses.QueryRetrieveUnableToProcess, e.Message);
                        finalResponseSent = true;
                    }
                    catch (Exception x)
                    {
                        Platform.Log(LogLevel.Error, x,
                                     "Unable to send final C-MOVE-RSP message on association from {0} to {1}",
                                     association.CallingAE, association.CalledAE);
                        server.Abort();
                    }
                }
            }

            return(false);
        }
Example #25
0
 public override bool OnReceiveRequest(DicomServer server, ServerAssociationParameters association,
                                       byte presentationId, DicomMessage message)
 {
     server.SendCEchoResponse(presentationId, message.MessageId, DicomStatuses.Success);
     return(true);
 }
Example #26
0
        void IDicomServerHandler.OnReceiveRequestMessage(DicomServer server, ServerAssociationParameters association, byte presentationID, DicomMessage message)
        {
            if (message.CommandField == DicomCommandField.CEchoRequest)
            {
                server.SendCEchoResponse(presentationID, message.MessageId, DicomStatuses.Success);
                return;
            }

            String   studyInstanceUid  = null;
            String   seriesInstanceUid = null;
            DicomUid sopInstanceUid;
            String   patientName = null;

            bool ok = message.DataSet[DicomTags.SopInstanceUid].TryGetUid(0, out sopInstanceUid);

            if (ok)
            {
                ok = message.DataSet[DicomTags.SeriesInstanceUid].TryGetString(0, out seriesInstanceUid);
            }
            if (ok)
            {
                ok = message.DataSet[DicomTags.StudyInstanceUid].TryGetString(0, out studyInstanceUid);
            }
            if (ok)
            {
                ok = message.DataSet[DicomTags.PatientsName].TryGetString(0, out patientName);
            }

            if (!ok)
            {
                Platform.Log(LogLevel.Error, "Unable to retrieve UIDs from request message, sending failure status.");

                server.SendCStoreResponse(presentationID, message.MessageId, sopInstanceUid.UID,
                                          DicomStatuses.ProcessingFailure);
                return;
            }
            TransferSyntax syntax = association.GetPresentationContext(presentationID).AcceptedTransferSyntax;

            if (List)
            {
                Platform.Log(LogLevel.Info, message.Dump());
            }

            if (Bitbucket)
            {
                Platform.Log(LogLevel.Info, "Received SOP Instance: {0} for patient {1} in syntax {2}", sopInstanceUid,
                             patientName, syntax.Name);

                server.SendCStoreResponse(presentationID, message.MessageId,
                                          sopInstanceUid.UID,
                                          DicomStatuses.Success);
                return;
            }

            if (!Directory.Exists(StorageLocation))
            {
                Directory.CreateDirectory(StorageLocation);
            }

            var path = new StringBuilder();

            path.AppendFormat("{0}{1}{2}{3}{4}", StorageLocation, Path.DirectorySeparatorChar,
                              studyInstanceUid, Path.DirectorySeparatorChar, seriesInstanceUid);

            Directory.CreateDirectory(path.ToString());

            path.AppendFormat("{0}{1}.dcm", Path.DirectorySeparatorChar, sopInstanceUid.UID);

            var dicomFile = new DicomFile(message, path.ToString())
            {
                TransferSyntaxUid            = syntax.UidString,
                MediaStorageSopInstanceUid   = sopInstanceUid.UID,
                ImplementationClassUid       = DicomImplementation.ClassUID.UID,
                ImplementationVersionName    = DicomImplementation.Version,
                SourceApplicationEntityTitle = association.CallingAE,
                MediaStorageSopClassUid      = message.SopClass.Uid
            };


            dicomFile.Save(DicomWriteOptions.None);

            Platform.Log(LogLevel.Info, "Received SOP Instance: {0} for patient {1} in syntax {2}", sopInstanceUid,
                         patientName, syntax.Name);

            server.SendCStoreResponse(presentationID, message.MessageId,
                                      sopInstanceUid.UID,
                                      DicomStatuses.Success);
        }
Example #27
0
 void IDicomServerHandler.OnReceiveResponseMessage(DicomServer server, ServerAssociationParameters association, byte presentationID, DicomMessage message)
 {
     Platform.Log(LogLevel.Error, "Unexpectedly received OnReceiveResponseMessage callback from {0} to {1}.  Aborting association.", association.CallingAE, association.CalledAE);
     server.SendAssociateAbort(DicomAbortSource.ServiceUser, DicomAbortReason.UnexpectedPDU);
 }
Example #28
0
        private void OnReceiveMWLQuery(DicomServer server, byte presentationId, DicomMessage message)
        {
            var tagList = new List <DicomTag>();

            string specificCharacterSet = string.Empty;

            foreach (var attrib in message.DataSet)
            {
                tagList.Add(attrib.Tag);

                if (!attrib.IsNull)
                {
                    switch (attrib.Tag.TagValue)
                    {
                    case DicomTags.SpecificCharacterSet:
                        specificCharacterSet = message.DataSet[DicomTags.SpecificCharacterSet];
                        break;

                        #region Case Scheduled Procedure Step Seq

                    case DicomTags.ScheduledProcedureStepSequence:
                        DicomElementSq    sequence   = attrib as DicomElementSq;
                        DicomSequenceItem sqSubItems = sequence[0];

                        foreach (var sqSubItem in sqSubItems)
                        {
                            if (sqSubItem.IsNull)
                            {
                                continue;
                            }

                            tagList.Add(sqSubItem.Tag);

                            switch (sqSubItem.Tag.TagValue)
                            {
                            case DicomTags.ScheduledStationName:
                                break;

                            case DicomTags.Modality:
                                break;

                            case DicomTags.ScheduledPerformingPhysiciansName:
                                break;

                            case DicomTags.ScheduledProcedureStepStartDate:
                                break;

                            case DicomTags.ScheduledProcedureStepStartTime:
                                break;

                            // Optional Matching keys
                            case DicomTags.ScheduledProcedureStepLocation:
                                break;

                            case DicomTags.ScheduledProcedureStepDescription:
                                break;

                            case DicomTags.RequestedProcedureId:
                                break;

                            case DicomTags.ScheduledProcedureStepId:
                                break;

                            default:
                                break;
                            }
                        }
                        break;

                        #endregion

                    case DicomTags.PatientId:
                        break;

                    case DicomTags.PatientsName:
                        break;

                    //Optional Matching Keys
                    case DicomTags.AccessionNumber:
                        break;

                    case DicomTags.ReferringPhysiciansName:
                        break;

                    default:
                        break;
                    }
                }
            }

            // Populate result Information from Db
            List <DicomMessage> results = new List <DicomMessage>();
            try
            {
                foreach (var dicomMessage in results)
                {
                    if (_cancelReceived)
                    {
                        throw new DicomException("DICOM C-Cancel Received");
                    }

                    server.SendCFindResponse(presentationId, message.MessageId, dicomMessage,
                                             DicomStatuses.Pending);
                }
            }
            catch (Exception)
            {
                if (_cancelReceived)
                {
                    var errorResponse = new DicomMessage();
                    server.SendCFindResponse(presentationId, message.MessageId, errorResponse,
                                             DicomStatuses.Cancel);
                }

                return;
            }

            var finalResponse = new DicomMessage();
            server.SendCFindResponse(presentationId, message.MessageId, finalResponse, DicomStatuses.Success);
        }
Example #29
0
 public bool Start()
 {
     server = new DicomServer <WorklistSCP>(Program.ConfigMgt.Config.SCPConfig.Port);
     return(true);
 }
Example #30
0
			internal DicomServerContext(DicomServer server)
			{
				_server = server;
     		}
Example #31
0
        /// <summary>
        /// Main routine for processing C-MOVE-RQ messages.  Called by the <see cref="DicomScp{DicomScpParameters}"/> component.
        /// </summary>
        /// <param name="server"></param>
        /// <param name="association"></param>
        /// <param name="presentationID"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public override bool OnReceiveRequest(DicomServer server, ServerAssociationParameters association, byte presentationID, DicomMessage message)
        {
            bool   finalResponseSent = false;
            string errorComment;

            try
            {
                // Check for a Cancel message, and cancel the SCU.
                if (message.CommandField == DicomCommandField.CCancelRequest)
                {
                    if (_theScu != null)
                    {
                        _theScu.Cancel();
                    }
                    return(true);
                }

                // Get the level of the Move.
                String level = message.DataSet[DicomTags.QueryRetrieveLevel].GetString(0, "");

                // Trim the remote AE, see extra spaces at the end before which has caused problems
                string remoteAe = message.MoveDestination.Trim();

                // Open a DB Connection
                using (IReadContext read = _store.OpenReadContext())
                {
                    // Load remote device information fromt he database.
                    Device device = LoadRemoteHost(read, Partition, remoteAe);
                    if (device == null)
                    {
                        errorComment = string.Format(
                            "Unknown move destination \"{0}\", failing C-MOVE-RQ from {1} to {2}",
                            remoteAe, association.CallingAE, association.CalledAE);
                        Platform.Log(LogLevel.Error, errorComment);
                        server.SendCMoveResponse(presentationID, message.MessageId, new DicomMessage(),
                                                 DicomStatuses.QueryRetrieveMoveDestinationUnknown, errorComment);
                        finalResponseSent = true;
                        return(true);
                    }

                    // If the remote node is a DHCP node, use its IP address from the connection information, else
                    // use what is configured.  Always use the configured port.
                    if (device.Dhcp)
                    {
                        device.IpAddress = association.RemoteEndPoint.Address.ToString();
                    }

                    // Now setup the StorageSCU component
                    _theScu = new ImageServerStorageScu(Partition, device,
                                                        association.CallingAE, message.MessageId);


                    // Now create the list of SOPs to send
                    bool bOnline;

                    if (level.Equals("PATIENT"))
                    {
                        bOnline = GetSopListForPatient(read, message, out errorComment);
                    }
                    else if (level.Equals("STUDY"))
                    {
                        bOnline = GetSopListForStudy(message, out errorComment);
                    }
                    else if (level.Equals("SERIES"))
                    {
                        bOnline = GetSopListForSeries(read, message, out errorComment);
                    }
                    else if (level.Equals("IMAGE"))
                    {
                        bOnline = GetSopListForSop(message, out errorComment);
                    }
                    else
                    {
                        errorComment = string.Format("Unexpected Study Root Move Query/Retrieve level: {0}", level);
                        Platform.Log(LogLevel.Error, errorComment);

                        server.SendCMoveResponse(presentationID, message.MessageId, new DicomMessage(),
                                                 DicomStatuses.QueryRetrieveIdentifierDoesNotMatchSOPClass,
                                                 errorComment);
                        finalResponseSent = true;
                        return(true);
                    }

                    // Could not find an online/readable location for the requested objects to move.
                    // Note that if the C-MOVE-RQ included a list of study instance uids, and some
                    // were online and some offline, we don't fail now (ie, the check on the Count)
                    if (!bOnline && _theScu.StorageInstanceList.Count == 0)
                    {
                        Platform.Log(LogLevel.Error, "Unable to find online storage location for C-MOVE-RQ: {0}", errorComment);

                        server.SendCMoveResponse(presentationID, message.MessageId, new DicomMessage(),
                                                 DicomStatuses.QueryRetrieveUnableToPerformSuboperations,
                                                 string.IsNullOrEmpty(errorComment) ? string.Empty : errorComment);
                        finalResponseSent = true;
                        _theScu.Dispose();
                        _theScu = null;
                        return(true);
                    }

                    // No files were eligible for transfer, just send success and return
                    if (_theScu.StorageInstanceList.Count == 0)
                    {
                        server.SendCMoveResponse(presentationID, message.MessageId, new DicomMessage(),
                                                 DicomStatuses.Success,
                                                 0, 0, 0, 0);
                        finalResponseSent = true;
                        _theScu.Dispose();
                        _theScu = null;
                        return(true);
                    }

                    // set the preferred syntax lists
                    _theScu.LoadPreferredSyntaxes(read);

                    _theScu.ImageStoreCompleted += delegate(Object sender, StorageInstance instance)
                    {
                        var         scu = (StorageScu)sender;
                        var         msg = new DicomMessage();
                        DicomStatus status;

                        if (instance.SendStatus.Status == DicomState.Failure)
                        {
                            errorComment =
                                string.IsNullOrEmpty(instance.ExtendedFailureDescription)
                                                                    ? instance.SendStatus.ToString()
                                                                    : instance.ExtendedFailureDescription;
                        }

                        if (scu.RemainingSubOperations == 0)
                        {
                            foreach (StorageInstance sop in _theScu.StorageInstanceList)
                            {
                                if ((sop.SendStatus.Status != DicomState.Success) &&
                                    (sop.SendStatus.Status != DicomState.Warning))
                                {
                                    msg.DataSet[DicomTags.FailedSopInstanceUidList].AppendString(sop.SopInstanceUid);
                                }
                            }
                            if (scu.Status == ScuOperationStatus.Canceled)
                            {
                                status = DicomStatuses.Cancel;
                            }
                            else if (scu.Status == ScuOperationStatus.ConnectFailed)
                            {
                                status = DicomStatuses.QueryRetrieveMoveDestinationUnknown;
                            }
                            else if (scu.FailureSubOperations > 0)
                            {
                                status = DicomStatuses.QueryRetrieveSubOpsOneOrMoreFailures;
                            }
                            else if (!bOnline)
                            {
                                status = DicomStatuses.QueryRetrieveUnableToPerformSuboperations;
                            }
                            else
                            {
                                status = DicomStatuses.Success;
                            }
                        }
                        else
                        {
                            status = DicomStatuses.Pending;

                            if ((scu.RemainingSubOperations % 5) != 0)
                            {
                                return;
                            }
                            // Only send a RSP every 5 to reduce network load
                        }
                        server.SendCMoveResponse(presentationID, message.MessageId,
                                                 msg, status,
                                                 (ushort)scu.SuccessSubOperations,
                                                 (ushort)scu.RemainingSubOperations,
                                                 (ushort)scu.FailureSubOperations,
                                                 (ushort)scu.WarningSubOperations,
                                                 status == DicomStatuses.QueryRetrieveSubOpsOneOrMoreFailures
                                                                                         ? errorComment
                                                                                         : string.Empty);


                        if (scu.RemainingSubOperations == 0)
                        {
                            finalResponseSent = true;
                        }
                    };

                    _theScu.AssociationAccepted +=
                        (sender, parms) => AssociationAuditLogger.BeginInstancesTransferAuditLogger(
                            _theScu.StorageInstanceList,
                            parms);

                    _theScu.BeginSend(
                        delegate(IAsyncResult ar)
                    {
                        if (_theScu != null)
                        {
                            if (!finalResponseSent)
                            {
                                var msg = new DicomMessage();
                                server.SendCMoveResponse(presentationID, message.MessageId,
                                                         msg, DicomStatuses.QueryRetrieveSubOpsOneOrMoreFailures,
                                                         (ushort)_theScu.SuccessSubOperations,
                                                         0,
                                                         (ushort)(_theScu.FailureSubOperations + _theScu.RemainingSubOperations),
                                                         (ushort)_theScu.WarningSubOperations, errorComment);
                                finalResponseSent = true;
                            }

                            _theScu.EndSend(ar);
                            _theScu.Dispose();
                            _theScu = null;
                        }
                    },
                        _theScu);

                    return(true);
                } // end using()
            }
            catch (Exception e)
            {
                Platform.Log(LogLevel.Error, e, "Unexpected exception when processing C-MOVE-RQ");
                if (finalResponseSent == false)
                {
                    try
                    {
                        server.SendCMoveResponse(presentationID, message.MessageId, new DicomMessage(),
                                                 DicomStatuses.QueryRetrieveUnableToProcess, e.Message);
                        finalResponseSent = true;
                    }
                    catch (Exception x)
                    {
                        Platform.Log(LogLevel.Error, x,
                                     "Unable to send final C-MOVE-RSP message on association from {0} to {1}",
                                     association.CallingAE, association.CalledAE);
                        server.Abort();
                    }
                }
            }
            return(false);
        }
Example #32
0
 public void OnReceiveDimseCommand(DicomServer server, ServerAssociationParameters association, byte presentationId,
                                   DicomAttributeCollection command)
 {
 }
Example #33
0
 /// <summary>
 /// Delegate for use with <see cref="DicomServer"/> to create a handler
 /// that implements the <see cref="IDicomServerHandler"/> interface for a new incoming association.
 /// </summary>
 /// <param name="assoc">The association parameters for the negotiated association.</param>
 /// <param name="server">The server.</param>
 /// <returns>A new <see cref="DicomScpHandler{TContext}"/> instance.</returns>
 public IDicomServerHandler StartAssociation(DicomServer server, ServerAssociationParameters assoc)
 {
     return(new DicomScpHandler <TContext>(server, assoc, _context, _verifier, _complete));
 }
Example #34
0
 public IDicomServerHandler ServerHandlerCreator(DicomServer server, ServerAssociationParameters assoc)
 {
     return(new ServerHandler(this, _serverType));
 }
Example #35
0
 public static void Start()
 {
     isRunning = true;
     LogManager.SetImplementation(ConsoleLogManager.Instance);
     server = DicomServer.Create <DicomCStoreProvider>(port);
 }
Example #36
0
 public virtual bool OnReceiveRequest(DicomServer server, ServerAssociationParameters association, byte presentationId, DicomMessage message)
 {
     throw new Exception("The method or operation is not implemented.  The method must be overriden.");
 }
Example #37
0
        void IDicomServerHandler.OnReceiveResponseMessage(DicomServer server, ServerAssociationParameters association, byte presentationID, DicomMessage message)
        {
            Platform.Log(LogLevel.Error, "Unexpectedly received response mess on server.");

            server.SendAssociateAbort(DicomAbortSource.ServiceUser, DicomAbortReason.UnrecognizedPDU);
        }
Example #38
0
 public virtual bool ReceiveMessageAsFileStream(DicomServer server, ServerAssociationParameters association, byte presentationId,
                                                DicomMessage message)
 {
     return(false);
 }
Example #39
0
        void S2S()
        {


            try
            {
                isS2Sing = true;
                Utility.SetMsg(lblS2Smsg, "", false);
                //cstore = null;
                
                

                if (grdStudyList.RowCount <= 0 || grdStudyList.SelectedRows == null) return;
                //Save to Server
                DataTable dtServerList = GetServerList();
                if (dtServerList.Rows.Count <= 0)
                {
                    Utility.ShowMsg("Chưa tồn tại danh sách các PACS Server nên bạn không thể thực hiện thao tác gửi ảnh tới Server.\nBạn hãy vào mục cấu hình và khai báo các Servers.", "Thông báo");
                    return;
                }
                DataRow dr = ((DataRowView)grdStudyList.CurrentRow.DataBoundItem).Row;
                long RegID = Convert.ToInt64(dr["Reg_ID"]);
                //string pcode = Utility.sDbnull(dr["Patient_Code"]);

                // string pname = Utility.sDbnull(dr["Patient_Name"]);
                //DateTime BirthDate = Convert.ToDateTime(dr["BIRTH_DATE"]);
                //string age= (DateTime.Now.Year - Convert.ToDateTime(dr["BIRTH_DATE"]).Year).ToString();

                //SubDirPatient = pcode + "_" + Bodau(pname).Replace(age, "").Trim().Replace(" ", "_").Trim() + "_" + age;
                //ArrayList _arrImg = GetArrImg(RegID);
                //if (_arrImg == null || _arrImg.Count <= 0)
                //{
                //    Utility.ShowMsg("Các file ảnh ứng với Bệnh nhân đang chọn không tồn tại. Đề nghị bạn kiểm tra lại thư mục lưu ảnh\n" + txtImgDir.Text.Trim(), "Thông báo");
                //    return;
                //}
                //StorageScu _storageScu = new StorageScu();

                //string FileErr = "";
                //foreach (string s in _arrImg)
                //{
                //    if (!_storageScu.AddFileToSend(s)) FileErr += s + ",";
                //}
                //if (FileErr.Trim() != "")
                //{
                //    Utility.ShowMsg("Các file sau không xác định được SopClassUid nên sẽ không thể gửi được tới Server. Bạn cần copy thủ công bằng tay các file này\n" + FileErr.Substring(0, FileErr.Length - 1) + "\nHãy nhấn OK để tiếp tục gửi các file hợp lệ", "Thông báo");
                //}

                string ErrorMsg = "";
                string SuccessConnect = "";
                foreach (DataRow dr1 in dtServerList.Rows)
                {
                    try
                    {
                        if (Convert.ToInt32(dr1["isActive"]) == 1)
                        {
                            CStore cstore = new CStore();
                            CreateCStoreObject(cstore,false);
                            string LocalAETitle = dr1["CallingAETitle"].ToString();
                            string LocalAddress = dr1["LocalAddress"].ToString();
                            string RemoteAETitle = dr1["CalledAETitle"].ToString();
                            string RemoteHost = dr1["IPAddress"].ToString();
                            int Port = Convert.ToInt32(dr1["Port"]);
                            int LocalPort = Convert.ToInt32(dr1["LocalPort"]);

                            DicomServer server = new DicomServer();
                            server.AETitle = RemoteAETitle;
                            server.LocalAddress = LocalAddress;
                            server.LocalPort = LocalPort;
                            server.Port = Port;
                            server.Address = IPAddress.Parse(RemoteHost);
                            server.IpType = DicomNetIpTypeFlags.Ipv4;
                            server.Timeout = 60;
                            cstore.Compression = DicomImageCompressionType.None;
                            cstore.PresentationContextType = 0;
                            AddFiles4Store(cstore);
                        
                            cstore.Store(server, RemoteAETitle, ref ErrorMsg);
                            //_storageScu.Send(LocalAETitle, RemoteAETitle, RemoteHost, Port);
                            //if (_storageScu._dicomClient == null || !_storageScu._dicomClient.ConnectSuccess)
                            //{
                            //    ErrorMsg = "Không thể kết nối tới Server " + RemoteHost + "(Port=" + Port.ToString() + ",RemoteAETitle=" + RemoteAETitle + ",LocalAETitle=" + LocalAETitle + ")";
                            //}
                            //else
                            //{
                            //    SuccessConnect += RemoteHost + ",";
                            //}
                        }
                        //if (SuccessConnect.Trim() != "")
                        //{
                        //    SuccessConnect = SuccessConnect.Substring(0, SuccessConnect.Length - 1);
                        //    SuccessConnect += "\n" + ErrorMsg;
                        //    Utility.ShowMsg("Đã lưu dữ liệu ảnh thành công tới Server: " + SuccessConnect, "Thông báo");
                        //}
                        //else
                        //{
                        //    if (ErrorMsg.Trim() != "") Utility.ShowMsg(ErrorMsg, "Thông báo");
                        //}


                    }

                    catch
                    {
                    }
                }
                //Update Datasource and reg Status

                if (new RegController().UpdateStatus(RegID, 3) == ActionResult.Success)
                {
                    DataRow[] arrDr = m_dtStudyListDataSource.Select("REG_ID=" + RegID);
                    if (arrDr.GetLength(0) > 0)
                    {
                        if (arrDr[0]["REGSTATUS"].ToString() != "2")
                        arrDr[0]["REGSTATUS"] = 3;
                    }
                    arrDr = m_dtWLDataSource.Select("REG_ID=" + RegID);
                    if (arrDr.GetLength(0) > 0)
                    {
                        if (arrDr[0]["REGSTATUS"].ToString() != "2")
                        arrDr[0]["REGSTATUS"] = 3;
                    }
                    arrDr = m_dtWLDataSource_Suspending.Select("REG_ID=" + RegID);
                    if (arrDr.GetLength(0) > 0)
                    {
                        if (arrDr[0]["REGSTATUS"].ToString() != "2")
                        arrDr[0]["REGSTATUS"] = 3;
                    }
                    m_dtStudyListDataSource.AcceptChanges();
                    m_dtWLDataSource.AcceptChanges();
                    m_dtWLDataSource_Suspending.AcceptChanges();
                    if (ErrorMsg.Trim() == "") Utility.SetMsg(lblS2Smsg, "Đã gửi dữ liệu thành công!", false);
                    else Utility.SetMsg(lblS2Smsg, ErrorMsg, true);
                }

            }
            catch
            {
            }
            finally
            {
                isS2Sing = false;
            }
        }
Example #40
0
 void IDicomServerHandler.OnReceiveReleaseRequest(DicomServer server, ServerAssociationParameters association)
 {
     Platform.Log(LogLevel.Info, "Received association release request from  {0}.", association.CallingAE);
 }
Example #41
0
 void IDicomServerHandler.OnReceiveAbort(DicomServer server, ServerAssociationParameters association, DicomAbortSource source, DicomAbortReason reason)
 {
     Platform.Log(LogLevel.Error, "Unexpected association abort received.");
 }
Example #42
0
        static void Main(string[] args)
        {
            //模拟一下接收到查询请求后本机的数据库等相关查询操作,即绑定DcmCFindCallback代理
            ZSCFindSCP.OnZSCFindRequest = (request) =>
                {
                    //request中的Identifier字段中包含了SCU希望在SCP端进行匹配查询的信息
                    //我们需要模拟相关操作,此处简单的假设本机中存在满足条件的结果,直接返回

                    IList<DicomDataset> queries = new List<DicomDataset>();

                    //我们此次查询到了三条记录
                    for (int i = 0; i < 3; ++i)
                    {
                        DicomDataset dataset = new DicomDataset();
                        DicomDataset dt = new DicomDataset();
                        dt.Add(DicomTag.PatientID, "20141130");
                        dt.Add(DicomTag.PatientName, "zsure");
                        dt.Add(DicomTag.PatientAge, i.ToString());
                        queries.Add(dt);
                    }
                    return queries;
                };
            var cfindServer = new DicomServer<ZSCFindSCP>(12345);
            //控制台程序,用于确保主程序不退出才可一直提供DICOM C-FIND 服务
            Console.ReadLine();
        }
Example #43
0
        static void Main(string[] args)
        {
            //开启C-STORE SCP服务,用于接收C-MOVE SCP返回的图像
            CStoreSCP.OnCStoreRequestCallBack = (request) =>
                {
                    var studyUid = request.Dataset.Get<string>(DicomTag.StudyInstanceUID);
                    var instUid = request.SOPInstanceUID.UID;

                    var path = Path.GetFullPath(@"c:\cmove-scu");
                    path = Path.Combine(path, studyUid);

                    if (!Directory.Exists(path))
                        Directory.CreateDirectory(path);

                    path = Path.Combine(path, instUid) + ".dcm";

                    request.File.Save(path);

                    return new DicomCStoreResponse(request, DicomStatus.Success);


                };

            var cstoreServer = new DicomServer<CStoreSCP>(22345);

            //发起C-MOVE-RQ操作,发送请求的StudyID是12
            DicomCMoveRequest req=new DicomCMoveRequest("DEST-AE","12");
            var client=new DicomClient();
            client.NegotiateAsyncOps();
            client.AddRequest(req);
            //这里的IP地址是C-MOVE SCP的地址,12345端口号是C-MOVE SCP提供C-MOVE服务的端口
            //在C-MOVE SCP端发出的C-STORE-RQ子操作请求的是C-MOVE SCU端我们实现的C-STORE SCP,C-STORE SCP绑定的端口是22345
            client.Send("127.0.0.1", 12345,false, "DEST-AE", "SCP-AE");
            Console.ReadLine();

        }
Example #44
0
 public void OnReceiveAbort(DicomServer server, ServerAssociationParameters association, DicomAbortSource source, DicomAbortReason reason)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Example #45
0
 void IDicomServerHandler.OnNetworkError(DicomServer server, ServerAssociationParameters association, Exception e)
 {
     Platform.Log(LogLevel.Error, e, "Unexpected network error over association from {0}.", association.CallingAE);
 }
Example #46
0
 public static void Start(int port, Printer printer, bool saveJob = false, bool preview = false)
 {
     Printer = printer;
     _server = new DicomServer<PrintService>(port);
     SaveJob = saveJob;
 }
Example #47
0
 public static void Start(int port, string aet)
 {
     Printer = new Printer(aet);
     _server = new DicomServer<PrintService>(port);
 }
Example #48
0
 void IDicomServerHandler.OnDimseTimeout(DicomServer server, ServerAssociationParameters association)
 {
     Platform.Log(LogLevel.Info, "Received DIMSE Timeout, continuing listening for messages");
 }