public void InvokeTypeDelete(Authentication authentication, Type type, CremaDataSet dataSet) { this.CremaHost.DebugMethod(authentication, this, nameof(InvokeTypeDelete), type); var dataTypes = new DataTypeCollection(dataSet, this.DataBase); var dataTables = new DataTableCollection(dataSet, this.DataBase); var dataType = dataSet.Types[type.Name, type.Category.Path]; var query = from table in dataSet.Tables from column in table.Columns where column.CremaType == dataType select column; var columns = query.ToArray(); foreach (var item in columns) { item.CremaType = null; } dataSet.Types.Remove(dataType); try { this.Repository.Delete(type.SchemaPath); dataTables.Modify(this.Repository); this.Context.InvokeTypeItemDelete(authentication, type); } catch (Exception e) { this.CremaHost.Error(e); this.Repository.Revert(); throw e; } }
public void InvokeChildTableCreate(Authentication authentication, Table table, CremaDataSet dataSet) { this.CremaHost.DebugMethod(authentication, this, nameof(InvokeChildTableCreate), table); var dataTables = new DataTableCollection(dataSet, this.DataBase); try { dataTables.Modify(this.Repository); } catch (Exception e) { this.CremaHost.Error(e); this.Repository.Revert(); throw e; } }
public void InvokeCategoryDelete(Authentication authentication, TypeCategory category, CremaDataSet dataSet) { this.CremaHost.DebugMethod(authentication, this, nameof(InvokeCategoryDelete), category); var dataTypes = new DataTypeCollection(dataSet, this.DataBase); var dataTables = new DataTableCollection(dataSet, this.DataBase); var query = from table in dataSet.Tables from column in table.Columns where column.CremaType != null let dataType = column.CremaType where dataType.CategoryPath.StartsWith(category.Path) select column; var columns = query.ToArray(); foreach (var item in columns) { item.CremaType = null; } foreach (var item in dataTypes) { var dataType = item.Key; var type = item.Value; if (type.Path.StartsWith(category.Path) == false) { continue; } dataSet.Types.Remove(dataType); } try { dataTables.Modify(this.Repository); this.Repository.Delete(category.LocalPath); this.Context.InvokeTypeItemDelete(authentication, category); } catch (Exception e) { this.CremaHost.Error(e); this.Repository.Revert(); throw e; } }
public void InvokeEndContentEdit(Authentication authentication, Table table, CremaDataSet dataSet) { this.CremaHost.DebugMethod(authentication, this, nameof(InvokeEndContentEdit), table); var dataTables = new DataTableCollection(dataSet, this.DataBase); try { dataTables.Modify(this.Repository); this.Context.InvokeTableItemChange(authentication, table); } catch (Exception e) { this.CremaHost.Error(e); this.Repository.Revert(); throw e; } }
public void InvokeTypeEndTemplateEdit(Authentication authentication, Type type, CremaDataType dataType) { this.CremaHost.DebugMethod(authentication, this, nameof(InvokeTypeEndTemplateEdit), type); var dataTypes = new DataTypeCollection(dataType.DataSet, this.DataBase); var dataTables = new DataTableCollection(dataType.DataSet, this.DataBase); try { dataTypes.Modify(this.Repository, item => item == type); dataTables.Modify(this.Repository); this.Context.InvokeTypeItemChange(authentication, type); } catch (Exception e) { this.CremaHost.Error(e); this.Repository.Revert(); throw e; } }
public void InvokeTableSetComment(Authentication authentication, Table table, string comment, CremaDataSet dataSet) { this.CremaHost.DebugMethod(authentication, this, nameof(InvokeTableSetComment), table, comment); var dataTables = new DataTableCollection(dataSet, this.DataBase); var dataTable = dataSet.Tables[table.Name, table.Category.Path]; dataTable.Comment = comment; try { dataTables.Modify(this.Repository); dataTables.Move(this.Repository); this.Context.InvokeTableItemChange(authentication, table); } catch (Exception e) { this.CremaHost.Error(e); this.Repository.Revert(); throw e; } }
public void InvokeTypeRename(Authentication authentication, Type type, string newName, CremaDataSet dataSet) { this.CremaHost.DebugMethod(authentication, this, nameof(InvokeTypeRename), type, newName); var dataTypes = new DataTypeCollection(dataSet, this.DataBase); var dataTables = new DataTableCollection(dataSet, this.DataBase); var dataType = dataSet.Types[type.Name, type.Category.Path]; dataType.TypeName = newName; try { dataTypes.Modify(this.Repository, item => item == type); dataTables.Modify(this.Repository); this.Context.InvokeTypeItemRename(authentication, type, newName); } catch (Exception e) { this.CremaHost.Error(e); this.Repository.Revert(); throw e; } }
public void InvokeTableEndTemplateEdit(Authentication authentication, Table table, CremaTemplate template) { this.CremaHost.DebugMethod(authentication, this, nameof(InvokeTableEndTemplateEdit), table); if (table.TemplatedParent != null) { throw new CremaException("템플릿을 사용하는 테이블을 직접 변경할 수 없습니다."); } var dataTable = template.TargetTable; var dataSet = dataTable.DataSet; var dataTables = new DataTableCollection(dataSet, this.DataBase); try { dataTables.Modify(this.Repository); this.Context.InvokeTableItemChange(authentication, table); } catch (Exception e) { this.CremaHost.Error(e); this.Repository.Revert(); throw e; } }
public void InvokeTableEndTemplateEdit(Authentication authentication, Table table, CremaTemplate template) { this.CremaHost.DebugMethod(authentication, this, nameof(InvokeTableEndTemplateEdit), table); if (table.TemplatedParent != null) { throw new InvalidOperationException(Resources.Exception_InheritedTableTemplateCannotEdit); } var dataTable = template.TargetTable; var dataSet = dataTable.DataSet; var dataTables = new DataTableCollection(dataSet, this.DataBase); try { dataTables.Modify(this.Repository); this.Context.InvokeTableItemChange(authentication, table); } catch (Exception e) { this.CremaHost.Error(e); this.Repository.Revert(); throw e; } }
public void Import(Authentication authentication, CremaDataSet dataSet, string comment) { this.Dispatcher?.VerifyAccess(); this.CremaHost.DebugMethod(authentication, this, nameof(Import), comment); this.ValidateImport(authentication, dataSet, comment); var query = from item in dataSet.Tables let table = this.Tables[item.Name] where table.LockInfo.Path != table.Path select table; var items = query.ToArray(); var comments = Enumerable.Repeat(comment, items.Length).ToArray(); foreach (var item in items) { item.LockInternal(Authentication.System, comment); } this.InvokeItemsLockedEvent(authentication, items, comments); try { var targetSet = new CremaDataSet(); foreach (var item in items.Where(i => i.Parent == null)) { var targetTable = item.ReadSchema(authentication, targetSet); var dataTable = dataSet.Tables[targetTable.TableName]; if (dataTable == null) { continue; } foreach (var row in dataTable.Rows) { targetTable.ImportRow(row); } targetTable.ContentsInfo = dataTable.ContentsInfo; } var dataTables = new DataTableCollection(targetSet, this.DataBase); try { dataTables.Modify(this.Repository); } catch { } foreach (var item in items) { var dataTable = targetSet.Tables[item.Name, item.Category.Path]; item.UpdateContent(dataTable.TableInfo); } var eventLog = EventLogBuilder.Build(authentication, this, nameof(Import), comment); this.Repository.Commit(authentication, comment, eventLog); this.OnItemsChanged(new ItemsEventArgs <ITableItem>(Authentication.System, items, targetSet)); } finally { foreach (var item in items) { item.UnlockInternal(Authentication.System); } this.InvokeItemsUnlockedEvent(authentication, items); } }