public static List <StatDTO> GetStatWeb( )
        {
            string str = @"select
HttpVerb as HttpVerb,
Name as URI, Count(NAME)  as RequestCount,Sum(DurationMilliseconds) as SumDurationMilliseconds, 
round(Avg(DurationMilliseconds),2) as AvgDurationMilliseconds,  
Max(DurationMilliseconds) as MaxDurationMilliseconds,
Sum(ErrorCount) as ErrorCount, 
Sum(DbCount) as SumDbCount, 
Sum(DbDuration) as SumDbDurationMilliseconds,
count(case when DurationMilliseconds >=0 and DurationMilliseconds <=1 then SEQ end) as DurationMilliseconds1,
count(case when DurationMilliseconds>1 and DurationMilliseconds <=10 then SEQ end) as DurationMilliseconds2,
count(case when DurationMilliseconds>10 and DurationMilliseconds <=100 then SEQ end) as DurationMilliseconds3,
count(case when DurationMilliseconds>100 and DurationMilliseconds <=1000 then SEQ end) as DurationMilliseconds4,
count(case when DurationMilliseconds>1000 and DurationMilliseconds <=10000 then SEQ end) as DurationMilliseconds5,
count(case when DurationMilliseconds>10000 and DurationMilliseconds <=100000 then SEQ end) as DurationMilliseconds6,
count(case when DurationMilliseconds>100000 then SEQ end) as DurationMilliseconds7
 from sys_pureprofiling  
where Type ='session' group by NAME, HttpVerb order by  RequestCount desc";


            var config = ConfigurationHelper.LoadPureProfilerConfigurationSection();

            if (config.DbType == "oracle")
            {
                str = @"select
HttpVerb as HttpVerb,
Name as URI, Count(NAME)  as RequestCount,Sum(DurationMilliseconds) as SumDurationMilliseconds, 
ROUND(Avg(DurationMilliseconds),2) as AvgDurationMilliseconds,  
Max(DurationMilliseconds) as MaxDurationMilliseconds,
Sum(ErrorCount) as ErrorCount, 
Sum(DbCount) as SumDbCount, 
Sum(DbDuration) as SumDbDurationMilliseconds,
count(case when DurationMilliseconds >=0 and DurationMilliseconds <=1 then SEQ end) as DurationMilliseconds1,
count(case when DurationMilliseconds>1 and DurationMilliseconds <=10 then SEQ end) as DurationMilliseconds2,
count(case when DurationMilliseconds>10 and DurationMilliseconds <=100 then SEQ end) as DurationMilliseconds3,
count(case when DurationMilliseconds>100 and DurationMilliseconds <=1000 then SEQ end) as DurationMilliseconds4,
count(case when DurationMilliseconds>1000 and DurationMilliseconds <=10000 then SEQ end) as DurationMilliseconds5,
count(case when DurationMilliseconds>10000 and DurationMilliseconds <=100000 then SEQ end) as DurationMilliseconds6,
count(case when DurationMilliseconds>100000 then SEQ end) as DurationMilliseconds7
 from sys_pureprofiling  
where Type ='session' group by NAME, HttpVerb order by  RequestCount desc";
            }


            using (var db = new PureProfilingDbContext())
            {
                var dt = db.ExecuteList <StatDTO>(str);// db.ExecuteDataTable(str);

                return(dt);
            }


            return(null);
        }
Example #2
0
        /// <summary>
        /// Saves an <see cref="ITimingSession"/>.
        /// </summary>
        /// <param name="session"></param>
        protected override void Save(ITimingSession session)
        {
            try
            {
                //if (!Logger.Value.IsInfoEnabled)
                //{
                //    return;
                //}

                if (session == null)
                {
                    return;
                }

                var v = FormatTimingSession(session);
                //SaveSessionJson(session);

                using (var db = new PureProfilingDbContext())
                {
                    if (session.Timings == null)
                    {
                        return;
                    }
                    long errorCount = 0;
                    foreach (var timing in session.Timings)
                    {
                        if (timing == null)
                        {
                            continue;
                        }

                        //SaveTimingJson(session, timing);
                        var v2 = FormatTiming(session, timing);

                        db.Insert <PureProfilingEntity>(v2, null);
                        errorCount += v2.ErrorCount;
                    }

                    v.ErrorCount = errorCount;
                    db.Insert <PureProfilingEntity>(v, null);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("PureProfiler DatabaseProfilingStorage Save error:" + ex);
            }
        }