private void CreateNewObjectBySchemaType(string schemaType) { this.Data = SchemaExtensions.CreateObject(schemaType); this.currentSchemaType.Value = schemaType; this.Data.ID = UuidHelper.NewUuidString(); }
/// <summary> /// 根据模式类型,查询ID类型和ID和时间点检索对象 /// </summary> /// <param name="schemaType">表示模式类型的字符串</param> /// <param name="idType">表示ID类型的<see cref="SnapshotQueryIDType"/>值之一</param> /// <param name="id">对象的ID</param> /// <param name="timePoint"></param> /// <returns></returns> public SchemaObjectBase LoadByID(string schemaType, SnapshotQueryIDType idType, string id, DateTime timePoint) { schemaType.CheckStringIsNullOrEmpty("schemaType"); id.CheckStringIsNullOrEmpty("id"); SchemaDefine schema = SchemaDefine.GetSchema(schemaType); var timeConditon = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint, "SN."); WhereSqlClauseBuilder whereBuilder = new WhereSqlClauseBuilder(); EnumItemDescriptionAttribute attr = EnumItemDescriptionAttribute.GetAttribute(idType); whereBuilder.AppendItem("SN." + attr.ShortName, id); string sql = string.Format("SELECT SO.* FROM SC.SchemaObject SO INNER JOIN {0} SN ON SO.ID = SN.ID WHERE {1}", schema.SnapshotTable, new ConnectiveSqlClauseCollection(whereBuilder, timeConditon).ToSqlString(TSqlBuilder.Instance)); DataTable table = DbHelper.RunSqlReturnDS(sql, this.GetConnectionName()).Tables[0]; SchemaObjectBase result = null; if (table.Rows.Count > 0) { result = SchemaExtensions.CreateObject(schemaType); result.FromString((string)table.Rows[0]["Data"]); ORMapping.DataRowToObject(table.Rows[0], result); } return(result); }
/// <summary> /// 反序列化 /// </summary> /// <param name="dictionary"></param> /// <param name="type"></param> /// <param name="serializer"></param> /// <returns></returns> public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer) { DESchemaObjectBase data = SchemaExtensions.CreateObject(DEStandardObjectSchemaType.DynamicEntityField.ToString()); dictionary.ForEach(p => { data.Properties.TrySetValue(p.Key, p.Value); }); return(data); }
protected void RandomGen1(object sender, EventArgs e) { var demoObj = (AU.AUAdminScopeItem)SchemaExtensions.CreateObject("AdminScope001"); demoObj.ID = UuidHelper.NewUuidString(); demoObj.AUScopeItemName = "Demo" + demoObj.ID.ToString(); AU.AUCommon.DoDbAction(() => { PC.Adapters.SchemaObjectAdapter.Instance.Update(demoObj); }); }
public void LoadFromDataView(DataView view) { foreach (DataRowView drv in view) { T obj = (T)SchemaExtensions.CreateObject((string)drv["SchemaType"]); obj.FromString((string)drv["Data"]); ORMapping.DataRowToObject(drv.Row, obj); this.Add(obj); } }
public void CreateObjectWithSortNo() { try { DynamicEntityField entity = SchemaExtensions.CreateObject("DynamicEntityField") as DynamicEntityField; Assert.AreEqual(0, entity.SortNo); } catch (Exception) { throw; } }
public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer) { string schemaType = dictionary.GetValue("schemaType", string.Empty); SchemaObjectBase data = SchemaExtensions.CreateObject(schemaType); data.ID = dictionary.GetValue("id", string.Empty); data.Properties.TrySetValue("Name", dictionary.GetValue("name", string.Empty)); data.Properties.TrySetValue("CodeName", dictionary.GetValue("codeName", string.Empty)); data.Properties.TrySetValue("DisplayName", dictionary.GetValue("displayName", string.Empty)); data.Properties.TrySetValue("Description", dictionary.GetValue("description", string.Empty)); return(data); }
protected override void LoadViewState(object savedState) { base.LoadViewState(savedState); this.Data = SchemaExtensions.CreateObject(Request.Form["currentSchemaType"]); PropertyValueCollection pvc = JSONSerializerExecute.Deserialize <PropertyValueCollection>(Request.Form.GetValue("properties", string.Empty)); this.Data.Properties.FromPropertyValues(pvc); if (this.Data is IPropertyExtendedObject) { ((IPropertyExtendedObject)this.Data).EnsureExtendedProperties(); this.Data.Properties.FromPropertyValues(pvc); } }
//初始化实体 private DynamicEntity InitEntity(string entityId, string categoryId) { DynamicEntity result; if (entityId.IsNotEmpty()) { result = (DynamicEntity)DESchemaObjectAdapter.Instance.Load(entityId); this.HFEntityID.Value = result.ID; this.HFEntityName.Value = result.Name; OperationMode = SCObjectOperationMode.Update; } else { categoryId.CheckStringIsNullOrEmpty("[类别编码]"); result = (DynamicEntity)SchemaExtensions.CreateObject(DEStandardObjectSchemaType.DynamicEntity.ToString()); result.CategoryID = categoryId; OperationMode = SCObjectOperationMode.Add; result.Fields = new DynamicEntityFieldCollection(); //根据不同的类别加载动态实体的默认字段 DECategory category = CategoryAdapter.Instance.GetByID(categoryId); if (category != null) { string defaultProperties = string.Empty; switch (category.FullPath) { case "/集团公司/招商平台/行动": defaultProperties = "ActionDefaultProperties"; break; case "/集团公司/招商平台/阶段": defaultProperties = "PhaseDefaultProperties"; break; } if (defaultProperties.IsNotEmpty()) { PropertyDefineCollection propeties = new PropertyDefineCollection(); propeties.LoadPropertiesFromConfiguration(defaultProperties); result.Fields.CopyFromPropertyDefineCollection(propeties); } } } return(result); }
//初始化实体 private ETLEntity InitETLEntity(string entityId, string categoryId) { ETLEntity result; if (entityId.IsNotEmpty()) { result = (ETLEntity)DESchemaObjectAdapter.Instance.Load(entityId); OperationMode = SCObjectOperationMode.Update; } else { categoryId.CheckStringIsNullOrEmpty("[类别编码]"); result = (ETLEntity)SchemaExtensions.CreateObject(DEStandardObjectSchemaType.ETLEntity.ToString()); result.CategoryID = categoryId; OperationMode = SCObjectOperationMode.Add; result.Fields = new DynamicEntityFieldCollection(); } return(result); }
/// <summary> /// 反序列化 /// </summary> /// <param name="dictionary"></param> /// <param name="type"></param> /// <param name="serializer"></param> /// <returns></returns> public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer) { //校验 string schemaType = dictionary.GetValue("SchemaType", string.Empty); DEStandardObjectSchemaType.DynamicEntity.ToString().Equals(schemaType).FalseThrow("DynamicEntityConvert不能处理该对象"); //反序列化 DynamicEntity data = SchemaExtensions.CreateObject(DEStandardObjectSchemaType.DynamicEntity.ToString()) as DynamicEntity; data.ID = dictionary.GetValue("ID", string.Empty); data.Name = dictionary.GetValue("Name", string.Empty); data.CategoryID = dictionary.GetValue("CategoryID", string.Empty); data.Description = dictionary.GetValue("Description", string.Empty); data.CreateDate = dictionary.GetValue("CreateDate", DateTime.MinValue); data.Tag = dictionary.GetValue("Tag", string.Empty); data.Properties.SetValue("CodeName", dictionary.GetValue("CodeName", string.Empty)); data.Fields = JSONSerializerExecute.Deserialize <DynamicEntityFieldCollection>(dictionary.GetValue("Fields", new ArrayList())) ?? new DynamicEntityFieldCollection(); return(data); }
private void CreateNewObjectBySchemaType(string schemaType) { this.Data = SchemaExtensions.CreateObject(schemaType); if (DESchemaObjectAdapter.Instance.Exist(this.Data.ID, DateTime.Now.SimulateTime())) { Data = DESchemaObjectAdapter.Instance.Load(this.Data.ID); } else { this.Data.Properties.ForEach(p => { if (Request.QueryString[p.Definition.Name].IsNotEmpty()) { p.StringValue = Request.QueryString[p.Definition.Name].Trim(); } }); this.currentSchemaType.Value = schemaType; this.Data.ID = UuidHelper.NewUuidString(); } }
public void CreateSchemaObjectPerformanceTest() { var schemaElem = ObjectSchemaSettings.GetConfig().Schemas[0]; Stopwatch sw = new Stopwatch(); sw.Start(); try { for (int i = 0; i < 100000; i++) { SchemaObjectBase obj = SchemaExtensions.CreateObject(schemaElem.Name); Assert.IsTrue(obj.Properties != null); } } finally { sw.Stop(); Console.WriteLine("经过时间{0:#,##0}毫秒", sw.ElapsedMilliseconds); } }