插件-辅助属性赋值

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

插件-辅助属性赋值

``` /// <summary> /// 已知辅助属性数据内码 /// </summary> /// <param name="billObjs"></param> /// <param name="auxPropId"></param> private void SetAuxPropById(DynamicObject[] billObjs, long auxPropId) { // 单据体元数据 Entity entity = this.BusinessInfo.GetEntity("FEntity"); // 辅助属性元数据:字段在单据体上 RelatedFlexGroupField fldAuxProp = this.BusinessInfo.GetField("FAuxPropId") as RelatedFlexGroupField; foreach (var billObj in billObjs) { DynamicObjectCollection rows = entity.DynamicProperty.GetValue(billObj) as DynamicObjectCollection; foreach (var row in rows) { // 根据辅助属性数据内码,加载辅助属性引用数据包(内含各维度数据) IViewService viewService = ServiceHelper.GetService<IViewService>(); DynamicObject[] auxPropObjs = viewService.LoadFromCache(this.Context, new object[] { auxPropId }, fldAuxProp.RefFormDynamicObjectType); // 把辅助属性字段值,填写到单据体数据包中:Id与引用数据包,均必须填写 fldAuxProp.RefIDDynamicProperty.SetValue(row, auxPropId); fldAuxProp.DynamicProperty.SetValue(row, auxPropObjs[0]); } } } /// <summary> /// 已知辅助属性各维度值 /// </summary> /// <param name="billObjs"></param> /// <param name="dctFlexItemIds"></param> private void SetAuxPropByValue(DynamicObject[] billObjs, Dictionary<string, string> dctFlexItemIds) { // 单据体元数据 Entity entity = this.BusinessInfo.GetEntity("FEntity"); // 辅助属性元数据:字段在单据体上 RelatedFlexGroupField fldAuxProp = this.BusinessInfo.GetField("FAuxPropId") as RelatedFlexGroupField; foreach (var billObj in billObjs) { DynamicObjectCollection rows = entity.DynamicProperty.GetValue(billObj) as DynamicObjectCollection; foreach (var row in rows) { // 新建辅助属性数据包,用来存储各维度值 DynamicObject auxPropObj = new DynamicObject(fldAuxProp.RefFormDynamicObjectType); // 把新建的辅助属性数据包,填写到单据体行上 fldAuxProp.RefIDDynamicProperty.SetValue(row, 0); fldAuxProp.DynamicProperty.SetValue(row, auxPropObj); // 填写各维度值:注意区分基础资料类型的维度,与普通文本类型的维度,赋值方式不同 foreach (var flexItem in dctFlexItemIds) { Field fldFlex = fldAuxProp.RelateFlexBusinessInfo.GetField(flexItem.Key); if (fldFlex is BaseDataField) {// 维度是基础资料类型 BaseDataField fldBDTypeFlex = fldFlex as BaseDataField; IViewService viewService = ServiceHelper.GetService<IViewService>(); DynamicObject[] flexItemObjs = viewService.LoadFromCache(this.Context, new object[] { flexItem.Value }, fldBDTypeFlex.RefFormDynamicObjectType); fldBDTypeFlex.RefIDDynamicProperty.SetValue(auxPropObj, flexItem.Value); fldBDTypeFlex.DynamicProperty.SetValue(auxPropObj, flexItemObjs[0]); } else {// 维度是普通文本类型 fldFlex.DynamicProperty.SetValue(auxPropObj, flexItem.Value); } } } } // 所有单据的辅助属性字段,维度值都已经填写完毕 // 开始调用弹性域服务,把辅助属性数据包,保存到数据库,自动产生数据内码,回填到单据数据包中 FlexSaveService flexSave = new FlexSaveService(this.Context, "Save"); flexSave.BatchSaveEntityFlexObject(this.BusinessInfo, entity, billObjs); }

插件-辅助属性赋值

``` /// <summary> /// 已知辅助属性数据内码 /// </summary> /// <par...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息