Пример #1
0
        public void TransferStudy(string studyUid, string targetAE)
        {
            Console.WriteLine("Initiating C-MOVE of {0} from {1} to {2}...", studyUid, _serverAddress, targetAE);

            var moveClient = new CMoveClient();
            moveClient.DestinationAE = targetAE;
            moveClient.CallingAE = _callingAE;
            moveClient.CalledAE = _serverAE;

            moveClient.AddQuery(DcmQueryRetrieveLevel.Study, studyUid);

            moveClient.OnCMoveResponse += (query, dataset, status, remain, complete, warning, failure) =>
                {
                    if (status == DcmStatus.Pending)
                    {
                        double progress = (double) complete / (double)(complete + remain);

                        Console.WriteLine("%{4} - {0}/{1} (warn:{2}, fail:{3})", complete, remain, warning, failure, GetAsciiArtForProgress(progress, 10));

                        Console.CursorVisible = false;
                        Console.CursorLeft = 0;
                        Console.CursorTop -= 1;
                    }
                    else if (status == DcmStatus.Success)
                    {
                        Console.WriteLine("{0}/{1} (warn:{2}, fail:{3})", complete, remain, warning, failure);
                        Console.WriteLine("Completed.");
                    }
                    else
                        Console.WriteLine("Status:{0}", status);
                };

            moveClient.Connect(_serverAddress.Address.ToString(), _serverAddress.Port, DcmSocketType.TCP);
            moveClient.Wait();

            Console.CursorVisible = true;
        }
Пример #2
0
        private void getInstancesButton_Click(object sender, RoutedEventArgs e)
        {
            var success = false;
            var message = "Unidentified failure.";

            try
            {
                Dispatcher.BeginInvoke(new ClearSelectedStudyDatasetsDelegate(() => SelectedStudyDatasets.Clear()));

                var selStudy = studiesListBox.SelectedItem as CFindStudyResponse;

                if (selStudy != null)
                {
                    var moveStudy = new CMoveClient
                                        {
                                            CallingAE = callingAetTextBox.Text,
                                            CalledAE = calledAetTextBox.Text,
                                            DestinationAE = callingAetTextBox.Text
                                        };
                    moveStudy.OnCMoveResponse +=
                        delegate(CMoveQuery query, DcmDataset dataset, DcmStatus status, ushort remain, ushort complete,
                                 ushort warning, ushort failure)
                            {
                            };
                    moveStudy.AddQuery(DcmQueryRetrieveLevel.Study, selStudy.StudyInstanceUID);

                    moveStudy.Connect(hostTextBox.Text, Int32.Parse(portTextBox.Text), DcmSocketType.TCP);
                    if (moveStudy.Wait())
                    {
                        success = true;
                    }
                    else
                    {
                        message = moveStudy.ErrorMessage;
                    }
                }
            }
            catch (Exception exception)
            {
                message = exception.Message;
            }

            if (!success)
            {
                MessageBox.Show(message, "C-MOVE Study error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }