123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- using System.Collections.Generic;
- //using Liger.Common.Extensions;
- using System;
- namespace LigerRM.Common
- {
- public sealed class SysContextToken
- {
- public static void SetCurrent(int userid)
- {
- CurrentUserID = userid.ToString();
- }
- public static void ClearUserStatus()
- {
- SsoTokenHelper.SetToken("userid", "", DateTime.Now);
- }
- /// <summary>
- /// 当前用户角色 多个用逗号隔开
- /// </summary>
- public static string roleid
- {
- get
- {
- try
- {
- return SsoTokenHelper.GetTokenValue("roleid").ToString();
- }
- catch
- {
- return "0";
- }
- }
- set
- {
- var Token = SsoTokenHelper.GetToken("roleid");
- if (Token != null)
- {
- SsoTokenHelper.SetToken("roleid", value, DateTime.Now.AddHours(1));
- }
- else
- {
- //有效期,一个钟头
- SsoTokenHelper.AddToken("roleid", value, DateTime.Now.AddHours(1));
- }
- }
- }
- /// <summary>
- /// 当前用户部门
- /// </summary>
- public static string CurrentDeptID
- {
- get
- {
- try
- {
- return SsoTokenHelper.GetTokenValue("CurrentDeptID").ToString();
- }
- catch
- {
- return "0";
- }
- }
- set
- {
- var Token = SsoTokenHelper.GetToken("CurrentDeptID");
- if (Token != null)
- {
- SsoTokenHelper.SetToken("CurrentDeptID", value.ToString(), DateTime.Now.AddHours(1));
- }
- else
- {
- //有效期,一个钟头
- SsoTokenHelper.AddToken("CurrentDeptID", value.ToString(), DateTime.Now.AddHours(1));
- }
- }
- }
- /// <summary>
- /// 供应商ID 如果当前用户是供应商,需要这个
- /// </summary>
- public static string CurrentSupplierID
- {
- get
- {
- try
- {
- return SsoTokenHelper.GetTokenValue("CurrentSupplierID").ToString();
- }
- catch
- {
- return "0";
- }
- }
- set
- {
- var Token = SsoTokenHelper.GetToken("CurrentSupplierID");
- if (Token != null)
- {
- SsoTokenHelper.SetToken("CurrentSupplierID", value.ToString(), DateTime.Now.AddHours(1));
- }
- else
- {
- //有效期,一个钟头
- SsoTokenHelper.AddToken("CurrentSupplierID", value.ToString(), DateTime.Now.AddHours(1));
- }
- }
- }
- /// <summary>
- /// 用户ID
- /// </summary>
- public static string CurrentUserID
- {
- get
- {
- try
- {
- return SsoTokenHelper.GetTokenValue("userid").ToString();
- }
- catch
- {
- return "0";
- }
- }
- set
- {
- var Token = SsoTokenHelper.GetToken("userid");
- if (Token != null)
- {
- SsoTokenHelper.SetToken("userid", value.ToString(), DateTime.Now.AddHours(1));
- }
- else
- {
- //有效期,一个钟头
- SsoTokenHelper.AddToken("userid", value.ToString(), DateTime.Now.AddHours(1));
- }
-
- }
- }
- public static string CurrentEmployeeID
- {
- get
- {
- try
- {
- return SsoTokenHelper.GetTokenValue("CurrentEmployeeID").ToString();
- }
- catch
- {
- return "0";
- }
- }
- set
- {
- var Token = SsoTokenHelper.GetToken("CurrentEmployeeID");
- if (Token != null)
- {
- SsoTokenHelper.SetToken("CurrentEmployeeID", value.ToString(), DateTime.Now.AddHours(1));
- }
- else
- {
- //有效期,一个钟头
- SsoTokenHelper.AddToken("CurrentEmployeeID", value.ToString(), DateTime.Now.AddHours(1));
- }
- }
- }
- /// <summary>
- /// 上次登录时间
- /// </summary>
- public static string CurrentUserLastLoginTime
- {
- get
- {
- return SsoTokenHelper.GetTokenValue("CurrentUserLastLoginTime");
- }
- set
- {
- var Token = SsoTokenHelper.GetToken("CurrentUserLastLoginTime");
- if (Token != null)
- {
- SsoTokenHelper.SetToken("CurrentUserLastLoginTime", value.ToString(), DateTime.Now.AddHours(1));
- }
- else
- {
- //有效期,一个钟头
- SsoTokenHelper.AddToken("CurrentUserLastLoginTime", value.ToString(), DateTime.Now.AddHours(1));
- }
- }
- }
- public static string CurrentUserTitle
- {
- get
- {
- try
- {
- return SsoTokenHelper.GetTokenValue("username").ToString();
- }
- catch
- {
- return "0";
- }
- }
- set
- {
- var Token = SsoTokenHelper.GetToken("username");
- if (Token != null)
- {
- SsoTokenHelper.SetToken("username", value, DateTime.Now.AddHours(1));
- }
- else
- {
- //有效期,一个钟头
- SsoTokenHelper.AddToken("username", value, DateTime.Now.AddHours(1));
- }
- }
- }
- }
- }
|