private static void InitEntity(int itemTyp, DBEntity ent) { DynamicObj dataParam = new DynamicObj(); dataParam.Add("DEFAULTLAYOUT", itemTyp); foreach (var fieldK in ent.Fields) { fieldK.Value.ControlType = GetDefaultControl(fieldK.Value.Type); fieldK.Value.Init(); } ent.Init(dataParam); }
public static void Build() { entities = new Dictionary <int, DBEntity>(); EntityCode.AllEntities = new Dictionary <string, int>(); try { var dbentities = DB.EntityDBService.GetEntities(); var dbentitiesScbhemas = DB.EntityDBService.GetEntitySchemas(); List <string> avlEntitiesName = new List <string>(); foreach (var ent in dbentities) { var name = ent.Get("name", ""); if (avlEntitiesName.Contains(name.ToUpper())) { throw new AppException($"Entity with same name {name} found in system"); } avlEntitiesName.Add(name.ToUpper()); DBEntity dbEntity = BuildEntity(dbentities, dbentitiesScbhemas, ent); int entid = dbEntity.EntityId.Code; entities.Add(entid, dbEntity); } Metadata.FixedEntities.BuildSchema(ref entities, dbentities); var defItemTypes = DB.EntityDBService.GetDefaultItemTypes(); foreach (var entK in entities) { var itemTyp = defItemTypes.Where(x => x.Get("entityid", 0) == entK.Value.EntityId.Code); var defItmType = 0; if (itemTyp.Count() > 0) { defItmType = itemTyp.First().Get("id", 0); } InitEntity(defItmType, entK.Value); } } catch (Exception ex) { throw new EntityException("Error in building entities. " + ex.Message); } }
private static DBEntity GetDBEntity(int masterId, int entid, string name, Dictionary <string, BaseField> fields, EntityType entityType, DbObject entityDbo) { DBEntity e; if (entid == 101) { e = new UserDbEntity(masterId, entid, name, fields, entityType, entityDbo); } else if (entid == 102) { e = new UserRoleEntity(masterId, entid, name, fields, entityType, entityDbo); } else { e = new DBEntity(masterId, entid, name, fields, entityType, entityDbo); } return(e); }