GetSysFuncPwrExcutor.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using System.Linq;
  5. using System.Text;
  6. using JLHHJSvr.BLL;
  7. using JLHHJSvr.Com;
  8. using JLHHJSvr.Com.Model;
  9. using JLHHJSvr.DBA.DBModle;
  10. using LJLib.DAL.SQL;
  11. using LJLib.Net.SPI.Server;
  12. using LJLib.SQLEX;
  13. namespace JLHHJSvr.Excutor
  14. {
  15. internal sealed class GetSysFuncPwrExcutor : ExcutorBase<GetSysFuncPwrRequest, GetSysFuncPwrResponse>
  16. {
  17. protected override void ExcuteInternal(GetSysFuncPwrRequest request, object state, GetSysFuncPwrResponse rslt)
  18. {
  19. var tokendata = BllHelper.GetToken(request.token);
  20. if (tokendata == null)
  21. {
  22. rslt.ErrMsg = "会话已经中断,请重新登录";
  23. return;
  24. }
  25. using (var con = GlobalVar.ConnectionString.NewSqlConnection())
  26. using (var cmd = con.CreateCommand())
  27. {
  28. con.Open();
  29. rslt.list = new List<sys_func_pwr>();
  30. var result = new List<sys_func_pwr>();
  31. var sysList = new List<sys_func_pwr>();
  32. DbSqlHelper.Select(cmd, "sys_func_pwr", "if_use = 1", null, null, 0, 0, sysList, null,
  33. "funcid, parentid, treename, menuname, if_use");
  34. GetChildrenData(sysList, 0, ref result);
  35. rslt.list = result;
  36. }
  37. }
  38. public void GetChildrenData (List<sys_func_pwr> data, int funcid, ref List<sys_func_pwr> reslist)
  39. {
  40. reslist = data.Where(t => t.parentid == funcid).ToList();
  41. foreach (var mx in reslist)
  42. {
  43. var list = data.Where(t => t.parentid == mx.funcid).ToList();
  44. if (list.Count > 0)
  45. {
  46. var result = new List<sys_func_pwr>();
  47. GetChildrenData(data, mx.funcid, ref result);
  48. mx.children = result;
  49. }
  50. }
  51. }
  52. }
  53. }