Example #1
0
        public async Task <Table[]> InheritAsync(Authentication authentication, Table table, string newTableName, string categoryPath, bool copyContent)
        {
            try
            {
                this.ValidateExpired();
                var path = await this.Dispatcher.InvokeAsync(() =>
                {
                    this.CremaHost.DebugMethod(authentication, this, nameof(InheritAsync), this, table, newTableName, categoryPath, copyContent);
                    this.ValidateInherit(authentication, table, newTableName, categoryPath, copyContent);
                    return(table.Path);
                });

                var taskID     = GuidUtility.FromName(nameof(InheritAsync) + categoryPath + newTableName + copyContent);
                var itemName   = new ItemName(path);
                var targetName = new ItemName(categoryPath, newTableName);
                var dataSet    = await table.ReadDataForCopyAsync(authentication, categoryPath);

                var dataTable    = dataSet.Tables[itemName.Name, itemName.CategoryPath];
                var dataTables   = dataSet.Tables.ToArray();
                var newDataTable = dataTable.Inherit(targetName, copyContent);
                newDataTable.CategoryPath = categoryPath;
                using var dataBaseSet     = await DataBaseSet.CreateAsync(this.DataBase, dataSet, DataBaseSetOptions.AllowTableCreation);

                var tables = await this.AddNewAsync(authentication, dataBaseSet);

                await this.Dispatcher.InvokeAsync(() => this.DataBase.InvokeTaskCompletedEvent(authentication, taskID));

                return(tables);
            }
            catch (Exception e)
            {
                this.CremaHost.Error(e);
                throw;
            }
        }
Example #2
0
        protected override async Task OnEndEditAsync(Authentication authentication)
        {
            var dataSet     = this.TemplateSource.DataSet;
            var dataTable   = this.TemplateSource.DataTable;
            var taskID      = this.Domain.ID;
            var dataTables  = EnumerableUtility.Friends(dataTable, dataTable.DerivedTables).ToArray();
            var itemPaths   = dataTables.Select(item => item.FullPath).ToArray();
            var dataBaseSet = await DataBaseSet.CreateAsync(this.DataBase, dataSet, DataBaseSetOptions.OmitUnlock | DataBaseSetOptions.AllowTableCreation);

            await this.Repository.LockAsync(authentication, this, nameof(OnEndEditAsync), itemPaths);

            try
            {
                dataBaseSet.TablesToCreate = dataTables;
                this.tables = await this.Container.AddNewAsync(authentication, dataBaseSet);

                this.Domain.Result = dataTables.Select(item => item.TableInfo).ToArray();
                await base.OnEndEditAsync(authentication);

                await this.Dispatcher.InvokeAsync(() => this.DataBase.InvokeTaskCompletedEvent(authentication, taskID));

                this.parent     = null;
                this.permission = null;
            }
            finally
            {
                await this.Repository.UnlockAsync(authentication, this, nameof(OnEndEditAsync), itemPaths);
            }
            await this.Repository.UnlockAsync(authentication, this, nameof(OnCancelEditAsync), this.ItemPaths);
        }
Example #3
0
        protected override async Task OnEndEditAsync(Authentication authentication)
        {
            var template    = this.TemplateSource;
            var dataSet     = template.DataTable.DataSet;
            var dataBaseSet = await DataBaseSet.CreateAsync(this.table.DataBase, dataSet);

            var tableInfo = template.TableInfo;
            var taskID    = this.Domain.ID;

            this.Domain.Result = new TableInfo[] { tableInfo };
            await this.Container.InvokeTableEndTemplateEditAsync(authentication, tableInfo, dataBaseSet);

            await base.OnEndEditAsync(authentication);

            await this.Dispatcher.InvokeAsync(() =>
            {
                this.table.UpdateTemplate(template.TableInfo);
                this.table.UpdateTags(template.Tags);
                this.table.UpdateComment(template.Comment);
                this.table.TableState = TableState.None;
                this.Container.InvokeTablesStateChangedEvent(authentication, this.tables);
                this.Container.InvokeTablesTemplateChangedEvent(authentication, this.tables, dataSet);
                this.DataBase.InvokeTaskCompletedEvent(authentication, taskID);
            });

            await this.Repository.UnlockAsync(authentication, this, nameof(OnEndEditAsync), this.ItemPaths);
        }
