/// <summary> /// TAB_TITLE /// </summary> private void LoadTabTitle() { List <StringValueDatasourceInfo> items = new List <StringValueDatasourceInfo>(); EntityInfo entityinfo = new EntityBLL().GetInfo(entityfieldinfo.EntityFid.GetValueOrDefault()); if (entityinfo == null) { return; } if (string.IsNullOrEmpty(entityinfo.TabTitles)) { return; } string[] tabtitles = entityinfo.TabTitles.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (var tabtitle in tabtitles) { string[] titletab = tabtitle.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); StringValueDatasourceInfo item = new StringValueDatasourceInfo(); item.StringValue = titletab[0]; item.ItemDisplay = titletab[1] + "[" + titletab[2] + "]"; items.Add(item); } cmbTabTitleCode.DisplayMember = "ItemDisplay"; cmbTabTitleCode.ValueMember = "StringValue"; cmbTabTitleCode.DataSource = items; }
/// <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); }
public virtual bool ChangeEntity(EntityBLL New) { if (uow.Entities.GetOne(o => o.Id == New.Id) != null) { EntityDAL type = Check(New); uow.Entities.Remove(uow.Entities.GetOne(o => o.Id == New.Id)); uow.Save(); uow.Entities.Create(type); uow.Save(); return(true); } else { throw new EntityNotFoundByIDException(string.Format("Entity with this \"{0}\" ID not Found.", New.Id)); } }
/// <summary> /// 获取缺件检查页面配置信息 /// </summary> /// <param name="context"></param> /// <returns></returns> public string GetLackOfInspectionEntityFields(HttpContext context) { ///实体名,可能是FORM的实体名 string entityName = context.Request["ENTITY_NAME"]; if (HttpCommon.IsNullOrEmptyOrUndefined(entityName)) { throw new Exception("MC:1x00000030");///参数获取错误 } ///表名 string tableName = context.Request["TABLE_NAMES"]; if (HttpCommon.IsNullOrEmptyOrUndefined(tableName)) { throw new Exception("MC:1x00000030");///参数获取错误 } ///FILTER string strWhere = context.Request["FILTER"]; if (HttpCommon.IsNullOrEmptyOrUndefined(strWhere)) { strWhere = string.Empty; } if (strWhere.Trim().ToUpper() == "AND") { strWhere = string.Empty; } ///EntityFieldInfo 获取实体字段在页面显示的信息 List <EntityFieldInfo> entityFieldList = GetSupplyPlanCheckFields(strWhere, entityName); /// string resultEntityFields = JsonHelper.ToJson(entityFieldList); ///EntityInfo EntityInfo entityinfo = new EntityBLL().GetInfo(entityName, tableName); string resultEntityInfo = JsonHelper.ToJson(entityinfo); return(@"{""entityfieldform"":" + resultEntityFields + @",""entityinfo"":" + resultEntityInfo + @"}"); }
public virtual EntityBLL GetEntityById(int id) { EntityBLL entity = new EntityBLL(); EntityDAL entityDAL = uow.Entities.GetOne(o => o.Id == id); if (entityDAL != null) { Dictionary <string, object> Dict = new Dictionary <string, object>(); foreach (var g in entityDAL.Attributes) { Dict.Add(g.Key, g.Value.Item); } entity.Id = entityDAL.Id; entity.NameEntity = entityDAL.NameEntity; entity.Attributes = Dict; return(entity); } else { throw new EntityNotFoundByIDException(string.Format("The entity under this (\"{0}\") ID was not found.", id)); } }
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 virtual bool AddEntity(EntityBLL New) { uow.Entities.Create(Check(New)); uow.Save(); return(true); }
private EntityDAL Check(EntityBLL New) { TypeBLL type = TA.GetTypeBLLByName(New.NameEntity.ToLower()); if (type != null) { if (type.Required != null) { foreach (var t in type.Required) { object attribute = new object(); New.Attributes.TryGetValue(t, out attribute); if (attribute == null || attribute.ToString() == "") { throw new ErrorRequiredException(string.Format("Required field \"{0}\" is empty.", t)); } } } if (type.MaxLength.Count != 0) { foreach (var t in type.MaxLength) { bool check = New.Attributes[t.Key].ToString().Length > int.Parse(type.MaxLength[t.Key]); if (check == true) { throw new OutOfMaxLengthException(string.Format("The field \"{0}\" accepts no more than {1} characters.", t, int.Parse(type.MaxLength[t.Key]))); } } } if (type.MinLength.Count != 0) { foreach (var t in type.MinLength) { bool check = New.Attributes[t.Key].ToString().Length < int.Parse(type.MinLength[t.Key]); if (check == true) { throw new OutOfMinLengthException(string.Format("The field \"{0}\" accepts no less than {1} characters.", t, int.Parse(type.MinLength[t.Key]))); } } } if (type.Attributes != null) { Dictionary <string, AttributeDAL> AttributesDal = new Dictionary <string, AttributeDAL>(); foreach (var t in type.Attributes) { if (New.Attributes.ContainsKey(t)) { AttributesDal.Add(t.ToLower(), new AttributeDAL() { Item = New.Attributes[t] }); } } return(new EntityDAL { NameEntity = New.NameEntity, Attributes = AttributesDal }); } else { throw new AttributesNotFoundException("Attributes Not Found."); } } else { throw new TypeNotFoundException(string.Format("Type \"{0}\" not found", New.NameEntity.ToLower())); } }
public void Put(int id, [FromBody] EntityBLL value) { value.Id = id; EA.ChangeEntity(value); }
public void Post([FromBody] EntityBLL value, string Name) { value.NameEntity = Name; EA.AddEntity(value); }
public int Create() { return(EntityBLL.Create(RegionID, Code, Name)); }
public static EntityDisplay GetDetails(int EntityID) { return((EntityDisplay)(EntityBLL.GetDetails(EntityID))); }
public static List <EntityDisplay> List() { return(EntityBLL.ListEntities().Select(e => (EntityDisplay)e).ToList()); }
/// <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); }