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

文章目录

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

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、验证校验器

相关推荐
唐青枫21 小时前
别再乱用 StartNew:C#.NET TaskFactory 任务调度实战详解
c#·.net
Artech1 天前
[MAF预定义的AIContextProvider-03]ChatHistoryMemoryProvider——赋予Agent从经验中学习的能力
ai·c#·agent·memory·maf
Scout-leaf3 天前
C#摸鱼实录——IoC与DI案例详解
c#
咕白m6253 天前
使用 C# 在 Excel 中应用多种字体样式
后端·c#
Artech3 天前
[MAF预定义的AIContextProvider-02]AgentSkillsProvider——将Agent Skills引入MAF
ai·c#·agent·agent skills·maf
SM177152118384 天前
NSK紧凑型FA系列丝杠技术详解
经验分享·规格说明书
闪闪发亮的小星星4 天前
高斯光以及高斯光公式解释
笔记
cqbzcsq4 天前
CellFlow虚拟细胞论文阅读
论文阅读·人工智能·笔记·学习·生物信息
2601_962072554 天前
李梦娇常识4600问|题库|打印版
sql·华为od·华为·c#·华为云·.net·harmonyos
fofantasy4 天前
NSK SFT3210-2.5 滚珠丝杠技术详解
经验分享·规格说明书