Exemple #1
0
        public static PerformanceEvent Write(PerformanceEvent performanceEvent)
        {
            String _dbConnection = ConfigurationManager.ConnectionStrings["IconoDB"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(_dbConnection))
            {
                SqlCommand command = connection.CreateCommand();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "[icoProd].[InsertUserPageRequest]";

                command.Parameters.AddWithValue("@pageUrl", EnsureFit(performanceEvent.RequestUrl, 4000));
                command.Parameters.AddWithValue("@urlParameters", EnsureFit(performanceEvent.RequestParameters, 4000));
                command.Parameters.AddWithValue("@duration", EnsureFit(performanceEvent.RequestDuration, int.MaxValue));
                command.Parameters.AddWithValue("@contactID", performanceEvent.ContactID);
                command.Parameters.AddWithValue("@aspnetSessionID", EnsureFit(performanceEvent.SessionID, 50));
                command.Parameters.AddWithValue("@isPostRequest", performanceEvent.IsPostRequest);
                var outParam = command.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int));
                outParam.Direction = ParameterDirection.Output;

                connection.Open();
                command.ExecuteNonQuery();

                int PerformanceEventID = (int)command.Parameters["@ID"].Value;
                performanceEvent.ID = PerformanceEventID;
            }
            return(performanceEvent);
        }
       public static PerformanceEvent Write(PerformanceEvent performanceEvent)
       {
          String _dbConnection = ConfigurationManager.ConnectionStrings["IconoDB"].ConnectionString;

          using (SqlConnection connection = new SqlConnection(_dbConnection))
          {
              SqlCommand command = connection.CreateCommand();
              command.CommandType = CommandType.StoredProcedure;
              command.CommandText = "[icoProd].[InsertUserPageRequest]";

              command.Parameters.AddWithValue("@pageUrl", EnsureFit(performanceEvent.RequestUrl, 4000));
              command.Parameters.AddWithValue("@urlParameters", EnsureFit(performanceEvent.RequestParameters, 4000));
              command.Parameters.AddWithValue("@duration", EnsureFit(performanceEvent.RequestDuration, int.MaxValue));
              command.Parameters.AddWithValue("@contactID", performanceEvent.ContactID);
              command.Parameters.AddWithValue("@aspnetSessionID", EnsureFit(performanceEvent.SessionID, 50));
              command.Parameters.AddWithValue("@isPostRequest", performanceEvent.IsPostRequest);          
              var outParam = command.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int));
              outParam.Direction = ParameterDirection.Output;
              
              connection.Open();
              command.ExecuteNonQuery();

              int PerformanceEventID  = (int)command.Parameters["@ID"].Value;
              performanceEvent.ID = PerformanceEventID;             
          }
          return performanceEvent;
       }
        public PerformanceEvent LogPerformanceRequest(HttpRequest request, int contactId, string sessionId, long totalMilliseconds)
        {
            PerformanceEvent performanceEvent = CreatePerformanceEvent(request, contactId, sessionId, totalMilliseconds);

            PerformanceEventDbUtil.Write(performanceEvent);

            return(performanceEvent);
        }
        private PerformanceEvent CreatePerformanceEvent(HttpRequest request, int contactId, string sessionId, long totalMilliseconds)
        {
            PerformanceEvent performanceEvent = new PerformanceEvent()
            {
                RequestUrl        = request.Path,
                RequestParameters = request.Url.Query,
                RequestDuration   = totalMilliseconds,
                IsPostRequest     = (request.RequestType.ToLower() == "post"),
                ContactID         = contactId,
                SessionID         = sessionId
            };

            return(performanceEvent);
        }
        private PerformanceEvent CreatePerformanceEvent(HttpRequest request, int contactId, string sessionId, long totalMilliseconds)
        {
            PerformanceEvent performanceEvent = new PerformanceEvent()
            {
                RequestUrl = request.Path,
                RequestParameters = request.Url.Query,
                RequestDuration = totalMilliseconds,
                IsPostRequest = (request.RequestType.ToLower() == "post"),
                ContactID = contactId,
                SessionID = sessionId
            };

            return performanceEvent;
        }