/// <summary> /// 网页访问日志(异步) /// </summary> /// <param name="subName"></param> /// <param name="message"></param> /// <param name="accId"></param> /// <param name="flag"></param> /// <param name="oHttp"></param> public static void AsyncLogEx(string subName, string message, int accId, string flag, HttpRequest oHttp = null) { try { var model = new WebLogModel(); model.Message = message; model.TargetName = message; model.SubName = subName; model.AccId = accId; model.Flag = flag; if (oHttp != null) { model.ActDate = DateTime.Now; model.TargetName = ""; model.UserAgent = oHttp.UserAgent; if (oHttp.Browser != null) { model.BrowserName = oHttp.Browser.Browser; model.BrowserVer = oHttp.Browser.Version; } if (oHttp.UserHostAddress != null) { model.FromIp = oHttp.UserHostAddress; } if (oHttp.UrlReferrer != null) { model.FromUrl = oHttp.UrlReferrer.ToString(); } } AsyncLog(model); } catch (Exception) { } }
/// <summary> /// 网页访问日志(异步) /// </summary> /// <param name="model"></param> public static void AsyncLog(WebLogModel model) { try { Task.Run(() => { WebLog(model); }); } catch (Exception) { } }
/// <summary> /// 网页访问日志 /// </summary> /// <param name="logModel"></param> public static void WebLog(WebLogModel webLogModel) { try { var logger = new LogCenter(); var logModel = new WebModel(); logModel.AccId = webLogModel.AccId; logModel.SubName = webLogModel.SubName; logModel.ActDate = webLogModel.ActDate; logModel.BrowserName = webLogModel.BrowserName; logModel.BrowserVer = webLogModel.BrowserVer; logModel.FromIp = webLogModel.FromIp; logModel.FromUrl = webLogModel.FromUrl; logModel.TargetName = webLogModel.TargetName; logModel.UserAgent = webLogModel.UserAgent; logModel.FromName = webLogModel.Message; logModel.ClientType = webLogModel.Flag; logger.WebLog(logModel); } catch (Exception) { } }