123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- 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);
- }
- /// <summary>
- /// 当前用户角色 多个用逗号隔开
- /// </summary>
- 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));
- }
- }
- }
- /// <summary>
- /// 当前用户部门
- /// </summary>
- 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));
- }
- }
- }
- /// <summary>
- /// 供应商ID 如果当前用户是供应商,需要这个
- /// </summary>
- 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));
- }
- }
- }
- /// <summary>
- /// 用户ID
- /// </summary>
- 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));
- }
- }
- }
- /// <summary>
- /// 上次登录时间
- /// </summary>
- 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));
- }
- }
- }
- }
- }
|