Esempio n. 1
0
        public int LogErrorInternal(string message, ErrorType type, Exception e, HttpContextLoggerInfo wrapper)
        {
            var connection = new SqlConnection(ConnectionString);
            var cmd = new SqlCommand("dbo.LogError", connection) {
                CommandType = CommandType.StoredProcedure
            };

            var requestIdParameter = new SqlParameter("RequestId", SqlDbType.BigInt) {
                Direction = ParameterDirection.InputOutput
            };
            cmd.Parameters.Add(requestIdParameter);

            if (wrapper == null)
            {
                requestIdParameter.Value = null;
            }
            else
            {
                SetWebEnabledParameters(cmd, wrapper);
                requestIdParameter.Value = wrapper.Items[REQUEST_ID_CONTEXT_KEY];
            }

            SetStandAloneErrorParameters(message, type, e, cmd);

            ExecuteCommand(connection, cmd);
            RequestId = Convert.ToInt32(cmd.Parameters["RequestId"].Value);

            if (wrapper != null && wrapper.Items[REQUEST_ID_CONTEXT_KEY] == null)
            {
                wrapper.Items[REQUEST_ID_CONTEXT_KEY] = RequestId;
            }

            return Convert.ToInt32(cmd.Parameters["ErrorId"].Value);
        }
Esempio n. 2
0
        public void LogSecurityEventInternal(EventType type, Result result, string description, HttpContextLoggerInfo wrapper)
        {
            var connection = new SqlConnection(ConnectionString);
            var cmd = new SqlCommand("dbo.LogSecurityEvent", connection) {
                CommandType = CommandType.StoredProcedure
            };

            var requestIdParameter = new SqlParameter("RequestId", SqlDbType.BigInt) {
                Direction = ParameterDirection.InputOutput
            };
            cmd.Parameters.Add(requestIdParameter);

            if (wrapper == null)
            {
                requestIdParameter.Value = null;
            }
            else
            {
                SetWebEnabledParameters(cmd, wrapper);
                requestIdParameter.Value = wrapper.Items[REQUEST_ID_CONTEXT_KEY];
            }

            SetStandAloneSecurityEventParameters(description, type, result, cmd);

            ExecuteCommand(connection, cmd);
            RequestId = Convert.ToInt32(cmd.Parameters["RequestId"].Value);

            if (wrapper != null && wrapper.Items[REQUEST_ID_CONTEXT_KEY] == null)
            {
                wrapper.Items[REQUEST_ID_CONTEXT_KEY] = RequestId;
            }
        }
Esempio n. 3
0
        private static void SetWebEnabledParameters(SqlCommand cmd, HttpContextLoggerInfo wrapper)
        {
            cmd.Parameters.Add(new SqlParameter("SessionKey", SqlDbType.NVarChar)).Value
                = wrapper.SessionID;

            cmd.Parameters.Add(new SqlParameter("Ip", SqlDbType.NChar)).Value
                = wrapper.UserHostAddress;

            cmd.Parameters.Add(new SqlParameter("UserAgent", SqlDbType.NVarChar)).Value
                = wrapper.UserAgent;

            cmd.Parameters.Add(new SqlParameter("UserId", SqlDbType.NVarChar)).Value
                = wrapper.UserName;

            cmd.Parameters.Add(new SqlParameter("Uri", SqlDbType.NVarChar)).Value
                = wrapper.AbsoluteUri;
        }