RoadFlow2.1 临时演示

TreeRefresh.ashx.cs 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. namespace WebForm.Platform.Members
  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. string showtype = context.Request.QueryString["showtype"] ?? "";
  17. string type = context.Request.QueryString["type"] ?? "";
  18. System.Text.StringBuilder json = new System.Text.StringBuilder("[", 1000);
  19. if ("1" == showtype)
  20. {
  21. #region 显示工作组
  22. RoadFlow.Platform.WorkGroup BWorkGroup = new RoadFlow.Platform.WorkGroup();
  23. var workGroups = BWorkGroup.GetAll();
  24. int countwg = workGroups.Count;
  25. int iwg = 0;
  26. foreach (var wg in workGroups)
  27. {
  28. json.Append("{");
  29. json.AppendFormat("\"id\":\"{0}\",", wg.ID);
  30. json.AppendFormat("\"parentID\":\"{0}\",", Guid.Empty);
  31. json.AppendFormat("\"title\":\"{0}\",", wg.Name);
  32. json.AppendFormat("\"ico\":\"{0}\",", "");
  33. json.AppendFormat("\"link\":\"{0}\",", "");
  34. json.AppendFormat("\"type\":\"{0}\",", 5);
  35. json.AppendFormat("\"hasChilds\":\"{0}\",", 0);
  36. json.Append("\"childs\":[");
  37. json.Append("]");
  38. json.Append("}");
  39. if (iwg++ < countwg - 1)
  40. {
  41. json.Append(",");
  42. }
  43. }
  44. json.Append("]");
  45. json.Append("}");
  46. context.Response.Write(json.ToString());
  47. context.Response.End();
  48. #endregion
  49. }
  50. Guid orgID;
  51. if (!id.IsGuid(out orgID))
  52. {
  53. json.Append("]");
  54. context.Response.Write(json.ToString());
  55. }
  56. RoadFlow.Platform.Organize BOrganize = new RoadFlow.Platform.Organize();
  57. var childOrgs = BOrganize.GetChilds(orgID);
  58. int count = childOrgs.Count;
  59. int i = 0;
  60. foreach (var org in childOrgs)
  61. {
  62. json.Append("{");
  63. json.AppendFormat("\"id\":\"{0}\",", org.ID);
  64. json.AppendFormat("\"parentID\":\"{0}\",", id);
  65. json.AppendFormat("\"title\":\"{0}\",", org.Name);
  66. json.AppendFormat("\"ico\":\"{0}\",", "");
  67. json.AppendFormat("\"link\":\"{0}\",", "");
  68. json.AppendFormat("\"type\":\"{0}\",", org.Type);
  69. json.AppendFormat("\"hasChilds\":\"{0}\",", org.ChildsLength);
  70. json.Append("\"childs\":[");
  71. json.Append("]");
  72. json.Append("}");
  73. if (i++ < count - 1)
  74. {
  75. json.Append(",");
  76. }
  77. }
  78. var userRelations = new RoadFlow.Platform.UsersRelation().GetAllByOrganizeID(orgID);
  79. var users = "5" == type ? BOrganize.GetAllUsers(RoadFlow.Platform.WorkGroup.PREFIX + id)
  80. : new RoadFlow.Platform.Users().GetAllByOrganizeID(orgID);
  81. int count1 = users.Count;
  82. if (count1 > 0 && count > 0)
  83. {
  84. json.Append(",");
  85. }
  86. int j = 0;
  87. foreach (var user in users)
  88. {
  89. var ur = userRelations.Find(p => p.UserID == user.ID);
  90. json.Append("{");
  91. json.AppendFormat("\"id\":\"{0}\",", user.ID);
  92. json.AppendFormat("\"parentID\":\"{0}\",", id);
  93. json.AppendFormat("\"title\":\"{0}{1}\",", user.Name, ur != null && ur.IsMain == 0 ? "<span style='color:#999;'>[兼职]</span>" : "");
  94. json.AppendFormat("\"ico\":\"{0}\",", Common.Tools.BaseUrl + "/images/ico/contact_grey.png");
  95. json.AppendFormat("\"link\":\"{0}\",", "");
  96. json.AppendFormat("\"type\":\"{0}\",", "4");
  97. json.AppendFormat("\"hasChilds\":\"{0}\",", "0");
  98. json.Append("\"childs\":[");
  99. json.Append("]");
  100. json.Append("}");
  101. if (j++ < count1 - 1)
  102. {
  103. json.Append(",");
  104. }
  105. }
  106. json.Append("]");
  107. context.Response.Write(json.ToString());
  108. }
  109. public bool IsReusable
  110. {
  111. get
  112. {
  113. return false;
  114. }
  115. }
  116. }
  117. }