コード例 #1
0
        /// <summary>
        /// Estimates the complexity of the query being executed.
        /// </summary>
        /// <returns>
        /// The estimated complexity of the query.
        /// </returns>
        public QueryComplexityEstimate GetQueryComplexityEstimate()
        {
            QueryComplexityEstimate complexityEstimate = new QueryComplexityEstimate();
            var    calculatedDataItemType = CalculatedDataItemType.SummaryStatisticsPerPolygon;
            string localeISOCode          = UserContext.Locale.ISOCode;
            CalculatedDataItem <List <SpeciesObservationsCountPerPolygon> > calculatedDataItem;

            calculatedDataItem = this.GetCacheCalculatedDataItem <List <SpeciesObservationsCountPerPolygon> >(calculatedDataItemType, localeISOCode);
            if (calculatedDataItem.HasData)
            {
                complexityEstimate.QueryComplexityExecutionTime = QueryComplexityExecutionTime.Fast;
                complexityEstimate.EstimatedProcessTime         = TimeSpan.FromSeconds(0);
                complexityEstimate.ComplexityDescription.Text   = "Result stored in cache";
            }
            else if (MySettings.Calculation.SummaryStatistics.CalculateNumberOfObservationsfromObsData && MySettings.Calculation.SummaryStatistics.CalculateNumberOfSpeciesfromObsData)
            {
                complexityEstimate.QueryComplexityExecutionTime = QueryComplexityExecutionTime.Slow;
                complexityEstimate.ComplexityDescription.Text   = Resources.Resource.ResultSummaryStatisticsPerPolygonComplexityEstimateBothCounts; // both number of observations and number of species selected
            }
            else if (MySettings.Calculation.SummaryStatistics.CalculateNumberOfObservationsfromObsData || MySettings.Calculation.SummaryStatistics.CalculateNumberOfSpeciesfromObsData)
            {
                complexityEstimate.QueryComplexityExecutionTime = QueryComplexityExecutionTime.Medium;
                complexityEstimate.ComplexityDescription.Text   = MySettings.Calculation.SummaryStatistics.CalculateNumberOfObservationsfromObsData
                        ? Resources.Resource.ResultSummaryStatisticsPerPolygonComplexityEstimateObservationCount
                        : Resources.Resource.ResultSummaryStatisticsPerPolygonComplexityEstimateSpeciesCount;
            }

            return(complexityEstimate);
        }
コード例 #2
0
        public QueryComplexityEstimate GetQueryComplexityEstimate()
        {
            QueryComplexityEstimate complexityEstimate = new QueryComplexityEstimate();
            int taxonCount = MySettings.Filter.Taxa.TaxonIds.Count;

            if (taxonCount == 0)
            {
                complexityEstimate.QueryComplexityExecutionTime = QueryComplexityExecutionTime.Slow;
                complexityEstimate.ComplexityDescription.Text   = Resources.Resource.ResultTaxonTableComplexityEstimateAllTaxa; // "Alla taxa är valda";
            }
            else if (taxonCount > 250 && taxonCount < 1000)
            {
                complexityEstimate.QueryComplexityExecutionTime = QueryComplexityExecutionTime.Medium;
                complexityEstimate.ComplexityDescription.Text   = Resources.Resource.ResultTaxonTableComplexityEstimate250; // "Mer än 250 taxa är valda";
            }
            else if (taxonCount >= 1000)
            {
                complexityEstimate.QueryComplexityExecutionTime = QueryComplexityExecutionTime.Slow;
                complexityEstimate.ComplexityDescription.Text   = Resources.Resource.ResultTaxonTableComplexityEstimate1000; // "Mer än 1000 taxa är valda";
            }
            else
            {
                complexityEstimate.QueryComplexityExecutionTime = QueryComplexityExecutionTime.Fast;
            }
            return(complexityEstimate);
        }
