public override void OnSetBusinessInfo(SetBusinessInfoArgs e) { new ExtensionPresenter(this); base.OnSetBusinessInfo(e); // 创建当前单据元数据副本,避免直接修改原始元数据,并发时串账 FormMetadata currmetadata = (FormMetadata)ObjectUtils.CreateCopy( this.View.OpenParameter.FormMetaData); _currBusinessInfo = currmetadata.BusinessInfo; _currLayoutInfo = currmetadata.GetLayoutInfo(); // 取单据头的元数据模型 currEntityKey = "FBillHead"; currEntity = _currBusinessInfo.GetEntity(currEntityKey); // 取配置字段的模板,动态添加的字段,是基于模板字段的一个分身 modelTextField = _currBusinessInfo.GetField("FModelText"); //文本模板 modelDecimalField = _currBusinessInfo.GetField("FModelDecimal"); //小数模板 modelF8Field = _currBusinessInfo.GetField("FModelF8"); //F8模板 modelAssistantField = _currBusinessInfo.GetField("FModelAssistant"); //辅助资料模板 var simpleExtension = this.View.OpenParameter.GetCustomParameter("simpleExtension") as DynamicObject; presenter.GenerateByJson(simpleExtension["FExtension"] as string); _currBusinessInfo.GetDynamicObjectType(true); e.BusinessInfo = _currBusinessInfo; e.BillBusinessInfo = _currBusinessInfo; }
/// <summary> /// 根据单据体内码,加载单据内码 /// </summary> /// <param name="targetBusinessInfo"></param> /// <param name="entityKey"></param> /// <param name="entityIds"></param> /// <returns></returns> private HashSet <long> LoadTargetBillIds( BusinessInfo targetBusinessInfo, string entityKey, HashSet <long> entityIds) { // 根据单据体内码,读取取下游单据的单据内码 HashSet <long> billIds = new HashSet <long>(); Entity entity = targetBusinessInfo.GetEntity(entityKey); if (entity is HeadEntity) { foreach (var billId in entityIds) { billIds.Add(billId); } } else { string entityPKFieldNameAs = string.Concat(entity.Key, "_", entity.EntryPkFieldName); QueryBuilderParemeter queryParem = new QueryBuilderParemeter() { FormId = targetBusinessInfo.GetForm().Id, BusinessInfo = targetBusinessInfo, }; queryParem.SelectItems.Add(new SelectorItemInfo(targetBusinessInfo.GetForm().PkFieldName)); queryParem.SelectItems.Add(new SelectorItemInfo(entityPKFieldNameAs)); queryParem.ExtJoinTables.Add( new ExtJoinTableDescription() { TableName = "table(fn_StrSplit(@EntryPKValue,',',1))", TableNameAs = "sp", FieldName = "FID", ScourceKey = entityPKFieldNameAs, }); queryParem.SqlParams.Add(new SqlParam("@EntryPKValue", KDDbType.udt_inttable, entityIds.ToArray())); IQueryService queryService = ServiceHelper.GetService <IQueryService>(); DynamicObjectCollection rows = queryService.GetDynamicObjectCollection(this.Context, queryParem); foreach (var row in rows) { long billId = Convert.ToInt64(row[0]); if (billIds.Contains(billId) == false) { billIds.Add(billId); } } } return(billIds); }
public static DynamicObjectCollection EntryProperty(this DynamicObject dataObject, BusinessInfo businessInfo, string keyName) { string entryName = businessInfo.GetEntity(keyName).EntryName; return(Property <DynamicObjectCollection>(dataObject, entryName)); }
public override void OnSetBusinessInfo(SetBusinessInfoArgs e) { base.OnSetBusinessInfo(e); FormMetadata currmetadata = (FormMetadata)ObjectUtils.CreateCopy(this.View.OpenParameter.FormMetaData); _currBusinessInfo = currmetadata.BusinessInfo; _currLayoutInfo = currmetadata.GetLayoutInfo(); // 获取单据体表格的元数据及布局 string entityKey = "FEntity"; Entity entity = _currBusinessInfo.GetEntity(entityKey); //EntityAppearance entityApp = _currLayoutInfo.GetEntityAppearance(entityKey); string FSDate = this.View.OpenParameter.GetCustomParameter("FSDate") == null ? "" : this.View.OpenParameter.GetCustomParameter("FSDate").ToString(); string FEDate = this.View.OpenParameter.GetCustomParameter("FEDate") == null ? "" : this.View.OpenParameter.GetCustomParameter("FEDate").ToString(); string FOrgId = this.View.OpenParameter.GetCustomParameter("FOrgId") == null ? "0" : this.View.OpenParameter.GetCustomParameter("FOrgId").ToString(); string FDeptID = this.View.OpenParameter.GetCustomParameter("FDeptID") == null ? "0" : this.View.OpenParameter.GetCustomParameter("FDeptID").ToString(); string FAccountId = this.View.OpenParameter.GetCustomParameter("FAccountId") == null ? "0" : this.View.OpenParameter.GetCustomParameter("FAccountId").ToString(); string sql = string.Format(@"EXEC proc_czly_AccountDept @SDt='{0}', @EDt='{1}', @FOrgId='{2}', @FDeptId='{3}', @FAccountId='{4}'", FSDate, FEDate, FOrgId, FDeptID, FAccountId); Field textField = _currBusinessInfo.GetField("FField"); Field decimalField = _currBusinessInfo.GetField("FDecimal"); //var textApp = _currLayoutInfo.GetEntityAppearance("FField"); entityData = DBUtils.ExecuteDataSet(this.Context, sql).Tables[0]; // 获取生成的费用项目列 sql = string.Format(@"EXEC proc_czly_AccountOrg @SDt='{0}', @EDt='{1}', @FOrgId='{2}', @FDeptId='{3}', @FAccountId='{4}'", FSDate, FEDate, FOrgId, FDeptID, FAccountId); costItems = DBUtils.ExecuteDataSet(this.Context, sql).Tables[0]; for (int i = 0; i < entityData.Columns.Count; i++) { string name = "FField_" + (i + 1).ToString(); //Field field = new Field(); Field field; if (i == 0) { field = (Field)ObjectUtils.CreateCopy(textField); } else { field = (Field)ObjectUtils.CreateCopy(decimalField); // 增加合计列 GroupSumColumn sumColumn = new GroupSumColumn(); sumColumn.FieldKey = name; sumColumn.Precision = -1; sumColumn.SumType = 1; entity.GroupColumnInfo.AddGroupSumColumn(sumColumn); } field.DynamicProperty = null; //field.ElementType = ElementType.BarItemElementType_TextField; field.Entity = entity; field.EntityKey = entityKey; field.Key = name; field.FieldName = name; field.PropertyName = name; field.Name = new LocaleValue(name); _currBusinessInfo.Add(field); } _currBusinessInfo.Remove(textField); _currBusinessInfo.Remove(decimalField); // 强制要求重新构建单据的ORM模型 _currBusinessInfo.GetDynamicObjectType(true); // 输出动态调整后的单据逻辑元数据模型(BusinessInfo) e.BusinessInfo = _currBusinessInfo; e.BillBusinessInfo = _currBusinessInfo; }