Exemplo n.º 1
0
        public override void OnTestMetric(string virtualUser, TestMetricEventArgs args)
        {
            try
            {
                if (!args.ElapsedTime.Equals(TimeSpan.Zero))
                {
                    var flattenedArgs = args.FlattenStateArgs();

                    var metric = string.Format(testMetricInsert,
                                               testRunId,
                                               args.VirtualUser,
                                               args.PerfID,
                                               args.Description,
                                               args.StartTime,
                                               args.StopTime,
                                               args.ElapsedTime.TotalSeconds,
                                               flattenedArgs);
#if VERBOSE
                    TestTrace.Trace(metric);
#endif

                    using (SqlCommand sqlCommand = sqlConnection.CreateCommand())
                    {
                        sqlCommand.CommandText = metric;
                        sqlCommand.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception e)
            {
                TestTrace.Trace(e.ToString());
            }
        }
        public override void OnTestMetric(string virtualUser, TestMetricEventArgs args)
        {
            if (!args.ElapsedTime.Equals(TimeSpan.Zero))
            {
                var flattenedArgs = args.FlattenStateArgs();

                var metric = string.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}",
                                           args.VirtualUser, args.PerfID, args.Description,
                                           formatDateTime(args.StartTime),
                                           formatDateTime(args.StopTime),
                                           args.ElapsedTime.TotalSeconds,
                                           string.IsNullOrEmpty(flattenedArgs) ? "" : string.Format("\"{0}\"", flattenedArgs));

                _metricsContent.AppendLine(metric);
            }
        }