| | |
| | | using System.Diagnostics; |
| | | using System.Threading; |
| | | using System.Data; |
| | | using Tiger.IBusiness; |
| | | |
| | | namespace Tiger.Business |
| | | { |
| | | public partial class Biz |
| | | { |
| | | /// <summary> |
| | | /// 获取条码规则缓存 |
| | | /// </summary> |
| | | public static CodeRuleCache CodeRule => DbCacheBus.CodeRuleCache; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// BAS_CODE_RULE 扩展类 |
| | | /// </summary> |
| | |
| | | /// <returns></returns> |
| | | public static Result Verify(this BAS_CODE_RULE rule, string sn) |
| | | { |
| | | return Biz.CodeRule.Verify(sn, rule); |
| | | return Cache.CodeRule.Verify(sn, rule); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public static Result Generate(this BAS_CODE_RULE rule, params object?[] args) |
| | | { |
| | | return Biz.CodeRule.Generate(rule.RULE_CODE, args); |
| | | return Cache.CodeRule.Generate(rule.RULE_CODE, args); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public static Result TryGenerate(this BAS_CODE_RULE rule, params object?[] args) |
| | | { |
| | | return Biz.CodeRule.TryGenerate(rule.RULE_CODE, args); |
| | | return Cache.CodeRule.TryGenerate(rule.RULE_CODE, args); |
| | | } |
| | | }//endClass |
| | | |
| | |
| | | public Expression<Func<BAS_CODE_RULE, bool>> Expression { get; set; } |
| | | public Exception VerifyException { get; set; } |
| | | private List<RuleVerifier> _Verifiers = new(); |
| | | public List<RuleVerifier> Verifiers => _Verifiers.IsNullOrEmpty() ? Biz.CodeRule.Rules.WhereIF(!Predicate.IsNullOrEmpty(), Predicate).Select(q => new RuleVerifier(q)).ToList() : _Verifiers; |
| | | public List<RuleVerifier> Verifiers => _Verifiers.IsNullOrEmpty() ? Cache.CodeRule.Rules.WhereIF(!Predicate.IsNullOrEmpty(), Predicate).Select(q => new RuleVerifier(q)).ToList() : _Verifiers; |
| | | /// <summary> |
| | | /// 是否完成验证 |
| | | /// </summary> |
| | |
| | | var begin = DateTime.Now; |
| | | ElapsedTime = 0; |
| | | //Debug.WriteLine($"{Code} verify begin at {begin:T}"); |
| | | _Verifiers = Biz.CodeRule.Rules.WhereIF(!Predicate.IsNullOrEmpty(), Predicate).Select(q => new RuleVerifier(q)).ToList(); |
| | | _Verifiers = Cache.CodeRule.Rules.WhereIF(!Predicate.IsNullOrEmpty(), Predicate).Select(q => new RuleVerifier(q)).ToList(); |
| | | foreach (var item in Verifiers) |
| | | { |
| | | Work.DoAsync(() => { item.Verify(Code); }); |