Нет описания

LoginUser.cs 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Web;
  7. using System.Web.UI;
  8. namespace CallCenter.Utility
  9. {
  10. public class LoginUser
  11. {
  12. private HttpRequest m_Request = null;
  13. private HttpContext m_HttpContent = null;
  14. private HttpResponse m_Response = null;
  15. private Page m_Page = null;
  16. //private HttpCookie m_Cookie = null;
  17. /// <summary>
  18. /// 构造器,读cookie使用
  19. /// </summary>
  20. /// <param name="p_HttpContext">Http请求上下文</param>
  21. public LoginUser(HttpContext p_HttpContext)
  22. {
  23. m_Request = p_HttpContext.Request;
  24. m_Response = p_HttpContext.Response;
  25. m_Page = (Page)p_HttpContext.CurrentHandler;
  26. m_HttpContent = p_HttpContext;
  27. }
  28. /// <summary>
  29. /// 构造器,写cookie使用
  30. /// </summary>
  31. /// <param name="p_HttpContext">Http请求上下文</param>
  32. /// <param name="p_WriteFlag">写标志,为true时设置写的Cookie的相关信息</param>
  33. public LoginUser(HttpContext p_HttpContext, bool p_WriteFlag)
  34. {
  35. m_Request = p_HttpContext.Request;
  36. m_Response = p_HttpContext.Response;
  37. m_Page = (Page)p_HttpContext.CurrentHandler;
  38. m_HttpContent = p_HttpContext;
  39. if (p_WriteFlag)
  40. {
  41. DateTime _Date = DateTime.Now.AddDays(7);
  42. m_Page.Response.Cookies["BaseCallCenter_T_User"].Expires = _Date;
  43. }
  44. }
  45. /// <summary>
  46. /// 用户ID,未正常取到值时返回 0
  47. /// </summary>
  48. public int UserID
  49. {
  50. get
  51. {
  52. string _UserId = string.Empty;
  53. if (m_Page.Request.Cookies["BaseCallCenter_T_User"] == null)
  54. return 0;
  55. _UserId = EncryptHelper.DecryptDES(m_Page.Request.Cookies["BaseCallCenter_T_User"]["F_UserId"]);
  56. return ToInt(_UserId, 0);
  57. }
  58. set
  59. {
  60. m_Page.Response.Cookies["BaseCallCenter_T_User"]["F_UserId"] = value.ToString();
  61. }
  62. }
  63. /// <summary>
  64. /// 用户工号,未正常取到值时返回空字符串
  65. /// </summary>
  66. public string UserCode
  67. {
  68. get
  69. {
  70. string _UserCode = string.Empty;
  71. if (m_Page.Request.Cookies["BaseCallCenter_T_User"] == null)
  72. return string.Empty;
  73. _UserCode = EncryptHelper.DecryptDES(m_Page.Request.Cookies["BaseCallCenter_T_User"]["F_UserCode"]);
  74. return _UserCode == null ? string.Empty : _UserCode;
  75. }
  76. set
  77. {
  78. m_Page.Response.Cookies["BaseCallCenter_T_User"]["F_UserCode"] = value;
  79. }
  80. }
  81. /// <summary>
  82. /// 用户权限,未正常取到值时返回空字符串
  83. /// </summary>
  84. public string SeatRight
  85. {
  86. get
  87. {
  88. string _SeatRight = string.Empty;
  89. if (m_Page.Request.Cookies["BaseCallCenter_T_User"] == null)
  90. return string.Empty;
  91. _SeatRight = EncryptHelper.DecryptDES(m_Page.Request.Cookies["BaseCallCenter_T_User"]["F_SeatRight"]);
  92. return _SeatRight == null ? string.Empty : _SeatRight;
  93. }
  94. set
  95. {
  96. m_Page.Response.Cookies["BaseCallCenter_T_User"]["F_SeatRight"] = value;
  97. }
  98. }
  99. /// <summary>
  100. /// 分机号,未正常取到值时返回空字符串
  101. /// </summary>
  102. public string ExtNo
  103. {
  104. get
  105. {
  106. string ExtNo = string.Empty;
  107. if (m_Page.Request.Cookies["BaseCallCenter_T_User"] == null)
  108. return string.Empty;
  109. ExtNo = EncryptHelper.DecryptDES(m_Page.Request.Cookies["BaseCallCenter_T_User"]["F_ExtensionNumber"]);
  110. return ExtNo == null ? string.Empty : ExtNo;
  111. }
  112. set
  113. {
  114. m_Page.Response.Cookies["BaseCallCenter_T_User"]["F_ExtensionNumber"] = value;
  115. }
  116. }
  117. /// <summary>
  118. /// 用户姓名,未正常取到值时返回空字符串
  119. /// </summary>
  120. public string UserName
  121. {
  122. get
  123. {
  124. string _Name = string.Empty;
  125. if (m_Page.Request.Cookies["BaseCallCenter_T_User"] == null)
  126. return string.Empty;
  127. _Name = EncryptHelper.DecryptDES(m_Page.Server.UrlDecode(m_Page.Request.Cookies["BaseCallCenter_T_User"]["F_UserName"]));
  128. return _Name == null ? string.Empty : _Name;
  129. }
  130. set
  131. {
  132. m_Page.Response.Cookies["BaseCallCenter_T_User"]["F_UserName"] = value;
  133. }
  134. }
  135. /// <summary>
  136. ///用户部门
  137. /// </summary>
  138. public int DeptId
  139. {
  140. get
  141. {
  142. string _DeptId = string.Empty;
  143. if (m_Page.Request.Cookies["BaseCallCenter_T_User"] == null)
  144. return 0;
  145. _DeptId = EncryptHelper.DecryptDES(m_Page.Request.Cookies["BaseCallCenter_T_User"]["F_DeptId"]);
  146. return ToInt(_DeptId, 0);
  147. }
  148. set
  149. {
  150. m_Page.Response.Cookies["BaseCallCenter_T_User"]["F_DeptId"] = value.ToString();
  151. }
  152. }
  153. /// <summary>
  154. ///角色名称
  155. /// </summary>
  156. public int RoleId
  157. {
  158. get
  159. {
  160. string _RoleId = string.Empty;
  161. if (m_Page.Request.Cookies["BaseCallCenter_T_User"] == null)
  162. return 0;
  163. _RoleId = EncryptHelper.DecryptDES(m_Page.Request.Cookies["BaseCallCenter_T_User"]["F_RoleID"]);
  164. return ToInt(_RoleId, 0);
  165. }
  166. set
  167. {
  168. m_Page.Response.Cookies["BaseCallCenter_T_User"]["F_RoleID"] = value.ToString();
  169. }
  170. }
  171. /// <summary>
  172. ///坐席组
  173. /// </summary>
  174. public int GroupID
  175. {
  176. get
  177. {
  178. string _GroupId = string.Empty;
  179. if (m_Page.Request.Cookies["BaseCallCenter_T_User"] == null)
  180. return 0;
  181. _GroupId = EncryptHelper.DecryptDES(m_Page.Request.Cookies["BaseCallCenter_T_User"]["F_GroupId"]);
  182. return ToInt(_GroupId, 0);
  183. }
  184. set
  185. {
  186. m_Page.Response.Cookies["BaseCallCenter_T_User"]["F_GroupId"] = value.ToString();
  187. }
  188. }
  189. /// <summary>
  190. /// 是否是坐席,未正常取到值时返回空字符串
  191. /// </summary>
  192. public string SeatFlag
  193. {
  194. get
  195. {
  196. string _SeatFlag = string.Empty;
  197. if (m_Page.Request.Cookies["BaseCallCenter_T_User"] == null)
  198. return string.Empty;
  199. _SeatFlag = EncryptHelper.DecryptDES(m_Page.Request.Cookies["BaseCallCenter_T_User"]["F_SeatFlag"]);
  200. return _SeatFlag == null ? string.Empty : _SeatFlag;
  201. }
  202. set
  203. {
  204. m_Page.Response.Cookies["BaseCallCenter_T_User"]["F_SeatFlag"] = value;
  205. }
  206. }
  207. /// <summary>
  208. /// 字符串转换为数值ss
  209. /// </summary>
  210. /// <param name="p_Value">要转换的字符串</param>
  211. /// <param name="p_DefaultValue">默认值,如果转换失败,返回此值</param>
  212. /// <returns>转换后的数值</returns>
  213. private int ToInt(string p_Value, int p_DefaultValue)
  214. {
  215. int _Value = 0;
  216. if (int.TryParse(p_Value, out _Value))
  217. return _Value;
  218. else
  219. return p_DefaultValue;
  220. }
  221. protected int my;
  222. }
  223. }