WebLibs.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Web;
  4. using System.Web.UI.WebControls;
  5. namespace CommonTool
  6. {
  7. public class WebLibs
  8. {
  9. /// <summary>
  10. /// 将不能在HTML中正常显示的ASCII字符串进行Html语法的翻译
  11. /// </summary>
  12. /// <param name="pcStr">需要进行Html语法翻译的ASCII字符串</param>
  13. public static void AreaToHtml(ref string pcStr)
  14. {
  15. if (pcStr != null)
  16. {
  17. pcStr = pcStr.Replace(" ", "&nbsp;");
  18. pcStr = pcStr.Replace("\r", "<br>");
  19. }
  20. }
  21. /// <summary>
  22. /// 替换Url地址信息里的 换行符号
  23. /// </summary>
  24. /// <param name="pcUrlMsg"></param>
  25. /// <returns></returns>
  26. public static string ConvertUrlMsg(string pcUrlMsg)
  27. {
  28. pcUrlMsg = pcUrlMsg.Replace("\n\r", " ");
  29. pcUrlMsg = pcUrlMsg.Replace("\r\n", " ");
  30. pcUrlMsg = pcUrlMsg.Replace("\r", " ");
  31. pcUrlMsg = pcUrlMsg.Replace("\n", " ");
  32. return pcUrlMsg;
  33. }
  34. //public static void WebShowMessage(string pcMsg)
  35. //{
  36. // WebShowMessage(pcMsg, ErrActType.Return);
  37. //}
  38. //public static void WebShowMessage(string pcMsg, ErrActType poErrActType)
  39. //{
  40. // pcMsg = ConvertURLMsg(pcMsg);
  41. // HttpContext.Current.Response.Redirect("../Pub/WebShowMsg.aspx?pc_ErrorMsg=" + pcMsg + "&pc_ActionType=" + poErrActType.ToString());
  42. //}
  43. public static Unit IntToUnit(int piPixels)
  44. {
  45. return Unit.Parse(piPixels.ToString() + "px");
  46. }
  47. public static string ColorToHex(System.Drawing.Color poColor)
  48. {
  49. string lcRetVal = poColor.ToArgb().ToString("X");
  50. lcRetVal = "#" + lcRetVal.Substring(2, 6);
  51. return lcRetVal;
  52. }
  53. public static string CurPageName
  54. {
  55. get
  56. {
  57. string lcRetVal = "";
  58. string[] arrayurl = HttpContext.Current.Request.Url.PathAndQuery.Split('?');
  59. if (arrayurl.Length > 0)
  60. {
  61. string file = arrayurl[0];
  62. string[] arr2 = file.Split('/');
  63. if (arr2.Length > 0)
  64. {
  65. if (arr2.Length == 1)
  66. lcRetVal = arr2[0];
  67. else
  68. lcRetVal = arr2[arr2.Length - 2] + "_" + arr2[arr2.Length - 1];
  69. }
  70. }
  71. return lcRetVal;
  72. }
  73. }
  74. public static UserSession GetUserSession()
  75. {
  76. UserSession loRetVal = null;
  77. if (HttpContext.Current != null && HttpContext.Current.Session != null && HttpContext.Current.Session[Contants.UserInfoId] != null)
  78. {
  79. loRetVal = (UserSession)HttpContext.Current.Session[Contants.UserInfoId];
  80. }
  81. return loRetVal;
  82. }
  83. public static UserSession CheckLogin()
  84. {
  85. var loRetVal = GetUserSession();
  86. if (loRetVal == null)
  87. {
  88. //System.Web.HttpContext.Current.Response.Write("<form id='Form2' method='post' action='../Default.aspx' target='_top' ></form><script>alert('对不起! 您还没有登录或超时'); Form2.submit();</script>");
  89. // System.Web.HttpContext.Current.Response.Write("<form id='Form2' method='post' action='../Default.aspx' target='_top' ></form><script>Form2.submit();</script>");
  90. //System.Web.HttpContext.Current.Response.Write("<script>window.location.href='../Default.aspx';</script>");
  91. HttpContext.Current.Response.Write("<script>window.location.href='../Manage/login.aspx';</script>");
  92. //System.Web.HttpContext.Current.Response.Write("timeout");
  93. HttpContext.Current.Response.End();
  94. }
  95. return loRetVal;
  96. }
  97. public static UserSession CheckLoginAjax()
  98. {
  99. var loRetVal = GetUserSession();
  100. if (loRetVal == null)
  101. {
  102. //System.Web.HttpContext.Current.Response.Write("<form id='Form2' method='post' action='../Default.aspx' target='_top' ></form><script>alert('对不起! 您还没有登录或超时'); Form2.submit();</script>");
  103. // System.Web.HttpContext.Current.Response.Write("<form id='Form2' method='post' action='../Default.aspx' target='_top' ></form><script>Form2.submit();</script>");
  104. //System.Web.HttpContext.Current.Response.Write("<script>window.location.href='../Default.aspx';</script>");
  105. //System.Web.HttpContext.Current.Response.Write("<script>window.location.href='../login/login.aspx';</script>");
  106. HttpContext.Current.Response.Write("timeout");
  107. HttpContext.Current.Response.End();
  108. }
  109. return loRetVal;
  110. }
  111. /**
  112. * 检查参会者的Session
  113. *
  114. * */
  115. public static string GetCookieValue(string pcCookieKey)
  116. {
  117. return GetCookieValue(pcCookieKey, Contants.SysCookieName);
  118. }
  119. public static string GetCookieValue(string pcCookieKey, string pcCookieName)
  120. {
  121. string lcRetVal = "";
  122. if (HttpContext.Current.Request.Browser.Cookies)
  123. {
  124. HttpCookie loCookie = HttpContext.Current.Request.Cookies[pcCookieName];
  125. string lcTempValue = loCookie?[pcCookieKey];
  126. if (lcTempValue != null)
  127. lcRetVal = lcTempValue;
  128. }
  129. return lcRetVal;
  130. }
  131. public static void SetCookieValue(string pcCookieKey, string pcCookieValue)
  132. {
  133. SetCookieValue(pcCookieKey, pcCookieValue, Contants.SysCookieName);
  134. }
  135. public static void SetCookieValue(string pcCookieKey, string pcCookieValue, string pcCookieName)
  136. {
  137. if (HttpContext.Current.Request.Browser.Cookies)
  138. {
  139. HttpCookie loCookie = HttpContext.Current.Request.Cookies[pcCookieName] ?? new HttpCookie(pcCookieName);
  140. loCookie.Values.Remove(pcCookieKey);
  141. loCookie.Values.Add(pcCookieKey, pcCookieValue);
  142. loCookie.Expires = DateTime.Now.AddMonths(6);
  143. HttpContext.Current.Response.SetCookie(loCookie);
  144. }
  145. }
  146. public static string CvStrByType(ref string pcStr, CovType typeUse)
  147. {
  148. pcStr = pcStr.Trim();
  149. switch (((int)typeUse))
  150. {
  151. case 1:
  152. pcStr = pcStr.Replace(@"\", @"\\");
  153. pcStr = pcStr.Replace("\r\n", @"\n");
  154. pcStr = pcStr.Replace("\r", "");
  155. pcStr = pcStr.Replace("\n", "");
  156. pcStr = pcStr.Replace("'", @"\'");
  157. break;
  158. case 2:
  159. pcStr = pcStr.Replace("&", "&amp;");
  160. pcStr = pcStr.Replace("<", "&lt;");
  161. pcStr = pcStr.Replace(">", "&gt;");
  162. pcStr = pcStr.Replace(" ", "&nbsp;");
  163. pcStr = pcStr.Replace("'", "\u2019");
  164. pcStr = pcStr.Replace("\r\n", "<br>");
  165. pcStr = pcStr.Replace("\r", "<br>");
  166. pcStr = pcStr.Replace("\n", "<br>");
  167. break;
  168. case 3:
  169. pcStr = pcStr.Replace("<br>", "\r\n");
  170. pcStr = pcStr.Replace("<BR>", "\r\n");
  171. pcStr = pcStr.Replace("<Br>", "\r\n");
  172. pcStr = pcStr.Replace("<bR>", "\r\n");
  173. break;
  174. case 4:
  175. pcStr = pcStr.Replace("\r\n", "<br>");
  176. pcStr = pcStr.Replace(" ", "&nbsp;");
  177. pcStr = pcStr.Replace("'", "\u2019");
  178. pcStr = pcStr.Replace("\r", "<br>");
  179. pcStr = pcStr.Replace("\n", "<br>");
  180. pcStr = pcStr.Replace("<", "&lt;");
  181. pcStr = pcStr.Replace(">", "&gt;");
  182. pcStr = pcStr.Replace("&", "\uff06");
  183. break;
  184. default:
  185. pcStr = pcStr.Replace("'", "''");
  186. break;
  187. }
  188. return (pcStr + "");
  189. }
  190. #region //===============================错误处理======================
  191. /// <summary>
  192. /// 权限检查错误转向页面
  193. /// </summary>
  194. /// <param name="asPowerType">1,没有浏览权;2,没有添加权 ; 3 没有修改权 4;没有删除权;
  195. /// 5,没有打印权; 7 页面权限编号信息错误</param>
  196. public static void NotPower(int asPowerType)
  197. {
  198. NotPower(asPowerType, "N");
  199. }
  200. /// <summary>
  201. /// 权限检查错误转向页面
  202. /// </summary>
  203. /// <param name="asPowerType"> 1,没有浏览权;2,没有添加权 ; 3 没有修改权 4;没有删除权;
  204. /// 5,没有打印权; 7 页面权限编号信息错误</param>
  205. /// <param name="asReturnType">参数 C 关闭;R 重定向 ;P 上一页; U 指定页面 ;N 不显示</param>
  206. public static void NotPower(int asPowerType, string asReturnType)
  207. {
  208. if (asPowerType == 1) { ErrRedirect(-30000001, asReturnType); } //浏览
  209. if (asPowerType == 2) { ErrRedirect(-30000002, asReturnType); } //添加
  210. if (asPowerType == 3) { ErrRedirect(-30000003, asReturnType); } //修改
  211. if (asPowerType == 4) { ErrRedirect(-30000004, asReturnType); } //删除
  212. if (asPowerType == 5) { ErrRedirect(-30000005, asReturnType); } //打印
  213. if (asPowerType == 5) { ErrRedirect(-30000006, asReturnType); } //审核
  214. if (asPowerType == 6) { ErrRedirect(-311271, asReturnType); } //检查是否有浏览新增删除修改的权限
  215. if (asPowerType == 7) { ErrRedirect(-30000008, asReturnType); } //页面权限编号信息错误
  216. if (asPowerType == 8) { ErrRedirect(-30000007, asReturnType); } //页面权限编号信息错误
  217. }
  218. /// <summary>
  219. /// 操作错误 提示页面
  220. /// </summary>
  221. /// <param name="asPowerType">1,为删除的行为空 ;2 编号为空 ;3 参数传递错误 </param>
  222. public static void OperationErr(int asPowerType)
  223. {
  224. OperationErr(asPowerType, "");
  225. }
  226. /// <summary>
  227. /// 操作错误 提示页面
  228. /// </summary>
  229. /// <param name="asOperationType">1,为删除的行为空 ;2 编号为空 ;3 参数传递错误 </param>
  230. /// <param name="asReturnType"></param>
  231. public static void OperationErr(int asOperationType, string asReturnType)
  232. {
  233. if (asOperationType == 1) { ErrRedirect(-10000101, asReturnType); }
  234. if (asOperationType == 2) { ErrRedirect(-10000102, asReturnType); }
  235. if (asOperationType == 3) { ErrRedirect(-10000103, asReturnType); }
  236. }
  237. public static void ErrRedirect(int asErrorCode, string asReturnType)
  238. {
  239. var returnType = asReturnType.Trim().Length == 0 ? "C" : asReturnType;
  240. PageRedirect(asErrorCode, returnType);
  241. }
  242. public static void PageRedirect(int errorCode, string returnType)
  243. {
  244. HttpContext.Current.Response.Redirect("../Pub/PubShowMessage.aspx?al_ErrCode=" + errorCode + "&as_ReturnType=" + returnType);
  245. }
  246. public static void LoginOut()
  247. {
  248. HttpContext.Current.Session.RemoveAll();
  249. HttpContext.Current.Response.Write("<form id='Form2' method='post' action='../Default.aspx' target='_top' ></form><script>Form2.submit();</script>");
  250. HttpContext.Current.Response.End();
  251. }
  252. #endregion
  253. }
  254. public sealed class Contants
  255. {
  256. public const string UserInfoId = "WeiBoYUserInfoIdInSession";
  257. public const string SysCookieName = "WeiBoYCookieKeyYue";
  258. public const string UserName = "WeiBoYCookieUserName";
  259. public const string PassWord = "WeiBoYCookieUserPassWord";
  260. public const string StatusNew = "new";
  261. public const string StatusExec = "exec";
  262. public const string StatusCmp = "cmp";
  263. public const string CustomerInfoNo = "ServiceTypeCustomerInfoNoSession";
  264. public const string SendMsgReg = "ServiceTypeSendMsgRegSession";
  265. public const string SendMsgLogin = "ServiceTypeSendMsgLoginSession";
  266. public const string SendEamilMsg = "CustomerSendEamilMsgModifyEmailSession";
  267. public const string AlumnuseInfoId = "AlumnuseInfoIdSession";
  268. }
  269. public sealed class Sc
  270. {
  271. public const string Select = " SELECT ";
  272. public const string And = " AND ";
  273. public const string From = " FROM ";
  274. public const string Where = " WHERE ";
  275. public const string Orderby = " ORDER BY ";
  276. public const string Delete = " DELETE ";
  277. public const string Update = " UPDATE ";
  278. public const string Set = " SET ";
  279. public const string Eq = " = ";
  280. public const string Or = " OR ";
  281. public const string Groupby = " GROUP BY ";
  282. public const string Like = " LIKE ";
  283. }
  284. public class UserSession
  285. {
  286. // Methods
  287. #region 权限菜单相关方法
  288. //private Dictionary<string, UIAndPower> _PowHas;
  289. //private UIAndPowerList _PowerList;
  290. //public bool CheckPowerNoErrRedirect(PowerType poType)
  291. //{
  292. // UserSession loSession = WebLibs.GetUserSession();
  293. // if (loSession != null)
  294. // {
  295. // SonicLog.LogInfo(loSession.UserInfo.UserNo + " --- " + WebLibs.CurPageName + " --- " + poType.ToString());
  296. // }
  297. // string pcUIID = UtilStr.UAndT(WebLibs.CurPageName);
  298. // bool lbRetVal = false;
  299. // if (this._PowerList.ContainPageName(pcUIID))
  300. // {
  301. // UIAndPower power = this._PowerList.getUIAndPowerByPageName(pcUIID);
  302. // switch (poType)
  303. // {
  304. // case PowerType.IsBrowse:
  305. // lbRetVal = power.IsBrowse;
  306. // break;
  307. // case PowerType.IsNew:
  308. // lbRetVal = power.IsAdd;
  309. // break;
  310. // case PowerType.IsEdit:
  311. // lbRetVal = power.IsUpdate;
  312. // break;
  313. // case PowerType.IsDelete:
  314. // lbRetVal = power.IsDelete;
  315. // break;
  316. // case PowerType.IsAudit:
  317. // lbRetVal = power.IsAudit;
  318. // break;
  319. // case PowerType.IsPrint:
  320. // lbRetVal = power.IsPrint;
  321. // break;
  322. // }
  323. // }
  324. // return lbRetVal;
  325. //}
  326. ///// <summary>
  327. ///// 权限检查
  328. ///// </summary>
  329. ///// <param name="poType">检查的类型</param>
  330. ///// <returns></returns>
  331. //public bool CheckPower(PowerType poType)
  332. //{
  333. // UserSession loSession = WebLibs.GetUserSession();
  334. // if (loSession != null)
  335. // {
  336. // SonicLog.LogInfo(loSession.UserInfo.UserNo+ " --- " + WebLibs.CurPageName + " --- " + poType.ToString());
  337. // }
  338. // string pcUIID = UtilStr.UAndT(WebLibs.CurPageName);
  339. // bool lbRetVal = false;
  340. // if (this._PowerList.ContainPageName(pcUIID))
  341. // {
  342. // UIAndPower power = this._PowerList.getUIAndPowerByPageName(pcUIID);
  343. // switch (poType)
  344. // {
  345. // case PowerType.IsBrowse:
  346. // lbRetVal = power.IsBrowse;
  347. // break;
  348. // case PowerType.IsNew:
  349. // lbRetVal = power.IsAdd;
  350. // break;
  351. // case PowerType.IsEdit:
  352. // lbRetVal = power.IsUpdate;
  353. // break;
  354. // case PowerType.IsDelete:
  355. // lbRetVal = power.IsDelete;
  356. // break;
  357. // case PowerType.IsAudit:
  358. // lbRetVal = power.IsAudit;
  359. // break;
  360. // case PowerType.IsPrint:
  361. // lbRetVal = power.IsPrint;
  362. // break;
  363. // }
  364. // }
  365. // else
  366. // {
  367. // JSComm.ShowMessage("该用户没有相应的权限");
  368. // }
  369. // return lbRetVal;
  370. //}
  371. //public bool CheckPower()
  372. //{
  373. // string lcPageName = UtilStr.UAndT(WebLibs.CurPageName);
  374. // bool lbRetVal = false;
  375. // if (this._PowerList.ContainPageName(lcPageName))
  376. // {
  377. // UIAndPower power = this._PowerList.getUIAndPowerByPageName(lcPageName);
  378. // if (power.IsBrowse && power.IsAdd && power.IsUpdate && power.IsDelete)
  379. // {
  380. // lbRetVal = true;
  381. // }
  382. // else
  383. // WebLibs.NotPower(6);
  384. // }
  385. // else
  386. // {
  387. // WebLibs.NotPower(7);
  388. // }
  389. // return lbRetVal;
  390. //}
  391. //private void CreatePowHasDict(DataTable poDataTable)
  392. //{
  393. // if (this._PowerList == null)
  394. // this._PowerList = new UIAndPowerList();
  395. // else
  396. // this._PowerList.Clear();
  397. // if (poDataTable!=null)
  398. // {
  399. // try
  400. // {
  401. // _PowerList.SetData(poDataTable);
  402. // }
  403. // catch (Exception e)
  404. // {
  405. // SonicLog.LogException(e);
  406. // _ErrorMsg = e.Message;
  407. // }
  408. // }
  409. //}
  410. //public void refreshFunctions()
  411. //{
  412. // string lcSql = "select * from " + Tn.v_UserHasAllFunctions_New + " where UserNo='" + this._UserInfo.UserNo + "' order by FunctionID ";
  413. // snQuery loQuery = DBConn.OpenQuery(lcSql);
  414. // if (loQuery != null && loQuery.IsOpened && loQuery.RecCount > 0)
  415. // {
  416. // CreatePowHasDict(loQuery.CurrentTable);
  417. // }
  418. // else
  419. // {
  420. // _ErrorMsg = DBConn.ErrorMsg;
  421. // SonicLog.LogError(_ErrorMsg);
  422. // }
  423. //}
  424. #endregion
  425. //List<string> _DenyList = null;
  426. //private List<string> DenyList
  427. //{
  428. // get
  429. // {
  430. // if (_DenyList == null)
  431. // {
  432. // string lcSql = " select * from " + Tn.v_UserDenyColumns + " where " + v_UserDenyColumns_info.cUserNo + "='" + _UserInfo.UserNo + "'";
  433. // snQuery loQuery = DBConn.OpenQuery(lcSql);
  434. // if (loQuery != null && loQuery.IsOpened && loQuery.RecCount > 0)
  435. // {
  436. // _DenyList = new List<string>();
  437. // loQuery.MoveFirst();
  438. // for (int i = 0; i < loQuery.RecCount; i++)
  439. // {
  440. // string lcTCol = loQuery.GetString("TableId") + "." + loQuery.GetString("ColumnId");
  441. // lcTCol = UtilStr.UAndT(lcTCol);
  442. // _DenyList.Add(lcTCol);
  443. // loQuery.MoveNext();
  444. // }
  445. // }
  446. // }
  447. // return _DenyList;
  448. // }
  449. //}
  450. //public bool ColDeny(string pcTableId, string pcColumnId)
  451. //{
  452. // bool lbRetVal = false;
  453. // if (DenyList != null)
  454. // {
  455. // string lcTCol = pcTableId + "." + pcColumnId;
  456. // lcTCol = UtilStr.UAndT(lcTCol);
  457. // lbRetVal = DenyList.Contains(lcTCol);
  458. // }
  459. // return lbRetVal;
  460. //}
  461. #region 基础属性
  462. public string ErrorMsg { get; set; } = "";
  463. //public bool IsAdvance
  464. //{
  465. // get { return UtilStr.StrToBool(_UserInfo.IsAdvance); }
  466. //}
  467. #endregion
  468. #region
  469. //IUserInfo _userInfos = null;
  470. //public IUserInfo UserInfos
  471. //{
  472. // get { return _userInfos; }
  473. // set { _userInfos = value; }
  474. //}
  475. //public string GetAuthSql(bool IsPath, bool IsWhere)
  476. //{
  477. // string lcRetVal = " 1=1 ";
  478. // if (!UtilStr.StrToBool(this.UserInfo.IsSys))
  479. // {
  480. // RegionGroups_info loRegion = new RegionGroups_info(this.UserInfo.RegionGroupNo,DBConn);
  481. // if (IsPath)
  482. // {
  483. // lcRetVal = " Path Like '" + loRegion.Path + "%' ";
  484. // }
  485. // else
  486. // {
  487. // string lcSql = " select RegionGroupNo from RegionGroups where Path Like '" + loRegion.Path + "%' ";
  488. // snQuery loQuery = DBConn.OpenQuery(lcSql);
  489. // string lcWhere = "";
  490. // if (loQuery != null && loQuery.IsOpened)
  491. // {
  492. // loQuery.MoveFirst();
  493. // for (int i = 0; i < loQuery.RecCount; i++)
  494. // {
  495. // lcWhere += (lcWhere == "" ? "" : ",") + "'" + loQuery.GetString("RegionGroupNo") + "'";
  496. // loQuery.MoveNext();
  497. // }
  498. // }
  499. // lcRetVal = " RegionGroupNo in (" + lcWhere + ") ";
  500. // }
  501. // }
  502. // if (IsWhere)
  503. // {
  504. // lcRetVal = " WHERE " + lcRetVal;
  505. // }
  506. // return lcRetVal;
  507. //}
  508. //public string GetPersonAuthSql(bool IsPath, bool IsWhere)
  509. //{
  510. // string lcRetVal = "";
  511. // if (!UtilStr.StrToBool(this.UserInfo.IsSys))
  512. // {
  513. // PersonGroups_info loRegion = new PersonGroups_info(this.UserInfo.PersonGroupNo, DBConn);
  514. // if (IsPath)
  515. // {
  516. // lcRetVal = " Path Like '" + loRegion.Path + "%' ";
  517. // }
  518. // if (IsWhere)
  519. // {
  520. // lcRetVal = " WHERE " + lcRetVal;
  521. // }
  522. // }
  523. // return lcRetVal;
  524. //}
  525. #endregion
  526. #region 获得菜单列表的方法
  527. /// <summary>
  528. /// 得到用户能查看的菜单所有列表的string型
  529. /// </summary>
  530. //public string UserFunctionIdList
  531. //{
  532. // get
  533. // {
  534. // if (_PowerList != null)
  535. // {
  536. // return _PowerList.UserFunctionIdList;
  537. // }
  538. // else
  539. // return "";
  540. // }
  541. //}
  542. //public string GetMenuTable(MenuType poMType)
  543. //{
  544. // string lcRetVal = "";
  545. // string lcSql = "select FunctionID,FunctionName,URL,FatherID ,Depth,IsLeaf,Sort from " + Tn.Sys_Functions + " where 1=1 ";
  546. // switch (poMType)
  547. // {
  548. // case MenuType.Back:
  549. // lcSql += " and IsBack='Y' ";
  550. // break;
  551. // case MenuType.Front:
  552. // lcSql += " and IsFront='Y' ";
  553. // break;
  554. // }
  555. // lcSql += " and FunctionID in ( " + UserFunctionIdList + " )";
  556. // lcSql += " order by sort asc ";
  557. // DataSet loDataSet = DBConn.OpenDataSet(lcSql);
  558. // if (loDataSet != null && loDataSet.Tables.Count > 0)
  559. // {
  560. // lcRetVal = loDataSet.GetXml();
  561. // }
  562. // else
  563. // {
  564. // JSComm.ShowMessage("该用户尚未配置相关权限,请与有关人员联系!");
  565. // System.Web.HttpContext.Current.Response.Write("<form id='Form2' method='post' action='../Default.aspx' target='_top' ></form><script>Form2.submit();</script>");
  566. // System.Web.HttpContext.Current.Response.End();
  567. // }
  568. // return lcRetVal;
  569. //}
  570. //public DataTable GetMenuTableDate(MenuType poMType)
  571. //{
  572. // DataTable loRetVal = null;
  573. // string lcSql = "select FunctionID,FunctionName,URL,FatherID ,Depth,IsLeaf,Sort from " + Tn.Sys_Functions + " where 1=1 ";
  574. // switch (poMType)
  575. // {
  576. // case MenuType.Back:
  577. // lcSql += " and IsBack='Y' ";
  578. // break;
  579. // case MenuType.Front:
  580. // lcSql += " and IsFront='Y' ";
  581. // break;
  582. // }
  583. // lcSql += " and FunctionID in ( " + _PowerList.UserFunctionIdList + " )";
  584. // lcSql += " order by sort asc ";
  585. // loRetVal = DBConn.OpenDataTable(lcSql);
  586. // return loRetVal;
  587. //}
  588. #endregion
  589. public void Destroy()
  590. {
  591. if (_objSave != null)
  592. {
  593. _objSave.Clear();
  594. _objSave = null;
  595. }
  596. }
  597. #region 对象存储
  598. Dictionary<string, object> _objSave;
  599. public void SetObj(string pcKey, object pcValue)
  600. {
  601. if (_objSave == null)
  602. _objSave = new Dictionary<string, object>();
  603. if (_objSave.ContainsKey(pcKey))
  604. _objSave[pcKey] = pcValue;
  605. else
  606. _objSave.Add(pcKey, pcValue);
  607. }
  608. public T GetObj<T>(string pcKey)
  609. {
  610. return GetObj<T>(pcKey, true);
  611. }
  612. /// <summary>
  613. /// 得到对象
  614. /// </summary>
  615. /// <param name="pcKey">索引值</param>
  616. /// <param name="pbClear">是否情况该对象</param>
  617. /// <returns></returns>
  618. public T GetObj<T>(string pcKey, bool pbClear)
  619. {
  620. T loRetVal = default(T);
  621. if (_objSave != null && _objSave.ContainsKey(pcKey))
  622. {
  623. if (_objSave[pcKey] is T)
  624. loRetVal = (T)_objSave[pcKey];
  625. if (pbClear)
  626. {
  627. _objSave.Remove(pcKey);
  628. }
  629. }
  630. return loRetVal;
  631. }
  632. /// <summary>
  633. /// 清空指定对象
  634. /// </summary>
  635. public void ClearObj(string pcKey)
  636. {
  637. if (_objSave != null)
  638. {
  639. if (_objSave.ContainsKey(pcKey))
  640. {
  641. _objSave.Remove(pcKey);
  642. }
  643. }
  644. }
  645. /// <summary>
  646. /// 清空对象
  647. /// </summary>
  648. public void ClearObj()
  649. {
  650. if (_objSave != null)
  651. {
  652. _objSave.Clear();
  653. _objSave = null;
  654. }
  655. }
  656. #endregion 对象存储
  657. }
  658. public enum MenuType
  659. {
  660. /// <summary>
  661. /// 前台显示
  662. /// </summary>
  663. Front = 0,
  664. /// <summary>
  665. /// 后台显示
  666. /// </summary>
  667. Back = 1,
  668. /// <summary>
  669. /// 显示所有
  670. /// </summary>
  671. All = 2
  672. }
  673. public enum AcountType
  674. {
  675. /// <summary>
  676. /// 系统用户
  677. /// </summary>
  678. System = 0,
  679. /// <summary>
  680. /// 高级用户
  681. /// </summary>
  682. Advance = 1,
  683. /// <summary>
  684. /// 普通用户
  685. /// </summary>
  686. Common = 2,
  687. /// <summary>
  688. /// 高级市场用户
  689. /// </summary>
  690. AdvanceMarket = 3,
  691. /// <summary>
  692. /// 普通市场用户
  693. /// </summary>
  694. CommonMarket = 4
  695. }
  696. }