1234567891011121314151617181920212223242526272829303132333435363738 |
- using DynamicExpresso;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using wispro.sp.entity;
- namespace wispro.sp.api.Utility
- {
- public class Utility
- {
- public static void CalBasePoint(PerformanceItem item, List<BasePointRule> rules)
- {
- #region 计算基本点数值及绩效类型
- rules.Sort((a, b) =>
- {
- var o = b.Priority - a.Priority;
- return o;
- });
- foreach (BasePointRule rule in rules)
- {
- var interpreter = new Interpreter();
- //item.ApplicationType
- Func<PerformanceItem, bool> func = interpreter.ParseAsDelegate<Func<PerformanceItem, bool>>(rule.Rule, "p");
- bool result = func.Invoke(item);
- if (result)
- {
- interpreter.SetVariable("p", item);
- item.BasePoint = (double?)interpreter.Eval(rule.PointExpress);
- }
- }
- #endregion
- }
- }
- }
|