private static Dictionary <string, RuleContents> LoadRuleContents() { Dictionary <string, RuleContents> ruleContents = new Dictionary <string, RuleContents>(); JObject o = JsonFileController.LoadJsonFile("assets\\基準30.json"); foreach (var rule in o) { RuleContents r = new RuleContents( rule.Value["Title"].ToString(), rule.Value["NotFitText"].ToString(), rule.Value["PassCondition"].ToString(), (int)rule.Value["Class"] ); int number = 1; foreach (JObject sub in rule.Value["SubRuleList"]) { SubRuleContents content = new SubRuleContents( sub["Description"].ToString(), sub["DefaultAcceptText"].ToString(), sub["DefaultFailText"].ToString(), number); r.SubRuleContentsList.Add(content); number++; } ruleContents.Add(rule.Key, r); } return(ruleContents); }
public void RuleStr2Contents(string ruleContent) { if (!string.IsNullOrEmpty(ruleContent)) { CalUtility calUtil = new CalUtility(ruleContent.Replace("并且", "&&").Replace("或者", "||")); QC_CheckItem_Table CheckItemGlobal = QC_CheckItem_Table.Global; for (int i = 0; i < calUtil.NifixExpression.Count; i++) { if (calUtil.NifixExpression[i].OpTyp == FormulaItemType.Tag) { if (calUtil.NifixExpression[i + 1].OpTyp == FormulaItemType.Operator && calUtil.NifixExpression[i + 2].OpTyp == FormulaItemType.Number) { QC_CheckItem ckItem = CheckItemGlobal.First <QC_CheckItem>((checkItem) => checkItem.CheckItemName == calUtil.NifixExpression[i].Name); QC_QualityRuleContent rc = new QC_QualityRuleContent(); rc.CheckItemNcId = ckItem.CheckItemNcId; rc.CheckItemCode = ckItem.CheckItemCode; rc.CheckItemName = ckItem.CheckItemName; rc.Relation = calUtil.NifixExpression[i + 1].Name; rc.ConstraintVal = calUtil.NifixExpression[i + 2].GetValue(); RuleContents.Add(rc); } else { throw new Exception("表达式不对," + ruleContent); } } } } }
protected override void AfterSave(System.Data.IDbTransaction trans) { if (this.SaveRuleContents) { if (this.DataState == DataRowState.Deleted) { DbContext.ExeSql("Delete From QC_QualityRuleContent where QualityRuleId=@QualityRuleId", this.QualityRuleId); RuleContents.Empty(); } else { foreach (var item in RuleContents) { item.QualityRuleId = this.QualityRuleId; } RuleContents.Save(trans); } } base.AfterSave(trans); }
public override void AfterLoad(string loadInfo) { RuleContents.LoadDataByWhere("QualityRuleId=@QualityRuleId", QualityRuleId); }