/// <summary> /// 判断是否登录成功 /// </summary> /// <returns></returns> private bool Is_Login_HongRenHui(string cookiename) { int userguid = 0; bool f = true; if (CookieManage2_HongRenHui.IsHaveCookie(cookiename)) { userguid = Convert.ToInt32(CookieManage2_HongRenHui.GetCookieValue(cookiename)); if (user_bll_h.Exists(userguid)) { //结束时间 DateTime end_time = CookieManage2_HongRenHui.GetCookieValue(cookiename, 2); //判断是否已经过期 if (!TimeParser.IsMoreSevenDays(DateTime.Now, end_time)) { f = false; } else { f = true; } } else { f = false; } } else { f = false; } return(f); }
/// <summary> /// 判断是否登录成功 /// </summary> /// <returns></returns> public bool Is_Logins() { int userguid = 0; bool f = true; try { if (CookieManage2.IsHaveCookie()) { userguid = Convert.ToInt32(CookieManage2.GetCookieValue()); if (user_bll_h.Exists(userguid)) { //结束时间 DateTime end_time = CookieManage2.GetCookieValue(2); //判断是否已经过期 if (!TimeParser.IsMoreSevenDays(DateTime.Now, end_time)) { f = false; } else { f = true; } } else { f = false; } } else { f = false; } } catch (Exception ex) { f = false; } return(f); }
/// <summary> /// 判断当前cookie是否存在,应用于后台 /// </summary> /// <param name="cookiename">名称</param> /// <returns></returns> public static bool IsLogin(string cookiename) { bool f = true; try { if (CookieManage.IsHaveCookie(cookiename)) { RED_USERID = Convert.ToInt32(CookieManage.GetCookieValue(cookiename)); if (user_bll_h.Exists(RED_USERID)) { //结束时间 DateTime end_time = CookieManage.GetCookieValue(cookiename, 2); //判断是否已经过期 if (!TimeParser.IsMoreSevenDays(DateTime.Now, end_time)) { f = false; } else { f = true; } } else { f = false; } } else { f = false; } } catch (Exception ex) { f = false; } return(f); }
/// <summary> /// 判断是否登录成功 /// </summary> /// <returns></returns> public static bool IsLogin() { bool f = true; try { if (CookieManage.IsHaveCookie()) { RED_USERID = Convert.ToInt32(CookieManage.GetCookieValue()); if (user_bll_h.Exists(RED_USERID)) { //结束时间 DateTime end_time = CookieManage.GetCookieValue(2); //判断是否已经过期 if (!TimeParser.IsMoreSevenDays(DateTime.Now, end_time)) { f = false; } else { f = true; } } else { f = false; } } else { f = false; } } catch (Exception ex) { f = false; } if (f) { #region 记录用户的登录和时间 NewXzc.Model.RED_USER_LOGIN_RECORD model_logintime = new Model.RED_USER_LOGIN_RECORD(); string ipAddress = RequestHelper.GetIP(); int isLogin = login_bll.GetRecordCount(" userid=" + RED_USERID + " and datediff(day,Login_Time,getdate())=0 "); string sessoinid = "0"; try { sessoinid = HttpContext.Current.Session.SessionID; } catch (Exception ex) { } try { if (isLogin <= 0) { model_logintime.USERID = RED_USERID; model_logintime.Login_IP = ipAddress; model_logintime.SessionID = sessoinid; model_logintime.Login_Time = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); model_logintime.Remark = ""; int logintype = 1; model_logintime.Login_Type = logintype; login_bll.Add(model_logintime); } else { model_logintime.Login_IP = ipAddress; model_logintime.Login_Time = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); model_logintime.Remark = ""; int logintype = 1; model_logintime.Login_Type = logintype; login_bll.Update(model_logintime); } } catch (Exception ex) { } #endregion } return(f); }