public override void OnActionExecuting(HttpActionContext actionContext) { log = new HttpWebAPILog(); RequestId = ActionId++; var strary = actionContext.Request.RequestUri.AbsolutePath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); controllername = strary[1]; ClientIp = ((HttpContextWrapper)actionContext.Request.Properties["MS_HttpContext"]).Request.UserHostAddress; if (ClientIp == "::1") { ClientIp = "localhost"; } var par = GetArguments(actionContext); log.RequestArguments = par; log.RequestIP = ClientIp ?? "localhost"; log.RequestMethod = actionContext.Request.Method.ToString(); log.RequestUri = actionContext.Request.RequestUri.ToString(); log.RequestDate = DateTime.Now; var id = httpApiLogBLL.AddLog(log); log.ID = id; if (_IsDebugLog) { Stopwatch stopWatch = new Stopwatch(); actionContext.Request.Properties[Key] = stopWatch; Debug.Print(JsonConvert.SerializeObject(actionContext.ActionArguments)); stopWatch.Start(); } }
public int AddLog(HttpWebAPILog webAPILog) { return(apiLogDAL.Add(webAPILog, "", 1)); }
public bool UpdateLog(HttpWebAPILog webAPILog) { return(apiLogDAL.Update(webAPILog, "ID,Milliseconds,ResponseDate,ResponseResult,StateCode", "")); }