Example #1
0
        public IList <Standard> GetStandards(StandardQuery query)
        {
            var standards = StandardStorage.GetData().Select(x => x.Value);

            if (query.StandardSubjectId.HasValue)
            {
                standards = standards.Where(x => x.StandardSubjectRef == query.StandardSubjectId);
            }
            if (query.GradeLavelId.HasValue)
            {
                standards =
                    standards.Where(
                        x => query.GradeLavelId <= x.LowerGradeLevelRef && query.GradeLavelId >= x.UpperGradeLevelRef);
            }
            if (!query.AllStandards || query.ParentStandardId.HasValue)
            {
                standards = standards.Where(x => x.ParentStandardRef == query.ParentStandardId);
            }

            if (query.ClassId.HasValue)
            {
                var classStandarts = ClassStandardStorage.GetAll(query.ClassId).Select(x => x.StandardRef);
                standards = standards.Where(x => classStandarts.Contains(x.Id));
            }
            //if (query.CourseId.HasValue)
            //{
            //    var classStandarts = Storage.ClasStandardStorage.GetAll(query.CourseId).Select(x => x.StandardRef);
            //    standards = standards.Where(x => classStandarts.Contains(x.Id));
            //}

            return(standards.ToList());
        }
        public void ExecuteQuery()
        {
            object query = null;
            switch (_view.SelectedQueryMode)
            {
                case QueryMode.Aggregate:
                    {
                        query = (_view.QueryView as IFdoAggregateQueryView).QueryObject;
                    }
                    break;
                case QueryMode.SQL:
                    {
                        query = (_view.QueryView as IFdoSqlQueryView).SQLString;
                    }
                    break;
                case QueryMode.Standard:
                    {
                        StandardQuery qry = new StandardQuery();
                        qry.UseExtendedSelect = (_view.QueryView as IFdoStandardQueryView).UseExtendedSelectForOrdering;
                        qry.query = (_view.QueryView as IFdoStandardQueryView).QueryObject;
                        qry.Limit = (_view.QueryView as IFdoStandardQueryView).Limit;
                        query = qry;
                    }
                    break;
            }
            if (query != null)
            {
                long count = 0;
                try
                {
                    count = GetFeatureCount();
                }
                catch (Exception)
                {
                    if (!_view.Confirm(ResourceService.GetString("TITLE_DATA_PREVIEW"), "An error occured attempting to get the total number of features in this feature class. As a result, the size of the result set produced by your query cannot be determined. Proceed anyway?"))
                    {
                        _view.SetBusyCursor(false);
                        return;
                    }
                }

                int limit = Preferences.DataPreviewWarningLimit;

                if (_view.SelectedQueryMode == QueryMode.Standard)
                {
                    if ((query as StandardQuery).Limit <= 0)
                    {
                        if (count > limit && !_view.ConfirmFormatted(ResourceService.GetString("TITLE_DATA_PREVIEW"), ResourceService.GetString("QUESTION_DATA_PREVIEW_LIMIT"), count.ToString()))
                        {
                            _view.SetBusyCursor(false);
                            return;
                        }
                    }
                }
                Clear();
                _view.CancelEnabled = true;
                _view.ClearEnabled = false;
                _view.ExecuteEnabled = false;
                _timer.Start();
                _view.StatusMessage = "Executing Query";
                _view.ElapsedMessage = "00:00:00";
                _queryStart = DateTime.Now;

                _view.SetBusyCursor(true);
                _queryWorker.RunWorkerAsync(query);
            }
        }
        public SolrQueryResults <CmsSearchResultItem> SearchIndex(string query, string[] searchfilters, int page, int pageSize, string sortOrder, string language = null)
        {
            StandardQuery standardQuery = this.CreateStandardQuery(query, searchfilters, page, pageSize, sortOrder, language);

            return(this.ExecuteQuery(standardQuery.LocalParams + (ISolrQuery)standardQuery.Query, standardQuery.QueryOptions));
        }
        public void ExecuteQuery()
        {
            object query = null;

            switch (_view.SelectedQueryMode)
            {
            case QueryMode.Aggregate:
            {
                query = (_view.QueryView as IFdoAggregateQueryView).QueryObject;
            }
            break;

            case QueryMode.SQL:
            {
                query = (_view.QueryView as IFdoSqlQueryView).SQLString;
            }
            break;

            case QueryMode.Standard:
            {
                StandardQuery qry = new StandardQuery();
                qry.UseExtendedSelect = (_view.QueryView as IFdoStandardQueryView).UseExtendedSelectForOrdering;
                qry.query             = (_view.QueryView as IFdoStandardQueryView).QueryObject;
                qry.Limit             = (_view.QueryView as IFdoStandardQueryView).Limit;
                query = qry;
            }
            break;
            }
            if (query != null)
            {
                long count = 0;
                try
                {
                    count = GetFeatureCount();
                }
                catch (Exception)
                {
                    if (!_view.Confirm(ResourceService.GetString("TITLE_DATA_PREVIEW"), "An error occured attempting to get the total number of features in this feature class. As a result, the size of the result set produced by your query cannot be determined. Proceed anyway?"))
                    {
                        _view.SetBusyCursor(false);
                        return;
                    }
                }

                int limit = Preferences.DataPreviewWarningLimit;

                if (_view.SelectedQueryMode == QueryMode.Standard)
                {
                    if ((query as StandardQuery).Limit <= 0)
                    {
                        if (count > limit && !_view.ConfirmFormatted(ResourceService.GetString("TITLE_DATA_PREVIEW"), ResourceService.GetString("QUESTION_DATA_PREVIEW_LIMIT"), count.ToString()))
                        {
                            _view.SetBusyCursor(false);
                            return;
                        }
                    }
                }
                Clear();
                _view.CancelEnabled  = true;
                _view.ClearEnabled   = false;
                _view.ExecuteEnabled = false;
                _timer.Start();
                _view.StatusMessage  = "Executing Query";
                _view.ElapsedMessage = "00:00:00";
                _queryStart          = DateTime.Now;

                _view.SetBusyCursor(true);
                _queryWorker.RunWorkerAsync(query);
            }
        }