Example #4
0
        protected override async Task OnEndEditAsync(Authentication authentication)
        {
            var dataSet     = this.TypeSource.DataSet;
            var dataType    = this.TypeSource;
            var taskID      = this.Domain.ID;
            var dataTypes   = new CremaDataType[] { dataType };
            var itemPaths   = new string[] { dataType.FullPath };
            var dataBaseSet = await DataBaseSet.CreateAsync(this.DataBase, dataSet, DataBaseSetOptions.OmitUnlock | DataBaseSetOptions.AllowTypeCreation);

            await this.Repository.LockAsync(authentication, this, nameof(OnEndEditAsync), itemPaths);

            try
            {
                dataBaseSet.TypesToCreate = dataTypes;
                this.types = await this.Types.AddNewAsync(authentication, dataBaseSet);

                this.type          = this.types.First();
                this.Domain.Result = dataTypes.Select(item => item.TypeInfo).ToArray();
                await base.OnEndEditAsync(authentication);

                await this.Dispatcher.InvokeAsync(() => this.DataBase.InvokeTaskCompletedEvent(authentication, taskID));
            }
            finally
            {
                await this.Repository.UnlockAsync(authentication, this, nameof(OnEndEditAsync), itemPaths);
            }
            await this.Repository.UnlockAsync(authentication, this, nameof(OnCancelEditAsync), this.ItemPaths);
        }
Example #5
0
        public async Task <Type[]> AddNewAsync(Authentication authentication, DataBaseSet dataBaseSet)
        {
            var dataTypes = dataBaseSet.TypesToCreate;

            await this.Dispatcher.InvokeAsync(() =>
            {
                foreach (var item in dataTypes)
                {
                    this.ValidateAddNew(item.Name, item.CategoryPath, authentication);
                }
            });

            var dataSet   = dataBaseSet.DataSet;
            var itemPaths = dataTypes.Select(item => item.FullPath).ToArray();
            var typeList  = new List <Type>(dataTypes.Length);
            var typePaths = dataTypes.Select(item => item.Path).ToArray();

            await this.InvokeTypeCreateAsync(authentication, typePaths, dataBaseSet);

            await this.Dispatcher.InvokeAsync(() =>
            {
                foreach (var item in dataTypes)
                {
                    var type = this.BaseAddNew(item.Name, item.CategoryPath, authentication);
                    type.Initialize(item.TypeInfo);
                    typeList.Add(type);
                }
                this.InvokeTypesCreatedEvent(authentication, typeList.ToArray(), dataSet);
            });

            return(typeList.ToArray());
        }
        public async Task <TypeCategory> AddNewAsync(Authentication authentication, string name, string parentPath)
        {
            try
            {
                if (authentication is null)
                {
                    throw new ArgumentNullException(nameof(authentication));
                }
                if (authentication.IsExpired == true)
                {
                    throw new AuthenticationExpiredException(nameof(authentication));
                }
                if (name is null)
                {
                    throw new ArgumentNullException(nameof(name));
                }
                if (parentPath is null)
                {
                    throw new ArgumentNullException(nameof(parentPath));
                }

                this.ValidateExpired();
                var categoryName = await this.Dispatcher.InvokeAsync(() =>
                {
                    this.CremaHost.DebugMethod(authentication, this, nameof(AddNewAsync), this, name, parentPath);
                    this.ValidateAddNew(authentication, name, parentPath);
                    return(new CategoryName(parentPath, name));
                });

                var taskID    = GuidUtility.FromName(categoryName);
                var fullPaths = new string[] { PathUtility.Separator + CremaSchema.TypeDirectory + categoryName };
                await this.Repository.LockAsync(authentication, this, nameof(AddNewAsync), fullPaths);

                using var dataBaseSet = await DataBaseSet.CreateEmptyAsync(this.DataBase, fullPaths);

                await this.InvokeCategoryCreateAsync(authentication, categoryName);

                var result = await this.Dispatcher.InvokeAsync(() =>
                {
                    this.CremaHost.Sign(authentication);
                    var category = this.BaseAddNew(name, parentPath, authentication);
                    var items    = EnumerableUtility.One(category).ToArray();
                    this.InvokeCategoriesCreatedEvent(authentication, items);
                    return(category);
                });

                await this.Dispatcher.InvokeAsync(() => this.DataBase.InvokeTaskCompletedEvent(authentication, taskID));

                return(result);
            }
            catch (Exception e)
            {
                this.CremaHost.Error(e);
                throw;
            }
        }
