RoadFlow2.1 临时演示

TreeRefresh.ashx.cs 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. namespace WebForm.Platform.Dictionary
  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.QueryString["refreshid"];
  16. Guid gid;
  17. if (!id.IsGuid(out gid))
  18. {
  19. context.Response.Write("[]");
  20. return;
  21. }
  22. System.Text.StringBuilder json = new System.Text.StringBuilder("[", 1000);
  23. RoadFlow.Platform.Dictionary BDict = new RoadFlow.Platform.Dictionary();
  24. var childs = BDict.GetChilds(gid).OrderBy(p => p.Sort);
  25. int i = 0;
  26. int count = childs.Count();
  27. foreach (var child in childs)
  28. {
  29. var hasChilds = BDict.HasChilds(child.ID);
  30. json.Append("{");
  31. json.AppendFormat("\"id\":\"{0}\",", child.ID);
  32. json.AppendFormat("\"parentID\":\"{0}\",", child.ParentID);
  33. json.AppendFormat("\"title\":\"{0}\",", child.Title);
  34. json.AppendFormat("\"type\":\"{0}\",", hasChilds ? "1" : "2");
  35. json.AppendFormat("\"ico\":\"{0}\",", "");
  36. json.AppendFormat("\"hasChilds\":\"{0}\",", hasChilds ? "1" : "0");
  37. json.Append("\"childs\":[");
  38. json.Append("]");
  39. json.Append("}");
  40. if (i++ < count - 1)
  41. {
  42. json.Append(",");
  43. }
  44. }
  45. json.Append("]");
  46. context.Response.Write(json.ToString());
  47. }
  48. public bool IsReusable
  49. {
  50. get
  51. {
  52. return false;
  53. }
  54. }
  55. }
  56. }