运行在App服务层的插件,如何加载单据,IViewService.Load()

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-23浏览:1

运行在App服务层的插件,如何加载单据,IViewService.Load()

Ø  运行在App层的插件

    包括操作插件、单据转换插件、反写插件、账表取数插件等,此类插件掌控着某种特定服务的执行过程,与交互界面无关;

Ø  实现思路

    通过Kingdee.BOS.App.dll的ServiceHelper类获取ViewService服务,调用此服务提供的Load方法

Ø  插件准备

    插件工程引用Kingdee.BOS.App.dll、Kingdee.BOS.Contracts.dll、Kingdee.BOS.DataEntity.dll

    类文件引用相关命名空间,详见示例代码


Ø  IViewService接口介绍

    public DynamicObject[] Load(Context ctx, BusinessInfo businessInfo, List<SelectorItemInfo> selector, OQLFilter ofilter).

构建过滤条件OQLFilter,检索某些字段片段信息(List<SelectorItemInfo>)的目标数据集合


    public DynamicObject[] Load(Context ctx, DynamicObjectType type, QueryBuilderParemeter queryParemeter)

构建过滤条件QueryBuilderParemeter,检索满足条件的目标数据集合


    public DynamicObject[] Load(Context ctx, Object[] pkArray, DynamicObjectType type)

指定目标数据id集合,根据数据id集合,动态对象类型,检索满足条件的目标数据集合


    public DynamicObject[] Load(Context ctx, string formid, List<SelectorItemInfo> selector, OQLFilter ofilter)

指定单据模型唯一标示,感兴趣的字段片段信息(也就是说,只取部分字段出来,不会把这个模型的所有字段数据都取出来),构建过滤条件OQLFilter

 

Ø  方法参数介绍

名称

类型

说明

ctx

Context

系统上下文信息

businessInfo

BusinessInfo

待检索数据的模型元数据信息

selector

List<SelectorItemInfo>

字段片段信息

ofilter

OQLFilter

快速过滤条件对象

type

DynamicObjectType

动态实体类型

queryParemeter

QueryBuilderParemeter

查询过滤对象

pkArray

Object[]

目标实体数据id集合

formid

string

待查询模型唯一标示


Ø  示例代码

C#


using   Kingdee.BOS.Contracts;

using   Kingdee.BOS.Core.DynamicForm.PlugIn;

using   Kingdee.BOS.Core.DynamicForm.PlugIn.Args;

using   Kingdee.BOS.Core.Metadata;

using   Kingdee.BOS.Core.SqlBuilder;

using   Kingdee.BOS.Orm.DataEntity;

using   System;

using   System.Collections.Generic;

using   System.Linq;

using   System.Text;

using   System.Threading.Tasks;

 

namespace MyOperaionServicePlugIn

{

    public class Class6 : AbstractOperationServicePlugIn

    {

        public override void BeforeExecuteOperationTransaction(BeforeExecuteOperationTransaction e)

        {

            //加载id10001的物料数据

            //获取ViewService

            IViewService viewService =

                Kingdee.BOS.App.ServiceHelper.GetService<IViewService>();

            //获取元数据服务

            IMetaDataService metadataService =  

                Kingdee.BOS.App.ServiceHelper.GetService<IMetaDataService>();

 

            //获取物料元数据

            FormMetadata materialMetada =

                  metadataService.Load(this.Context, "BD_Material") as FormMetadata;

 

            //构建过滤条件

            QueryBuilderParemeter queryParameter = new QueryBuilderParemeter();

              queryParameter.BusinessInfo = materialMetada.BusinessInfo;

              queryParameter.FilterClauseWihtKey = "FMaterailId = 10001";

 

            //构建快捷过滤条件

            OQLFilter filter = new OQLFilter();

            filter.Add(new OQLFilterHeadEntityItem() { FilterString   = "FMaterialId   = 10001" });

 

            //构建关心的字段片段信息

            List<SelectorItemInfo>   lstSelectorItemInfos = new List<SelectorItemInfo>();

            //物料属性

              lstSelectorItemInfos.Add(new SelectorItemInfo("FErpClsId"));

            //使用组织

              lstSelectorItemInfos.Add(new SelectorItemInfo("FUseOrgId"));

 

            //方法1

            DynamicObject[] objs =   viewService.Load(

                this.Context,

                  materialMetada.BusinessInfo.GetDynamicObjectType(),

                queryParameter);

 

            //方法2

            objs =   viewService.Load(

                this.Context,

                new object[] { 10001 },

                  materialMetada.BusinessInfo.GetDynamicObjectType());

 

            //方法3

            objs =   viewService.Load(

                this.Context,

                  materialMetada.BusinessInfo,

                  lstSelectorItemInfos,

                filter);

 

            //方法4

            objs =   viewService.Load(

                this.Context,

                "BD_Material",

                  lstSelectorItemInfos,

                filter);

        }

    }

}


运行在App服务层的插件,如何加载单据,IViewService.Load()

Ø 运行在App层的插件 包括操作插件、单据转换插件、反写插件、账表取数插件等,此类插件掌控着某种特定服务的执行过程,与交互界面无...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息