public Table AddNew(Authentication authentication, TableInfo tableInfo) { this.DataBase.ValidateBeginInDataBase(authentication); this.Container.InvokeChildTableCreate(authentication, this); var tableName = tableInfo.TableName; var childTable = this.Container.AddNew(authentication, tableInfo.Name, tableInfo.CategoryPath); childTable.Initialize(tableInfo); foreach (var item in this.DerivedTables) { var derivedInfo = tableInfo; derivedInfo.Name = CremaDataTable.GenerateName(item.Name, tableName); derivedInfo.CategoryPath = item.Category.Path; derivedInfo.TemplatedParent = childTable.Name; var derivedChild = this.Container.AddNew(authentication, derivedInfo.Name, derivedInfo.CategoryPath); derivedChild.TemplatedParent = childTable; derivedChild.Initialize(derivedInfo); } var items = EnumerableUtility.Friends(childTable, childTable.DerivedTables).ToArray(); this.Container.InvokeTablesCreatedEvent(authentication, items); return(childTable); }
public Table AddNew(Authentication authentication, CremaTemplate template) { try { this.DataBase.ValidateBeginInDataBase(authentication); var dataSet = template.TargetTable.DataSet.Copy(); this.Container.InvokeChildTableCreate(authentication, this, dataSet); var tableName = template.TableName; var childTable = this.Container.AddNew(authentication, CremaDataTable.GenerateName(base.Name, tableName), template.CategoryPath); childTable.Initialize(dataSet.Tables[childTable.Name, childTable.Category.Path].TableInfo); foreach (var item in this.DerivedTables) { var derivedChild = this.Container.AddNew(authentication, CremaDataTable.GenerateName(item.Name, tableName), item.Category.Path); derivedChild.TemplatedParent = childTable; derivedChild.Initialize(dataSet.Tables[derivedChild.Name, derivedChild.Category.Path].TableInfo); } this.Sign(authentication); var items = EnumerableUtility.Friends(childTable, childTable.DerivedTables).ToArray(); this.Container.InvokeTablesCreatedEvent(authentication, items, dataSet); return(childTable); } catch (Exception e) { this.CremaHost.Error(e); throw; } }