U9的插件主要分为3种,即
(1)BE插件
(2)UI插件
(3)BP/SV插件

1.新建类库解决方案
插件开发--BE插件开发

2.新建插件类,并引用以下dll,UBF安装目录U9.VOB.Product.UBF\UBFStudio\Runtime
UFSoft.UBF.Analysis.Exceptions.dll
UFSoft.UBF.Business.dll
并继续接口UFSoft.UBF.Eventing.IEventSubscriber
插件开发--BE插件开发

3.实现接口代码,以之前做过的礼品单据作为插件对象,则要引入礼品单据的BE的dll,并复制以下代码,据实际情况实现逻辑

class GiftDocBEPlugExtend : UFSoft.UBF.Eventing.IEventSubscriber
    {

        public void Notify(params object[] args)
        {
            //throw new NotImplementedException();
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }

            BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            if (key == null)
            {
                return;
            }

            //以下代码实现业务逻辑
            HomaGiftDoc doc = key.GetEntity() as HomaGiftDoc;
            if (doc == null)
            {
                return;
            }

            if (doc.DocNo == "")
            {
                throw new Exception("单号不能为空!");
            }

            for (int i = 0; i < doc.HomaGiftDocLine.Count; i++)
            {
                if (doc.HomaGiftDocLine[i].ItemQty <= 0)
                {
                    throw new Exception("" + doc.HomaGiftDocLine[i].RowNo + "数量不能小于0!");
                }
            }
        }
    }
插件实现代码

相关文章: