public int AddEntitytoDataView(EntityStructure maintab) { DMEEditor.ErrorObject.Flag = Errors.Ok; string tablename = maintab.DatasourceEntityName; try { maintab.Id = NextHearId(); maintab.ViewID = 0; if (maintab.ParentId == -1) { maintab.ParentId = 0; } //--- check entity already exist , if it does change Entity Name if (CheckEntityExist(maintab.DatasourceEntityName)) { int cnt = EntitiesNames.Where(p => p.Equals(maintab.DatasourceEntityName, StringComparison.OrdinalIgnoreCase)).Count() + 1; maintab.EntityName = maintab.DatasourceEntityName + "_" + cnt; } DataView.Entities.Add(maintab); EntitiesNames.Add(maintab.EntityName); IDataSource entityds = DMEEditor.GetDataSource(maintab.DataSourceID); if (entityds != null && entityds.Category == DatasourceCategory.RDBMS) { List <ChildRelation> ds = entityds.GetChildTablesList(maintab.DatasourceEntityName, entityds.Dataconnection.ConnectionProp.SchemaName, null); if (ds != null && ds.Count > 0) { // var tb = ds.Tables[0]; //------------------------------- // Create Parent Record First //------------------------------- if (ds.Count > 0) { foreach (ChildRelation r in ds) { EntityStructure a; a = SetupEntityInView(DataView, DataView.Entities, r.child_table, maintab.DatasourceEntityName, r.child_column, r.parent_column, maintab.Id, entityds.DatasourceName); } } } } return(maintab.Id); } catch (Exception) { return(-1); } }
public int AddEntityAsChild(IDataSource conn, string tablename, string SchemaName, string Filterparamters, int viewindex, int ParentTableIndex) { DMEEditor.ErrorObject.Flag = Errors.Ok; List <ChildRelation> ds = conn.GetChildTablesList(tablename, SchemaName, Filterparamters); EntityStructure maintab = new EntityStructure() { Id = NextHearId(), EntityName = tablename }; maintab.DataSourceID = conn.DatasourceName; maintab.EntityName = tablename; maintab.ViewID = DataView.ViewID; maintab.ParentId = ParentTableIndex; maintab.DatasourceEntityName = tablename; if (CheckEntityExist(maintab.DatasourceEntityName)) { int cnt = EntitiesNames.Where(p => p.Equals(maintab.DatasourceEntityName, StringComparison.OrdinalIgnoreCase)).Count(); maintab.EntityName = maintab.DatasourceEntityName + "_" + cnt + 1; } DataView.Entities.Add(maintab); EntitiesNames.Add(maintab.EntityName); if (ds != null && ds.Count > 0) { //var tb = ds.Tables[0]; //------------------------------- // Create Parent Record First //------------------------------- if (ds.Count > 0) { foreach (ChildRelation r in ds) { EntityStructure a; a = SetupEntityInView(DataView, DataView.Entities, r.child_table, maintab.DatasourceEntityName, r.child_column, r.parent_column, maintab.Id, conn.DatasourceName); } } } return(maintab.Id); }
public int AddEntitytoDataView(IDataSource conn, string tablename, string SchemaName, string Filterparamters) { DMEEditor.ErrorObject.Flag = Errors.Ok; EntityStructure maintab; try { List <ChildRelation> ds = conn.GetChildTablesList(tablename, SchemaName, Filterparamters); maintab = new EntityStructure() { Id = NextHearId(), EntityName = tablename }; maintab.DataSourceID = conn.DatasourceName; maintab.EntityName = tablename.ToUpper(); maintab.ViewID = 0; maintab.ParentId = 0; maintab.DatabaseType = conn.DatasourceType; maintab.DatasourceEntityName = tablename; if (CheckEntityExist(maintab.DatasourceEntityName)) { int cnt = EntitiesNames.Where(p => p.Equals(maintab.DatasourceEntityName, StringComparison.OrdinalIgnoreCase)).Count(); maintab.EntityName = maintab.DatasourceEntityName + "_" + cnt + 1; } switch (maintab.DatabaseType) { case DataSourceType.Oracle: case DataSourceType.SqlServer: case DataSourceType.Mysql: case DataSourceType.SqlCompact: case DataSourceType.Postgre: case DataSourceType.Firebase: case DataSourceType.FireBird: case DataSourceType.Couchbase: case DataSourceType.RavenDB: case DataSourceType.MongoDB: case DataSourceType.CouchDB: case DataSourceType.VistaDB: case DataSourceType.DB2: case DataSourceType.SqlLite: maintab.Viewtype = ViewType.Table; break; case DataSourceType.Text: case DataSourceType.CSV: case DataSourceType.Xls: case DataSourceType.Json: case DataSourceType.xml: maintab.Viewtype = ViewType.File; break; case DataSourceType.WebService: case DataSourceType.OPC: maintab.Viewtype = ViewType.Url; break; default: break; } DataView.Entities.Add(maintab); EntitiesNames.Add(maintab.EntityName); if (ds != null && ds.Count > 0) { // var tb = ds.Tables[0]; //------------------------------- // Create Parent Record First //------------------------------- if (ds.Count > 0) { foreach (ChildRelation r in ds) { EntityStructure a; a = SetupEntityInView(DataView, DataView.Entities, r.child_table, tablename, r.child_column, r.parent_column, maintab.Id, conn.DatasourceName); } } } return(maintab.Id); } catch (Exception) { return(-1); } }