Пример #1
0
        private static ITrackerReportResults ToMongoAggregationResult(IReportSpecification specification,
                                                                      AggregateResult queryResults)
        {
            const string utcDateKey    = "UtcDateTime";
            const string totalKey      = "_Total";
            const string occurrenceKey = "_Occurrence";
            const string KEY_FILTER    = "KeyFilter";
            const string ID_KEY        = "_id";
            const string TYPE_KEY      = "Type";

            var results = new MongoTrackerResults(specification);

            if (!queryResults.ResultDocuments.Any())
            {
                return(results);
            }

            int           count = queryResults.ResultDocuments.Count();
            List <string> names =
                queryResults.ResultDocuments.First().Names.Where(x => !(x == utcDateKey || x == "_id")).ToList();

            foreach (BsonDocument document in queryResults.ResultDocuments)
            {
                BsonDocument dateTime = document[utcDateKey].AsBsonDocument;

                long     total       = document[totalKey].ToInt64();
                long     occurrence  = document[occurrenceKey].ToInt64();
                string   typeName    = document[ID_KEY][TYPE_KEY].AsString;
                string   keyFilter   = document[ID_KEY][KEY_FILTER].ToString();
                DateTime utcDateTime = ConvertDateTimeDocumentToDateTime(dateTime);

                IAggregationBuildableResult trackerResult = results.AddAggregationResult(utcDateTime, typeName, keyFilter, occurrence, total);
                var relevantNames = names.Where(x => x.GetFullyQualifiedNameFromFormattedString().StartsWith(typeName));
                foreach (string key in relevantNames)
                {
                    string       fullyQualifiedName = key.GetFullyQualifiedNameFromFormattedString();
                    BsonValue    measurementResult  = document[key];
                    IMeasurement measurement        =
                        specification.Counters.FirstOrDefault(x => x.FullyQualifiedPropertyName == fullyQualifiedName);
                    if (measurement != null)
                    {
                        trackerResult.AddMeasurementResult(measurement, measurementResult.ToString());
                    }
                }
            }

            return(results);
        }
Пример #2
0
        private static ITrackerReportResults ToMongoAggregationResult(IReportSpecification specification,
            AggregateResult result)
        {
            const string utcDateKey = "UtcDateTime";
            const string totalKey = "_Total";
            const string occurrenceKey = "_Occurrence";
            int count = result.ResultDocuments.Count();
            List<string> names =
                result.ResultDocuments.First().Names.Where(x => !(x == utcDateKey || x == "_id")).ToList();

            var results = new MongoTrackerResults(specification);

            foreach (BsonDocument document in result.ResultDocuments)
            {
                BsonDocument dateTime = document[utcDateKey].AsBsonDocument;

                long total = document[totalKey].ToInt64();
                long occurrence = document[occurrenceKey].ToInt64();
                DateTime utcDateTime = ConvertDateTimeDocumentToDateTime(dateTime);

                IAggregationResult trackerResult = results.AddAggregationResult(utcDateTime, occurrence, total);
                foreach (string key in names)
                {
                    string fullyQualifiedName = key.GetFullyQualifiedNameFromFormattedString();
                    BsonValue measurementResult = document[key];
                    IMeasurement measurement =
                        specification.Counters.FirstOrDefault(x => x.FullyQualifiedPropertyName == fullyQualifiedName);
                    if (measurement != null)
                        trackerResult.AddMeasurementResult(measurement, measurementResult.ToString());
                }
            }

            return results;
        }
Пример #3
0
        private static ITrackerReportResults ToMongoAggregationResult(IReportSpecification specification,
            AggregateResult queryResults)
        {
            const string utcDateKey = "UtcDateTime";
            const string totalKey = "_Total";
            const string occurrenceKey = "_Occurrence";
            const string KEY_FILTER = "KeyFilter";
            const string ID_KEY = "_id";
            const string TYPE_KEY = "Type";

            var results = new MongoTrackerResults(specification);

            if (! queryResults.ResultDocuments.Any())
                return results;

            int count = queryResults.ResultDocuments.Count();
            List<string> names =
                queryResults.ResultDocuments.First().Names.Where(x => !(x == utcDateKey || x == "_id")).ToList();

            foreach (BsonDocument document in queryResults.ResultDocuments)
            {
                BsonDocument dateTime = document[utcDateKey].AsBsonDocument;

                long total = document[totalKey].ToInt64();
                long occurrence = document[occurrenceKey].ToInt64();
                string typeName = document[ID_KEY][TYPE_KEY].AsString;
                string keyFilter = document[ID_KEY][KEY_FILTER].ToString();
                DateTime utcDateTime = ConvertDateTimeDocumentToDateTime(dateTime);

                IAggregationBuildableResult trackerResult = results.AddAggregationResult(utcDateTime, typeName, keyFilter, occurrence, total);
                var relevantNames = names.Where(x => x.GetFullyQualifiedNameFromFormattedString().StartsWith(typeName));
                foreach (string key in relevantNames )
                {
                    string fullyQualifiedName = key.GetFullyQualifiedNameFromFormattedString();
                    BsonValue measurementResult = document[key];
                    IMeasurement measurement =
                        specification.Counters.FirstOrDefault(x => x.FullyQualifiedPropertyName == fullyQualifiedName);
                    if (measurement != null)
                        trackerResult.AddMeasurementResult(measurement, measurementResult.ToString());
                }
            }

            return results;
        }