/// <summary> /// 给栏目绑定指标 页面 /// </summary> /// <param name="keyValue">栏目Id</param> /// <param name="indexType">所属平台 0web平台 1安卓平台 2App</param> /// <param name="Templet">所属栏目</param> /// <returns></returns> public ActionResult TerminalBindForm(string keyValue, int indexType, int Templet) { Operator user = OperatorProvider.Provider.Current(); DepartmentEntity userdept = new DepartmentBLL().GetCompany(user.DeptId); TerminalDataSetBLL dataSetBLL = new TerminalDataSetBLL(); List <TerminalDataSetEntity> indexlist = new List <TerminalDataSetEntity>(); indexlist = dataSetBLL.GetList().Where(p => p.IsOpen == 1).ToList(); //if (indexType == 2) //{ // indexlist = dataSetBLL.GetList().Where(p => p.IsOpen == 1 && (p.DataSetType == indexType.ToString() )).ToList(); //所有的手机APP指标 //} //else //{ // indexlist = dataSetBLL.GetList().Where(p => p.IsOpen == 1 && (p.DataSetType == indexType.ToString() || p.DataSetType == null)).ToList(); //所有的终端指标 //} //查询本IndexType的栏目 var titleIds = manageBLL.GetList(userdept.DepartmentId, indexType).Where(x => x.Templet == Templet).Select(x => x.Id); //查找所有的关联关系 IIndexAssocationBLL indexAssocationBLL = new IIndexAssocationBLL(); List <IndexAssocationEntity> indices = indexAssocationBLL.GetListByTitleId(titleIds.ToArray()); //先剔除非本IndexType的关联关系 indices = indices.Where(x => titleIds.Contains(x.TitleId)).ToList(); //查询未被其他标题绑定的指标 var BindIds = indices.Where(x => x.TitleId != keyValue).Select(p => p.DataSetId); //非当前标题 已经的被帮的指标 var thisBindIds = indices.Where(x => x.TitleId == keyValue).Select(p => p.DataSetId); //当前标题绑定的指标 var data = indexlist.Where(x => !BindIds.Contains(x.Id)).ToList(); //当前标题 可显示的指标 ViewBag.ChceckIds = thisBindIds.ToList(); ViewBag.TitleId = keyValue; return(View(data)); }
public ActionResult RemoveTitle(string keyValue) { try { manageBLL.Remove(keyValue); //删除与指标的关联关系 IIndexAssocationBLL assocationBLL = new IIndexAssocationBLL(); //先查出该标题下所有的指标 List <IndexAssocationEntity> entities = assocationBLL.GetListByTitleId(keyValue); assocationBLL.Remove(entities); return(Success("操作成功")); } catch (Exception ex) { return(Error(ex.Message)); } }
public ActionResult SaveAssociation(string titleId, string indexIdStr) { try { List <string> indexIds = Newtonsoft.Json.JsonConvert.DeserializeObject <List <string> >(indexIdStr); IIndexAssocationBLL assocationBLL = new IIndexAssocationBLL(); //先查出该标题下所有的指标 List <IndexAssocationEntity> oldEntity = assocationBLL.GetListByTitleId(titleId); //要删除的数据 List <IndexAssocationEntity> delEntity = oldEntity.Where(x => !indexIds.Contains(x.DataSetId)).ToList(); //要新增进去的数据 var oldids = oldEntity.Select(o => o.DataSetId).ToList(); var addIds = indexIds.Where(p => !oldids.Contains(p)).ToList(); Operator user = OperatorProvider.Provider.Current(); List <IndexAssocationEntity> addEntitys = new List <IndexAssocationEntity>(); addIds.ForEach(setId => { addEntitys.Add(new IndexAssocationEntity() { Id = Guid.NewGuid().ToString(), DataSetId = setId, DeptId = user.DeptId, TitleId = titleId }); }); assocationBLL.Remove(delEntity); assocationBLL.Insert(addEntitys); return(Success("操作成功")); } catch (Exception ex) { return(Error("保存失败:" + ex.Message)); } }