/// <summary> /// 取定义的校审步骤 /// </summary> /// <param name="auditConfig"></param> /// <returns></returns> public virtual List <AuditStep> GetDefStepList(S_C_ProofreadConfiguration auditConfig, Dictionary <string, Dictionary <string, string> > userInfo) { List <AuditStep> stepList = new List <AuditStep>(); var auditList = JsonHelper.ToObject <List <Dictionary <string, object> > >(auditConfig.AuditSteps); foreach (var dic in auditList) { var step = new AuditStep(dic); //设置人员 if (!string.IsNullOrEmpty(dic.GetValue("AuditRole"))) { foreach (string role in dic.GetValue("AuditRole").Split(',')) { var user = userInfo.GetValue(role); if (user == null) { continue; } string userID = user.GetValue("UserID"); //如果配置的是角色顺序优先,且第一个角色有人,则直接赋值,退出循环 //if (dic.GetValue("OnlyFirst") == "是" && !string.IsNullOrEmpty(userID)) //{ // step.UserID = user.GetValue("UserID"); // step.UserName = user.GetValue("UserName"); // break; //} //else if (!string.IsNullOrEmpty(userID) && step.UserID.IndexOf(userID) < 0) { string[] ids = userID.Split(','); string[] names = user.GetValue("UserName").Split(','); for (int i = 0; i < ids.Length; i++) { if (step.UserID.IndexOf(ids[i]) < 0) { step.UserID = step.UserID + ids[i] + ","; step.UserName = step.UserName + names[i] + ","; } } } } step.UserID = step.UserID.TrimEnd(','); step.UserName = step.UserName.TrimEnd(','); } //如果配置了人员为空,跳过本环节,则进行下个循环 if (!string.IsNullOrEmpty(dic.GetValue("EmptyToNext")) && dic.GetValue("EmptyToNext") == "是" && string.IsNullOrEmpty(step.UserID)) { continue; } stepList.Add(step); } return(stepList); }
public virtual bool IsMatching(S_C_ProofreadConfiguration auditConfig, S_W_WBS wbs, S_I_ProjectInfo projectInfo, List <S_E_Product> productList) { if (string.IsNullOrEmpty(auditConfig.AuditParams)) { return(true); } List <AuditConfigParam> list = JsonHelper.ToObject <List <AuditConfigParam> >(auditConfig.AuditParams); bool isTure = true; var taskWork = wbs.S_W_TaskWork.FirstOrDefault(); foreach (var param in list) { //如果值空,忽略此条件 if (string.IsNullOrEmpty(param.PropertyKey)) { continue; } Type t = Type.GetType("Project.Logic.Domain." + param.TableKey); if (t == null) { return(false); } PropertyInfo pi = t.GetProperty(param.ColumnKey); if (pi == null) { return(false); } switch (param.TableKey) { case "S_I_ProjectInfo": string value = (string)pi.GetValue(projectInfo, null); if (value == null || !param.PropertyKey.Split(',').Contains(value)) { return(false); } break; case "S_W_TaskWork": //var taskWork = wbs.S_W_TaskWork.FirstOrDefault(); if (taskWork == null) { return(false); } value = (string)pi.GetValue(taskWork, null); if (value == null || !param.PropertyKey.Split(',').Contains(value)) { return(false); } break; case "S_E_Product": bool exists = false; foreach (var product in productList) { value = (string)pi.GetValue(product, null); if (value != null && param.PropertyKey.Split(',').Contains(value)) { exists = true; break; } } if (!exists) { return(false); } break; } } return(isTure); }