实现跨数据中心访问单据原创
金蝶云社区-eris
eris
19人赞赏了该文章 885次浏览 未经作者许可,禁止转载编辑于2021年03月18日 08:33:17

在一个数据中心的某单据点击任何菜单操作,访问另外一个数据中心中的单据A,并且能够引入引出。

  1. 插件代码:

image.png

2. 在L采购订单的表单插件中注册插件

image.png

3. 点击L采购订单任何按钮,显示单据A列表,如下图:

image.png

4. 具体代码:

using System;

using System.Data;

using System.ComponentModel;

using System.Collections.Generic;


using Kingdee.BOS.Core;

using Kingdee.BOS.Util;

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

using Kingdee.BOS.Core.List;

using Kingdee.BOS.Core.DynamicForm;

using Kingdee.BOS.Core.Bill.PlugIn;

using Kingdee.BOS.ServiceHelper;

using Kingdee.BOS.ServiceFacade.KDServiceFx;

using Kingdee.BOS.Web.Core;


 namespace Kingdee.BOS.TestPlugIn.FormPlugin

{

    [HotUpdate]

    [Description("显示跨数据中心单据A")]

    public class ShowCrossBillAPlugIn : AbstractBillPlugIn

    {

        public override void BarItemClick(BarItemClickEventArgs e)

        {

            if (e.BarItemKey == "" || true)

            {

                var lstParam = new ListShowParameter();

                lstParam.FormId = "KKK_BillA";   //另外一个数据中心的表单formId

                lstParam.OpenStyle.ShowType = ShowType.MainNewTabPage;

                lstParam.Context = DataCenterService.GetDataCenterContextByID("5f191f0ff4b034"); //另外一个数据中心id

                lstParam.Context.UserId = 100008; //另外一个数据的用户内码

                lstParam.Context.CurrentOrganizationInfo = this.View.Context.CurrentOrganizationInfo;

                lstParam.Context.ConsolePageId = this.View.Context.ConsolePageId;

                //把会话信息保存在全局缓存和通用会话中

                KDServiceSession kdSession = new KDServiceSession(lstParam.Context.SessionId);

                kdSession.AppContext = lstParam.Context;

                GlobalCacheManager.TryAdd(lstParam.Context.UserToken, kdSession);

                CommonSession.AddOrUpdateContext(lstParam.Context.UserToken, lstParam.Context);

                this.View.ShowForm(lstParam);

                this.View.SendDynamicFormAction(this.View);

            }

        }

    }

}


赞 19