Example #7
0
        public async Task <Guid> RenameAsync(Authentication authentication, string name)
        {
            try
            {
                if (authentication is null)
                {
                    throw new ArgumentNullException(nameof(authentication));
                }
                if (authentication.IsExpired == true)
                {
                    throw new AuthenticationExpiredException(nameof(authentication));
                }
                if (name is null)
                {
                    throw new ArgumentNullException(nameof(name));
                }

                this.ValidateExpired();
                var tuple = await this.Dispatcher.InvokeAsync(() =>
                {
                    this.CremaHost.DebugMethod(authentication, this, nameof(RenameAsync), this, name);
                    base.ValidateRename(authentication, name);
                    var items      = new Type[] { this };
                    var oldNames   = items.Select(item => item.Name).ToArray();
                    var oldPaths   = items.Select(item => item.Path).ToArray();
                    var typeInfo   = base.TypeInfo;
                    var targetName = new ItemName(base.Path)
                    {
                        Name = name
                    };
                    return(items, oldNames, oldPaths, typeInfo, targetName);
                });

                var taskID  = Guid.NewGuid();
                var dataSet = await this.ReadDataForPathAsync(authentication, tuple.targetName);

                using var dataBaseSet = await DataBaseSet.CreateAsync(this.DataBase, dataSet);

                await this.Container.InvokeTypeRenameAsync(authentication, tuple.typeInfo, name, dataBaseSet);

                await this.Dispatcher.InvokeAsync(() =>
                {
                    this.CremaHost.Sign(authentication);
                    base.Rename(authentication, name);
                    this.Container.InvokeTypesRenamedEvent(authentication, tuple.items, tuple.oldNames, tuple.oldPaths, dataSet);
                    this.DataBase.InvokeTaskCompletedEvent(authentication, taskID);
                });

                return(taskID);
            }
            catch (Exception e)
            {
                this.CremaHost.Error(e);
                throw;
            }
        }
Example #8
0
        public async Task <Guid> MoveAsync(Authentication authentication, string categoryPath)
        {
            try
            {
                if (authentication is null)
                {
                    throw new ArgumentNullException(nameof(authentication));
                }
                if (authentication.IsExpired == true)
                {
                    throw new AuthenticationExpiredException(nameof(authentication));
                }
                if (categoryPath is null)
                {
                    throw new ArgumentNullException(nameof(categoryPath));
                }

                this.ValidateExpired();
                var tuple = await this.Dispatcher.InvokeAsync(() =>
                {
                    this.CremaHost.DebugMethod(authentication, this, nameof(Move), this, categoryPath);
                    base.ValidateMove(authentication, categoryPath);
                    var items            = EnumerableUtility.One(this).ToArray();
                    var oldPaths         = items.Select(item => item.Path).ToArray();
                    var oldCategoryPaths = items.Select(item => item.Category.Path).ToArray();
                    var typeInfo         = base.TypeInfo;
                    var targetName       = new ItemName(categoryPath, base.Name);
                    return(items, oldPaths, oldCategoryPaths, typeInfo, targetName);
                });

                var taskID  = Guid.NewGuid();
                var dataSet = await this.ReadDataForPathAsync(authentication, tuple.targetName);

                using var dataBaseSet = await DataBaseSet.CreateAsync(this.DataBase, dataSet);

                await this.Container.InvokeTypeMoveAsync(authentication, tuple.typeInfo, categoryPath, dataBaseSet);

                await this.Dispatcher.InvokeAsync(() =>
                {
                    this.CremaHost.Sign(authentication);
                    base.Move(authentication, categoryPath);
                    this.Container.InvokeTypesMovedEvent(authentication, tuple.items, tuple.oldPaths, tuple.oldCategoryPaths, dataSet);
                    this.DataBase.InvokeTaskCompletedEvent(authentication, taskID);
                });

                return(taskID);
            }
            catch (Exception e)
            {
                this.CremaHost.Error(e);
                throw;
            }
        }
