Exemplo n.º 1
0
        private async Task Log(System.Web.Routing.RouteData routeData, HttpContextBase httpContext)
        {
            if (httpContext.Request.RequestType == "POST")
            {
                string userIP     = httpContext.Request.UserHostAddress;
                string userName   = httpContext.User.Identity.Name;
                string reqType    = httpContext.Request.RequestType;
                string reqData    = GetRequestData(httpContext);
                string controller = routeData.Values["controller"].ToString();
                string action     = routeData.Values["action"].ToString();

                //SAVE LOG
                try
                {
                    Inaeba_SaptraEntities db = new Inaeba_SaptraEntities();
                    db.mBitacora.Add(new mBitacora()
                    {
                        ExecuteDate = DateTime.Now,
                        Ip          = userIP,
                        Username    = userName,
                        Reqtype     = reqType,
                        Reqdata     = reqData,
                        Controller  = controller,
                        Action      = action
                    });
                    await db.SaveChangesAsync();

                    db.Dispose();
                }
                catch { }
            }
        }