地铁二期项目正式开始

LoginUser.cs 7.8KB

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