private OpenStudyInfo[] GetStudiesToOpen(ICollection<OpenStudyInfo> studiesToOpen) { OpenStudyInfo[] returnInfo = new OpenStudyInfo[studiesToOpen.Count]; int i = 0; foreach (OpenStudyInfo info in studiesToOpen) returnInfo[i++] = info; return returnInfo; }
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); } } }