コード例 #3
0
        public QueryComplexityEstimate GetQueryComplexityEstimate(bool tableResult = true)
        {
            var complexityEstimate = new QueryComplexityEstimate
            {
                QueryComplexityExecutionTime = QueryComplexityExecutionTime.Fast
            };

            if (!MySettings.Filter.Spatial.IsSettingsDefault())
            {
                complexityEstimate.QueryComplexityExecutionTime = QueryComplexityExecutionTime.Medium;
                complexityEstimate.ComplexityDescription.Text   = Resource.QueryComplexitySpatialFilterIsUsed;
            }
            if (MySettings.Filter.Taxa.TaxonIds.Count == 0)
            {
                complexityEstimate.QueryComplexityExecutionTime = QueryComplexityExecutionTime.Slow;
                complexityEstimate.ComplexityDescription.Text   = Resource.QueryComplexityAllTaxaSelected;
                if (tableResult)
                {
                    complexityEstimate.ComplexityDescription.SuggestedResultViews.Add(new SpeciesObservationGridTableResultView());
                }
                else
                {
                    complexityEstimate.ComplexityDescription.SuggestedResultViews.Add(new SpeciesObservationGridMapResultView());
                }
            }
            else if (MySettings.Filter.Taxa.TaxonIds.Count > 50)
            {
                complexityEstimate.QueryComplexityExecutionTime = QueryComplexityExecutionTime.Medium;
                complexityEstimate.ComplexityDescription.Text   = string.Format(Resource.QueryComplexityManyTaxaIsUsedTemplate, MySettings.Filter.Taxa.TaxonIds.Count);
            }

            return(complexityEstimate);
        }
        public void GetQueryComplexityEstimate_ObservationMapWithoutTaxaFilter_ReturnSlowEstimate()
        {
            SpeciesObservationResultCalculator resultCalculator = new SpeciesObservationResultCalculator(SessionHandler.UserContext, SessionHandler.MySettings);
            QueryComplexityEstimate            result           = resultCalculator.GetQueryComplexityEstimate();

            //var result = QueryComplexityManager.GetQueryComplexityEstimate(ResultType.SpeciesObservationMap, SessionHandler.UserContext, SessionHandler.MySettings);
            Assert.AreEqual(QueryComplexityExecutionTime.Slow, result.QueryComplexityExecutionTime);
        }
        public void GetQueryComplexityEstimate_ObservationMapWith100Taxa_ReturnMediumEstimate()
        {
            SessionHandler.MySettings.Filter.Taxa.AddTaxonIds(Enumerable.Range(1, 100));
            //var result = QueryComplexityManager.GetQueryComplexityEstimate(ResultType.SpeciesObservationMap, SessionHandler.UserContext, SessionHandler.MySettings);
            SpeciesObservationResultCalculator resultCalculator = new SpeciesObservationResultCalculator(SessionHandler.UserContext, SessionHandler.MySettings);
            QueryComplexityEstimate            result           = resultCalculator.GetQueryComplexityEstimate();

            Assert.AreEqual(QueryComplexityExecutionTime.Medium, result.QueryComplexityExecutionTime);
        }
        public void GetQueryComplexityEstimate_ObservationMapWithoutTaxaFilter_ReturnGridMapResultViewSuggestion()
        {
            SpeciesObservationResultCalculator resultCalculator = new SpeciesObservationResultCalculator(SessionHandler.UserContext, SessionHandler.MySettings);
            QueryComplexityEstimate            result           = resultCalculator.GetQueryComplexityEstimate(false);

            //QueryComplexityEstimate result;
            //result = QueryComplexityManager.GetQueryComplexityEstimate(
            //    ResultType.SpeciesObservationMap,
            //    SessionHandler.UserContext,
            //    SessionHandler.MySettings);
            Assert.AreEqual(ResultType.SpeciesObservationGridMap, result.ComplexityDescription.SuggestedResultViews[0].ResultType);
        }
        public void GetQueryComplexityEstimate_ObservationMapWith1TaxaWithSpatialFilter_ReturnMediumEstimate()
        {
            DataPolygon dataPolygon = CreateSampleDataPolygon();

            SessionHandler.MySettings.Filter.Taxa.AddTaxonId(1);
            SessionHandler.MySettings.Filter.Spatial.Polygons.Add(dataPolygon);
            //var result = QueryComplexityManager.GetQueryComplexityEstimate(ResultType.SpeciesObservationMap, SessionHandler.UserContext, SessionHandler.MySettings);
            SpeciesObservationResultCalculator resultCalculator = new SpeciesObservationResultCalculator(SessionHandler.UserContext, SessionHandler.MySettings);
            QueryComplexityEstimate            result           = resultCalculator.GetQueryComplexityEstimate();

            Assert.AreEqual(QueryComplexityExecutionTime.Medium, result.QueryComplexityExecutionTime);
        }
        public void GetQueryComplexityEstimate_ObservationMapWithoutTaxaFilterButWithCachedResult_ReturnFastEstimate()
        {
            SpeciesObservationsData speciesObservationsData;

            //QueryComplexityEstimate result;
            LoginApplicationUser();

            speciesObservationsData = CreateSpeciesObservationData(SessionHandler.UserContext, SessionHandler.MySettings);
            CalculatedDataItemCacheManager.GetSpeciesObservationData(SessionHandler.MySettings, "").Data = speciesObservationsData;
            SpeciesObservationResultCalculator resultCalculator = new SpeciesObservationResultCalculator(SessionHandler.UserContext, SessionHandler.MySettings);
            QueryComplexityEstimate            result           = resultCalculator.GetQueryComplexityEstimate();

            //result = QueryComplexityManager.GetQueryComplexityEstimate(ResultType.SpeciesObservationMap, SessionHandler.UserContext, SessionHandler.MySettings);
            Assert.AreEqual(QueryComplexityExecutionTime.Fast, result.QueryComplexityExecutionTime);
        }
コード例 #9
0
        public QueryComplexityEstimate GetQueryComplexityEstimate()
        {
            var complexityEstimate = new QueryComplexityEstimate
            {
                QueryComplexityExecutionTime = QueryComplexityExecutionTime.Fast
            };

            if (MySettings.Filter.Taxa.TaxonIds.Count == 0)
            {
                complexityEstimate.QueryComplexityExecutionTime = QueryComplexityExecutionTime.Medium;
                complexityEstimate.ComplexityDescription.Text   = string.Format(Resource.QueryComplexityAllTaxaSelected);
            }
            else if (MySettings.Filter.Taxa.TaxonIds.Count > 50)
            {
                complexityEstimate.QueryComplexityExecutionTime = QueryComplexityExecutionTime.Medium;
                complexityEstimate.ComplexityDescription.Text   = string.Format(Resource.QueryComplexityManyTaxaIsUsedTemplate, MySettings.Filter.Taxa.TaxonIds.Count);
            }

            return(complexityEstimate);
        }
コード例 #10
0
        public QueryComplexityEstimate GetQueryComplexityEstimate()
        {
            QueryComplexityEstimate queryComplexity = new QueryComplexityEstimate();

            return(queryComplexity);
        }