public void AddEvent(string strManagerName, string strMsg, int intType) { EventLogInfo eventLogInfo = new EventLogInfo(); eventLogInfo.UserName = strManagerName; eventLogInfo.EventType = intType; eventLogInfo.Lang = JObject.cultureLang; string iP = IPUtils.GetIP(); if (!string.IsNullOrEmpty(iP)) { eventLogInfo.IPAddress = iP; if (intType.Equals(1)) { eventLogInfo.IPArea = IPUtils.GetIPAreaFromPcOnline(eventLogInfo.IPAddress); } else { eventLogInfo.IPArea = string.Empty; } } else { eventLogInfo.IPAddress = "127.0.0.1"; eventLogInfo.IPArea = "未知地址或者获取地址失败"; } eventLogInfo.EventInfo = strMsg; eventLogInfo.AutoTimeStamp = DateTime.Now; EventLog.Add(eventLogInfo); }
private void AddComment() { int formInt = WebUtils.GetFormInt("cmtcontid", 0); ContentInfo contentById = Content.GetContentById(formInt); string formString = WebUtils.GetFormString("cmtusername"); string formString2 = WebUtils.GetFormString("cmtemail"); string formString3 = WebUtils.GetFormString("cmttitle"); string formString4 = WebUtils.GetFormString("cmtcontent"); string formString5 = WebUtils.GetFormString("ccode"); if (base.ValidateCode != formString5) { base.Response.Write("验证码不正确"); } else if (contentById == null) { base.Response.Write("没有找到相关内容"); } else if (string.IsNullOrEmpty(formString)) { base.Response.Write("用户名称不为空"); } else if (string.IsNullOrEmpty(formString3)) { base.Response.Write("标题不为空"); } else if (string.IsNullOrEmpty(formString4)) { base.Response.Write("评论内容不为空"); } else if (Comment.Add(new CommentInfo { Content = formString4, ContID = contentById.AutoID, ContName = contentById.Title, EnableAnonymous = true, IPAddress = IPUtils.GetIP(), IPArea = string.Empty, IsAudit = true, IsReply = false, Lang = base.cultureLang, ReplyID = 0, Title = formString3, UserID = 0, UserName = formString, AutoTimeStamp = System.DateTime.Now }) > 0) { base.Response.Write("发表评论成功"); } else { base.Response.Write("发表评论失败"); } }
public IActionResult Index() { /* * net core不自带httpcontext 需要在 Startup 注入 * 1、在ConfigureServices 中 services.AddStaticHttpContext(); * 2、在Configure 中 app.UseStaticHttpContext(); */ var builder = new StringBuilder("测试如下:\r\n"); //Post builder.Append($"Post值:{WebUtils.GetFormVal<string>("a")}\r\n"); //IP builder.Append($"IP:{IPUtils.GetIP()}\r\n"); //WebUtils builder.Append($"pid:{WebUtils.GetQueryVal<int>("pid")}\r\n"); //?pid=1 builder.Append($"date:{WebUtils.GetQueryVal<DateTime>("date", new DateTime(1900, 1, 1))}\r\n"); //?date=2020-12-31 //全url builder.Append($"全URL:{WebUtils.GetAbsoluteUri()}\r\n"); //CacheUtils 缓存 DateTime dateTime = DateTime.Now; var cache = new CacheUtils(); var cacheDT = DateTime.Now; if (cache.ContainKey("time")) { cacheDT = cache.Get <DateTime>("time"); } else { cache.Insert <DateTime>("time", dateTime, 3600); } builder.Append($"当前时间:{dateTime.ToFormatString()} \r\n"); builder.Append($"缓存时间:{cacheDT.ToFormatString()} \r\n"); //当前网站目录 builder.Append($"当前网站目录:{SystemUtils.GetMapPath()} \r\n"); builder.Append($"upload目录:{SystemUtils.GetMapPath("/upload")} \r\n"); //cookie CookieUtils.SetCookie("username", "jsonlee"); builder.Append($"username cookie: {CookieUtils.GetCookie("username")} \r\n"); //session SessionUtils.SetSession("username", System.Web.HttpUtility.UrlEncode("刘备")); builder.Append($"username session: {System.Web.HttpUtility.UrlDecode(SessionUtils.GetSession("username"))} \r\n"); return(Content(builder.ToString())); }
public static bool HasCai(int intCommentID) { CommentActiveLogInfo model = BizBase.dbo.GetModel <CommentActiveLogInfo>(string.Concat(new object[] { " SELECT TOP 1 * FROM cms_CommentActiveLog WHERE IsCai=1 AND CommentID=", intCommentID, " AND IPAddress='", IPUtils.GetIP(), "' ORDER BY AutoID DESC " })); return(model != null); }
public ActionResult Index() { var builder = new StringBuilder("测试如下:<br/>\r\n"); //IP builder.Append($"IP:{IPUtils.GetIP()}<br/>\r\n"); //WebUtils builder.Append($"pid:{WebUtils.GetQueryInt("pid")}<br/>\r\n"); //?pid=1 //全url builder.Append($"全URL:{WebUtils.GetAbsoluteUri()}<br/>\r\n"); //CacheUtils 缓存 DateTime dateTime = DateTime.Now; var cache = new CacheUtils(); var cacheDT = DateTime.Now; if (cache.ContainKey("time")) { cacheDT = cache.Get <DateTime>("time"); } else { cache.Insert <DateTime>("time", dateTime, 3600); } builder.Append($"当前时间:{dateTime.ToFormatString()} <br/>\r\n"); builder.Append($"缓存时间:{cacheDT.ToFormatString()} <br/>\r\n"); //当前网站目录 builder.Append($"当前网站目录:{SystemUtils.GetMapPath()} <br/>"); builder.Append($"upload目录:{SystemUtils.GetMapPath("/upload")} <br/>"); //cookie CookieUtils.SetCookie("username", "jsonlee"); builder.Append($"username cookie: {CookieUtils.GetCookie("username")} <br/>\r\n"); //session SessionUtils.SetSession("username", "刘备"); builder.Append($"username session: {SessionUtils.GetSession<string>("username")} <br/>\r\n"); builder.Append($"mobile client : {SystemUtils.IsMobileClient.Value} <br/>\r\n"); builder.Append($"weixin client : {SystemUtils.IsWeixinClient.Value} <br/>\r\n"); builder.Append($"is iphone : {SystemUtils.IsIphone.Value} <br/>\r\n"); builder.Append($"is android : {SystemUtils.IsAndroid.Value} <br/>\r\n"); return(Content(builder.ToString())); }
public void AddLoginLog(UserType userType, string strUserName, bool isLogined) { LoginLogInfo last = LoginLog.GetLast(userType, strUserName); LoginLogInfo entity = new LoginLogInfo { UserType = userType.ToString(), UserName = strUserName, IPAddress = IPUtils.GetIP(), IPArea = ((userType == UserType.Manager) ? IPUtils.GetIPAreaFromPcOnline(IPUtils.GetIP()) : string.Empty), LoginStatus = (isLogined ? 1 : 0), LoginFailCount = ((!isLogined) ? ((last == null) ? 1 : (last.LoginFailCount + 1)) : 0), Lang = JObject.cultureLang, AutoTimeStamp = DateTime.Now }; LoginLog.Add(entity); }
/// <summary> /// 添加登录日志 /// </summary> /// <param name="info"></param> /// <returns></returns> public async Task Add(LogLoginRequest info) { string ua = _context.HttpContext.Request.Headers["User-Agent"]; var client = UAParser.Parser.GetDefault().Parse(ua); info.UserAgent = ua; info.Browser = client.UA.ToString(); info.Os = client.OS.ToString(); info.IP = IPUtils.GetIP(_context?.HttpContext?.Request); var model = _mapper.Map <LogLogin>(info); using (_db) { await _db.AddAsync(model); await _db.SaveChangesAsync(); } }
public static void RegAndLogin(string strUserName, string strSex, string strHeaderPhoto) { UserInfo userInfo = User.GetUserByName(strUserName); if (userInfo == null) { IEnumerable <UserGroupInfo> source = from p in UserGroup.GetCacheUserGroupList() where p.GroupName.Equals("个人会员") select p; IEnumerable <UserLevelInfo> source2 = from p in UserLevel.GetCacheUserLevelList() where p.LevelName.Equals("初级会员") select p; TaoBaoAreaInfo iPAreaFromTaoBao = IPUtils.GetIPAreaFromTaoBao(IPUtils.GetIP()); userInfo = new UserInfo { UserName = strUserName, Password = User.GetEncodePwd(StringUtils.GetRandomNumber(3, false)), GroupID = ((source.Count <UserGroupInfo>() > 0) ? source.First <UserGroupInfo>().AutoID : 0), LevelID = ((source2.Count <UserLevelInfo>() > 0) ? source2.First <UserLevelInfo>().AutoID : 0), Email = string.Empty, Mobile = string.Empty, NickName = strUserName, Gender = strSex, HeaderPhoto = strHeaderPhoto, Country = ((iPAreaFromTaoBao == null) ? string.Empty : iPAreaFromTaoBao.data.country), Province = ((iPAreaFromTaoBao == null) ? string.Empty : iPAreaFromTaoBao.data.region), City = ((iPAreaFromTaoBao == null) ? string.Empty : iPAreaFromTaoBao.data.city), County = ((iPAreaFromTaoBao == null) ? string.Empty : iPAreaFromTaoBao.data.country), Status = 99, AutoTimeStamp = DateTime.Now }; User.Reg(userInfo); } if (User.UserLogin(userInfo.UserName, userInfo.Password) == LoginStatus.Success) { HttpContext.Current.Response.Redirect("/user/infocenter"); } }
public static VisitorInfo GetVisitorInfo() { VisitorInfo result; if (HttpContext.Current != null) { VisitorInfo visitorInfo = new VisitorInfo(); HttpContext.Current.Response.Expires = 0; NameValueCollection serverVariables = HttpContext.Current.Request.ServerVariables; visitorInfo.IPAddress = IPUtils.GetIP(); string text = serverVariables["HTTP_USER_AGENT"] ?? string.Empty; visitorInfo.UserAgent = text; visitorInfo.OPSystem = STATClient.GetOPSystem(text); visitorInfo.CustomerLang = ((HttpContext.Current.Request.UserLanguages != null) ? HttpContext.Current.Request.UserLanguages[0].ToLower() : string.Empty); visitorInfo.Navigator = STATClient.GetBrowser(text); HttpBrowserCapabilities browser = HttpContext.Current.Request.Browser; visitorInfo.IsMobileDevice = browser.IsMobileDevice; visitorInfo.IsSupportActiveX = browser.ActiveXControls; visitorInfo.IsSupportCookie = browser.Cookies; visitorInfo.IsSupportJavascript = browser.JavaScript; if (browser.ClrVersion == null) { visitorInfo.NETVer = "不支持"; } else { visitorInfo.NETVer = browser.ClrVersion.ToString(); } visitorInfo.IsCrawler = browser.Crawler; visitorInfo.VPage = HttpContext.Current.Request.Url.ToString(); if (HttpContext.Current.Request.UrlReferrer != null) { string text2 = HttpContext.Current.Request.UrlReferrer.ToString(); if (text2 != "" && text2.Substring(text2.Length - 1, 1) == "/") { text2 = text2.Substring(0, text2.Length - 1); } visitorInfo.ApproachUrl = text2; string[] array = STATClient.GetSearchEngine(text2).Split(new char[] { '|' }); if (array.Length == 3) { visitorInfo.Engine = array[0] + "[" + array[1] + "]"; visitorInfo.KeyWord = array[2]; } } else { visitorInfo.ApproachUrl = "手动输入地址"; } if (HttpContext.Current.Request.Cookies.Count > 0) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < HttpContext.Current.Request.Cookies.Count; i++) { if (i == HttpContext.Current.Request.Cookies.Count - 1) { stringBuilder.Append(HttpContext.Current.Request.Cookies[i].Name + ":" + HttpContext.Current.Request.Cookies[i].Values); } else { stringBuilder.Append(string.Concat(new object[] { HttpContext.Current.Request.Cookies[i].Name, ":", HttpContext.Current.Request.Cookies[i].Values, "|" })); } } visitorInfo.CookieParameter = stringBuilder.ToString(); } if (HttpContext.Current.Request.QueryString.Count > 0) { StringBuilder stringBuilder2 = new StringBuilder(); for (int i = 0; i < HttpContext.Current.Request.QueryString.Count; i++) { if (i == HttpContext.Current.Request.QueryString.Count - 1) { stringBuilder2.Append(HttpContext.Current.Request.QueryString.AllKeys[i] + ":" + HttpContext.Current.Request.QueryString[i]); } else { stringBuilder2.Append(HttpContext.Current.Request.QueryString.AllKeys[i] + ":" + HttpContext.Current.Request.QueryString[i] + "|"); } } visitorInfo.GETParameter = stringBuilder2.ToString(); } if (HttpContext.Current.Request.Form.Count > 0) { StringBuilder stringBuilder3 = new StringBuilder(); for (int i = 0; i < HttpContext.Current.Request.Form.Count; i++) { string a = HttpContext.Current.Request.Form.AllKeys[i]; if (a != "__VIEWSTATE") { if (i == HttpContext.Current.Request.Form.Count - 1) { stringBuilder3.Append(HttpContext.Current.Request.Form.AllKeys[i] + ":" + HttpContext.Current.Request.Form[i]); } else { stringBuilder3.Append(HttpContext.Current.Request.Form.AllKeys[i] + ":" + HttpContext.Current.Request.Form[i] + "|"); } } } visitorInfo.POSTParameter = stringBuilder3.ToString(); } visitorInfo.ErrMessage = string.Empty; visitorInfo.StackTrace = string.Empty; visitorInfo.Lang = JObject.cultureLang; visitorInfo.AutoTimeStamp = DateTime.Now; result = visitorInfo; } else { result = null; } return(result); }
protected void Page_Load(object sender, System.EventArgs e) { if (base.IsPost) { RegType regType = (RegType)System.Enum.Parse(typeof(RegType), WebUtils.GetFormString("_regtype", "Normal")); string strGroupName = WebUtils.GetFormString("_usergroupname", "个人会员"); System.Collections.Generic.IEnumerable <UserGroupInfo> source = from p in UserGroup.GetCacheUserGroupList() where p.GroupName.Equals(strGroupName) select p; System.Collections.Generic.IEnumerable <UserLevelInfo> source2 = (from p in UserLevel.GetCacheUserLevelList() orderby p.Integral select p).Take(1); TaoBaoAreaInfo iPAreaFromTaoBao = IPUtils.GetIPAreaFromTaoBao(IPUtils.GetIP()); UserInfo userInfo = new UserInfo { UserName = WebUtils.GetFormString("_regname"), Password = WebUtils.GetFormString("_regpwd"), GroupID = ((source.Count <UserGroupInfo>() > 0) ? source.First <UserGroupInfo>().AutoID : 0), LevelID = ((source2.Count <UserLevelInfo>() > 0) ? source2.First <UserLevelInfo>().AutoID : 0), Email = ((regType == RegType.ByEmail) ? WebUtils.GetFormString("_regname") : WebUtils.GetFormString("_regemail")), Mobile = ((regType == RegType.ByMobile) ? WebUtils.GetFormString("_regname") : WebUtils.GetFormString("_regmobile")), Country = ((iPAreaFromTaoBao == null) ? string.Empty : iPAreaFromTaoBao.data.country), Province = ((iPAreaFromTaoBao == null) ? string.Empty : iPAreaFromTaoBao.data.region), City = ((iPAreaFromTaoBao == null) ? string.Empty : iPAreaFromTaoBao.data.city), County = ((iPAreaFromTaoBao == null) ? string.Empty : iPAreaFromTaoBao.data.country), Status = 99, AutoTimeStamp = System.DateTime.Now }; string[] array = PageBase.config.SysUserName.Split(new char[] { ',' }); string strA = string.Empty; switch (regType) { case RegType.ByMobile: { SMSInfo lastCheckCode = SMS.GetLastCheckCode(userInfo.Mobile); if (lastCheckCode != null) { strA = lastCheckCode.ValidateCode; } goto IL_27A; } case RegType.ByEmail: { SMSInfo lastCheckCode = SMS.GetLastCheckCode(userInfo.Email); if (lastCheckCode != null) { strA = lastCheckCode.ValidateCode; } goto IL_27A; } } strA = base.ValidateCode; IL_27A: if (PageBase.config.VerifycodeForReg && string.Compare(strA, WebUtils.GetFormString("_regyzm"), true) != 0) { base.WriteJsonTip(base.GetCaption("ValidateCodeIncorrect")); } else if (userInfo.GroupID.Equals(0) || userInfo.LevelID.Equals(0)) { base.WriteJsonTip(base.GetCaption("Reg_MemberInfoNotComplete")); } else if (!SinGooCMS.BLL.User.IsValidUserName(userInfo.UserName) && !ValidateUtils.IsEmail(userInfo.UserName) && !ValidateUtils.IsMobilePhone(userInfo.UserName)) { base.WriteJsonTip(base.GetCaption("Reg_InvalidUserName")); } else if (array.Length > 0 && array.Contains(userInfo.UserName)) { base.WriteJsonTip(base.GetCaption("Reg_SystemRetainsUserName").Replace("${username}", userInfo.UserName)); } else if (SinGooCMS.BLL.User.IsExistsByName(userInfo.UserName)) { base.WriteJsonTip(base.GetCaption("Reg_UserNameAlreadyExists")); } else if (userInfo.Password.Length < 6) { base.WriteJsonTip(base.GetCaption("Reg_UserPwdLenNeed")); } else if (userInfo.Password != WebUtils.GetFormString("_regpwdagain")) { base.WriteJsonTip(base.GetCaption("Reg_2PwdInputNoMatch")); } else if (!string.IsNullOrEmpty(userInfo.Email) && !ValidateUtils.IsEmail(userInfo.Email)) { base.WriteJsonTip(base.GetCaption("Reg_EmailTypeError")); } else if (!string.IsNullOrEmpty(userInfo.Email) && SinGooCMS.BLL.User.IsExistsByEmail(userInfo.Email)) { base.WriteJsonTip(base.GetCaption("Reg_EmailAddressAlreadyExists")); } else if (!string.IsNullOrEmpty(userInfo.Mobile) && !ValidateUtils.IsMobilePhone(userInfo.Mobile)) { base.WriteJsonTip(base.GetCaption("Reg_MobileTypeError")); } else if (!string.IsNullOrEmpty(userInfo.Mobile) && SinGooCMS.BLL.User.IsExistsByMobile(userInfo.Mobile)) { base.WriteJsonTip(base.GetCaption("Reg_MobileAlreadyExists")); } else { int autoID = 0; System.Collections.Generic.IList <UserFieldInfo> fieldListByModelID = UserField.GetFieldListByModelID(userInfo.GroupID, true); System.Collections.Generic.Dictionary <string, UserFieldInfo> dictionary = new System.Collections.Generic.Dictionary <string, UserFieldInfo>(); foreach (UserFieldInfo current in fieldListByModelID) { current.Value = WebUtils.GetFormString(current.FieldName); dictionary.Add(current.FieldName, current); } UserStatus userStatus = SinGooCMS.BLL.User.Reg(userInfo, dictionary, ref autoID); if (userStatus.Equals(UserStatus.Success)) { new MsgService(userInfo).SendRegMsg(); new MsgService().SendRegMsg2Mger(); if (PageBase.config.RegGiveIntegral > 0) { userInfo.AutoID = autoID; AccountDetail.AddIntegral(userInfo, 1, (double)PageBase.config.RegGiveIntegral, "注册赠送积分"); } UserInfo userInfo2 = new UserInfo(); LoginStatus loginStatus = SinGooCMS.BLL.User.UserLogin(userInfo.UserName, userInfo.Password, ref userInfo2); string text = base.Server.UrlDecode(WebUtils.GetFormString("_regreturnurl")); if (!string.IsNullOrEmpty(text)) { base.WriteJsonTip(true, base.GetCaption("Reg_Success"), text); } else { base.WriteJsonTip(true, base.GetCaption("Reg_Success"), "/user/regsuccess.html?info=" + base.Server.UrlEncode(base.GetCaption("Reg_SuccessWillJumpMemberCenter"))); } } else { base.WriteJsonTip(base.GetCaption("Reg_FailWithMsg").Replace("${msg}", base.GetCaption("UserStatus_" + userStatus.ToString()))); } } } else { System.Collections.Generic.IEnumerable <UserGroupInfo> source3 = from p in UserGroup.GetCacheUserGroupList() where p.GroupName.Equals("个人会员") select p; base.Put("usermodel", UserField.GetFieldListByModelID((source3.Count <UserGroupInfo>() > 0) ? source3.First <UserGroupInfo>().AutoID : 0, true)); base.Put("returnurl", WebUtils.GetQueryString("returnurl")); base.UsingClient("user/注册.html"); } }
private void SaveFeedback() { string formString = WebUtils.GetFormString("_uname"); string formString2 = WebUtils.GetFormString("_email"); string formString3 = WebUtils.GetFormString("_mobile"); string formString4 = WebUtils.GetFormString("_phone"); string formString5 = WebUtils.GetFormString("_title"); string formString6 = WebUtils.GetFormString("_content"); if (string.Compare(base.ValidateCode, WebUtils.GetFormString("_yzm"), true) != 0) { base.Response.Write("{\"msg\":\"" + base.GetCaption("ValidateCodeIncorrect") + "\",\"status\":\"fail\"}"); } else if (string.IsNullOrEmpty(formString)) { base.Response.Write("{\"msg\":\"" + base.GetCaption("Feedback_UserNameEmpty") + "\",\"status\":\"fail\"}"); } else if (string.IsNullOrEmpty(formString6)) { base.Response.Write("{\"msg\":\"" + base.GetCaption("Feedback_ContentEmpty") + "\",\"status\":\"fail\"}"); } else { FeedbackInfo feedbackInfo = new FeedbackInfo { UserName = formString, Title = (string.IsNullOrEmpty(formString5) ? base.GetCaption("Feedback_Title").Replace("${username}", formString) : formString5), Content = formString6, Email = formString2, Mobile = formString3, Telephone = formString4, IPaddress = IPUtils.GetIP(), Replier = string.Empty, ReplyContent = string.Empty, ReplyDate = new System.DateTime(1900, 1, 1), IsAudit = true, Lang = base.cultureLang, AutoTimeStamp = System.DateTime.Now }; int num = Feedback.Add(feedbackInfo); if (num > 0) { string empty = string.Empty; if (WebUtils.GetBool(base.GetConfigValue("IsSendMailForLY")) && !string.IsNullOrEmpty(base.GetConfigValue("ReciverEMail"))) { if (MsgService.SendMail(base.GetConfigValue("ReciverEMail"), formString5, feedbackInfo.Content, out empty)) { base.Response.Write("{\"msg\":\"" + base.GetCaption("Feedback_Success") + "\",\"status\":\"success\"}"); } else { base.Response.Write("{\"msg\":\"" + base.GetCaption("Feedback_SuccessButMailFail") + "\",\"status\":\"fail\"}"); } } else { base.Response.Write("{\"msg\":\"" + base.GetCaption("Feedback_Success") + "\",\"status\":\"success\"}"); } } else { base.Response.Write("{\"msg\":\"" + base.GetCaption("Feedback_Error") + "\",\"status\":\"fail\"}"); } } }
public static LoginStatus UserLogin(string strLoginName, string strEncryPassword, ref UserInfo userRef) { SqlParameter[] arrParam = new SqlParameter[] { new SqlParameter("@loginname", strLoginName) }; userRef = BizBase.dbo.GetModel <UserInfo>(BizBase.dbo.ExecProcReReader("p_System_UserLogin", arrParam)); LoginLogInfo last = LoginLog.GetLast(UserType.User, strLoginName); LoginStatus result; if (userRef == null) { result = LoginStatus.UserNameIncorrect; } else if (last != null && last.LoginFailCount >= ConfigProvider.Configs.TryLoginTimes && (DateTime.Now - last.AutoTimeStamp).TotalMinutes < 5.0) { result = LoginStatus.MutilLoginFail; } else if (strEncryPassword != userRef.Password) { new LogManager().AddLoginLog(UserType.User, strLoginName, false); result = LoginStatus.PasswordIncorrect; } else if (userRef.Status != 99) { result = LoginStatus.StatusNotAllow; } else { HttpCookie httpCookie = new HttpCookie("singoouser"); httpCookie.Values["uid"] = userRef.AutoID.ToString(); httpCookie.Values["uname"] = HttpUtility.UrlEncode(userRef.UserName); httpCookie.Values["nickname"] = HttpUtility.UrlEncode(userRef.NickName); httpCookie.Values["pwd"] = HttpUtility.UrlEncode(DEncryptUtils.DESEncode(userRef.Password)); string cookieTime = ConfigProvider.Configs.CookieTime; if (cookieTime != null) { if (!(cookieTime == "一周")) { if (cookieTime == "一年") { httpCookie.Expires = DateTime.Now.AddYears(1); } } else { httpCookie.Expires = DateTime.Now.AddDays(7.0); } } HttpContext.Current.Response.Cookies.Add(httpCookie); userRef.LoginCount++; userRef.LastLoginIP = IPUtils.GetIP(); userRef.LastLoginTime = DateTime.Now; if (string.IsNullOrEmpty(userRef.Province)) { TaoBaoAreaInfo iPAreaFromTaoBao = IPUtils.GetIPAreaFromTaoBao(IPUtils.GetIP()); if (iPAreaFromTaoBao != null) { userRef.Country = iPAreaFromTaoBao.data.country; userRef.Province = iPAreaFromTaoBao.data.region; userRef.City = iPAreaFromTaoBao.data.city; userRef.County = iPAreaFromTaoBao.data.county; } } User.Update(userRef); new LogManager().AddLoginLog(UserType.User, strLoginName, true); result = LoginStatus.Success; } return(result); }