GetSysFuncPwrExcutor.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. namespace JLHHJSvr.Excutor
  13. {
  14. internal sealed class GetSysFuncPwrExcutor : ExcutorBase<GetSysFuncPwrRequest, GetSysFuncPwrResponse>
  15. {
  16. protected override void ExcuteInternal(GetSysFuncPwrRequest request, object state, GetSysFuncPwrResponse rslt)
  17. {
  18. var tokendata = BllHelper.GetToken(request.token);
  19. if (tokendata == null)
  20. {
  21. rslt.ErrMsg = "会话已经中断,请重新登录";
  22. return;
  23. }
  24. using (var con = new SqlConnection(GlobalVar.ConnectionString))
  25. using (var cmd = con.CreateCommand())
  26. {
  27. con.Open();
  28. rslt.list = new List<sys_func_pwr>();
  29. var result = new List<sys_func_pwr>();
  30. var sysList = new List<sys_func_pwr>();
  31. DbSqlHelper.Select(cmd, "sys_func_pwr", "if_use = 1", null, null, 0, 0, sysList, null,
  32. "funcid, parentid, treename, menuname, if_use");
  33. GetChildrenData(sysList, 0, ref result);
  34. rslt.list = result;
  35. }
  36. }
  37. public void GetChildrenData (List<sys_func_pwr> data, int funcid, ref List<sys_func_pwr> reslist)
  38. {
  39. reslist = data.Where(t => t.parentid == funcid).ToList();
  40. foreach (var mx in reslist)
  41. {
  42. var list = data.Where(t => t.parentid == mx.funcid).ToList();
  43. if (list.Count > 0)
  44. {
  45. var result = new List<sys_func_pwr>();
  46. GetChildrenData(data, mx.funcid, ref result);
  47. mx.children = result;
  48. }
  49. }
  50. }
  51. }
  52. }