/// <summary> /// 指标采集-数据导出-部门树 /// </summary> /// <returns></returns> // GET /api/DepartmentApi/GetDepartment public HttpResponseMessage GetDepartment() { BaseService bs_gp = new BaseService(); UtilFunction uf = new UtilFunction(); // 部门TREE List <Tree_t> list = new List <Tree_t>(); // 查询所有部门 DataTable datatable = bs_gp.GetDataTableToID("findDepartment_To2GP"); // 一级部门 foreach (DataRow row1 in datatable.Select("parent_id=0")) { Tree_t tree1 = new Tree_t(); tree1.id = row1["id"].ToString(); tree1.text = row1["dname"].ToString(); tree1.nodes = new List <Tree_t>(); // 二级部门 foreach (DataRow row2 in datatable.Select("parent_id=" + tree1.id)) { Tree_t tree2 = new Tree_t(); tree2.id = row2["id"].ToString(); tree2.text = row2["dname"].ToString(); tree2.nodes = new List <Tree_t>(); tree1.nodes.Add(tree2); } list.Add(tree1); } string myjson = uf.ToJson(list); return(GetJSONMessage(myjson)); }
// GET api/userapi/GetTBTreeView 配置用户指标 /// <summary> /// 配置用户指标 /// </summary> /// <param name="userid">用户编号</param> /// <returns></returns> public HttpResponseMessage GetTBTreeView(int userid) { try { FileLog.WriteLog("InfoApiTime:" + DateTime.Now.ToString() + ",调用:Angel.ControllersApi/ControllerApi/UserApiController/GetTBTreeView()方法"); string[] IndicatoryList = { "" }; if (userid > 0) { string indicatorlist = IndicatorListdata(userid); if (indicatorlist.Trim().Length > 2) { JObject model = JObject.FromObject(JsonConvert.DeserializeObject("{indicator:" + indicatorlist + "}")); IndicatoryList = model["indicator"][0]["indicator_content"].ToString().ToUpper().Split(','); } else { IndicatoryList = null; } } else { IndicatoryList = null; } BaseService bs = new BaseService(); UtilFunction uf = new UtilFunction(); DataTable TableB = bs.GetDataTableToID("TreeViewBusiness"); List <Tree_t> list = new List <Tree_t>(); foreach (DataRow row in TableB.Rows) { Tree_t treeview = new Tree_t(); treeview.text = (string)row["title"]; treeview.id = (string)row["id"]; treeview.pid = "0"; state st = new state(); if (IndicatoryList != null && IndicatoryList.Contains((string)row["id"])) { st.@checked = "true"; } // st.selected = "true"; treeview.state = st; //查询业务下所有维度信息start string sql = "{\"BuesinessIDGetDimension\":[{\"[@c0]\": \"" + row["id"].ToString() + "\"}]}"; var listsql = Newtonsoft.Json.Linq.JObject.Parse(sql); Dictionary <string, JArray> jarrays = new Dictionary <string, JArray>(); foreach (var arry in listsql) { jarrays.Add(arry.Key, arry.Value as JArray); } DataTable DimTable = bs.GetDataTableToParamID(jarrays); List <Tree_t> listdim = new List <Tree_t>(); foreach (DataRow rowd in DimTable.Rows) { Tree_t treeview_d = new Tree_t(); treeview_d.text = (string)rowd["title"]; treeview_d.id = (string)rowd["id"]; treeview_d.pid = "1"; state std = new state(); if (IndicatoryList != null && IndicatoryList.Contains((string)rowd["id"])) { std.@checked = "true"; } // st.selected = "true"; treeview_d.state = std; //查询维度下所有指标信息start string sqli = "{\"DimIdGetIndicator\":[{\"[@c0]\": \"" + rowd["id"].ToString() + "\"}]}"; var listsqli = Newtonsoft.Json.Linq.JObject.Parse(sqli); Dictionary <string, JArray> jarraysi = new Dictionary <string, JArray>(); foreach (var arryi in listsqli) { jarraysi.Add(arryi.Key, arryi.Value as JArray); } DataTable InTable = bs.GetDataTableToParamID(jarraysi); List <Tree_t> listIn = new List <Tree_t>(); foreach (DataRow rowi in InTable.Rows) { Tree_t treeview_i = new Tree_t(); treeview_i.text = (string)rowi["title"]; treeview_i.id = (string)rowi["id"]; treeview_i.pid = "2"; state sti = new state(); if (IndicatoryList != null && IndicatoryList.Contains((string)rowi["id"])) { sti.@checked = "true"; } // st.selected = "true"; treeview_i.state = sti; listIn.Add(treeview_i); } //指标end treeview_d.nodes = listIn; listdim.Add(treeview_d); } //维度end treeview.nodes = listdim; list.Add(treeview); } //开始解析treeview string myjson = uf.ToJson(list); return(GetJSONMessage(myjson)); } catch (Exception er) { FileLog.WriteLog("Error:调用Angel.ControllersApi/ControllerApi/UserApiController/GetTBTreeView()方法," + er.ToString()); return(GetJSONMessage("")); } }