/// <summary> /// 移除不需要的列 /// </summary> /// <param name="entity">实体集合</param> /// <param name="excludeColumns">需要移除的列</param> /// <returns></returns> private DependencyObjectCollection RemoveObjectType(DependencyObjectCollection entity, string[] excludeColumns) { DependencyObjectType cloneObjectType = new DependencyObjectType("collection1_clone"); IDataEntityType dataEntityType = entity.ItemDependencyObjectType; foreach (ISimpleProperty property in dataEntityType.SimpleProperties) { if (!excludeColumns.Contains(property.Name)) { cloneObjectType.RegisterSimpleProperty(property.Name, property.PropertyType); } } DependencyObjectCollection cloneObject = new DependencyObjectCollection(cloneObjectType);//克隆对象 foreach (DependencyObject item in entity) { var newItem = cloneObject.AddNew(); foreach (ISimpleProperty property in ((IDataEntityType)item.DependencyObjectType).SimpleProperties) { if (newItem.DependencyObjectType.Properties.Contains(property.Name)) { newItem[property.Name] = item[property.Name]; } } } return(cloneObject); }
/// <summary> /// 对单身分组 /// 单身和条码明显的分组依据不一样 /// </summary> /// <param name="tmpIssueReceiptD"></param> /// <returns></returns> public QueryNode GroupNode(IDataEntityType tmpIssueReceiptD, bool isEntityLine) { List <QueryProperty> properties = new List <QueryProperty> { OOQL.CreateProperty("TMP.DOC_NO") , OOQL.CreateProperty("TMP.SequenceNumber") , OOQL.CreateProperty("TMP.PLANT_CODE") , OOQL.CreateProperty("TMP.ITEM_CODE") , OOQL.CreateProperty("TMP.ITEM_FEATURE_CODE") , OOQL.CreateProperty("TMP.UNIT_CODE") , OOQL.CreateProperty("TMP.WAREHOUSE_CODE") , OOQL.CreateProperty("TMP.BIN_CODE") , OOQL.CreateProperty("TMP.LOT_CODE") }; List <QueryProperty> groupProperties = new List <QueryProperty>(); groupProperties = new List <QueryProperty>(); groupProperties.AddRange(properties); if (!isEntityLine) { properties.Add(OOQL.CreateProperty("TMP.BARCODE_NO")); groupProperties.Add(OOQL.CreateProperty("TMP.BARCODE_NO")); } properties.Add(Formulas.IsNull(Formulas.Sum(OOQL.CreateProperty("TMP.ISSUE_RECEIPT_QTY")), OOQL.CreateConstants(0), "ISSUE_RECEIPT_QTY")); QueryNode node = OOQL.Select(properties ) .From(tmpIssueReceiptD.Name, "TMP") .GroupBy(groupProperties); return(node); }
/// <summary> /// 简单属性的类型转换 /// 将移动对应的实体的字符串类型统一转换为指定的数据类型 /// </summary> /// <param name="sourceType">原数据类型</param> /// <param name="businessTypeService">业务服务接口</param> /// <returns></returns> public DependencyObjectType ConvertToDependencyObjectType(IDataEntityType sourceType, IBusinessTypeService businessTypeService) { DependencyObjectType newType = new DependencyObjectType(sourceType.Name); foreach (DependencyProperty property in sourceType.SimpleProperties) { if (_dateTimeProperties.Contains(property.Name)) { newType.RegisterSimpleProperty(property.Name, typeof(DateTime), OrmDataOption.EmptyDateTime , false, new Attribute[] { new SimplePropertyAttribute(GeneralDBType.DateTime) }); } else if (_decimalProperties.Contains(property.Name)) { newType.RegisterSimpleProperty(property.Name, businessTypeService.SimpleQuantityType, 0m , false, new Attribute[] { businessTypeService.SimpleQuantity }); } else if (_intProperties.Contains(property.Name)) { newType.RegisterSimpleProperty(property.Name, typeof(int), 0 , false, new Attribute[] { new SimplePropertyAttribute(GeneralDBType.Int32) }); } else { newType.RegisterSimpleProperty(property.Name, typeof(string), string.Empty , false, new Attribute[] { new SimplePropertyAttribute(GeneralDBType.String) }); } } return(newType); }
/// <summary> /// 对单身分组 /// 单身和条码明显的分组依据不一样 /// </summary> /// <param name="tmpIssueReceiptD"></param> /// <returns></returns> public QueryNode GetGroupForInsert(IDataEntityType tempEntityD) { List <QueryProperty> selectOrGroupList = new List <QueryProperty>(); selectOrGroupList.Add(OOQL.CreateProperty("item_no")); selectOrGroupList.Add(OOQL.CreateProperty("item_feature_no")); selectOrGroupList.Add(OOQL.CreateProperty("picking_unit_no")); selectOrGroupList.Add(OOQL.CreateProperty("doc_no")); selectOrGroupList.Add(OOQL.CreateProperty("seq")); selectOrGroupList.Add(OOQL.CreateProperty("warehouse_no")); selectOrGroupList.Add(OOQL.CreateProperty("storage_spaces_no")); selectOrGroupList.Add(OOQL.CreateProperty("lot_no")); selectOrGroupList.Add(OOQL.CreateProperty("barcode_no")); List <QueryProperty> selectList = new List <QueryProperty>(); foreach (QueryProperty selectOrGroupObj in selectOrGroupList) { selectList.Add(selectOrGroupObj); } selectList.Add(Formulas.Sum(OOQL.CreateProperty("picking_qty"), "sum_picking_qty")); QueryNode selectNode = OOQL.Select(selectList.ToArray()) .From(tempEntityD.Name, "TEMP") .GroupBy(selectOrGroupList.ToArray()); return(selectNode); }
private IDataEntityType BindToType(IDataEntityType canUseType) { string name = this._reader.Name; Dictionary <string, string> attributes = new Dictionary <string, string>(); int attributeCount = this._reader.AttributeCount; for (int i = 0; i < attributeCount; i++) { this._reader.MoveToAttribute(i); attributes.Add(this._reader.Name, this._reader.Value); } IDataEntityType type = this._binder.BindToType(name, attributes); if ((type == null) && (canUseType != null)) { string a = this._binder.BindToName(canUseType); if (this._binder.IgnoreCase ? string.Equals(a, name, StringComparison.OrdinalIgnoreCase) : string.Equals(a, name, StringComparison.Ordinal)) { type = canUseType; } } if (type == null) { SerializationException.SerializationExceptionData data = new SerializationException.SerializationExceptionData { CanIgnore = false }; this.ThrowXmlException("??????", string.Format(ResManager.LoadKDString("未能找到{0}对应的数据类型,请检查是否Xml中拼写错误。", "014009000001751", SubSystemType.SL, new object[0]), name), data, null); } return(type); }
/// <summary> /// 创建临时表#Table_scan_detail /// </summary> /// <returns></returns> private void CreateTempTableScanDetail() { string tempName = "TEMP_SCAN_DETAIL" + "_" + DateTime.Now.ToString("HHmmssfff"); DependencyObjectType defaultType = new DependencyObjectType(tempName, new Attribute[] { }); SimplePropertyAttribute tempAttr = new SimplePropertyAttribute(GeneralDBType.String); #region 字段 ////主键 //defaultType.RegisterSimpleProperty("Table_scan_detail_ID", _businessTypeSrv.SimplePrimaryKeyType, // Maths.GuidDefaultValue(), false, // new Attribute[] { _businessTypeSrv.SimplePrimaryKey }); //信息批号 defaultType.RegisterSimpleProperty("info_lot_no", typeof(string), string.Empty, false, new Attribute[] { tempAttr }); // 转入仓库 defaultType.RegisterSimpleProperty("site_no", typeof(string), string.Empty, false, new Attribute[] { tempAttr }); //条码编号 defaultType.RegisterSimpleProperty("barcode_no", typeof(string), string.Empty, false, new Attribute[] { tempAttr }); //料件编号 defaultType.RegisterSimpleProperty("item_no", _businessTypeSrv.SimpleItemCodeType, string.Empty, false, new Attribute[] { _businessTypeSrv.SimpleItemCode }); // 产品特征 defaultType.RegisterSimpleProperty("item_feature_no", _businessTypeSrv.SimpleItemFeatureType, string.Empty, false, new Attribute[] { _businessTypeSrv.SimpleItemFeature }); // 仓库 defaultType.RegisterSimpleProperty("warehouse_no", typeof(string), string.Empty, false, new Attribute[] { tempAttr }); //库位 defaultType.RegisterSimpleProperty("storage_spaces_no", typeof(string), string.Empty, false, new Attribute[] { tempAttr }); //批号 defaultType.RegisterSimpleProperty("lot_no", _businessTypeSrv.SimpleLotCodeType, string.Empty, false, new Attribute[] { _businessTypeSrv.SimpleLotCode }); //拣货数量 defaultType.RegisterSimpleProperty("picking_qty", _businessTypeSrv.SimpleQuantityType, 0m, false, new Attribute[] { _businessTypeSrv.SimpleQuantity }); //拣货单位 defaultType.RegisterSimpleProperty("picking_unit_no", typeof(string), string.Empty, false, new Attribute[] { tempAttr }); //单号 defaultType.RegisterSimpleProperty("doc_no", _businessTypeSrv.SimpleDocNoType, string.Empty, false, new Attribute[] { _businessTypeSrv.SimpleDocNo }); //来源序号 tempAttr = new SimplePropertyAttribute(GeneralDBType.Int32); defaultType.RegisterSimpleProperty("seq", typeof(int), 0, false, new Attribute[] { tempAttr }); #endregion _TEMP_SCAN_DETAIL = defaultType; _querySrv.CreateTempTable(defaultType); }
public object ReadElement(IDataEntityType dt, object entity) { MoveToFirstElement(this._reader); string name = this._reader.Name; if (entity == null) { dt = this.BindToType(dt); if (dt.Flag != DataEntityTypeFlag.Primitive) { entity = this._binder.CreateInstance(dt); } } else { IDataEntityType dataEntityType = this.GetDataEntityType(entity); if (dataEntityType != null) { dt = this.BindToType(dt); if ((!object.Equals(dt, dataEntityType) && !dt.IsAssignableFrom(dataEntityType)) && (dt.Flag != DataEntityTypeFlag.Primitive)) { entity = this._binder.CreateInstance(dt); } } } this.Push(entity); if (!this._reader.IsEmptyElement) { if (dt.Flag != DataEntityTypeFlag.Primitive) { while (this.MoveToNextElement(name)) { IDataEntityProperty property; if ((dt.Properties.TryGetValue(this._reader.Name, out property) && !this.ReadSimpleProperty(property as ISimpleProperty, entity)) && (!this.ReadComplexProperty(property as IComplexProperty, entity) && !this.ReadCollectionProperty(property as ICollectionProperty, entity))) { SerializationException.SerializationExceptionData data = new SerializationException.SerializationExceptionData { CanIgnore = true }; this.ThrowXmlException("??????", string.Format(ResManager.LoadKDString("XML节点中出现的属性{0},必须是简单属性、复杂或集合属性的一种。", "014009000001739", SubSystemType.SL, new object[0]), property.Name), data, null); } this.SafeDo(); } return(entity); } string str2 = this._reader.ReadString(); Type primitiveType = DcxmlBinder.GetPrimitiveType(dt.Name.ToLowerInvariant()); if (primitiveType != typeof(string)) { entity = Convert.ChangeType(str2, primitiveType, this._binder.Culture); } else { entity = str2; } this.SafeDo(); } return(entity); }
public void Delete(IDataEntityType entityType, object oid) { IDocumentService service = OrmEntry.CreateDocumentService(entityType, this.DBDriver) as IDocumentService; if (service != null) { service.Delete(oid); } }
/// <summary> /// 创建存储传入参数集合的临时表 /// </summary> private void CreateTemp() { IBusinessTypeService businessSrv = this.GetServiceForThisTypeKey <IBusinessTypeService>(); string typeName = "Temp_Scan" + DateTime.Now.ToString("HHmmssfff");// 临时表表名的处理 DependencyObjectType defaultType = new DependencyObjectType(typeName, new Attribute[] { }); #region 单头 defaultType.RegisterSimpleProperty("ID", businessSrv.SimplePrimaryKeyType, Maths.GuidDefaultValue(), false, new Attribute[] { businessSrv.SimplePrimaryKey }); //人员 defaultType.RegisterSimpleProperty("employee_no", businessSrv.GetBusinessType("BusinessCode"), string.Empty, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("BusinessCode") }); SimplePropertyAttribute tempAttr = new SimplePropertyAttribute(GeneralDBType.String); tempAttr.Size = 10; //部门 defaultType.RegisterSimpleProperty("picking_department_no", typeof(string), string.Empty, false, new Attribute[] { tempAttr }); //工厂编号 defaultType.RegisterSimpleProperty("site_no", businessSrv.GetBusinessType("Factory"), string.Empty, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("Factory") }); //信息批号 tempAttr.Size = 30; defaultType.RegisterSimpleProperty("info_lot_no", typeof(string), string.Empty, false, new Attribute[] { tempAttr }); _tempScan = defaultType; _qurService.CreateTempTable(_tempScan); #endregion typeName = "Temp_ScanDetail" + DateTime.Now.ToString("HHmmssfff");// 临时表表名的处理 defaultType = new DependencyObjectType(typeName, new Attribute[] { }); #region 单身 defaultType.RegisterSimpleProperty("ID", businessSrv.SimplePrimaryKeyType, Maths.GuidDefaultValue(), false, new Attribute[] { businessSrv.SimplePrimaryKey }); //信息批号 tempAttr.Size = 30; defaultType.RegisterSimpleProperty("info_lot_no", typeof(string), string.Empty, false, new Attribute[] { tempAttr }); //序号 tempAttr = new SimplePropertyAttribute(GeneralDBType.Int32); defaultType.RegisterSimpleProperty("SequenceNumber", typeof(Int32), 0, false, new Attribute[] { tempAttr }); //品号 defaultType.RegisterSimpleProperty("item_no", businessSrv.GetBusinessType("ItemCode"), string.Empty, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("ItemCode") }); //特征码 defaultType.RegisterSimpleProperty("item_feature_no", businessSrv.GetBusinessType("ItemFeature"), string.Empty, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("ItemFeature") }); //单位 defaultType.RegisterSimpleProperty("picking_unit_no", businessSrv.GetBusinessType("UnitCode"), string.Empty, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("UnitCode") }); //仓库 defaultType.RegisterSimpleProperty("warehouse_no", businessSrv.GetBusinessType("WarehouseCode"), string.Empty, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("WarehouseCode") }); //库位 defaultType.RegisterSimpleProperty("storage_spaces_no", businessSrv.GetBusinessType("Bin"), string.Empty, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("Bin") }); //批号 defaultType.RegisterSimpleProperty("lot_no", businessSrv.GetBusinessType("LotCode"), string.Empty, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("LotCode") }); //拣货数量 defaultType.RegisterSimpleProperty("picking_qty", businessSrv.GetBusinessType("Quantity"), 0M, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("Quantity") }); //条码编号 tempAttr = new SimplePropertyAttribute(GeneralDBType.String); tempAttr.Size = 1000; defaultType.RegisterSimpleProperty("barcode_no", typeof(string), string.Empty, false, new Attribute[] { tempAttr }); _tempScanDetail = defaultType; _qurService.CreateTempTable(_tempScanDetail); #endregion }
public object Read(IDataEntityType entityType, object oid) { IDocumentService service = OrmEntry.CreateDocumentService(entityType, this.DBDriver) as IDocumentService; if (service != null) { return(service.Read(oid)); } return(null); }
/// <summary> /// 组织新的数据类型 /// </summary> /// <param name="sourceType">原数据类型</param> /// <param name="newType">新数据类型</param> /// <param name="businessTypeService"></param> public void BuildCollectionPorpertyType(IDataEntityType sourceType, IDataEntityType newType, IBusinessTypeService businessTypeService) { //集合属性需重新运用递归计算类型 foreach (var subCollPro in sourceType.CollectionProperties) { DependencyObjectType subNewType = ConvertToDependencyObjectType(subCollPro.ItemDataEntityType, businessTypeService); (newType as DependencyObjectType).RegisterCollectionProperty(subCollPro.Name, subNewType); BuildCollectionPorpertyType(subCollPro.ItemDataEntityType, subNewType, businessTypeService); } }
public virtual string BindToName(IDataEntityType dt) { string name = dt.Name; if (name.EndsWith("Element", this._stringComparison)) { return(name.Substring(0, name.Length - 7)); } return(name); }
private object Clone(IDataEntityType dt, object dataEntity, bool clearPrimaryKeyValue) { if (dataEntity == null) { return(null); } object newEntity = dt.CreateInstance(); this.CopyData(dt, dataEntity, newEntity, clearPrimaryKeyValue); return(newEntity); }
private object ReadElement(XmlReader reader, IDataEntityType dt, object entity) { DcxmlSerializerReadImplement implement = new DcxmlSerializerReadImplement(this._binder, reader, this._colloctionIgnorePKValue) { OnlyLocaleValue = this.OnlyLocaleVale, ResetLoacaleValueBy2052 = this.ResetLoacaleValueBy2052 }; object obj2 = implement.ReadElement(dt, entity); implement.EndInitialize(); return(obj2); }
public static object Clone(this object dataEntity, IDataEntityType dt, bool onlyDbProperty = false, bool clearPrimaryKeyValue = false) { if (dataEntity == null) { return(null); } if (dt == null) { throw new ArgumentNullException("dt"); } return(new CloneUtils(onlyDbProperty, clearPrimaryKeyValue).Clone(dt, dataEntity)); }
private void CreateTempTable() { IBusinessTypeService businessTypeSrv = GetServiceForThisTypeKey <IBusinessTypeService>(); #region 单头临时表 string tempName = "Table_scan" + "_" + DateTime.Now.ToString("HHmmssfff"); DependencyObjectType defaultType = new DependencyObjectType(tempName, new Attribute[] { null }); SimplePropertyAttribute tempAttr = new SimplePropertyAttribute(GeneralDBType.String); #region 字段 //营运据点 defaultType.RegisterSimpleProperty("site_no", typeof(string), string.Empty, false, new Attribute[] { tempAttr }); //条码编号 defaultType.RegisterSimpleProperty("barcode_no", typeof(string), string.Empty, false, new Attribute[] { tempAttr }); //料件编号 defaultType.RegisterSimpleProperty("item_no", businessTypeSrv.GetBusinessType("ItemCode"), string.Empty, false, new Attribute[] { businessTypeSrv.GetSimplePropertyAttribute("ItemCode") }); //产品特征 defaultType.RegisterSimpleProperty("item_feature_no", businessTypeSrv.GetBusinessType("ItemFeature"), string.Empty, false, new Attribute[] { businessTypeSrv.GetSimplePropertyAttribute("ItemFeature") }); //库位编号 defaultType.RegisterSimpleProperty("warehouse_no", businessTypeSrv.GetBusinessType("WarehouseCode"), string.Empty, false, new Attribute[] { businessTypeSrv.GetSimplePropertyAttribute("WarehouseCode") }); //储位编号 defaultType.RegisterSimpleProperty("storage_spaces_no", businessTypeSrv.GetBusinessType("Bin"), string.Empty, false, new Attribute[] { businessTypeSrv.GetSimplePropertyAttribute("Bin") }); //批号 defaultType.RegisterSimpleProperty("lot_no", businessTypeSrv.GetBusinessType("LotCode"), string.Empty, false, new Attribute[] { businessTypeSrv.GetSimplePropertyAttribute("LotCode") }); //盘点数量 defaultType.RegisterSimpleProperty("qty", businessTypeSrv.GetBusinessType("Quantity"), 0M, false, new Attribute[] { businessTypeSrv.GetSimplePropertyAttribute("Quantity") }); //盘点人员 defaultType.RegisterSimpleProperty("employee_no", businessTypeSrv.GetBusinessType("BusinessCode"), string.Empty, false, new Attribute[] { businessTypeSrv.GetSimplePropertyAttribute("BusinessCode") }); //盘点日期 defaultType.RegisterSimpleProperty("complete_date", typeof(DateTime), OrmDataOption.EmptyDateTime, false, new Attribute[] { new SimplePropertyAttribute(GeneralDBType.Date) }); //交易对象类型 defaultType.RegisterSimpleProperty("transaction_type", typeof(string), string.Empty, false, new Attribute[] { tempAttr }); tempAttr.Size = 10; //交易对象编号 defaultType.RegisterSimpleProperty("transaction_no", typeof(string), string.Empty, false, new Attribute[] { tempAttr }); #endregion _Table_scan = defaultType; _qurService.CreateTempTable(_Table_scan); #endregion }
/// <summary> /// 先删除BCLine,后面再重新生成 /// </summary> /// <param name="qrySrv"></param> /// <param name="tmpIssueReceiptD"></param> private void DeleteBCLine(IQueryService qrySrv, IDataEntityType tempEntityD) { QueryNode deleteNode = OOQL.Delete("BC_LINE") .Where(OOQL.CreateProperty("SOURCE_ID.ROid").In( OOQL.Select(OOQL.CreateProperty("SALES_ISSUE_D.SALES_ISSUE_D_ID")) .From("SALES_ISSUE", "SALES_ISSUE") .InnerJoin(tempEntityD.Name, "TMP") .On(OOQL.CreateProperty("SALES_ISSUE.DOC_NO") == OOQL.CreateProperty("TMP.doc_no")) .InnerJoin("SALES_ISSUE.SALES_ISSUE_D", "SALES_ISSUE_D") .On(OOQL.CreateProperty("SALES_ISSUE.SALES_ISSUE_ID") == OOQL.CreateProperty("SALES_ISSUE_D.SALES_ISSUE_ID")) )); qrySrv.ExecuteNoQuery(deleteNode); }
/// <summary> /// 先删除BCLine,后面再重新生成 /// </summary> /// <param name="qrySrv"></param> /// <param name="tmpIssueReceiptD"></param> private void DeleteBCLine(IQueryService qrySrv, IDataEntityType tmpIssueReceiptD) { QueryNode deleteNode = OOQL.Delete("BC_LINE") .Where(OOQL.CreateProperty("SOURCE_ID.ROid").In( OOQL.Select(OOQL.CreateProperty("ISSUE_RECEIPT_D.ISSUE_RECEIPT_D_ID")) .From("ISSUE_RECEIPT", "ISSUE_RECEIPT") .InnerJoin(tmpIssueReceiptD.Name, "TMP") .On(OOQL.CreateProperty("ISSUE_RECEIPT.DOC_NO") == OOQL.CreateProperty("TMP.DOC_NO")) .InnerJoin("ISSUE_RECEIPT.ISSUE_RECEIPT_D", "ISSUE_RECEIPT_D") .On(OOQL.CreateProperty("ISSUE_RECEIPT.ISSUE_RECEIPT_ID") == OOQL.CreateProperty("ISSUE_RECEIPT_D.ISSUE_RECEIPT_ID")) )); qrySrv.ExecuteNoQuery(deleteNode); }
/// <summary> /// 利用临时表关联实体表进行批量新增条码交易明细 /// </summary> /// <param name="qrySrv"></param> /// <param name="tmpBCLine"></param> private void InsertBCLine(IQueryService qrySrv, IDataEntityType tmpIssueReceiptD) { #region properties List <QueryProperty> properties = new List <QueryProperty>(); properties.AddRange(new QueryProperty[] { Formulas.NewId("BC_LINE_ID"), //主键 OOQL.CreateProperty("TmpTable.BARCODE_NO", "BARCODE_NO"), //条码CODE OOQL.CreateConstants("ISSUE_RECEIPT.ISSUE_RECEIPT_D", "SOURCE_ID.RTK"), //来源单据类型 OOQL.CreateProperty("ISSUE_RECEIPT_D.ISSUE_RECEIPT_D_ID", "SOURCE_ID.ROid"), //来源单据 Formulas.Ext("UNIT_CONVERT", "QTY", new object[] { OOQL.CreateProperty("ITEM.ITEM_ID") , OOQL.CreateProperty("UNIT.UNIT_ID") , OOQL.CreateProperty("TmpTable.ISSUE_RECEIPT_QTY") , OOQL.CreateProperty("ITEM.STOCK_UNIT_ID") , OOQL.CreateConstants(0) }), //数量 Formulas.IsNull(OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_ID"), OOQL.CreateConstants(Maths.GuidDefaultValue()), "WAREHOUSE_ID"), //仓库 //20161208 modi by shenbao fro P001-161208001 Formulas.IsNull(Formulas.Case(null, OOQL.CreateProperty("BIN.BIN_ID"), new CaseItem[] { new CaseItem(OOQL.CreateProperty("TmpTable.BIN_CODE") == OOQL.CreateConstants("") , OOQL.CreateConstants(Maths.GuidDefaultValue())) }), OOQL.CreateConstants(Maths.GuidDefaultValue()), "BIN_ID") //库位 //20161208 modi by shenbao fro P001-161208001 }); #endregion QueryNode groupNode = GroupNode(tmpIssueReceiptD, false); QueryNode insertNode = OOQL.Select( properties ) .From(groupNode, "TmpTable") .InnerJoin("ISSUE_RECEIPT") .On(OOQL.CreateProperty("TmpTable.DOC_NO") == OOQL.CreateProperty("ISSUE_RECEIPT.DOC_NO")) .InnerJoin("ISSUE_RECEIPT.ISSUE_RECEIPT_D", "ISSUE_RECEIPT_D") .On(OOQL.CreateProperty("TmpTable.SequenceNumber") == OOQL.CreateProperty("ISSUE_RECEIPT_D.SequenceNumber") & OOQL.CreateProperty("ISSUE_RECEIPT.ISSUE_RECEIPT_ID") == OOQL.CreateProperty("ISSUE_RECEIPT_D.ISSUE_RECEIPT_ID")) .InnerJoin("ITEM") .On(OOQL.CreateProperty("TmpTable.ITEM_CODE") == OOQL.CreateProperty("ITEM.ITEM_CODE")) .InnerJoin("UNIT") .On(OOQL.CreateProperty("TmpTable.UNIT_CODE") == OOQL.CreateProperty("UNIT.UNIT_CODE")) .LeftJoin("WAREHOUSE") .On(OOQL.CreateProperty("TmpTable.WAREHOUSE_CODE") == OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_CODE") & OOQL.CreateProperty("ISSUE_RECEIPT.Owner_Org.ROid") == OOQL.CreateProperty("WAREHOUSE.Owner_Org.ROid")) .LeftJoin("WAREHOUSE.BIN", "BIN") .On(OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_ID") == OOQL.CreateProperty("BIN.WAREHOUSE_ID") & OOQL.CreateProperty("TmpTable.BIN_CODE") == OOQL.CreateProperty("BIN.BIN_CODE")) .Where(OOQL.CreateProperty("TmpTable.BARCODE_NO") != OOQL.CreateConstants("")); //执行插入 UtilsClass.InsertDocumentToDataBaseOrTmpTable(qrySrv, "BC_LINE", insertNode, properties.Select(c => c.Alias).ToArray()); }
/// <summary> /// 利用临时表关联实体表进行批量更新领料单 /// </summary> private void UpdateSalesIssueD(IQueryService qrySrv, IDataEntityType tempEntityD) { QueryNode selectNode = OOQL.Select(true, OOQL.CreateProperty("SALES_ISSUE_D.SALES_ISSUE_D_ID")) .From("SALES_ISSUE.SALES_ISSUE_D", "SALES_ISSUE_D") .InnerJoin("SALES_ISSUE", "SALES_ISSUE") .On(OOQL.CreateProperty("SALES_ISSUE.SALES_ISSUE_ID") == OOQL.CreateProperty("SALES_ISSUE_D.SALES_ISSUE_ID")) .InnerJoin(tempEntityD.Name, "TEMP") .On(OOQL.CreateProperty("TEMP.doc_no") == OOQL.CreateProperty("SALES_ISSUE.DOC_NO") & OOQL.CreateProperty("TEMP.seq") == OOQL.CreateProperty("SALES_ISSUE_D.SequenceNumber")); QueryNode node = OOQL.Update("SALES_ISSUE.SALES_ISSUE_D") .Set(new SetItem[] { new SetItem(OOQL.CreateProperty("BC_CHECK_STATUS"), OOQL.CreateConstants("2")) }) .From(selectNode, "selectNode") .Where(OOQL.CreateProperty("SALES_ISSUE.SALES_ISSUE_D.SALES_ISSUE_D_ID") == OOQL.CreateProperty("selectNode.SALES_ISSUE_D_ID")); qrySrv.ExecuteNoQueryWithManageProperties(node); }
public static StringBuilder DataEntityToString(IDataEntityType dt, object dataEntity) { StringBuilder sb = new StringBuilder(); DcxmlSerializer serializer = new DcxmlSerializer(new IDataEntityType[] { dt }) { Binder = { OnlyDbProperty = false } }; using (StringWriter writer = new StringWriter(sb)) { using (XmlTextWriter writer2 = new XmlTextWriter(writer)) { serializer.Serialize(writer2, dataEntity, null); } } return(sb); }
//20170905 add by wangyq for P001-170717001 =================begin=================== /// <summary> /// 利用临时表关联实体表进行批量更新领料单 /// </summary> private void UpdateBcCheckStatus(IQueryService qrySrv, IDataEntityType tempEntityD) { QueryNode selectNode = OOQL.Select(true, OOQL.CreateProperty("ISSUE_RECEIPT_D.ISSUE_RECEIPT_D_ID")) .From("ISSUE_RECEIPT.ISSUE_RECEIPT_D", "ISSUE_RECEIPT_D") .InnerJoin("ISSUE_RECEIPT", "ISSUE_RECEIPT") .On(OOQL.CreateProperty("ISSUE_RECEIPT.ISSUE_RECEIPT_ID") == OOQL.CreateProperty("ISSUE_RECEIPT_D.ISSUE_RECEIPT_ID")) .InnerJoin(tempEntityD.Name, "TEMP") .On(OOQL.CreateProperty("TEMP.DOC_NO") == OOQL.CreateProperty("ISSUE_RECEIPT.DOC_NO") & OOQL.CreateProperty("TEMP.SequenceNumber") == OOQL.CreateProperty("ISSUE_RECEIPT_D.SequenceNumber")); QueryNode node = OOQL.Update("ISSUE_RECEIPT.ISSUE_RECEIPT_D") .Set(new SetItem[] { new SetItem(OOQL.CreateProperty("BC_CHECK_STATUS"), OOQL.CreateConstants("2")) }) .From(selectNode, "selectNode") .Where(OOQL.CreateProperty("ISSUE_RECEIPT.ISSUE_RECEIPT_D.ISSUE_RECEIPT_D_ID") == OOQL.CreateProperty("selectNode.ISSUE_RECEIPT_D_ID")); qrySrv.ExecuteNoQueryWithManageProperties(node); }
/// <summary> /// 利用临时表关联实体表进行批量新增条码交易明细 /// </summary> /// <param name="qrySrv"></param> /// <param name="tmpBCLine"></param> private void InsertBCLine(IQueryService qrySrv, IDataEntityType tmpIssueReceiptD) { #region properties List <QueryProperty> selectListPro = new List <QueryProperty>(); selectListPro.Add(Formulas.NewId("BC_LINE_ID")); //主键 selectListPro.Add(OOQL.CreateProperty("TmpTable.barcode_no", "BARCODE_NO")); //条码CODE selectListPro.Add(OOQL.CreateConstants("SALES_ISSUE.SALES_ISSUE_D", "SOURCE_ID.RTK")); //来源单据类型 selectListPro.Add(OOQL.CreateProperty("SALES_ISSUE_D.SALES_ISSUE_D_ID", "SOURCE_ID.ROid")); //来源单据 selectListPro.Add(Formulas.Ext("UNIT_CONVERT", "QTY", new object[] { OOQL.CreateProperty("ITEM.ITEM_ID") , OOQL.CreateProperty("UNIT.UNIT_ID") , OOQL.CreateProperty("TmpTable.sum_picking_qty") , OOQL.CreateProperty("ITEM.STOCK_UNIT_ID") , OOQL.CreateConstants(0) })); //数量 selectListPro.Add(Formulas.IsNull(OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_ID"), OOQL.CreateConstants(Maths.GuidDefaultValue()), "WAREHOUSE_ID")); //仓库 selectListPro.Add(Formulas.IsNull(Formulas.Case(null, OOQL.CreateProperty("BIN.BIN_ID"), new CaseItem[] { new CaseItem(OOQL.CreateProperty("TmpTable.storage_spaces_no") == OOQL.CreateConstants(string.Empty) , OOQL.CreateConstants(Maths.GuidDefaultValue())) }), OOQL.CreateConstants(Maths.GuidDefaultValue()), "BIN_ID")); //库位 #endregion QueryNode groupNode = GetGroupForInsert(tmpIssueReceiptD); QueryNode insertNode = OOQL.Select(selectListPro.ToArray()) .From(groupNode, "TmpTable") .InnerJoin("SALES_ISSUE", "SALES_ISSUE") .On(OOQL.CreateProperty("TmpTable.doc_no") == OOQL.CreateProperty("SALES_ISSUE.DOC_NO")) .InnerJoin("SALES_ISSUE.SALES_ISSUE_D", "SALES_ISSUE_D") .On(OOQL.CreateProperty("TmpTable.seq") == OOQL.CreateProperty("SALES_ISSUE_D.SequenceNumber") & OOQL.CreateProperty("SALES_ISSUE.SALES_ISSUE_ID") == OOQL.CreateProperty("SALES_ISSUE_D.SALES_ISSUE_ID")) .InnerJoin("ITEM", "ITEM") .On(OOQL.CreateProperty("TmpTable.item_no") == OOQL.CreateProperty("ITEM.ITEM_CODE")) .InnerJoin("UNIT", "UNIT") .On(OOQL.CreateProperty("TmpTable.picking_unit_no") == OOQL.CreateProperty("UNIT.UNIT_CODE")) .LeftJoin("WAREHOUSE", "WAREHOUSE") .On(OOQL.CreateProperty("TmpTable.warehouse_no") == OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_CODE") & OOQL.CreateProperty("SALES_ISSUE.Owner_Org.ROid") == OOQL.CreateProperty("WAREHOUSE.Owner_Org.ROid")) .LeftJoin("WAREHOUSE.BIN", "BIN") .On(OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_ID") == OOQL.CreateProperty("BIN.WAREHOUSE_ID") & OOQL.CreateProperty("TmpTable.storage_spaces_no") == OOQL.CreateProperty("BIN.BIN_CODE")) .Where(OOQL.CreateProperty("TmpTable.barcode_no") != OOQL.CreateConstants(String.Empty)); InsertBcLineDB(insertNode, qrySrv); }
public static object StringToDataEntity(IDataEntityType dt, string xml) { DcxmlSerializer serializer = new DcxmlSerializer(new IDataEntityType[] { dt }); return(serializer.DeserializeFromString(xml, null)); }
private static bool TryGetOldProperty(IDataEntityProperty dp, IDataEntityType dtOldData, out IDataEntityProperty dpOldProperty) { dpOldProperty = null; return(((dtOldData != null) && (dp != null)) && dtOldData.Properties.TryGetValue(dp.Name, out dpOldProperty)); }
/// <summary> /// 把一个实体数据拷贝到另一个实体 /// </summary> /// <param name="dataEntity"></param> /// <param name="newEntity"></param> /// <param name="copyHandler"></param> /// <param name="clearPrimaryKeyValue"></param> /// <param name="onlyDbProperty"></param> /// <param name="onlyDirtyProperty"></param> public static void CopyData(this IDataEntityBase dataEntity, IDataEntityBase newEntity, Func <string, string, bool> copyHandler = null, bool clearPrimaryKeyValue = false, bool onlyDbProperty = false, bool onlyDirtyProperty = false) { IDataEntityType dataEntityType = dataEntity.GetDataEntityType(); IDataEntityType type2 = newEntity.GetDataEntityType(); if (copyHandler == null) { copyHandler = (dtName, propName) => true; } IEnumerable <IDataEntityProperty> dirtyProperties = dataEntityType.GetDirtyProperties(dataEntity); foreach (ISimpleProperty property in type2.Properties.GetSimpleProperties(onlyDbProperty)) { if (copyHandler(type2.Name, property.Name)) { IDataEntityProperty dpOldProperty = null; TryGetOldProperty(property, dataEntityType, out dpOldProperty); if ((!onlyDirtyProperty || dirtyProperties.Contains <IDataEntityProperty>(dpOldProperty)) && !(property.IsReadOnly || (dpOldProperty == null))) { property.SetValue(newEntity, dpOldProperty.GetValue(dataEntity)); } } } if (clearPrimaryKeyValue) { ISimpleProperty primaryKey = type2.PrimaryKey; if (primaryKey != null) { primaryKey.ResetValue(newEntity); } type2.SetDirty(newEntity, true); } foreach (IComplexProperty property4 in type2.Properties.GetComplexProperties(onlyDbProperty)) { IDataEntityProperty property5 = null; TryGetOldProperty(property4, dataEntityType, out property5); IDataEntityBase base2 = property5.GetValue(dataEntity) as IDataEntityBase; if (base2 != null) { IDataEntityBase base3; if (property4.IsReadOnly) { base3 = property4.GetValue(newEntity) as IDataEntityBase; if (base3 == null) { throw new ORMDesignException("??????", ResManager.LoadKDString("哦,真不幸,只读的属性却返回了NULL值。", "014009000001633", SubSystemType.SL, new object[0])); } base2.CopyData(base3, copyHandler, false, onlyDbProperty, false); } else { base3 = property4.ComplexPropertyType.CreateInstance() as IDataEntityBase; base2.CopyData(base3, copyHandler, clearPrimaryKeyValue, onlyDbProperty, false); property4.SetValue(newEntity, base3); } } } foreach (ICollectionProperty property6 in type2.Properties.GetCollectionProperties(onlyDbProperty)) { IDataEntityProperty property7 = null; TryGetOldProperty(property6, dataEntityType, out property7); object obj2 = property7.GetValue(dataEntity); if (obj2 != null) { IEnumerable enumerable2 = obj2 as IEnumerable; if (enumerable2 == null) { throw new ORMDesignException("??????", ResManager.LoadKDString("哦,真不幸,集合的属性返回值不支持枚举。", "014009000001634", SubSystemType.SL, new object[0])); } object obj3 = property6.GetValue(newEntity); if (obj3 == null) { if (property6.IsReadOnly) { throw new ORMDesignException("??????", ResManager.LoadKDString("哦,真不幸,集合的属性返回值为null。", "014009000001635", SubSystemType.SL, new object[0])); } obj3 = Activator.CreateInstance(property6.PropertyType); property6.SetValue(newEntity, obj3); } IList list = obj3 as IList; if (list == null) { throw new ORMDesignException("??????", ResManager.LoadKDString("哦,真不幸,集合的属性返回值不支持IList。", "014009000001636", SubSystemType.SL, new object[0])); } list.Clear(); foreach (IDataEntityBase base4 in enumerable2) { IDataEntityBase base5 = property6.CollectionItemPropertyType.CreateInstance() as IDataEntityBase; base4.CopyData(base5, copyHandler, clearPrimaryKeyValue, onlyDbProperty, false); list.Add(base5); } } } }
private void CopyData(IDataEntityType dt, object dataEntity, object newEntity, bool clearPrimaryKeyValue) { IDataEntityType objA = dt; IDataEntityType objB = dt; if (dataEntity is IDataEntityBase) { objA = (dataEntity as IDataEntityBase).GetDataEntityType(); } if (newEntity is IDataEntityBase) { objB = (newEntity as IDataEntityBase).GetDataEntityType(); } if ((dataEntity is DynamicObject) && object.ReferenceEquals(objA, objB)) { ((DynamicObject)newEntity).DataStorage = ((DynamicObject)dataEntity).DataStorage.MemberClone(); } else { foreach (ISimpleProperty property in dt.Properties.GetSimpleProperties(this._onlyDbProperty)) { IDataEntityProperty dpOldProperty = null; this.TryGetOldProperty(property, objA, out dpOldProperty); if (!property.IsReadOnly && (dpOldProperty != null)) { property.SetValue(newEntity, dpOldProperty.GetValue(dataEntity)); } } } if (clearPrimaryKeyValue) { ISimpleProperty primaryKey = dt.PrimaryKey; if (primaryKey != null) { primaryKey.ResetValue(newEntity); } objB.SetDirty(newEntity, true); } foreach (IComplexProperty property4 in dt.Properties.GetComplexProperties(this._onlyDbProperty)) { if (!property4.IsRefrenceObject()) { IDataEntityProperty property5 = null; this.TryGetOldProperty(property4, objA, out property5); object obj2 = property5.GetValue(dataEntity); if (obj2 != null) { object obj3; IDataEntityType dataEntityType; IDataEntityBase base2 = obj2 as IDataEntityBase; if (base2 != null) { dataEntityType = base2.GetDataEntityType(); } else { dataEntityType = property4.ComplexPropertyType; } if (property4.IsReadOnly) { obj3 = property4.GetValue(newEntity); if (obj3 == null) { throw new ORMDesignException("??????", ResManager.LoadKDString("哦,真不幸,只读的属性却返回了NULL值。", "014009000001633", SubSystemType.SL, new object[0])); } this.CopyData(dataEntityType, obj2, obj3, false); } else { if (property4.IsDbIgnore()) { obj3 = this.Clone(dataEntityType, obj2, false); } else { obj3 = this.Clone(dataEntityType, obj2, this._clearPrimaryKeyValue); } property4.SetValue(newEntity, obj3); } } } } foreach (ICollectionProperty property6 in dt.Properties.GetCollectionProperties(this._onlyDbProperty)) { IDataEntityProperty property7 = null; this.TryGetOldProperty(property6, objA, out property7); object obj4 = property7.GetValue(dataEntity); if (obj4 != null) { IEnumerable enumerable = obj4 as IEnumerable; if (enumerable == null) { throw new ORMDesignException("??????", ResManager.LoadKDString("哦,真不幸,集合的属性返回值不支持枚举。", "014009000001634", SubSystemType.SL, new object[0])); } if (newEntity is DynamicObject) { ((DynamicObject)newEntity).DataStorage.SetLocalValue((DynamicProperty)property6, null); } object obj5 = property6.GetValue(newEntity); if (obj5 == null) { if (property6.IsReadOnly) { throw new ORMDesignException("??????", ResManager.LoadKDString("哦,真不幸,集合的属性返回值为null。", "014009000001635", SubSystemType.SL, new object[0])); } obj5 = Activator.CreateInstance(property6.PropertyType); property6.SetValue(newEntity, obj5); } IList list = obj5 as IList; if (list == null) { throw new ORMDesignException("??????", ResManager.LoadKDString("哦,真不幸,集合的属性返回值不支持IList。", "014009000001636", SubSystemType.SL, new object[0])); } list.Clear(); foreach (object obj6 in enumerable) { IDataEntityType collectionItemPropertyType; IDataEntityBase base3 = obj6 as IDataEntityBase; if (base3 == null) { collectionItemPropertyType = property6.CollectionItemPropertyType; } else { collectionItemPropertyType = base3.GetDataEntityType(); } list.Add(this.Clone(collectionItemPropertyType, obj6)); } } } }
public object Clone(IDataEntityType dt, object dataEntity) { return(this.Clone(dt, dataEntity, this._clearPrimaryKeyValue)); }
public object Clone(IDataEntityBase dataEntity) { IDataEntityType dataEntityType = dataEntity.GetDataEntityType(); return(this.Clone(dataEntityType, dataEntity)); }
/// <summary> /// 搜索实体中各个层级的所有数据 /// </summary> /// <param name="dataEntities"></param> /// <param name="dt"></param> /// <param name="callback"></param> /// <param name="onlyDbProperty"></param> public static void DataEntityWalker(IEnumerable <object> dataEntities, IDataEntityType dt, DataEntityWalkerCallback callback, bool onlyDbProperty = true) { DataEntityWalkerEventArgs.DataEntityWalker(dataEntities, dt, callback, onlyDbProperty); }