Example #9
0
        public async Task <Type> CopyAsync(Authentication authentication, string typeName, string newTypeName, string categoryPath)
        {
            try
            {
                this.ValidateExpired();
                var tuple = await this.Dispatcher.InvokeAsync(() =>
                {
                    this.CremaHost.DebugMethod(authentication, this, nameof(CopyAsync), typeName, newTypeName, categoryPath);
                    this.ValidateCopy(authentication, typeName, newTypeName);
                    return(this[typeName], this[typeName].Path);
                });

                var type       = tuple.Item1;
                var path       = tuple.Path;
                var taskID     = GuidUtility.FromName(categoryPath + newTypeName);
                var itemName   = new ItemName(tuple.Path);
                var targetName = new ItemName(categoryPath, newTypeName);
                var dataSet    = await type.ReadDataForCopyAsync(authentication, categoryPath);

                var dataType    = dataSet.Types[itemName.Name, itemName.CategoryPath];
                var newDataType = dataType.Copy(targetName);
                using var dataBaseSet = await DataBaseSet.CreateAsync(this.DataBase, dataSet, DataBaseSetOptions.AllowTypeCreation);

                var typePaths = new string[] { categoryPath + newTypeName };
                await this.InvokeTypeCreateAsync(authentication, typePaths, dataBaseSet);

                var result = await this.Dispatcher.InvokeAsync(() =>
                {
                    this.CremaHost.Sign(authentication);
                    var newType = this.BaseAddNew(newTypeName, categoryPath, authentication);
                    newType.Initialize(newDataType.TypeInfo);
                    this.InvokeTypesCreatedEvent(authentication, new Type[] { newType }, dataSet);
                    this.DataBase.InvokeTaskCompletedEvent(authentication, taskID);
                    return(newType);
                });

                return(result);
            }
            catch (Exception e)
            {
                this.CremaHost.Error(e);
                throw;
            }
        }
Example #10
0
 void IDomainHost.Attach(Domain domain)
 {
     this.dataSet     = domain.Source as CremaDataSet;
     this.domain      = domain;
     this.domain.Host = this;
     this.dataBaseSet = DataBaseSet.Create(this.DataBase, dataSet, DataBaseSetOptions.None);
     this.itemPaths   = this.dataSet.GetItemPaths();
     this.Repository.Dispatcher.Invoke(() => this.Repository.Lock(Authentication.System, this, nameof(IDomainHost.Attach), this.itemPaths));
     foreach (var item in this.Contents)
     {
         item.domainHost       = this;
         item.Domain           = domain;
         item.DataTable        = dataSet.Tables[item.Table.Name, item.Table.Category.Path];
         item.Table.TableState = TableState.IsBeingEdited;
         item.ServiceState     = ServiceState.Open;
         item.IsModified       = domain.ModifiedTables.Contains(item.dataTable.Name);
     }
     this.domain.Dispatcher.Invoke(this.AttachDomainEvent);
 }
Example #11
0
            public async Task BeginContentAsync(Authentication authentication)
            {
                try
                {
                    this.dataSet = await this.Container.ReadDataForContentAsync(authentication, this.Tables);

                    this.domain      = new TableContentDomain(authentication, dataSet, this.DataBase, this.path, typeof(TableContent).Name, this);
                    this.dataBaseSet = await DataBaseSet.CreateAsync(this.DataBase, dataSet);

                    this.itemPaths = this.dataSet.GetItemPaths();
                    await this.DomainContext.AddAsync(authentication, this.domain, this.DataBase);
                }
                catch
                {
                    if (this.dataBaseSet != null)
                    {
                        await this.Repository.UnlockAsync(authentication, this, nameof(BeginContentAsync), this.dataBaseSet.ItemPaths);
                    }
                    this.dataSet     = null;
                    this.domain      = null;
                    this.dataBaseSet = null;
                    throw;
                }
                await this.Dispatcher.InvokeAsync(() =>
                {
                    foreach (var item in this.Contents)
                    {
                        item.Domain           = this.domain;
                        item.domainHost       = this;
                        item.DataTable        = dataSet.Tables[item.Table.Name, item.Table.Category.Path];
                        item.Table.TableState = TableState.IsBeingEdited;
                        item.IsModified       = domain.ModifiedTables.Contains(item.dataTable.Name);
                    }
                });

                await this.domain.Dispatcher.InvokeAsync(this.AttachDomainEvent);

                await this.Dispatcher.InvokeAsync(() =>
                {
                    this.Container.InvokeTablesStateChangedEvent(authentication, this.Tables);
                });
            }
