RoadFlow2.1 临时演示

Tree1.aspx.cs 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. namespace WebForm.Platform.UserApp
  8. {
  9. public partial class Tree1 : System.Web.UI.Page
  10. {
  11. protected void Page_Load(object sender, EventArgs e)
  12. {
  13. string roleID = Request.QueryString["roleid"];
  14. Guid roleGuid;
  15. if (!roleID.IsGuid(out roleGuid))
  16. {
  17. Response.Write("[]");
  18. Response.End();
  19. }
  20. RoadFlow.Platform.RoleApp BRoleApp = new RoadFlow.Platform.RoleApp();
  21. var appDt = BRoleApp.GetAllDataTableByRoleID(roleGuid);
  22. if (appDt.Rows.Count == 0)
  23. {
  24. Response.Write("[]");
  25. Response.End();
  26. }
  27. var root = appDt.Select("ParentID='" + Guid.Empty.ToString() + "'");
  28. if (root.Length == 0)
  29. {
  30. Response.Write("[]");
  31. Response.End();
  32. }
  33. var apps = appDt.Select("ParentID='" + root[0]["ID"].ToString() + "'");
  34. System.Text.StringBuilder json = new System.Text.StringBuilder("[", 1000);
  35. System.Data.DataRow rootDr = root[0];
  36. json.Append("{");
  37. json.AppendFormat("\"id\":\"{0}\",", rootDr["ID"]);
  38. json.AppendFormat("\"title\":\"{0}\",", rootDr["Title"]);
  39. json.AppendFormat("\"ico\":\"{0}\",", rootDr["Ico"]);
  40. json.AppendFormat("\"link\":\"{0}\",", rootDr["Address"]);
  41. json.AppendFormat("\"type\":\"{0}\",", "0");
  42. json.AppendFormat("\"model\":\"{0}\",", rootDr["OpenMode"]);
  43. json.AppendFormat("\"width\":\"{0}\",", rootDr["Width"]);
  44. json.AppendFormat("\"height\":\"{0}\",", rootDr["Height"]);
  45. json.AppendFormat("\"hasChilds\":\"{0}\",", apps.Length > 0 ? "1" : "0");
  46. json.AppendFormat("\"childs\":[");
  47. for (int i = 0; i < apps.Length; i++)
  48. {
  49. System.Data.DataRow dr = apps[i];
  50. var childs = appDt.Select("ParentID='" + dr["ID"].ToString() + "'");
  51. json.Append("{");
  52. json.AppendFormat("\"id\":\"{0}\",", dr["ID"]);
  53. json.AppendFormat("\"title\":\"{0}\",", dr["Title"]);
  54. json.AppendFormat("\"ico\":\"{0}\",", dr["Ico"]);
  55. json.AppendFormat("\"link\":\"{0}\",", dr["Address"]);
  56. json.AppendFormat("\"type\":\"{0}\",", "0");
  57. json.AppendFormat("\"model\":\"{0}\",", dr["OpenMode"]);
  58. json.AppendFormat("\"width\":\"{0}\",", dr["Width"]);
  59. json.AppendFormat("\"height\":\"{0}\",", dr["Height"]);
  60. json.AppendFormat("\"hasChilds\":\"{0}\",", childs.Length > 0 ? "1" : "0");
  61. json.AppendFormat("\"childs\":[");
  62. json.Append("]");
  63. json.Append("}");
  64. if (i < apps.Length - 1)
  65. {
  66. json.Append(",");
  67. }
  68. }
  69. json.Append("]");
  70. json.Append("}");
  71. json.Append("]");
  72. Response.Write(json.ToString());
  73. }
  74. }
  75. }