金蝶云星空自定义校验器和使用

文章目录

金蝶云星空自定义校验器和使用

1、创建类,并继承抽象接口

csharp 复制代码
using Kingdee.BOS.Core;
using Kingdee.BOS.Core.Validation;
using System;

namespace mm.K3.SCM.App.Service.PlugIn.SC.Validator
{
    public class AfterOrderCheckOtherBillValidator : AbstractValidator
    {
         
    }
}

2、重写抽象方法,对指定的数据进行校验

csharp 复制代码
public override void Validate(ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Kingdee.BOS.Context ctx)
        {
            throw new NotImplementedException();
            foreach (ExtendedDataEntity dyn in dataEntities)
            {
                string billNo = dyn["BillNo"] + "";
                long fid = Convert.ToInt64(dyn["Id"]);//单FID
                //异常信息
                string _errorMsg = string.Empty;
                #region
                //逻辑处理,不符合条件就把异常信息汇总到 _errorMsg
                #endregion

                errorLable:
                if (!string.IsNullOrEmpty(_errorMsg))
                {
                    string titleInfo = string.Format("售后单-反审核");
                    ValidationErrorInfo errorInfo = new ValidationErrorInfo(string.Empty, fid.ToString(), dyn.DataEntityIndex, dyn.RowIndex
                       , fid.ToString(),
                       _errorMsg, titleInfo, ErrorLevel.Error);
                    validateContext.AddError(dyn, errorInfo);
                }
            }
        }

3、服务端操作插件注册校验器

csharp 复制代码
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Util;
using mm.K3.SCM.App.Service.PlugIn.SC.Validator;
using System.ComponentModel;

namespace mm.K3.SCM.App.Service.PlugIn.SC
{
    [Description("售后单-反审核"), HotUpdate]
    public class AfterOrderUnAudit : AbstractOperationServicePlugIn
    {
        public override void OnAddValidators(AddValidatorsEventArgs e)
        {
            AfterOrderCheckOtherBillValidator validator = new AfterOrderCheckOtherBillValidator()
            {
                AlwaysValidate = true,
                EntityKey = "FBillHead"
            };
            e.Validators.Add(validator);
        }
    }
}

4、验证校验器

相关推荐
爱分享的康康1 分钟前
初创车企自动驾驶数采设备选配指南:参数、接口与分阶段选型思路
经验分享·自动驾驶
果壳science1 小时前
张祥前最新研究成果登上SCI期刊!
笔记·嵌入式硬件·算法·硬件工程·几何学
Rabitebla1 小时前
【Linux 底层原理】工具篇(一):掌握 Ubuntu apt,让软件安装与管理更简单
linux·笔记·算法·ubuntu
叼烟扛炮1 小时前
Linux 学习笔记(二十三):深入 Ext 文件系统(下)—— 原理、缓存与软硬链接
linux·笔记·学习
stolentime2 小时前
SOS DP学习笔记
c++·笔记·学习·算法·贪心算法·动态规划·二进制
淡海水2 小时前
07-01-源码-.NET Core GC总览与架构
unity·架构·c#·.netcore·gc
陈哈哈11112 小时前
折腾了半天,总算把 CodeBlocks 装明白了
笔记
虹科数字化与AR3 小时前
电子PDF、电子SOP与Connected Worker平台有什么区别?
经验分享
ss2733 小时前
AI时代首先数据库-PostgreSQL实战笔记 | 24 PostgreSQL WAL日志与崩溃恢复原理
数据库·笔记·postgresql
叼烟扛炮3 小时前
Linux 学习笔记(二十二):深入 Ext 文件系统(上)—— 磁盘、块与神秘的 inode
linux·笔记·学习