Exemplo n.º 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);
                    }
                }
            }
        }
Exemplo n.º 2
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);
                }
            }
        }