Пример #1
0
        private void RefreshViewers(bool silent)
        {
            using (AutomationClient client = new AutomationClient())
            {
                try
                {
                    GetActiveViewersResult result = client.GetActiveViewers();

                    ClearAllViewers();

                    foreach (Viewer viewer in result.ActiveViewers)
                    {
                        StudyItem study = GetStudy(viewer.PrimaryStudyInstanceUid);
                        if (study != null)
                        {
                            study.AddViewer(viewer.Identifier);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ClearAllViewers();
                    if (!silent)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
Пример #2
0
        private void OnActivateViewer(object sender, EventArgs e)
        {
            StudyItem study = GetSelectedStudy();

            if (study == null)
            {
                MessageBox.Show("Select a single study item in the list.");
                return;
            }

            Guid?viewerId = GetSelectedViewer();

            if (viewerId == null)
            {
                MessageBox.Show("An active viewer must be selected.");
                return;
            }

            using (AutomationClient client = new AutomationClient())
            {
                try
                {
                    ActivateViewerRequest request = new ActivateViewerRequest();
                    request.Viewer            = new Viewer();
                    request.Viewer.Identifier = GetIdentifier(viewerId.Value);
                    client.ActivateViewer(request);
                }
                catch (Exception ex)
                {
                    study.RemoveViewer(viewerId.Value);
                    MessageBox.Show(ex.Message);
                }
            }
        }
Пример #3
0
        private void OnOpenStudy(object sender, EventArgs e)
        {
            StudyItem study = GetSelectedStudy();

            if (study == null)
            {
                return;
            }

            using (AutomationClient client = new AutomationClient())
            {
                try
                {
                    OpenStudiesRequest   request       = new OpenStudiesRequest();
                    List <OpenStudyInfo> studiesToOpen = new List <OpenStudyInfo>();
                    foreach (StudyItem s in GetSelectedStudies())
                    {
                        OpenStudyInfo info = new OpenStudyInfo();
                        info.StudyInstanceUid = s.StudyInstanceUid;
                        info.SourceAETitle    = s.RetrieveAETitle;
                        studiesToOpen.Add(info);
                    }

                    request.StudiesToOpen         = GetStudiesToOpen(studiesToOpen);
                    request.ActivateIfAlreadyOpen = _activateIfOpen.Checked;

                    OpenStudiesResult result = client.OpenStudies(request);
                    if (result.Viewer != null)
                    {
                        bool shouldExist = study.HasViewers && _activateIfOpen.Checked;
                        bool exists      = study.HasViewer(result.Viewer.Identifier);
                        if (shouldExist && !exists)
                        {
                            study.ClearViewers();
                        }

                        if (!exists)
                        {
                            study.AddViewer(result.Viewer.Identifier);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Пример #4
0
        private void OnGetSelectedInfo(object sender, EventArgs e)
        {
            StudyItem study = GetSelectedStudy();

            if (study == null)
            {
                MessageBox.Show("Select a single study item in the list.");
                return;
            }

            Guid?selectedViewer = GetSelectedViewer();

            if (selectedViewer == null)
            {
                MessageBox.Show("An active viewer must be selected.");
                return;
            }

            using (AutomationClient client = new AutomationClient())
            {
                try
                {
                    GetViewerInfoRequest request = new GetViewerInfoRequest();
                    request.Viewer            = new Viewer();
                    request.Viewer.Identifier = GetIdentifier(selectedViewer.Value);
                    GetViewerInfoResult result = client.GetViewerInfo(request);

                    StringBuilder builder = new StringBuilder();
                    builder.AppendLine("Additional studies:");

                    foreach (string additionalStudyUid in result.AdditionalStudyInstanceUids)
                    {
                        builder.AppendLine(additionalStudyUid);
                    }

                    MessageBox.Show(builder.ToString());
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Пример #5
0
		private void RefreshViewers(bool silent)
		{
			using (AutomationClient client = new AutomationClient())
			{
				try
				{
					GetActiveViewersResult result = client.GetActiveViewers();

					ClearAllViewers();

					foreach (Viewer viewer in result.ActiveViewers)
					{
						StudyItem study = GetStudy(viewer.PrimaryStudyInstanceUid);
						if (study != null)
							study.AddViewer(viewer.Identifier);
					}
				}
				catch (Exception ex)
				{
					ClearAllViewers();
					if (!silent)
						MessageBox.Show(ex.Message);
				}
			}
		}
Пример #6
0
		private void OnCloseViewer(object sender, EventArgs e)
		{
			StudyItem study = GetSelectedStudy();
			if (study == null)
			{
				MessageBox.Show("Select a single study item in the list.");
				return;
			}

			Guid? viewerId = GetSelectedViewer();
			if (viewerId == null)
			{
				MessageBox.Show("An active viewer must be selected.");
				return;
			}

			using (AutomationClient client = new AutomationClient())
			{
				try
				{
					CloseViewerRequest request = new CloseViewerRequest();
					request.Viewer = new Viewer();
					request.Viewer.Identifier = GetIdentifier(viewerId.Value);
					client.CloseViewer(request);
				}
				catch (Exception ex)
				{
					MessageBox.Show(ex.Message);
				}
				finally
				{
					study.RemoveViewer(viewerId.Value);
				}
			}
		}
Пример #7
0
		private void OnOpenStudy(object sender, EventArgs e)
		{
			StudyItem study = GetSelectedStudy();
			if (study == null)
				return;

			using (AutomationClient client = new AutomationClient())
			{
				try
				{
					OpenStudiesRequest request = new OpenStudiesRequest();
					List<OpenStudyInfo> studiesToOpen = new List<OpenStudyInfo>();
					foreach (StudyItem s in GetSelectedStudies())
					{
						OpenStudyInfo info = new OpenStudyInfo();
						info.StudyInstanceUid = s.StudyInstanceUid;
						info.SourceAETitle = s.RetrieveAETitle;
						studiesToOpen.Add(info);
					}

					request.StudiesToOpen = GetStudiesToOpen(studiesToOpen);
					request.ActivateIfAlreadyOpen = _activateIfOpen.Checked;

					OpenStudiesResult result = client.OpenStudies(request);
					if (result.Viewer != null)
					{
						bool shouldExist = study.HasViewers && _activateIfOpen.Checked;
						bool exists = study.HasViewer(result.Viewer.Identifier);
						if (shouldExist && !exists)
							study.ClearViewers();

						if (!exists)
							study.AddViewer(result.Viewer.Identifier);
					}
				}
				catch (Exception ex)
				{
					MessageBox.Show(ex.Message);
				}
			}
		}
Пример #8
0
		private void OnGetSelectedInfo(object sender, EventArgs e)
		{
			StudyItem study = GetSelectedStudy();
			if (study == null)
			{
				MessageBox.Show("Select a single study item in the list.");
				return;
			}

			Guid? selectedViewer = GetSelectedViewer();
			if (selectedViewer == null)
			{
				MessageBox.Show("An active viewer must be selected.");
				return;
			}

			using (AutomationClient client = new AutomationClient())
			{
				try
				{
					GetViewerInfoRequest request = new GetViewerInfoRequest();
					request.Viewer = new Viewer();
					request.Viewer.Identifier = GetIdentifier(selectedViewer.Value);
					GetViewerInfoResult result = client.GetViewerInfo(request);

					StringBuilder builder = new StringBuilder();
					builder.AppendLine("Additional studies:");

					foreach (string additionalStudyUid in result.AdditionalStudyInstanceUids)
						builder.AppendLine(additionalStudyUid);

					MessageBox.Show(builder.ToString());
				}
				catch (Exception ex)
				{
					MessageBox.Show(ex.Message);
				}
			}
		}