Example #12
0
        public async Task <Table[]> AddNewAsync(Authentication authentication, DataBaseSet dataBaseSet)
        {
            var dataTables = dataBaseSet.TablesToCreate;

            await this.Dispatcher.InvokeAsync(() =>
            {
                foreach (var item in dataTables)
                {
                    this.ValidateAddNew(item.Name, item.CategoryPath, authentication);
                }
            });

            var dataSet    = dataBaseSet.DataSet;
            var itemPaths  = dataTables.Select(item => item.FullPath).ToArray();
            var tableList  = new List <Table>(dataTables.Length);
            var tablePaths = dataTables.Select(item => item.Path).ToArray();

            await this.InvokeTableCreateAsync(authentication, tablePaths, dataBaseSet);

            await this.Dispatcher.InvokeAsync(() =>
            {
                foreach (var item in dataTables)
                {
                    var table = this.AddNew(authentication, item.Name, item.CategoryPath);
                    if (item.TemplatedParentName != string.Empty)
                    {
                        table.TemplatedParent = this[item.TemplatedParentName];
                    }
                    table.Initialize(item.TableInfo);
                    tableList.Add(table);
                }
                this.InvokeTablesCreatedEvent(authentication, tableList.ToArray(), dataSet);
            });

            return(tableList.ToArray());
        }
Example #13
0
        public Task InvokeTypeEndTemplateEditAsync(Authentication authentication, string typeName, DataBaseSet dataBaseSet)
        {
            var message = EventMessageBuilder.ChangeTypeTemplate(authentication, typeName);

            return(this.Repository.Dispatcher.InvokeAsync(() =>
            {
                try
                {
                    this.Repository.ModifyType(dataBaseSet);
                    this.Repository.Commit(authentication, message);
                }
                catch
                {
                    this.Repository.Revert();
                    throw;
                }
            }));
        }
Example #14
0
        public Task InvokeTypeDeleteAsync(Authentication authentication, TypeInfo typeInfo, DataBaseSet dataBaseSet)
        {
            var message = EventMessageBuilder.DeleteType(authentication, typeInfo.Name);

            return(this.Repository.Dispatcher.InvokeAsync(() =>
            {
                try
                {
                    this.Repository.DeleteType(dataBaseSet, typeInfo.Path);
                    this.Repository.Commit(authentication, message);
                }
                catch
                {
                    this.Repository.Revert();
                    throw;
                }
            }));
        }
Example #15
0
        public Task InvokeTypeCreateAsync(Authentication authentication, string[] typePaths, DataBaseSet dataBaseSet)
        {
            var message = EventMessageBuilder.CreateType(authentication, typePaths);

            return(this.Repository.Dispatcher.InvokeAsync(() =>
            {
                try
                {
                    this.Repository.CreateType(dataBaseSet, typePaths);
                    this.Repository.Commit(authentication, message);
                }
                catch
                {
                    this.Repository.Revert();
                    throw;
                }
            }));
        }
        public Task InvokeCategoryDeleteAsync(Authentication authentication, string categoryPath, DataBaseSet dataBaseSet)
        {
            var message = EventMessageBuilder.DeleteTableCategory(authentication, categoryPath);

            return(this.Repository.Dispatcher.InvokeAsync(() =>
            {
                try
                {
                    this.Repository.DeleteTypeCategory(dataBaseSet, categoryPath);
                    this.Repository.Commit(authentication, message);
                }
                catch
                {
                    this.Repository.Revert();
                    throw;
                }
            }));
        }
        public Task InvokeCategoryMoveAsync(Authentication authentication, string categoryPath, string parentPath, DataBaseSet dataBaseSet)
        {
            var categoryName    = new CategoryName(categoryPath);
            var newCategoryPath = new CategoryName(parentPath, categoryName.Name);
            var message         = EventMessageBuilder.MoveTypeCategory(authentication, categoryPath, categoryName.ParentPath, parentPath);

            return(this.Repository.Dispatcher.InvokeAsync(() =>
            {
                try
                {
                    this.Repository.MoveTypeCategory(dataBaseSet, categoryPath, newCategoryPath);
                    this.Repository.Commit(authentication, message);
                }
                catch
                {
                    this.Repository.Revert();
                    throw;
                }
            }));
        }
Example #18
0
        public Task InvokeTableEndContentEditAsync(Authentication authentication, Table[] tables, DataBaseSet dataBaseSet)
        {
            var message = EventMessageBuilder.ChangeTableContent(authentication, tables);

            return(this.Repository.Dispatcher.InvokeAsync(() =>
            {
                try
                {
                    this.Repository.ModifyTable(dataBaseSet);
                    this.Repository.Commit(authentication, message);
                }
                catch
                {
                    this.Repository.Revert();
                    throw;
                }
            }));
        }
Example #19
0
        public Task InvokeTableMoveAsync(Authentication authentication, TableInfo tableInfo, string newCategoryPath, DataBaseSet dataBaseSet)
        {
            var message = EventMessageBuilder.MoveTable(authentication, tableInfo.Name, newCategoryPath, tableInfo.CategoryPath);

            return(this.Repository.Dispatcher.InvokeAsync(() =>
            {
                try
                {
                    this.Repository.MoveTable(dataBaseSet, tableInfo.Path, newCategoryPath);
                    this.Repository.Commit(authentication, message);
                }
                catch
                {
                    this.Repository.Revert();
                    throw;
                }
            }));
        }
