public override void Validate(ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Context ctx) { BudgetFormulaService service = new BudgetFormulaService(); foreach (ExtendedDataEntity entity in dataEntities) { this.CheckFormula(ctx, validateContext, entity, service); } }
public override void BeginOperationTransaction(BeginOperationTransactionArgs e) { DynamicObjectCollection allCustomFunctions = new BudgetFormulaService().GetAllCustomFunctions(base.Context); foreach (DynamicObject obj2 in e.DataEntitys) { string input = Convert.ToString(obj2["Express"]).ToLowerInvariant(); List <string> values = new List <string>(); foreach (DynamicObject obj3 in allCustomFunctions) { Regex regex = new Regex(string.Format(@"\s*({0})\s*\(", Convert.ToString(obj3["FNumber"])), RegexOptions.IgnoreCase); if (regex.Match(input).Success) { values.Add("_" + Convert.ToString(obj3["FID"]) + "_"); } } obj2["FunctionIds"] = string.Join(",", values); } }
private void CheckFormula(Context ctx, ValidateContext validateContext, ExtendedDataEntity entity, BudgetFormulaService service) { string formula = Convert.ToString(entity["Express"]); if (!service.ValidityFormula(formula)) { string title = ResManager.LoadKDString("合法性校验", "003286000011212", SubSystemType.FIN, new object[0]); string msg = ResManager.LoadKDString("公式设置不正确,请重新设置!", "003286000011305", SubSystemType.FIN, new object[0]); CommonValidate.AddMsg(validateContext, entity, title, msg, "", ErrorLevel.Error); } }