private void OnSearchCompleted(List <StudyTableItem> aggregateItems, List <KeyValuePair <string, Exception> > failedServerInfo)
        {
            CurrentSearchResult.SearchEnded(aggregateItems, _filterDuplicateStudies);

            //#10023: always select the first entry when refreshed
            SetSelection(new Selection(CollectionUtils.FirstElement(CurrentSearchResult.StudyTable.Items)));

            // re-enable the study browser
            this.IsEnabled = true;
            EventsHelper.Fire(this.SearchEnded, this, EventArgs.Empty);

            if (failedServerInfo.Count > 0)
            {
                var aggregateExceptionMessage = new StringBuilder();
                var count = 0;
                foreach (var pair in failedServerInfo)
                {
                    if (count++ > 0)
                    {
                        aggregateExceptionMessage.Append("\n\n");
                    }

                    aggregateExceptionMessage.AppendFormat(SR.FormatUnableToQueryServer, pair.Key, pair.Value.Message);
                }

                // this isn't ideal, but since we can operate on multiple entities, we need to aggregate all the
                // exception messages. We should at least attempt to get at the first inner exception, and that's
                // what we do here, to aid in debugging

                //NOTE: must use Application.ActiveDesktopWindow instead of Host.DesktopWindow b/c this
                //method is called on startup before the component is started.
                Application.ActiveDesktopWindow.ShowMessageBox(aggregateExceptionMessage.ToString(), MessageBoxActions.Ok);
            }
        }
        public virtual void Search(StudyRootStudyIdentifier criteria)
        {
            if (_selectedServers == null)
            {
                return;
            }

            // cancel any pending searches
            Async.CancelPending(this);

            if (!_selectedServers.IsLocalServer)
            {
                if (criteria.IsOpenQuery() && Host.DesktopWindow.ShowMessageBox(SR.MessageConfirmContinueOpenSearch, MessageBoxActions.YesNo) == DialogBoxAction.No)
                {
                    return;
                }
            }

            // disable the study browser while the search is executing
            this.IsEnabled = false;
            CurrentSearchResult.SearchStarted();

            EventsHelper.Fire(this.SearchStarted, this, EventArgs.Empty);

            _lastQueryCriteria = criteria;
            var failedServerInfo       = new List <KeyValuePair <string, Exception> >();
            var aggregateStudyItemList = new List <StudyTableItem>();

            Async.Invoke(this,
                         () => aggregateStudyItemList = Query(criteria, failedServerInfo),
                         () => OnSearchCompleted(aggregateStudyItemList, failedServerInfo));
        }
        private void OnConfigurationSettingsChanged(object sender, PropertyChangedEventArgs e)
        {
            _searchResultColumnOptions = SearchResult.ColumnOptions;
            _searchResultColumnOptions.ApplyColumnSettings(CurrentSearchResult);

            if (CurrentSearchResult != null)
            {
                CurrentSearchResult.UpdateColumnVisibility();
            }
        }
        private void OnSelectedServerChanged()
        {
            CurrentSearchResult.ServerGroupName      = _selectedServers.Name;
            CurrentSearchResult.IsLocalServer        = _selectedServers.IsLocalServer;
            CurrentSearchResult.NumberOfChildServers = _selectedServers.Count;
            CurrentSearchResult.FilterDuplicates     = _filterDuplicateStudies;

            CurrentSearchResult.UpdateColumnVisibility();

            EventsHelper.Fire(_selectedServerChangedEvent, this, EventArgs.Empty);
            EventsHelper.Fire(_studyTableChanged, this, EventArgs.Empty);

            UpdateResultsTitle();
        }
        public virtual void CancelSearch()
        {
            if (!CurrentSearchResult.SearchInProgress)
            {
                return;
            }

            Async.CancelPending(this);
            CurrentSearchResult.SearchCanceled();

            // re-enable the study browser
            this.IsEnabled = true;

            EventsHelper.Fire(this.SearchEnded, this, EventArgs.Empty);
        }