using System.Collections.Generic; //using Liger.Common.Extensions; using System; namespace LigerRM.Common { public sealed class SysContext { public static void SetCurrent(int userid) { CurrentUserID = userid.ToString(); } public static void ClearUserStatus() { CookieHelper.SetCookie("CurrentUserID", "0", DateTime.Now); } /// /// 当前用户角色 多个用逗号隔开 /// public static string CurrentRoleID { get { try { return CookieHelper.GetCookieValue("CurrentRoleID").ToString(); } catch { return "0"; } } set { var cookie = CookieHelper.GetCookie("CurrentRoleID"); if (cookie != null) { CookieHelper.SetCookie("CurrentRoleID", value, DateTime.Now.AddHours(1)); } else { //有效期,一个钟头 CookieHelper.AddCookie("CurrentRoleID", value, DateTime.Now.AddHours(1)); } } } /// /// 当前用户部门 /// public static string CurrentDeptID { get { try { return CookieHelper.GetCookieValue("CurrentDeptID").ToString(); } catch { return "0"; } } set { var cookie = CookieHelper.GetCookie("CurrentDeptID"); if (cookie != null) { CookieHelper.SetCookie("CurrentDeptID", value.ToString(), DateTime.Now.AddHours(1)); } else { //有效期,一个钟头 CookieHelper.AddCookie("CurrentDeptID", value.ToString(), DateTime.Now.AddHours(1)); } } } /// /// 供应商ID 如果当前用户是供应商,需要这个 /// public static string CurrentSupplierID { get { try { return CookieHelper.GetCookieValue("CurrentSupplierID").ToString(); } catch { return "0"; } } set { var cookie = CookieHelper.GetCookie("CurrentSupplierID"); if (cookie != null) { CookieHelper.SetCookie("CurrentSupplierID", value.ToString(), DateTime.Now.AddHours(1)); } else { //有效期,一个钟头 CookieHelper.AddCookie("CurrentSupplierID", value.ToString(), DateTime.Now.AddHours(1)); } } } /// /// 用户ID /// public static string CurrentUserID { get { try { return CookieHelper.GetCookieValue("CurrentUserID").ToString(); } catch { return "0"; } } set { var cookie = CookieHelper.GetCookie("CurrentUserID"); if (cookie != null) { CookieHelper.SetCookie("CurrentUserID", value.ToString(), DateTime.Now.AddHours(1)); } else { //有效期,一个钟头 CookieHelper.AddCookie("CurrentUserID", value.ToString(), DateTime.Now.AddHours(1)); } } } public static string CurrentEmployeeID { get { try { return CookieHelper.GetCookieValue("CurrentEmployeeID").ToString(); } catch { return "0"; } } set { var cookie = CookieHelper.GetCookie("CurrentEmployeeID"); if (cookie != null) { CookieHelper.SetCookie("CurrentEmployeeID", value.ToString(), DateTime.Now.AddHours(1)); } else { //有效期,一个钟头 CookieHelper.AddCookie("CurrentEmployeeID", value.ToString(), DateTime.Now.AddHours(1)); } } } /// /// 上次登录时间 /// public static string CurrentUserLastLoginTime { get { return CookieHelper.GetCookieValue("CurrentUserLastLoginTime"); } set { var cookie = CookieHelper.GetCookie("CurrentUserLastLoginTime"); if (cookie != null) { CookieHelper.SetCookie("CurrentUserLastLoginTime", value.ToString(), DateTime.Now.AddHours(1)); } else { //有效期,一个钟头 CookieHelper.AddCookie("CurrentUserLastLoginTime", value.ToString(), DateTime.Now.AddHours(1)); } } } public static string CurrentUserTitle { get { try { return CookieHelper.GetCookieValue("CurrentUserTitle").ToString(); } catch { return "0"; } } set { var cookie = CookieHelper.GetCookie("CurrentUserTitle"); if (cookie != null) { CookieHelper.SetCookie("CurrentUserTitle", value, DateTime.Now.AddHours(1)); } else { //有效期,一个钟头 CookieHelper.AddCookie("CurrentUserTitle", value, DateTime.Now.AddHours(1)); } } } } }