/// <summary> /// Gets the entity field properties. /// </summary> /// <param name="props">The props.</param> /// <param name="state">The state.</param> public void GetEntityFieldProperties(PropertyDescriptorCollection props, IDictionary <string, object> state) { var upgradeId = ( Guid )state["entityUpgradeId"]; var sb = new StringBuilder( ); sb.AppendLine(string.Format(SqlQueries.GetTenantAppData, $"AND e.UpgradeId = '{upgradeId}'")); using (IDbCommand command = Context.CreateCommand( )) { command.CommandText = sb.ToString( ); Context.AddParameter(command, "@tenant", DbType.Int64, Tenant.Id); Context.AddParameter(command, "@solutionId", DbType.Int64, Id); using (IDataReader reader = command.ExecuteReader( )) { int fieldCounter = 0; while (reader.Read( )) { Guid fieldUpgradeId = reader.GetGuid(2); object value = reader.GetValue(3); string fieldName = reader.GetString(5, null); var field = new EntityFieldInfo($"FLD{fieldCounter++}", "Fields", fieldName ?? fieldUpgradeId.ToString("B"), $"The '{fieldName ?? fieldUpgradeId.ToString( "B" )}' field value."); field.SetValue(this, value); props.Add(new FieldPropertyDescriptor(field)); } } } }
public static EntityFieldInfo ToEntityFieldInfo(this IProperty p, EntityInfo e, bool isPk = false) { var annotation = p.FindAnnotation(ColumnNameAnnoName); var info = new EntityFieldInfo { ClrProperty = p.PropertyInfo, PropertyName = p.Name, DbName = annotation != null?annotation.Value.ToString() : p.Name, ValType = p.ClrType, IsPrimaryKey = isPk, Entity = e }; if (info.ClrProperty == null) { var columnName = info.DbName != info.PropertyName ? $" (column {e.EntityName}.{info.DbName})" : string.Empty; var msg = $@"Property '{e.Type.Name}.{info.PropertyName}'{columnName} does not have meta data 'PropertyInfo'. Please check if it is setup correctly in the data context. EF may generate this column by convention if it is associated with relations."; throw new Exception(msg); } return(info); }
/// <summary> /// Gets the entity properties. /// </summary> /// <param name="props">The props.</param> /// <param name="state">The state.</param> public void GetEntityProperties(PropertyDescriptorCollection props, IDictionary <string, object> state) { using (IDbCommand command = Context.CreateCommand( )) { command.CommandText = $"SELECT Id FROM Entity WHERE UpgradeId = '{( Guid ) state[ "entityUpgradeId" ]}' AND TenantId = {Id}"; object entityIdObject = command.ExecuteScalar( ); long entityId = -1; if (entityIdObject != null) { entityId = ( long )entityIdObject; state["entityId"] = entityId; } ///// // Id. ///// var baseInfo = new EntityFieldInfo("base0", "Entity", "Id", "The Entity Id."); baseInfo.SetValue(this, entityId.ToString(CultureInfo.InvariantCulture)); props.Add(new FieldPropertyDescriptor(baseInfo)); ///// // Upgrade Id. ///// baseInfo = new EntityFieldInfo("base1", "Entity", "UpgradeId", "The Entity upgrade Id."); baseInfo.SetValue(this, (( Guid )state["entityUpgradeId"]).ToString("B")); props.Add(new FieldPropertyDescriptor(baseInfo)); } }
/// <summary> /// Gets the relationship properties. /// </summary> /// <param name="props">The props.</param> /// <param name="state">The state.</param> public void GetEntityRelationshipProperties(PropertyDescriptorCollection props, IDictionary <string, object> state) { var entityId = ( long )state["entityId"]; using (IDbCommand command = Context.CreateCommand( )) { Context.AddParameter(command, "@tenantId", DbType.Int64, Id); Context.AddParameter(command, "@entityId", DbType.Int64, entityId); ///// // Get the relationships that this entity is involved in. ///// command.CommandText = SqlQueries.GetTenantEntityViewerRelationships; using (IDataReader reader = command.ExecuteReader( )) { int relationshipCounter = 0; while (reader.Read( )) { string name = reader.GetString(0); var field = new EntityFieldInfo($"RLN{relationshipCounter++.ToString( "0000" )}", reader.GetString(2) + " relationships", name, $"The '{name}' field value."); field.SetValue(this, reader.GetString(1)); props.Add(new FieldPropertyDescriptor(field)); } } } }
/// <summary> /// Gets the entity relationship properties. /// </summary> /// <param name="props">The props.</param> /// <param name="state">The state.</param> public override void GetEntityRelationshipProperties(PropertyDescriptorCollection props, IDictionary <string, object> state) { var entityUid = ( Guid )state["entityUpgradeId"]; using (IDbCommand command = CreateCommand( )) { command.CommandText = string.Format(SqlQueries.GetFileEntityViewerRelationships, entityUid.ToString( ).ToLower( )); using (IDataReader reader = command.ExecuteReader( )) { int relationshipCounter = 0; while (reader.Read( )) { string direction = reader.GetString(0); Guid typeId = reader.GetGuid(1, Guid.Empty); string typeName = reader.GetString(2, null); Guid toId = reader.GetGuid(3, Guid.Empty); string toName = reader.GetString(4, null); ReferToUpgradeIdLookup(ref typeName, typeId); ReferToUpgradeIdLookup(ref toName, toId); var field = new EntityFieldInfo($"RLN{relationshipCounter++.ToString( "0000" )}", direction + " relationships", typeName ?? typeId.ToString("B"), $"The '{typeName ?? typeId.ToString( "B" )}' field value."); field.SetValue(this, toName ?? toId.ToString("B")); props.Add(new FieldPropertyDescriptor(field)); } } } }
private static void AddExpandableSelectRest(StringBuilder sb, EntityFieldInfo field, EntityFieldExpandInfo expandFields, string path) { EntityInfo collectionEntityInfo = null; if (expandFields == null) { collectionEntityInfo = EntityManager.Instance.GetStaticClassInfo(field.ExpandFieldInfo.Type); expandFields = field.ExpandFieldInfo; } else { if (expandFields.Type != null) { collectionEntityInfo = EntityManager.Instance.GetStaticClassInfo(expandFields.Type); } } if (collectionEntityInfo != null) { foreach (var expandableField in expandFields.Fields.OrderBy(p => p.Expandable)) { var expandableFieldInfo = collectionEntityInfo.Fields.First(p => p.Name == expandableField.Name); if (!expandableFieldInfo.SharePointExpandable) { sb.Append($"{JsonMappingHelper.GetRestField(field)}{path}/{JsonMappingHelper.GetRestField(expandableFieldInfo)},"); } else { path = path + "/" + JsonMappingHelper.GetRestField(expandableFieldInfo); AddExpandableSelectRest(sb, field, expandableField, path); path = ""; } } } }
/// <summary> /// Gets the entity relationship properties. /// </summary> /// <param name="props">The props.</param> /// <param name="state">The state.</param> public void GetEntityRelationshipProperties(PropertyDescriptorCollection props, IDictionary <string, object> state) { var upgradeId = ( Guid )state["entityUpgradeId"]; using (IDbCommand command = Context.CreateCommand(SqlQueries.GetAppLibraryEntityViewerRelationships)) { Context.AddParameter(command, "@appVerId", DbType.Guid, Id); Context.AddParameter(command, "@entityUid", DbType.Guid, upgradeId); using (IDataReader reader = command.ExecuteReader( )) { int relationshipCounter = 0; while (reader.Read( )) { string name = reader.GetString(0, string.Empty); Guid id = reader.GetGuid(3, Guid.Empty); string val = reader.GetString(1, string.Empty); Guid valId = reader.GetGuid(4, Guid.Empty); ReferToUpgradeIdLookup(ref name, id); ReferToUpgradeIdLookup(ref val, valId); var field = new EntityFieldInfo($"RLN{relationshipCounter++.ToString( "0000" )}", reader.GetString(2) + " relationships", name, $"The '{name}' field value."); field.SetValue(this, val); props.Add(new FieldPropertyDescriptor(field)); } } } }
/// <summary> /// /// </summary> /// <param name="whereText"></param> /// <returns></returns> private List <EntityFieldInfo> GetSupplyPlanFields(string whereText, string entityName) { ///EntityFieldInfo 获取实体字段在页面显示的信息 List <EntityFieldInfo> entityFieldList = new EntityBLL().GetGridFieldByEntityName(entityName, "TT_ATP_SUPPLY_PLAN"); ///追加动态日期列 ///供货计划默认展示最大天数,默认14 string supplyPlanDefaultShowMaxDays = new ConfigBLL().GetValueByCode("SUPPLY_PLAN_DEFAULT_SHOW_MAX_DAYS"); int intSupplyPlanDefaultShowMaxDays = GetSupplyPlanShowDays(supplyPlanDefaultShowMaxDays, whereText, out DateTime seedDate); List <string> dateColumns = GetValidDates(intSupplyPlanDefaultShowMaxDays, seedDate); ///种子顺序 int seedDisplayOrder = 70; for (int i = 0; i < intSupplyPlanDefaultShowMaxDays; i++) { #region EntityFieldInfo EntityFieldInfo entityFieldInfo = new EntityFieldInfo(); entityFieldInfo.FieldName = "D" + seedDate.ToString("yyyyMMdd"); entityFieldInfo.TableFieldName = "D" + seedDate.ToString("yyyyMMdd"); entityFieldInfo.DisplayNameCn = seedDate.ToString("MM月dd日"); entityFieldInfo.DisplayNameEn = seedDate.ToString("yyyyMMdd"); entityFieldInfo.DisplayOrder = seedDisplayOrder; entityFieldInfo.DataType = (int)DataTypeConstants.DECIMAL; entityFieldInfo.ControlType = (int)ControlTypeConstants.NUMBERBOX; entityFieldInfo.DataLength = 18; entityFieldInfo.Precision = 0; entityFieldInfo.DefaultValue = string.Empty; entityFieldInfo.Nullenable = null; entityFieldInfo.Regex = string.Empty; entityFieldInfo.ErrorMsg = string.Empty; entityFieldInfo.MinValue = null; entityFieldInfo.MaxValue = null; entityFieldInfo.Editable = false; entityFieldInfo.EditDisplayWidth = string.Empty; entityFieldInfo.Listable = true; entityFieldInfo.ListDisplayWidth = "80"; entityFieldInfo.Extend1 = string.Empty; entityFieldInfo.Extend2 = string.Empty; entityFieldInfo.Extend3 = string.Empty; entityFieldInfo.EditReadonly = (int)ReadonlyTypeConstants.NOTREADONLY; entityFieldInfo.TabTitleCode = string.Empty; entityFieldInfo.Sortable = false; entityFieldInfo.ExportExcelFlag = true; entityFieldInfo.ExportExcelOrder = seedDisplayOrder; entityFieldInfo.TooltipHelperCn = string.Empty; entityFieldInfo.TooltipHelperEn = string.Empty; seedDisplayOrder += 10; if (dateColumns.Contains(seedDate.ToString("yyyyMMdd"))) { entityFieldList.Add(entityFieldInfo); } seedDate = seedDate.AddDays(1); #endregion } return(entityFieldList); }
/// <summary> /// InsertInfo /// </summary> /// <param name="info"></param> /// <returns></returns> public long InsertInfo(EntityFieldInfo info) { int cnt = dal.GetCounts("[ENTITY_FID] = N'" + info.EntityFid.GetValueOrDefault() + "' and [FIELD_NAME] = N'" + info.FieldName + "'"); if (cnt > 0) { throw new Exception("MC:0x00000045");///同一数据模型里的字段不允许重复 } return(dal.Add(info)); }
/// <summary> /// Gets the entity properties. /// </summary> /// <param name="props">The props.</param> /// <param name="state">The state.</param> public override void GetEntityProperties(PropertyDescriptorCollection props, IDictionary <string, object> state) { ///// // Upgrade Id. ///// var baseInfo = new EntityFieldInfo("base1", "Entity", "UpgradeId", "The Entity upgrade Id."); baseInfo.SetValue(this, (( Guid )state["entityUpgradeId"]).ToString("B")); props.Add(new FieldPropertyDescriptor(baseInfo)); }
private static void ProcessChangeElement(object pnpObject, IDataModelParent parent, PnPContext context, JsonElement element, Guid batchRequestId) { var metadataBasedObject = pnpObject as IMetadataExtensible; var entity = EntityManager.GetClassInfo <IChange>(pnpObject.GetType(), null); SetBatchRequestId(pnpObject as TransientObject, batchRequestId); // Enumerate the received properties and try to map them to the model foreach (var property in element.EnumerateObject()) { // Find the model field linked to this field EntityFieldInfo entityField = entity.Fields.FirstOrDefault(p => p.SharePointName == property.Name); // Entity field should be populated for the actual fields we've requested if (entityField != null) { if (entityField.PropertyInfo.PropertyType == typeof(IChangeToken)) // Special case { var changeToken = GetConcreteInstance(property.Value); ProcessChangeElement(changeToken, parent, context, property.Value, batchRequestId); entityField.PropertyInfo?.SetValue(pnpObject, changeToken); } else if (entityField.PropertyInfo.PropertyType == typeof(IContentType)) { // Since this is an SP.ContentTypeId and NOT an SP.ContentType, it's not a perfect entity match; we'll do it manually var concreteInstance = (IContentType)EntityManager.GetEntityConcreteInstance(entityField.PropertyInfo.PropertyType, parent, context); var contentTypeId = property.Value.GetProperty("StringValue").GetString(); concreteInstance.SetSystemProperty(ct => ct.Id, contentTypeId); concreteInstance.SetSystemProperty(ct => ct.StringId, contentTypeId); (concreteInstance as IMetadataExtensible).Metadata.Add(PnPConstants.MetaDataType, "SP.ContentTypeId"); (concreteInstance as IMetadataExtensible).Metadata.Add(PnPConstants.MetaDataId, contentTypeId); (concreteInstance as IMetadataExtensible).Metadata.Add(PnPConstants.MetaDataRestId, contentTypeId); concreteInstance.Requested = true; entityField.PropertyInfo?.SetValue(pnpObject, concreteInstance); } else // Simple property mapping { // Set the object property value taken from the JSON payload entityField.PropertyInfo?.SetValue(pnpObject, JsonMappingHelper.GetJsonFieldValue(null, entityField.Name, property.Value, entityField.DataType, entityField.SharePointUseCustomMapping, null)); } } else { // Let's keep track of the object metadata, useful when creating new requests if (property.Name == "__metadata") { JsonMappingHelper.TrackSharePointMetaData(metadataBasedObject, property); } } } }
private void grdFields_RowLeave(object sender, DataGridViewCellEventArgs e) { // see if this is a new row EntityFieldInfo field = grdFields.Rows[e.RowIndex].DataBoundItem as EntityFieldInfo; if (field.EntityFieldId == 0) { field.EntityId = Entity.EntityId; field.EntityFieldId = getNewFieldId(); field.StatusCode = EntityFieldStatusCodes.Staged; } }
public static EntityFieldInfo ToEntityFieldInfo(this IProperty p, EntityInfo e, bool isPk = false) { var annotation = p.FindAnnotation(ColumnNameAnnoName); var info = new EntityFieldInfo { ClrProperty = p.PropertyInfo, PropertyName = p.Name, DbName = annotation != null?annotation.Value.ToString() : p.Name, ValType = p.ClrType, IsPrimaryKey = isPk, Entity = e }; return(info); }
/// <summary> /// Gets the entity field properties. /// </summary> /// <param name="props">The props.</param> /// <param name="state">The state.</param> public override void GetEntityFieldProperties(PropertyDescriptorCollection props, IDictionary <string, object> state) { var entityUid = ( Guid )state["entityUpgradeId"]; int fieldCounter = 0; foreach (var fieldData in _data.Where(d => d.EntityUpgradeId == entityUid)) { var fieldName = GetFieldName(fieldData.FieldUpgradeId); string value = fieldData.Value.ToString( ); var field = new EntityFieldInfo($"FLD{fieldCounter++}", "Fields", fieldName, $"The '{fieldName}' field value."); field.SetValue(this, value); props.Add(new FieldPropertyDescriptor(field)); } }
/// <summary> /// Gets the entity relationship properties. /// </summary> /// <param name="props">The props.</param> /// <param name="state">The state.</param> public override void GetEntityRelationshipProperties(PropertyDescriptorCollection props, IDictionary <string, object> state) { var entityUid = ( Guid )state["entityUpgradeId"]; int relationshipCounter = 0; foreach (var relData in _relationships.Where(r => r.FromUpgradeId == entityUid || r.ToUpgradeId == entityUid)) { string direction = relData.FromUpgradeId == entityUid ? "Forward" : "Reverse"; Guid typeId = relData.TypeUpgradeId; string typeName = GetFieldName(relData.TypeUpgradeId); Guid toId = relData.ToUpgradeId; string toName = GetFieldName(relData.ToUpgradeId); var field = new EntityFieldInfo($"RLN{relationshipCounter++.ToString( "0000" )}", direction + " relationships", typeName ?? typeId.ToString("B"), $"The '{typeName ?? typeId.ToString( "B" )}' field value."); field.SetValue(this, toName ?? toId.ToString("B")); props.Add(new FieldPropertyDescriptor(field)); } }
/// <summary> /// Gets the field properties. /// </summary> /// <param name="props">The props.</param> /// <param name="state">The state.</param> public void GetEntityFieldProperties(PropertyDescriptorCollection props, IDictionary <string, object> state) { var entityId = ( long )state["entityId"]; using (IDbCommand command = Context.CreateCommand( )) { ///// // Get all the field information in a single request. ///// command.CommandText = string.Format(SqlQueries.GetTenantEntityViewerFields, entityId.ToString(CultureInfo.InvariantCulture), Id.ToString(CultureInfo.InvariantCulture)); using (IDataReader reader = command.ExecuteReader( )) { int fieldCounter = 0; while (reader.Read( )) { string value = reader.GetString(0); if (!string.IsNullOrEmpty(value)) { value = value.Replace("\r\n", " ").Replace("\n", " ").Replace("\t", " "); while (value.IndexOf(" ", StringComparison.Ordinal) >= 0) { value = value.Replace(" ", " "); } value = value.Trim( ); } var field = new EntityFieldInfo($"FLD{fieldCounter++}", "Fields", value, $"The '{value}' field value."); field.SetValue(this, reader.IsDBNull(1) ? "<null>" : reader.GetString(1)); props.Add(new FieldPropertyDescriptor(field)); } } } }
/// <summary> /// Gets the entity relationship properties. /// </summary> /// <param name="props">The props.</param> /// <param name="state">The state.</param> public void GetEntityRelationshipProperties(PropertyDescriptorCollection props, IDictionary <string, object> state) { var upgradeId = ( Guid )state["entityUpgradeId"]; string query = string.Format(SqlQueries.GetTenantAppRelationshipsViewer, Id, Tenant.Id, upgradeId); using (IDbCommand command = Context.CreateCommand(query)) { using (IDataReader reader = command.ExecuteReader( )) { int relationshipCounter = 0; while (reader.Read( )) { string name = reader.GetString(0); var field = new EntityFieldInfo($"RLN{relationshipCounter++.ToString( "0000" )}", reader.GetString(2) + " relationships", name, $"The '{name}' field value."); field.SetValue(this, reader.GetString(1)); props.Add(new FieldPropertyDescriptor(field)); } } } }
private void btnCreateEntity_Click(object sender, EventArgs e) { string spaceName = cbNameSpace.Text.ToUpper(); string entityName = txtEntityName.Text.Trim(); if (string.IsNullOrEmpty(entityName)) { DialogTextbox dialog = new DialogTextbox("请输入数据模型名称"); if (dialog.ShowDialog(this) == DialogResult.Yes) { entityName = dialog.content; txtEntityName.Text = entityName; } dialog.Dispose(); } if (string.IsNullOrEmpty(entityName)) { return; } EntityInfo entityinfo = new EntityBLL().GetInfo(entityName, GetTableNameByEntityName(entityName)); if (entityinfo != null) { ErrorMessage(entityName + "已存在"); return; } entityinfo = new EntityInfo(); entityinfo.Fid = Guid.NewGuid(); entityinfo.EntityName = entityName; entityinfo.TableNames = GetTableNameByEntityName(entityName); SelectedField keyField = selectedFields.FirstOrDefault(d => d.keyFieldFlag); if (keyField == null) { return; } entityinfo.DefaultSort = "dbo.[" + keyField.tableName + "].[" + keyField.fieldName + "]-desc";///KT默认为NID倒排序 entityinfo.Comments = string.Empty; entityinfo.ValidFlag = true; entityinfo.CreateUser = string.Empty; entityinfo.CreateDate = DateTime.Now; entityinfo.EntityType = 1; List <EntityFieldInfo> fieldlist = new List <EntityFieldInfo>(); int cnt = 1; foreach (var field in selectedFields.Where(d => !d.keyFieldFlag)) { EntityFieldInfo fieldinfo = new EntityFieldInfo(); fieldinfo.Fid = Guid.NewGuid(); fieldinfo.EntityFid = entityinfo.Fid; fieldinfo.FieldName = GetEntityNameByTableName(field.tableName) + "_" + field.fieldName; ///对象的属性 fieldinfo.TableFieldName = field.fieldName; ///数据库字段 fieldinfo.DisplayNameCn = field.descCn; fieldinfo.DisplayNameEn = field.descEn; fieldinfo.DisplayOrder = cnt * 10; fieldinfo.DataType = 10; ///string fieldinfo.ControlType = 10; ///textbox fieldinfo.DataLength = field.maxLength; fieldinfo.Nullenable = true; fieldinfo.Editable = true; fieldinfo.EditDisplayWidth = "200"; fieldinfo.Listable = true; fieldinfo.ListDisplayWidth = "100"; fieldinfo.Regex = string.Empty; fieldinfo.ValidFlag = true; fieldinfo.CreateDate = DateTime.Now; fieldinfo.CreateUser = string.Empty; fieldlist.Add(fieldinfo); cnt++; } using (var trans = new TransactionScope()) { if (new EntityBLL().InsertInfo(entityinfo) == 0) { ErrorMessage(entityName + "已经生成实体类失败"); return; } foreach (var fieldinfo in fieldlist) { if (new EntityFieldBLL().InsertInfo(fieldinfo) == 0) { ErrorMessage("插入字段数据失败"); return; } } trans.Complete(); } ShowMessage("数据模型添加成功"); btnClear_Click(null, null); }
public DialogEntityField(EntityFieldInfo _entityfieldinfo) { InitializeComponent(); entityfieldinfo = _entityfieldinfo; }
/// <summary> /// /// </summary> /// <param name="whereText"></param> /// <param name="entityName"></param> /// <returns></returns> private List <EntityFieldInfo> GetSupplyPlanCheckFields(string whereText, string entityName) { ///EntityFieldInfo 获取实体字段在页面显示的信息 List <EntityFieldInfo> entityFieldList = new EntityBLL().GetGridFieldByEntityName(entityName, "TT_ATP_SUPPLY_PLAN"); ///追加动态日期列 ///缺件检查显示供货计划天数 string lackOfInspectionDisplaySupplyPlanDays = new ConfigBLL().GetValueByCode("LACK_OF_INSPECTION_DISPLAY_SUPPLY_PLAN_DAYS"); int intLackOfInspectionDisplaySupplyPlanDays = GetSupplyPlanShowDays(lackOfInspectionDisplaySupplyPlanDays, whereText, out DateTime seedDate); List <string> dateColumns = GetValidDates(intLackOfInspectionDisplaySupplyPlanDays, seedDate); ///生产计划锁定临近天数 string productionPlanLockedDays = new ConfigBLL().GetValueByCode("PRODUCTION_PLAN_LOCKED_DAYS"); if (!int.TryParse(productionPlanLockedDays, out int intProductionPlanLockedDays)) { throw new Exception("MC:1x00000031");///系统配置错误 } if (intProductionPlanLockedDays > intLackOfInspectionDisplaySupplyPlanDays) { throw new Exception("MC:1x00000031");///系统配置错误 } ///种子顺序 int seedDisplayOrder = 70; #region RDC EntityFieldInfo rdcEntityFieldInfo = new EntityFieldInfo(); rdcEntityFieldInfo.FieldName = "RDC"; rdcEntityFieldInfo.TableFieldName = "RDC"; rdcEntityFieldInfo.DisplayNameCn = "RDC库存"; rdcEntityFieldInfo.DisplayNameEn = "RDC Inventory"; rdcEntityFieldInfo.DisplayOrder = seedDisplayOrder; rdcEntityFieldInfo.DataType = (int)DataTypeConstants.INT; rdcEntityFieldInfo.ControlType = (int)ControlTypeConstants.NUMBERBOX; rdcEntityFieldInfo.DataLength = 18; rdcEntityFieldInfo.Precision = 0; rdcEntityFieldInfo.DefaultValue = string.Empty; rdcEntityFieldInfo.Nullenable = null; rdcEntityFieldInfo.Regex = string.Empty; rdcEntityFieldInfo.ErrorMsg = string.Empty; rdcEntityFieldInfo.MinValue = null; rdcEntityFieldInfo.MaxValue = null; rdcEntityFieldInfo.Editable = false; rdcEntityFieldInfo.EditDisplayWidth = string.Empty; rdcEntityFieldInfo.Listable = true; rdcEntityFieldInfo.ListDisplayWidth = "65"; rdcEntityFieldInfo.Extend1 = string.Empty; rdcEntityFieldInfo.Extend2 = string.Empty; rdcEntityFieldInfo.Extend3 = string.Empty; rdcEntityFieldInfo.EditReadonly = (int)ReadonlyTypeConstants.NOTREADONLY; rdcEntityFieldInfo.TabTitleCode = string.Empty; rdcEntityFieldInfo.Sortable = false; rdcEntityFieldInfo.ExportExcelFlag = true; rdcEntityFieldInfo.ExportExcelOrder = seedDisplayOrder; rdcEntityFieldInfo.TooltipHelperCn = string.Empty; rdcEntityFieldInfo.TooltipHelperEn = string.Empty; seedDisplayOrder += 10; entityFieldList.Add(rdcEntityFieldInfo); #endregion #region VMI EntityFieldInfo vmiEntityFieldInfo = new EntityFieldInfo(); vmiEntityFieldInfo.FieldName = "VMI"; vmiEntityFieldInfo.TableFieldName = "VMI"; vmiEntityFieldInfo.DisplayNameCn = "VMI库存"; vmiEntityFieldInfo.DisplayNameEn = "VMI Inventory"; vmiEntityFieldInfo.DisplayOrder = seedDisplayOrder; vmiEntityFieldInfo.DataType = (int)DataTypeConstants.DECIMAL; vmiEntityFieldInfo.ControlType = (int)ControlTypeConstants.NUMBERBOX; vmiEntityFieldInfo.DataLength = 18; vmiEntityFieldInfo.Precision = 0; vmiEntityFieldInfo.DefaultValue = string.Empty; vmiEntityFieldInfo.Nullenable = null; vmiEntityFieldInfo.Regex = string.Empty; vmiEntityFieldInfo.ErrorMsg = string.Empty; vmiEntityFieldInfo.MinValue = null; vmiEntityFieldInfo.MaxValue = null; vmiEntityFieldInfo.Editable = false; vmiEntityFieldInfo.EditDisplayWidth = string.Empty; vmiEntityFieldInfo.Listable = true; vmiEntityFieldInfo.ListDisplayWidth = "65"; vmiEntityFieldInfo.Extend1 = string.Empty; vmiEntityFieldInfo.Extend2 = string.Empty; vmiEntityFieldInfo.Extend3 = string.Empty; vmiEntityFieldInfo.EditReadonly = (int)ReadonlyTypeConstants.NOTREADONLY; vmiEntityFieldInfo.TabTitleCode = string.Empty; vmiEntityFieldInfo.Sortable = false; vmiEntityFieldInfo.ExportExcelFlag = true; vmiEntityFieldInfo.ExportExcelOrder = seedDisplayOrder; vmiEntityFieldInfo.TooltipHelperCn = string.Empty; vmiEntityFieldInfo.TooltipHelperEn = string.Empty; seedDisplayOrder += 10; entityFieldList.Add(vmiEntityFieldInfo); #endregion ///累计日期字符串 string accumulativeDate = string.Empty; for (int i = 0; i < intLackOfInspectionDisplaySupplyPlanDays; i++) { EntityFieldInfo entityFieldInfo = new EntityFieldInfo(); entityFieldInfo.FieldName = "D" + seedDate.ToString("yyyyMMdd"); entityFieldInfo.TableFieldName = "D" + seedDate.ToString("yyyyMMdd"); entityFieldInfo.DisplayNameCn = seedDate.ToString("MM月dd日"); entityFieldInfo.DisplayNameEn = seedDate.ToString("yyyyMMdd"); entityFieldInfo.DisplayOrder = seedDisplayOrder; entityFieldInfo.DataType = (int)DataTypeConstants.DECIMAL; entityFieldInfo.ControlType = (int)ControlTypeConstants.NUMBERBOX; entityFieldInfo.DataLength = 18; entityFieldInfo.Precision = 0; entityFieldInfo.DefaultValue = string.Empty; entityFieldInfo.Nullenable = null; entityFieldInfo.Regex = string.Empty; entityFieldInfo.ErrorMsg = string.Empty; entityFieldInfo.MinValue = null; entityFieldInfo.MaxValue = null; entityFieldInfo.Editable = false; entityFieldInfo.EditDisplayWidth = string.Empty; entityFieldInfo.Listable = true; entityFieldInfo.ListDisplayWidth = "65"; entityFieldInfo.Extend1 = string.Empty; entityFieldInfo.Extend2 = string.Empty; entityFieldInfo.Extend3 = string.Empty; entityFieldInfo.EditReadonly = (int)ReadonlyTypeConstants.NOTREADONLY; entityFieldInfo.TabTitleCode = string.Empty; entityFieldInfo.Sortable = false; entityFieldInfo.ExportExcelFlag = true; entityFieldInfo.ExportExcelOrder = seedDisplayOrder; entityFieldInfo.TooltipHelperCn = string.Empty; entityFieldInfo.TooltipHelperEn = string.Empty; seedDisplayOrder += 10; seedDate = seedDate.AddDays(1); ///超过生产计划锁定临近天数时不再做数量差异判定 if (i >= intProductionPlanLockedDays) { entityFieldList.Add(entityFieldInfo); continue; } ///从第二天起需要累加之前日期的数量 if (i > 0) { accumulativeDate += "+row.D"; } accumulativeDate += seedDate.AddDays(-1).ToString("yyyyMMdd"); entityFieldInfo.Extend3 = "styler^样式逻辑:(Math.round(row.RDC)+Math.round(row.VMI) >= (row.D" + accumulativeDate + ")? row.D" + seedDate.AddDays(-1).ToString("yyyyMMdd") + " : -1).toString(),背景颜色:#00FF00,字体颜色:black"; entityFieldList.Add(entityFieldInfo); } return(entityFieldList); }
public void GetEntityFieldProperties(PropertyDescriptorCollection props, IDictionary <string, object> state) { var upgradeId = ( Guid )state["entityUpgradeId"]; var sb = new StringBuilder( ); sb.AppendLine("CREATE TABLE #Names ( EntityUid UNIQUEIDENTIFIER PRIMARY KEY, Data NVARCHAR( MAX ) )"); sb.AppendLine( ); sb.AppendLine(@" INSERT INTO #Names SELECT n.EntityUid, n.Data FROM AppData_NVarChar n WHERE n.FieldUid = 'f8def406-90a1-4580-94f4-1b08beac87af' AND n.AppVerUid = @appVerId" ); sb.AppendLine("SELECT x.Type, x.EntityUpgradeId, x.FieldUpgradeId, x.Data, e.Data, f.Data, x.Namespace, x.Additional FROM ("); bool firstDataType = true; foreach (string type in Diff.Data.DataTypes) { if (!firstDataType) { sb.AppendLine( ); sb.AppendLine("UNION ALL"); } else { firstDataType = false; } sb.AppendFormat(SqlQueries.GetAppLibEntityViewerData, $"AppData_{type}", type, type == "Alias" ? "d.Namespace, d.AliasMarkerId" : "NULL, NULL"); } sb.AppendLine( ); sb.AppendLine(@" ) x LEFT JOIN #Names e ON x.EntityUpgradeId = e.EntityUid LEFT JOIN #Names f ON x.FieldUpgradeId = f.EntityUid ORDER BY CAST(x.EntityUpgradeId AS NVARCHAR(100)), CAST(x.FieldUpgradeId AS NVARCHAR(100)) DROP TABLE #Names"); using (IDbCommand command = Context.CreateCommand(sb.ToString( ))) { Context.AddParameter(command, "@appVerId", DbType.Guid, Id); Context.AddParameter(command, "@entityUid", DbType.Guid, upgradeId); using (IDataReader reader = command.ExecuteReader( )) { int fieldCounter = 0; while (reader.Read( )) { string type = reader.GetString(0, null); Guid fieldUpgradeId = reader.GetGuid(2); object value = reader.GetValue(3); string fieldName = reader.GetString(5, null); ReferToUpgradeIdLookup(ref fieldName, fieldUpgradeId); if (type == "Alias") { string nameSpace = reader.GetString(6); string aliasMarkerId = reader.GetInt32(7).ToString(CultureInfo.InvariantCulture); value = nameSpace + ":" + value + ":" + aliasMarkerId; } var field = new EntityFieldInfo($"FLD{fieldCounter++}", "Fields", fieldName ?? fieldUpgradeId.ToString("B"), $"The '{fieldName ?? fieldUpgradeId.ToString( "B" )}' field value."); field.SetValue(this, value); props.Add(new FieldPropertyDescriptor(field)); } } } }
/// <summary> /// Gets the entity field properties. /// </summary> /// <param name="props">The props.</param> /// <param name="state">The state.</param> public override void GetEntityFieldProperties(PropertyDescriptorCollection props, IDictionary <string, object> state) { var entityUid = ( Guid )state["entityUpgradeId"]; var sb = new StringBuilder( ); bool firstDataType = true; foreach (string type in Diff.Data.DataTypes) { if (!firstDataType) { sb.AppendLine("UNION ALL"); } else { firstDataType = false; } sb.AppendLine(string.Format(SqlQueries.GetFileEntityViewerFields, $"_Data_{type}", entityUid.ToString( ).ToLower( ))); } using (IDbCommand command = CreateCommand( )) { command.CommandText = sb.ToString( ); using (IDataReader reader = command.ExecuteReader( )) { int fieldCounter = 0; while (reader.Read( )) { string fieldName = reader.GetString(0, null); object value = reader.GetValue(1); Guid fieldUid = reader.GetGuid(2, Guid.Empty); ReferToUpgradeIdLookup(ref fieldName, fieldUid); if (!string.IsNullOrEmpty(fieldName)) { fieldName = fieldName.Replace("\r\n", " ").Replace("\n", " ").Replace("\t", " "); while (fieldName.IndexOf(" ", StringComparison.Ordinal) >= 0) { fieldName = fieldName.Replace(" ", " "); } fieldName = fieldName.Trim( ); } else { fieldName = fieldUid.ToString("B"); } var field = new EntityFieldInfo($"FLD{fieldCounter++}", "Fields", fieldName, $"The '{fieldName}' field value."); field.SetValue(this, value.ToString( )); props.Add(new FieldPropertyDescriptor(field)); } } } }