| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Web;
- using System.Web.UI;
- namespace YTSoft.Common
- {
- public class LoginUser
- {
- private HttpRequest m_Request = null;
- private HttpContext m_HttpContent = null;
- private HttpResponse m_Response = null;
- private Page m_Page = null;
- //private HttpCookie m_Cookie = null;
- /// <summary>
- /// 构造器,读cookie使用
- /// </summary>
- /// <param name="p_HttpContext">Http请求上下文</param>
- public LoginUser(HttpContext p_HttpContext)
- {
- m_Request = p_HttpContext.Request;
- m_Response = p_HttpContext.Response;
- m_Page = (Page)p_HttpContext.CurrentHandler;
- m_HttpContent = p_HttpContext;
- }
- /// <summary>
- /// 构造器,写cookie使用
- /// </summary>
- /// <param name="p_HttpContext">Http请求上下文</param>
- /// <param name="p_WriteFlag">写标志,为true时设置写的Cookie的相关信息</param>
- public LoginUser(HttpContext p_HttpContext, bool p_WriteFlag)
- {
- m_Request = p_HttpContext.Request;
- m_Response = p_HttpContext.Response;
- m_Page = (Page)p_HttpContext.CurrentHandler;
- m_HttpContent = p_HttpContext;
- if (p_WriteFlag)
- {
- DateTime _Date = DateTime.Now.AddDays(7);
- m_Page.Response.Cookies["BaseCallCenter_T_User"].Expires = _Date;
- }
- }
- /// <summary>
- /// 用户ID,未正常取到值时返回 0
- /// </summary>
- public int UserID
- {
- get
- {
- string _UserId = string.Empty;
- if (m_Page.Request.Cookies["BaseCallCenter_T_User"] == null)
- return 0;
- _UserId = DESEncrypt.Decrypt(m_Page.Request.Cookies["BaseCallCenter_T_User"]["F_UserId"]);
- return ToInt(_UserId, 0);
- }
- set
- {
- m_Page.Response.Cookies["BaseCallCenter_T_User"]["F_UserId"] = value.ToString();
- }
- }
- /// <summary>
- /// 用户工号,未正常取到值时返回空字符串
- /// </summary>
- public string UserCode
- {
- get
- {
- string _UserCode = string.Empty;
- if (m_Page.Request.Cookies["BaseCallCenter_T_User"] == null)
- return string.Empty;
- _UserCode = DESEncrypt.Decrypt(m_Page.Request.Cookies["BaseCallCenter_T_User"]["F_UserCode"]);
- return _UserCode == null ? string.Empty : _UserCode;
- }
- set
- {
- m_Page.Response.Cookies["BaseCallCenter_T_User"]["F_UserCode"] = value;
- }
- }
- /// <summary>
- /// 用户权限,未正常取到值时返回空字符串
- /// </summary>
- public string SeatRight
- {
- get
- {
- string _SeatRight = string.Empty;
- if (m_Page.Request.Cookies["BaseCallCenter_T_User"] == null)
- return string.Empty;
- _SeatRight = DESEncrypt.Decrypt(m_Page.Request.Cookies["BaseCallCenter_T_User"]["F_SeatRight"]);
- return _SeatRight == null ? string.Empty : _SeatRight;
- }
- set
- {
- m_Page.Response.Cookies["BaseCallCenter_T_User"]["F_SeatRight"] = value;
- }
- }
- /// <summary>
- /// 分机号,未正常取到值时返回空字符串
- /// </summary>
- public string ExtNo
- {
- get
- {
- string ExtNo = string.Empty;
- if (m_Page.Request.Cookies["BaseCallCenter_T_User"] == null)
- return string.Empty;
- ExtNo = DESEncrypt.Decrypt(m_Page.Request.Cookies["BaseCallCenter_T_User"]["F_ExtensionNumber"]);
- return ExtNo == null ? string.Empty : ExtNo;
- }
- set
- {
- m_Page.Response.Cookies["BaseCallCenter_T_User"]["F_ExtensionNumber"] = value;
- }
- }
- /// <summary>
- /// 用户姓名,未正常取到值时返回空字符串
- /// </summary>
- public string UserName
- {
- get
- {
- string _Name = string.Empty;
- if (m_Page.Request.Cookies["BaseCallCenter_T_User"] == null)
- return string.Empty;
- _Name = DESEncrypt.Decrypt(m_Page.Server.UrlDecode(m_Page.Request.Cookies["BaseCallCenter_T_User"]["F_UserName"]));
- return _Name == null ? string.Empty : _Name;
- }
- set
- {
- m_Page.Response.Cookies["BaseCallCenter_T_User"]["F_UserName"] = value;
- }
- }
- /// <summary>
- ///用户部门
- /// </summary>
- public int DeptId
- {
- get
- {
- string _DeptId = string.Empty;
- if (m_Page.Request.Cookies["BaseCallCenter_T_User"] == null)
- return 0;
- _DeptId = DESEncrypt.Decrypt(m_Page.Request.Cookies["BaseCallCenter_T_User"]["F_DeptId"]);
- return ToInt(_DeptId, 0);
- }
- set
- {
- m_Page.Response.Cookies["BaseCallCenter_T_User"]["F_DeptId"] = value.ToString();
- }
- }
- /// <summary>
- ///角色名称
- /// </summary>
- public int RoleId
- {
- get
- {
- string _RoleId = string.Empty;
- if (m_Page.Request.Cookies["BaseCallCenter_T_User"] == null)
- return 0;
- _RoleId = DESEncrypt.Decrypt(m_Page.Request.Cookies["BaseCallCenter_T_User"]["F_RoleID"]);
- return ToInt(_RoleId, 0);
- }
- set
- {
- m_Page.Response.Cookies["BaseCallCenter_T_User"]["F_RoleID"] = value.ToString();
- }
- }
- /// <summary>
- ///用户组
- /// </summary>
- public int GroupID
- {
- get
- {
- string _GroupId = string.Empty;
- if (m_Page.Request.Cookies["BaseCallCenter_T_User"] == null)
- return 0;
- _GroupId = DESEncrypt.Decrypt(m_Page.Request.Cookies["BaseCallCenter_T_User"]["F_GroupId"]);
- return ToInt(_GroupId, 0);
- }
- set
- {
- m_Page.Response.Cookies["BaseCallCenter_T_User"]["F_GroupId"] = value.ToString();
- }
- }
- /// <summary>
- /// 是否是坐席,未正常取到值时返回空字符串
- /// </summary>
- public string SeatFlag
- {
- get
- {
- string _SeatFlag = string.Empty;
- if (m_Page.Request.Cookies["BaseCallCenter_T_User"] == null)
- return string.Empty;
- _SeatFlag = DESEncrypt.Decrypt(m_Page.Request.Cookies["BaseCallCenter_T_User"]["F_SeatFlag"]);
- return _SeatFlag == null ? string.Empty : _SeatFlag;
- }
- set
- {
- m_Page.Response.Cookies["BaseCallCenter_T_User"]["F_SeatFlag"] = value;
- }
- }
- /// <summary>
- /// 字符串转换为数值ss
- /// </summary>
- /// <param name="p_Value">要转换的字符串</param>
- /// <param name="p_DefaultValue">默认值,如果转换失败,返回此值</param>
- /// <returns>转换后的数值</returns>
- private int ToInt(string p_Value, int p_DefaultValue)
- {
- int _Value = 0;
- if (int.TryParse(p_Value, out _Value))
- return _Value;
- else
- return p_DefaultValue;
- }
- protected int my;
- }
- }
|