public void ProcessRequest(HttpContext context) { string strJSON = null; try { string strId = context.Request.Params["id"]; string strData = context.Request.Params["data"]; type_t EntityType = (type_t)Enum.Parse(typeof(type_t), strData, true); System.Diagnostics.Debug.WriteLine(strId); System.Diagnostics.Debug.WriteLine(strData); System.Diagnostics.Debug.WriteLine(EntityType); string strSQL = GetSQL(strId, EntityType); System.Data.DataTable dt = SQL.GetDataTable(strSQL); List <TreeItem> ls = new List <TreeItem>(); foreach (System.Data.DataRow dr in dt.Rows) { TreeItem root = new TreeItem(); root.id = System.Convert.ToString(dr["obj_uid"]); root.text = System.Convert.ToString(dr["caption"]); root.children = System.Convert.ToBoolean(dr["HasChildren"]); root.state = NodeState.closed; root.data = System.Convert.ToString(dr["objtype"]); // root.type = 123; // root.type = type_t.SO; // root.type = (type_t)Enum.Parse(typeof(type_t), System.Convert.ToString(dr["objtype"])); root.type = System.Convert.ToString(dr["objtype"]); // root.a_attr.target = "_blank"; // root.a_attr.href = "http://127.0.0.1"; ls.Add(root); } // Next dr strJSON = Tools.Serialization.JSON.Serialize(ls); // List<TreeItem > obj = Tools.Serialization.JSON.Deserialize<List<TreeItem >>(strJSON); // Console.WriteLine(obj); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); Tools.AJAX.cAjaxResult AjaxResult = new Tools.AJAX.cAjaxResult(); AjaxResult.error = new Tools.AJAX.AJAXException(ex); strJSON = Tools.Serialization.JSON.Serialize(AjaxResult); } System.Diagnostics.Debug.WriteLine(strJSON); context.Response.ContentType = "application/json"; context.Response.Write(strJSON); } // End Sub ProcessRequest
public void ProcessRequest(HttpContext context) { string strJSON = null; try { string strId = context.Request.Params["id"]; string strData = context.Request.Params["data"]; //type_t EntityType = (type_t)Enum.Parse(typeof(type_t), strData, true); System.Diagnostics.Debug.WriteLine(strId); System.Diagnostics.Debug.WriteLine(strData); // System.Diagnostics.Debug.WriteLine(EntityType); List<TreeItem> ls = null; if(StringComparer.InvariantCultureIgnoreCase.Equals(strData, "NULL")) ls = GetRootData(); else ls = GetNonRootData(strData); strJSON = Tools.Serialization.JSON.Serialize(ls); // List<TreeItem > obj = Tools.Serialization.JSON.Deserialize<List<TreeItem >>(strJSON); // Console.WriteLine(obj); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); Tools.AJAX.cAjaxResult AjaxResult = new Tools.AJAX.cAjaxResult(); AjaxResult.error = new Tools.AJAX.AJAXException(ex); strJSON = Tools.Serialization.JSON.Serialize(AjaxResult); } System.Diagnostics.Debug.WriteLine(strJSON); context.Response.ContentType = "application/json"; context.Response.Write(strJSON); } // End Sub ProcessRequest
public void ProcessRequest(System.Web.HttpContext context) { string strJSON = null; try { string strId = context.Request.Params["id"]; System.Diagnostics.Debug.WriteLine(strId); List <TreeItem> ls = new List <TreeItem>(); TreeItem root = new TreeItem(); if (string.IsNullOrEmpty(strId)) { root.id = "1"; root.text = "RootNode "; } else { root.id = strId + ".1"; root.text = "Node " + strId; } // root.state = "closed"; //root.id = System.Guid.NewGuid().ToString(); root.children = true; //root.state = new KeyValuePair<string, jsbool>("closed", jsbool.@true); //root.state = oldNodeState.Disabled; // root.newstate.Add(NodeState.leaf, jsbool.@true); // root.newstate.Add(NodeState.disabled, jsbool.@true); // root.newstate.Add(NodeState.opened | NodeState.closed, jsbool.@true); // root.state = NodeState.closed | NodeState.selected | NodeState.disabled; //root.state = NodeState.closed; bool bRandomChildren = true; if (bRandomChildren) { for (int i = 0; i < 10; ++i) { TreeItem ChildNode = new TreeItem(); ChildNode.id = i.ToString(); ChildNode.text = "ChildNode " + i.ToString(); //ChildNode.state="closed"; if (i == 1) { TreeItem ChildChild = new TreeItem(); ChildChild.id = "lol"; ChildChild.text = "hello"; //ChildNode.children.Add(ChildChild); } // End if (i == 1) //root.children.Add(ChildNode); } // Next i } // End if(bRandomChildren) ls.Add(root); TreeItem root2 = new TreeItem(); if (string.IsNullOrEmpty(strId)) { root2.id = "bla"; root2.text = "Ho;ha"; } else { root2.id = strId + ".1"; root2.text = "More blabla"; } ls.Add(root2); strJSON = Tools.Serialization.JSON.Serialize(ls); } // End Try catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); Tools.AJAX.cAjaxResult AjaxResult = new Tools.AJAX.cAjaxResult(); AjaxResult.error = new Tools.AJAX.AJAXException(ex); strJSON = Tools.Serialization.JSON.Serialize(AjaxResult); } // End Catch System.Diagnostics.Debug.WriteLine(strJSON); context.Response.ContentType = "application/json"; context.Response.Write(strJSON); } // End Sub ProcessRequest
} // End Function GetSQL public void ProcessRequest(HttpContext context) { string strJSON = null; try { string strId = context.Request.Params["id"]; string strData = context.Request.Params["data"]; string strPath = context.Request.Params["path"]; string path_id = context.Request.Params["path_id"]; type_t EntityType = (type_t)Enum.Parse(typeof(type_t), strData, true); System.Diagnostics.Debug.WriteLine(strId); System.Diagnostics.Debug.WriteLine(strData); System.Diagnostics.Debug.WriteLine(strPath); System.Diagnostics.Debug.WriteLine(path_id); System.Diagnostics.Debug.WriteLine(EntityType); string strSQL = GetSQL(strId, EntityType); long lng; long.TryParse(strId, out lng); strSQL = strSQL.Replace("@abc", lng.ToString()); System.Data.DataTable dt = SQL.GetDataTable(strSQL); List <TreeItem> ls = new List <TreeItem>(); foreach (System.Data.DataRow dr in dt.Rows) { TreeItem root = new TreeItem(); //root.id = strPath + "/" + System.Convert.ToString(dr["Path_Id"]); // Trouble - symlink unfortunately has same id // but this id is only used by jsTree anyway root.id = System.Guid.NewGuid().ToString(); root.real_id = System.Convert.ToString(dr["real_path_id"]); root.path_id = System.Convert.ToString(dr["Path_Id"]); root.text = System.Convert.ToString(dr["name"]); root.children = System.Convert.ToBoolean(dr["HasChildren"]); root.state = NodeState.closed; root.data = System.Convert.ToString(dr["objtype"]); // root.type = 123; // root.type = type_t.SO; // root.type = (type_t)Enum.Parse(typeof(type_t), System.Convert.ToString(dr["objtype"])); root.type = System.Convert.ToString(dr["objtype"]); // root.a_attr.target = "_blank"; // root.a_attr.href = "http://127.0.0.1"; ls.Add(root); } // Next dr strJSON = Tools.Serialization.JSON.Serialize(ls); // List<TreeItem > obj = Tools.Serialization.JSON.Deserialize<List<TreeItem >>(strJSON); // Console.WriteLine(obj); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); Tools.AJAX.cAjaxResult AjaxResult = new Tools.AJAX.cAjaxResult(); AjaxResult.error = new Tools.AJAX.AJAXException(ex); strJSON = Tools.Serialization.JSON.Serialize(AjaxResult); } System.Diagnostics.Debug.WriteLine(strJSON); context.Response.ContentType = "application/json"; context.Response.Write(strJSON); } // End Sub ProcessRequest