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));
        }
        public void TestIsOpenQuery()
        {
            var identifier = new StudyRootStudyIdentifier();

            Assert.IsTrue(identifier.IsOpenQuery());

            identifier.RetrieveAeTitle      = "Test";
            identifier.InstanceAvailability = "Test";
            identifier.SpecificCharacterSet = "Test";

            Assert.IsTrue(identifier.IsOpenQuery());

            identifier.PatientId = "Test";
            Assert.IsFalse(identifier.IsOpenQuery());

            identifier.PatientId    = "";
            identifier.PatientsName = "Test";
            Assert.IsFalse(identifier.IsOpenQuery());

            identifier.PatientId    = "T";
            identifier.PatientsName = "T";
            Assert.IsFalse(identifier.IsOpenQuery());
        }