public ActionResult Machine() { var bllMachine = new MesWeb.BLL.T_Machine(); var machineList = bllMachine.GetModelList(""); var bllParam = new MesWeb.BLL.T_ParameterCode(); var bllSensor = new MesWeb.BLL.T_SensorModule(); var bllSensor_Param = new MesWeb.BLL.T_SensorModule_T_ParameterCode(); //机台参数树状结构 var vmJSTree = new List <VM_JSTree>(); //遍历机台 foreach (var machine in machineList) { var machineTreeId = "mach_" + machine.MachineID.ToString(); var machTree = new VM_JSTree { text = machine.MachineName, id = machineTreeId }; var sensorList = bllSensor.GetModelList("MachineID = " + machine.MachineID); machTree.children = new List <VM_JSTree>(); foreach (var sensor in sensorList) { var spList = bllSensor_Param.GetModelList("SensorModuleID = " + sensor.SensorModuleID); //遍历参数 foreach (var sp in spList) { var param = bllParam.GetModel(sp.ParameterCodeID.Value); machTree.children.Add( new VM_JSTree { text = param.ParameterName, id = machineTreeId + "_param_" + param.ParameterCodeID.ToString() }); } } vmJSTree.Add(machTree); } return(View(vmJSTree)); }
/// <summary> /// 用户配置 /// </summary> /// <returns></returns> public ActionResult UserConf() { var vmJstreeList = new List <VM_JSTree>(); var bllDept = new MesWeb.BLL.T_Department(); var bllEmp = new MesWeb.BLL.T_Employee(); var deptList = bllDept.GetModelList(""); var bllUser = new MesWeb.BLL.T_User(); var userList = bllUser.GetModelList(""); foreach (var dept in deptList) { var deptTree = new VM_JSTree { text = dept.DepartmentName, id = "dept_" + dept.DepartmentID.ToString() }; deptTree.children = new List <VM_JSTree>(); foreach (var user in userList) { if (!user.EmployeeID.HasValue) { continue; } var emp = bllEmp.GetModel(user.EmployeeID.Value); if (emp != null) { if (emp.DepartmentID == dept.DepartmentID) { deptTree.children.Add(new VM_JSTree { text = user.UserName, id = "user_" + user.UserID.ToString() }); // userList.Remove(user); } } } vmJstreeList.Add(deptTree); } return(View(vmJstreeList)); }