单据转换插件--创建关联数据包后事件(OnAfterCreateLink)原创
4人赞赏了该文章
295次浏览
编辑于2023年11月22日 15:47:33
一、说明
1、触发时机
1)创建关联数据包后事件,在创建关联数据包完后触发
2、主要作用
可以对目标数据包进行干预
3、参数说明
参数CreateLinkEventArgs,属性包括
1)Context 上下文
2)SourceBusinessInfo 源单元数据
2)TargetBusinessInfo 目标单元数据
4)DicSelectField 字段Key与字段别名关系字典
5)TargetExtendedDataEntities 目标单扩展数据实体数据集
6)Cancel 在此事件中无作用
二、示例
1、说明
1)得到关联主实体每个实体数据包下的关联数据包
2、转换插件代码
using System; using System.ComponentModel; using System.Text; using System.Linq; using System.Collections.Generic; using Kingdee.BOS.Core; using Kingdee.BOS.Util; using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn; using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.Core.Metadata.EntityElement; namespace Kingdee.BOS.TestPlugIn.BillABillB { [HotUpdate] [Description("单据转换插件")] public class BillConvertPlugIn : AbstractConvertPlugIn { /// <summary> /// 得到关联主实体每个实体数据包下的关联数据包 /// </summary> /// <param name="e"></param> public override void OnAfterCreateLink(CreateLinkEventArgs e) { base.OnAfterCreateLink(e); var linkEntitys = e.TargetBusinessInfo.GetForm().LinkSet.LinkEntitys; if (linkEntitys.IsEmpty() == false) { var exLinkParentDataObjs = e.TargetExtendedDataEntities.FindByEntityKey(linkEntitys[0].ParentEntityKey); if (exLinkParentDataObjs.IsEmpty() == false) { foreach (var exDataObj in exLinkParentDataObjs) { var linkDataObjs = exDataObj.DataEntity[linkEntitys[0].Key] as DynamicObjectCollection; } } } } } }