예제 #1
0
        //[TestMethod] This is a bad test. This assumes there is already data in Graphene
        public void GivenATrackerWithNoCustomFields_WhenIncrementingTraker_ThenTotalReflectsIncrementAndNoOccurencesIsSet()
        {
            var generator = new MongoReportGenerator("mongodb://localhost:9001/Graphene", _fakeLogger);

            var spec = new ReportSpecification(new[] { typeof(PatientDemographicSearchMatchesTracker) },
                                               DateTime.UtcNow.AddDays(-100), DateTime.UtcNow, ReportResolution.Hour);


            ITrackerReportResults newresult = generator.BuildReport(spec);

            Assert.IsTrue(newresult.AggregationResults.Any());
        }
예제 #2
0
        //[TestMethod]
        public void ReportOnTrackerWithBlankFilters()
        {
            var generator = new MongoReportGenerator("mongodb://localhost:9001/Graphene", _fakeLogger);

            var spec = new ReportSpecification(new[] { typeof(PatientDemographicSearchMatchesTracker) },
                                               new[] { new OrgAndVendorFilter {
                                                           Vendor = "", OrgId = ""
                                                       } },
                                               DateTime.UtcNow.AddDays(-100), DateTime.UtcNow, ReportResolution.Hour);

            ITrackerReportResults newresult = generator.BuildReport(spec);

            Assert.IsTrue(newresult.AggregationResults.Any());
        }
예제 #3
0
        public static AggregationResults <T1> Report(DateTime fromUtc, DateTime toUtc,
                                                     ReportSpecification <T, T1> reportSpecs)

        {
            ITrackerReportResults trackerReportResults =
                Configurator.Configuration.ReportGenerator.BuildReport(reportSpecs);

            var aggResults = new AggregationResults <T1> {
                Resolution = reportSpecs.Resolution
            };

            if (trackerReportResults == null)
            {
                return(aggResults);
            }

            foreach (IAggregationResult aggregationResult in trackerReportResults.AggregationResults)
            {
                var aggResult = new AggregationResult <T1>();
                aggResult.MesurementTimeUtc = aggregationResult.MesurementTimeUtc;


                aggResult.Occurrence = aggregationResult.Occurence;
                aggResult.Total      = aggregationResult.Total;


                foreach (IMeasurementResult mV in aggregationResult.MeasurementValues)
                {
                    Type type = aggResult.Tracker.GetType();

                    PropertyInfo property = null;
                    if (mV.PropertyName != null)
                    {
                        property = type.GetProperty(mV.PropertyName);
                    }
                    if (property != null)
                    {
                        object convertedValue = Convert.ChangeType(mV.Value, property.PropertyType);
                        property.SetValue(aggResult.Tracker, convertedValue);
                    }
                }
                aggResults.Results.Add(aggResult);
            }

            return(aggResults);
        }