internal void SavePlanDefineScope(PlanDefine planDefine) { List <Organization> orgList = planDefine.OrgList; List <Role> roleList = planDefine.RoleList; if (orgList != null && orgList.Count > 0) { if (roleList != null && roleList.Count > 0) { orgList.ForEach(org => { roleList.ForEach(role => { string insertSql = $@"insert into plandefineallocation(id, roleid, plandefineid, tenantid, orgid) values('{Guid.NewGuid().ToString()}','{role.ID}','{planDefine.ID}','{Utils.GetTenantId()}','{org.ID}')"; db.ExecSqlStatement(insertSql); }); }); } else { throw new Exception("角色未指定。"); } } else { throw new Exception("组织未指定。"); } }
public InfoResponse <string> Put([FromBody] PlanDefine planDefine) { InfoResponse <string> response = new InfoResponse <string>(); response.Data = PlanDefineService.Current.UpdatePlanDefine(planDefine); return(response); }
public string UpdatePlanDefine(PlanDefine planDefine) { string updateSql = $@" update plandefine set name='{planDefine.Name}',state='{Convert.ToInt32(planDefine.State)}',modelid='{planDefine.PlanModel.ID}',setid='{planDefine.PeriodSet.ID}',typeid='{planDefine.PeriodType.ID}',lastmodifiedtime='{DateTime.Now}' where id='{planDefine.ID}'"; db.ExecSqlStatement(updateSql); return(planDefine.ID); }
internal PlanDefine GetPlanDefine(string planDefineID) { PlanDefine planDefine = dac.GetPlanDefineInfo(planDefineID); List <string> orgStrList = new List <string>(); List <string> roleStrList = new List <string>(); dac.AssemblyAllocation(planDefineID, orgStrList, roleStrList); List <Organization> orgList = new List <Organization>(); List <Role> roleList = new List <Role>(); EcpOrgService orgService = new EcpOrgService(); if (orgStrList != null && orgStrList.Count > 0) { orgStrList.ForEach(orgID => { Organization org = orgService.GetByID(orgID, Utils.GetTenantId()); if (org != null) { orgList.Add(org); } }); planDefine.OrgList = orgList; } if (roleStrList != null && roleStrList.Count > 0) { Manager manager = new Manager(); roleStrList.ForEach(roleID => { Role role = manager.GetRoleByID(roleID); if (role != null) { roleList.Add(role); } }); planDefine.RoleList = roleList; } if (planDefine.PlanModel != null && planDefine.PlanModel.PlanItemModelContent != null && planDefine.PlanModel.PlanItemModelContent.Count > 0) { Dictionary <string, bool> customizedModelField = new Dictionary <string, bool>(); if (planDefine.PlanItemCustomization != null && planDefine.PlanItemCustomization.CustomizedModelContent != null && planDefine.PlanItemCustomization.CustomizedModelContent.Count > 0) { planDefine.PlanItemCustomization.CustomizedModelContent.ForEach(field => { if (!customizedModelField.ContainsKey(field.ID)) { customizedModelField.Add(field.ID, field.IsEnable); } }); } List <PlanItemModelField> content = planDefine.PlanModel.PlanItemModelContent; for (int i = 0; i < content.Count; i++) { content[i].IsEnable = true; if (customizedModelField.ContainsKey(content[i].ID)) { content[i].IsEnable = customizedModelField[content[i].ID]; } } } return(planDefine); }
public string UpdatePlanDefine(PlanDefine planDefine) { var db = Utils.GetDb(); PlanDefineDac dac = new PlanDefineDac(db); db.BeginTransaction(); try { dac.UpdatePlanDefine(planDefine); if (planDefine.PlanItemCustomization != null) { if (dac.IsExistCustomizedModel(planDefine.ID)) { dac.UpdateCustomizedModel(planDefine.PlanItemCustomization, planDefine.ID); } else { dac.SaveCustomizedModel(planDefine.PlanItemCustomization, planDefine.ID); } } if (planDefine.OrgList != null && planDefine.OrgList.Count > 0 && planDefine.RoleList != null && planDefine.RoleList.Count > 0) { dac.DeletePlanDefineScope(planDefine.ID); dac.SavePlanDefineScope(planDefine); } db.Commit(); return(planDefine.ID); } catch { db.Rollback(); throw; } }
public string SavePlanDefine(PlanDefine planDefine) { planDefine.ID = Guid.NewGuid().ToString(); string insertSql = $@"insert into plandefine(id,name,state,modelid,setid,typeid,tenantid, createdtime, lastmodifiedtime) values('{ planDefine.ID }','{planDefine.Name}','{Convert.ToInt32(planDefine.State)}','{planDefine.PlanModel.ID}','{planDefine.PeriodSet.ID}','{planDefine.PeriodType.ID}','{Utils.GetTenantId()}','{DateTime.Now}','{DateTime.Now}')"; db.ExecSqlStatement(insertSql); return(planDefine.ID); }
internal PlanDefine GetPlanDefineInfo(string planDefineID) { PlanDefine planDefine = new PlanDefine(); var queryStr = planDefineDetailInfo + $@" where (a.tenantid='0' or a.tenantid='{Utils.GetTenantId()}') and a.id = '{planDefineID}' "; var ds = db.ExecuteDataSet(queryStr); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count > 0) { planDefine = AssamblyPlanDefineDetailInfo(ds.Tables[0].Rows[0]); } return(planDefine); }
private PlanDefine AssamblyPlanDefineBaseInfo(DataRow row) { PlanDefine define = new PlanDefine(); define.ID = Convert.ToString(row["id"]); define.Name = Convert.ToString(row["name"]); define.PeriodSet.ID = Convert.ToString(row["setid"]); define.PeriodSet.Name = Convert.ToString(row["setname"]); define.PeriodType.ID = Convert.ToString(row["typeid"]); define.PeriodType.Code = Convert.ToString(row["typecode"]); define.PeriodType.Name = Convert.ToString(row["typename"]); define.PlanModel.ID = Convert.ToString(row["modelid"]); define.State = (PlanDefineState)Convert.ToInt32(row["state"]); return(define); }
private PlanDefine AssamblyPlanDefineDetailInfo(DataRow row) { PlanDefine define = AssamblyPlanDefineBaseInfo(row); define.PlanModel.Name = Convert.ToString(row["modelname"]); string modelContent = Convert.ToString(row["modelcontent"]); if (!string.IsNullOrEmpty(modelContent)) { define.PlanModel.PlanItemModelContent = Serializer.JsonDeserialize <List <PlanItemModelField> >(modelContent); } define.PlanItemCustomization.ID = Convert.ToString(row["customizeid"]); string coleDesc = Convert.ToString(row["modeldesc"]); if (!string.IsNullOrEmpty(coleDesc)) { define.PlanItemCustomization.CustomizedModelContent = Serializer.JsonDeserialize <List <CustomizedModelField> >(coleDesc); } return(define); }
public string SavePlanDefine(PlanDefine planDefine) { var db = Utils.GetDb(); PlanDefineDac dac = new PlanDefineDac(db); db.BeginTransaction(); try { string id = dac.SavePlanDefine(planDefine); if (planDefine.PlanItemCustomization != null) { dac.SaveCustomizedModel(planDefine.PlanItemCustomization, id); } dac.SavePlanDefineScope(planDefine); db.Commit(); return(id); } catch { db.Rollback(); throw; } }
public string UpdatePlanDefine(PlanDefine planDefine) { return(manager.UpdatePlanDefine(planDefine)); }
public string SavePlanDefine(PlanDefine planDefine) { return(manager.SavePlanDefine(planDefine)); }