protected void Page_Load(object sender, EventArgs e) { ckId = RequestData.Get("ckId") + ""; nodeId = RequestData.Get("nodeId") + ""; allowNodeId = RequestData.Get("allowNodeId") + ""; string SQLINStr = string.Empty; // eg: '123123','bbbb' if (allowNodeId.Contains(",")) { string[] tmpArr = allowNodeId.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < tmpArr.Length; i++) { if (i > 0) { SQLINStr += ","; } SQLINStr += "'" + tmpArr[i] + "'"; } } string jsonStr = string.Empty; //string SQL = "select * from FL_Culture..V_MiddleDbOrg"; string SQL = "select GroupID As ID ,GroupID,Name,Code,ParentID from SysGroup where Type=2 and ParentID is not null"; if (!string.IsNullOrEmpty(nodeId)) { var Ent = SysInfoConfig.FindFirstByProperties("Code", "MiddleDbOrg"); DoUpdateNode(Ent, SQL); if (!string.IsNullOrEmpty(allowNodeId)) { GDt = DataHelper.QueryDataTable(SQL); DataRow[] rows = null; if (!string.IsNullOrEmpty(SQLINStr)) { rows = GDt.Select(" GroupID in (" + SQLINStr + ") "); //better指定公司 } else { rows = GDt.Select(" GroupID in ('" + allowNodeId + "') "); //better指定公司 } List <TreeNode> listTree = GetTree(rows); jsonStr = JsonHelper.GetJsonString(listTree); } else { jsonStr = Ent.Content; } Response.Write(jsonStr); Response.End(); } }
/// <summary> /// 更新节点json /// </summary> private void DoUpdateNode(SysInfoConfig Ent, string SQL) { if (Ent.UpdateTime.GetValueOrDefault().Year < DateTime.Now.Year || Ent.UpdateTime.GetValueOrDefault().DayOfYear < DateTime.Now.DayOfYear) //以天为周期更新 { GDt = DataHelper.QueryDataTable(SQL); DataRow[] rows = SelectDt(GDt, adapterNodeId(nodeId)); List <TreeNode> listTree = GetTree(rows); string jsonStr = JsonHelper.GetJsonString(listTree); Ent.UpdateTime = DateTime.Now; Ent.Content = jsonStr; Ent.DoUpdate(); } }