public JsonResult AddChildWithDefAttr(string Children) { var dic = JsonHelper.ToObject(Children); string parentIDs = dic["ParentIDs"].ToString(); string children = dic["childNodes"].ToString(); string type = dic["Type"].ToString(); var list = BaseConfigFO.GetWBSAttrList(type); foreach (var parentID in parentIDs.TrimEnd(',').Split(',')) { var parent = this.GetEntityByID <S_D_WBSTemplateNode>(parentID); if (parent == null) { throw new Formula.Exceptions.BusinessException("未能找到ID为【" + parentID + "】的WBS节点,无法增加子节点"); } foreach (var item in children.Split(',')) { var attrDefine = list.FirstOrDefault(d => d.Code == item); if (attrDefine == null) { continue; } var wbs = new S_D_WBSTemplateNode(); wbs.WBSType = dic["Type"].ToString(); wbs.Name = attrDefine.Name; wbs.SortIndex = attrDefine.SortIndex; wbs.WBSValue = item; parent.AddChild(wbs); } } this.entities.SaveChanges(); return(Json("")); }
public JsonResult ImportPackage(string DataSource, string TargetID, string TemplateID) { var templateInfo = this.GetEntityByID <S_D_WBSTemplate>(TemplateID); var list = JsonHelper.ToList(DataSource); if (templateInfo == null) { throw new Formula.Exceptions.BusinessException("未能找到ID为【" + TemplateID + "】的项目对象,导入工作包失败"); } var majorList = templateInfo.GetMajorList(); if (majorList.Count == 0) { throw new Formula.Exceptions.BusinessException("没有策划专业节点,无法进行工作包导入操作"); } if (String.IsNullOrEmpty(TargetID)) { foreach (var item in list) { string majorValue = item.GetValue("MajorCode"); var wbslist = majorList.Where(d => d.WBSValue == majorValue).ToList(); foreach (var wbs in wbslist) { var task = new S_D_WBSTemplateNode(); task.Name = item.GetValue("Name"); task.WBSType = WBSNodeType.Work.ToString(); task.Code = item.GetValue("Code"); if (!String.IsNullOrEmpty(item.GetValue("WorkLoad"))) { task.WorkLoad = Convert.ToDecimal(item.GetValue("WorkLoad")); } wbs.AddChild(task); } } } else { var wbs = this.GetEntityByID <S_D_WBSTemplateNode>(TargetID); if (wbs == null) { throw new Formula.Exceptions.BusinessException("未能找到ID为【" + TargetID + "】的WBS节点,导入工作包失败"); } foreach (var item in list) { string majorValue = item.GetValue("MajorCode"); var task = new S_D_WBSTemplateNode(); task.Name = item.GetValue("Name"); task.WBSType = WBSNodeType.Work.ToString(); task.Code = item.GetValue("Code"); if (!String.IsNullOrEmpty(item.GetValue("WorkLoad"))) { task.WorkLoad = Convert.ToDecimal(item.GetValue("WorkLoad")); } wbs.AddChild(task); } } this.entities.SaveChanges(); return(Json("")); }
public JsonResult AddChild(string parentIDs, string Children, string WBSType) { foreach (var parentID in parentIDs.TrimEnd(',').Split(',')) { var parent = this.GetEntityByID <S_D_WBSTemplateNode>(parentID); if (parent == null) { throw new Formula.Exceptions.BusinessException("未能找到ID为【" + parentID + "】的WBS节点,无法增加子节点"); } var list = JsonHelper.ToList(Children); foreach (var item in list) { var wbs = new S_D_WBSTemplateNode(); this.UpdateEntity <S_D_WBSTemplateNode>(wbs, item); parent.AddChild(wbs); } } this.entities.SaveChanges(); return(Json("")); }