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