RoadFlow2.1 临时演示

TreeRefresh.ashx.cs 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. namespace WebForm.Platform.RoleApp
  6. {
  7. /// <summary>
  8. /// TreeRefresh 的摘要说明
  9. /// </summary>
  10. public class TreeRefresh : IHttpHandler
  11. {
  12. public void ProcessRequest(HttpContext context)
  13. {
  14. context.Response.ContentType = "text/plain";
  15. string id = context.Request["refreshid"];
  16. if (!id.IsGuid())
  17. {
  18. context.Response.Write("[]");
  19. return;
  20. }
  21. RoadFlow.Platform.RoleApp BRoleApp = new RoadFlow.Platform.RoleApp();
  22. var childs = BRoleApp.GetChild(id.ToGuid());
  23. System.Text.StringBuilder json = new System.Text.StringBuilder("[", childs.Count * 50);
  24. int count = childs.Count;
  25. int i = 0;
  26. foreach (var child in childs)
  27. {
  28. json.Append("{");
  29. json.AppendFormat("\"id\":\"{0}\",", child.ID);
  30. json.AppendFormat("\"title\":\"{0}\",", child.Title);
  31. json.AppendFormat("\"ico\":\"{0}\",", child.Ico.IsNullOrEmpty() ? "" : Common.Tools.BaseUrl + child.Ico);
  32. json.AppendFormat("\"link\":\"{0}\",", "");
  33. json.AppendFormat("\"type\":\"{0}\",", "0");
  34. json.AppendFormat("\"model\":\"{0}\",", "");
  35. json.AppendFormat("\"width\":\"{0}\",", "");
  36. json.AppendFormat("\"height\":\"{0}\",", "");
  37. json.AppendFormat("\"hasChilds\":\"{0}\",", BRoleApp.HasChild(child.ID) ? "1" : "0");
  38. json.AppendFormat("\"childs\":[");
  39. json.Append("]");
  40. json.Append("}");
  41. if (i++ < count - 1)
  42. {
  43. json.Append(",");
  44. }
  45. }
  46. json.Append("]");
  47. context.Response.Write(json.ToString());
  48. }
  49. public bool IsReusable
  50. {
  51. get
  52. {
  53. return false;
  54. }
  55. }
  56. }
  57. }