Ejemplo n.º 1
0
        public static void LogError(Exception ex, HttpContext httpContext, ExpenseConnection _conn)
        {
            var appErrors = new AppErrors();

            try
            {
                appErrors.Host = httpContext.Request.Host.HasValue ? httpContext.Request.Host.ToString() : "";

                appErrors.IpAddress = httpContext.Request.HttpContext.Connection.RemoteIpAddress.ToString();

                appErrors.Url = httpContext.Request.Path;

                appErrors.HttpMethod = httpContext.Request.Method;

                var userId = httpContext.User.Claims.Where(c => c.Type == ClaimTypes.PrimarySid).FirstOrDefault()?.Value;

                if (!string.IsNullOrEmpty(userId))
                {
                    appErrors.UserId = Convert.ToInt32(userId);
                }

                appErrors.Username = httpContext.User.Claims.Where(c => c.Type == ClaimTypes.Name).FirstOrDefault()?.Value;

                appErrors.StackTrace = ex.StackTrace;

                appErrors.InnerException = ex.InnerException.Message;

                appErrors.TimeStamp = DateTime.Now;

                _conn.BeginTransaction();
                _conn.Insert(appErrors);
                _conn.Commit();
            }
            catch (Exception ex1)
            {
                if (_conn.InTransaction)
                {
                    _conn.RollBack();
                }
                var x = ex1.Message.ToString();
            }
        }
Ejemplo n.º 2
0
 public static void Log(Exception Ex, HttpContext Context, ExpenseConnection _conn)
 {
 }
Ejemplo n.º 3
0
 public void LogExecption(Exception ex, ExpenseConnection _conn)
 {
     ErrorLog.LogError(ex, Request.HttpContext, _conn);
 }