Esempio n. 1
0
        /// <summary>
        /// Loads the MiniProfiler identifed by 'id' from the database.
        /// </summary>
        public override MiniProfiler Load(Guid id)
        {
            var query = Query.EQ("_id", id.ToString());

            var profilerPoco = Profilers.FindOne(query);

            if (profilerPoco != null)
            {
                var profiler = new MiniProfiler
                {
                    Id            = Guid.Parse(profilerPoco.Id),
                    Name          = profilerPoco.Name,
                    Started       = profilerPoco.Started,
                    MachineName   = profilerPoco.MachineName,
                    User          = profilerPoco.User,
                    Level         = profilerPoco.Level,
                    HasUserViewed = profilerPoco.HasUserViewed
                };

                if (profiler != null)  //This is very similar to the Load logic in the SqlServerStorage.
                //Perhaps another abstraction layer(or moving some logic into the Base) which both Mongo and Sql inherit from would eliminate somewhat repetitive code.
                {
                    var           timings          = LoadTimings(profiler.Id);
                    var           sqlTimings       = LoadSqlTimings(profiler.Id);
                    var           sqlParams        = LoadSqlTimingParameters(profiler.Id);
                    var           clientTimingList = LoadClientTimings(profiler.Id);
                    ClientTimings clientTimings    = null;
                    if (clientTimingList.Count > 0)
                    {
                        clientTimings         = new ClientTimings();
                        clientTimings.Timings = clientTimingList;
                    }

                    MapTimings(profiler, timings, sqlTimings, sqlParams, clientTimings);
                }

                profiler.OnDeserialized(new StreamingContext());

                return(profiler);
            }

            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Loads the MiniProfiler identifed by 'id' from the database.
        /// </summary>
        public override MiniProfiler Load(Guid id)
        {
            var query = Query.EQ("_id", id.ToString());

            var profilerPoco = Profilers.FindOne(query);

            if (profilerPoco != null)
            {
                var profiler = new MiniProfiler
                {
                    Id = Guid.Parse(profilerPoco.Id),
                    Name = profilerPoco.Name,
                    Started = profilerPoco.Started,
                    MachineName = profilerPoco.MachineName,
                    User = profilerPoco.User,
                    Level = profilerPoco.Level,
                    HasUserViewed = profilerPoco.HasUserViewed
                };

                if (profiler != null)  //This is very similar to the Load logic in the SqlServerStorage.
                    //Perhaps another abstraction layer(or moving some logic into the Base) which both Mongo and Sql inherit from would eliminate somewhat repetitive code.
                {
                    var timings = LoadTimings(profiler.Id);
                    var sqlTimings = LoadSqlTimings(profiler.Id);
                    var mongoTimings = LoadMongoTimings(profiler.Id);
                    var sqlParams = LoadSqlTimingParameters(profiler.Id);
                    var clientTimingList = LoadClientTimings(profiler.Id);
                    ClientTimings clientTimings = null;
                    if (clientTimingList.Count > 0)
                    {
                        clientTimings = new ClientTimings();
                        clientTimings.Timings = clientTimingList;
                    }

                    MapTimings(profiler, timings, sqlTimings, sqlParams, clientTimings, mongoTimings);
                }

                profiler.OnDeserialized();

                return profiler;
            }

            return null;
        }