Example #20
0
        public Task InvokeTableRenameAsync(Authentication authentication, TableInfo tableInfo, string newName, DataBaseSet dataBaseSet)
        {
            var name    = tableInfo.ParentName == string.Empty ? newName : tableInfo.ParentName + "." + newName;
            var message = EventMessageBuilder.RenameTable(authentication, tableInfo.Name, name);

            return(this.Repository.Dispatcher.InvokeAsync(() =>
            {
                try
                {
                    this.Repository.RenameTable(dataBaseSet, tableInfo.Path, name);
                    this.Repository.Commit(authentication, message);
                }
                catch
                {
                    this.Repository.Revert();
                    throw;
                }
            }));
        }
        public Task InvokeCategoryRenameAsync(Authentication authentication, string categoryPath, string name, DataBaseSet dataBaseSet)
        {
            var newCategoryPath = new CategoryName(categoryPath)
            {
                Name = name
            };
            var message = EventMessageBuilder.RenameTableCategory(authentication, categoryPath, newCategoryPath);

            return(this.Repository.Dispatcher.InvokeAsync(() =>
            {
                try
                {
                    this.Repository.RenameTableCategory(dataBaseSet, categoryPath, newCategoryPath);
                    this.Repository.Commit(authentication, message);
                }
                catch
                {
                    this.Repository.Revert();
                    throw;
                }
            }));
        }
Example #22
0
        public async Task <Guid> ImportAsync(Authentication authentication, CremaDataSet dataSet, string comment)
        {
            try
            {
                if (authentication is null)
                {
                    throw new ArgumentNullException(nameof(authentication));
                }
                if (authentication.IsExpired == true)
                {
                    throw new AuthenticationExpiredException(nameof(authentication));
                }
                if (dataSet is null)
                {
                    throw new ArgumentNullException(nameof(dataSet));
                }
                if (comment is null)
                {
                    throw new ArgumentNullException(nameof(comment));
                }

                await this.Dispatcher.InvokeAsync(() =>
                {
                    this.CremaHost.DebugMethod(authentication, this, nameof(ImportAsync), comment);
                    this.ValidateImport(authentication, dataSet, comment);
                    this.CremaHost.Sign(authentication);
                });

                var taskID = Guid.NewGuid();
                var filter = new CremaDataSetFilter()
                {
                    Tables      = dataSet.Tables.Select(item => item.Name).ToArray(),
                    OmitContent = true
                };
                var targetSet = await this.GetDataSetAsync(authentication, filter, string.Empty);

                await this.Dispatcher.InvokeAsync(() =>
                {
                    this.LockTypes(authentication, targetSet, comment);
                    this.LockTables(authentication, targetSet, comment);
                });

                try
                {
                    targetSet.SignatureDateProvider = new SignatureDateProvider(authentication.ID);
                    foreach (var item in targetSet.Tables)
                    {
                        var dataTable = dataSet.Tables[item.Name];
                        foreach (var row in dataTable.Rows)
                        {
                            item.ImportRow(row);
                        }
                        item.BeginLoad();
                        foreach (var row in item.Rows)
                        {
                            row.CreationInfo     = authentication.SignatureDate;
                            row.ModificationInfo = authentication.SignatureDate;
                        }
                        item.ContentsInfo = authentication.SignatureDate;
                        item.EndLoad();
                    }
                    var dataBaseSet = await DataBaseSet.CreateAsync(this, targetSet);

                    await this.Repository.Dispatcher.InvokeAsync(() =>
                    {
                        try
                        {
                            this.Repository.Modify(dataBaseSet);
                            this.Repository.Commit(authentication, comment);
                        }
                        catch
                        {
                            this.Repository.Revert();
                            throw;
                        }
                    });

                    await this.Dispatcher.InvokeAsync(() =>
                    {
                        this.UpdateTables(authentication, targetSet);
                    });

                    return(taskID);
                }
                finally
                {
                    await this.Dispatcher.InvokeAsync(() =>
                    {
                        this.UnlockTypes(authentication, targetSet);
                        this.UnlockTables(authentication, targetSet);
                    });
                }
            }
            catch (Exception e)
            {
                this.CremaHost.Error(e);
                throw;
            }
        }