public static void LoginLog_Insert(Resp_OpenUser_Login login, Req_Open_Login openlog) { var agent = WebOperationContext.Current.IncomingRequest.UserAgent; var ua = UserAgentCache.CreateOrGetCacheItem(agent); var log = new Users_LoginLogs_Info(); log.ul_type = openlog.us_type; log.ul_createTime = DateTime.Now; log.ul_ip = Util.Get_RemoteIp(); log.ul_os = ua.GetPlatform(); log.ul_browser = ua.GetBrowser(); log.ul_clientId = openlog.us_uid; log.ul_userAgent = agent; log.ul_u_uid = login.u_id; log.ul_u_name = openlog.us_nick; // 登陆名 log.ul_status = 1; // 1 -> NORMAL; 0 -> EXCEPTION log.ul_error = "正常"; DataAccess.LoginLog_Insert(log); }
/// <summary> /// /// </summary> /// <param name="head"></param> /// <returns></returns> public static AppOrgCompanyLogInfo To_AppOrgCompanyLog(this Request_Head h) { var l = new AppOrgCompanyLogInfo(); l.cl_browser = UserAgentCache.CreateOrGetCacheItem(WebOperationContext.Current.IncomingRequest.UserAgent).GetBrowser(); l.cl_cookieId = h.Cookie; l.cl_date = DateTime.Now; l.cl_screenSize = h.Screen_Size; l.cl_appVer = h.App_Ver; if (h.Platform == Platform.Android) { l.cl_osName = "Android"; } else if (h.Platform == Platform.Iphone) { l.cl_osName = "IOS"; } return(l); }
/// <summary> /// 插入访问日志或分享日志 /// </summary> /// <param name="rData"></param> /// <param name="shareUrl"></param> /// <param name="preTableName"></param> /// <returns></returns> private int VisitLog_Insert(NewsContentInfo_RD rData, string shareUrl, string preTableName = "VisitLog_") { WebOperationContext context = WebOperationContext.Current; context.OutgoingResponse.ContentType = "application/json; charset=utf-8"; VisitLogInfo vlog = new VisitLogInfo(); IncomingWebRequestContext inContext = context.IncomingRequest; UserAgent ua = UserAgentCache.CreateOrGetCacheItem(inContext.UserAgent); vlog.vl_browser = ua.GetBrowser(); vlog.vl_cookieId = string.Empty; vlog.vl_createTime = DateTime.Now; vlog.vl_gid = rData.n_gid; vlog.vl_id = 0; vlog.vl_ip = Util.Get_RemoteIp(); vlog.vl_remoteAddr = vlog.vl_ip; vlog.vl_osName = ua.GetPlatform(); // todo 操作系统的获取可能需要重新实现 //UserAgent.KeyItem ki = ua.Spider(); vlog.vl_spiderName = rData.vl_spiderName != null?ShareFlatform(rData.vl_spiderName) : string.Empty; vlog.vl_referrer = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.RequestUri.OriginalString + "/" + rData.n_gid; vlog.vl_url = shareUrl;// 拼接成PC端地址 vlog.vl_cateId = rData.vl_cateId; //vlog.vl_screenSize = string.Empty; vlog.vl_totalTime = 0; vlog.vl_type = rData.vl_type; string userName = rData.vl_userId; vlog.vl_userName = (userName == "|") ? "" : userName; vlog.vl_screenSize = rData.vl_screenSize; vlog.vl_host = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.RequestUri.Host; // 主域名 string tblName = preTableName + vlog.vl_createTime.ToString("yyyyMMdd"); // 插入表的表名 // 插入浏览记录 int logIndex = DataAccess_News.VisitLog_Insert(vlog, tblName); return(logIndex); }