示例#1
0
        public void InvokeDomainMemberAddedEvent(Authentication authentication, Domain domain, DomainMember domainMember, Guid taskID)
        {
            var args = new DomainMemberAddedEventArgs(authentication, domain, domainMember, null)
            {
                TaskID = taskID
            };
            var eventLog = EventLogBuilder.Build(authentication, this, nameof(InvokeDomainMemberAddedEvent), domain, domainMember);
            var comment  = EventMessageBuilder.EnterDomainMember(authentication, domain);

            this.CremaHost.Debug(eventLog);
            this.CremaHost.Info(comment);
            this.OnDomainMemberAdded(args);
        }
示例#2
0
        public void InvokeDomainUserAddedEvent(Authentication authentication, Domain domain, DomainUser domainUser)
        {
            var args     = new DomainUserEventArgs(authentication, domain, domainUser);
            var eventLog = EventLogBuilder.Build(authentication, this, nameof(InvokeDomainUserAddedEvent), domain, domainUser);
            var comment  = EventMessageBuilder.EnterDomainUser(authentication, domain);

            this.Dispatcher.InvokeAsync(() =>
            {
                this.CremaHost.Debug(eventLog);
                this.CremaHost.Info(comment);
                this.OnDomainUserAdded(args);
            });
        }
示例#3
0
        public void InvokeItemsDeletedEvent(Authentication authentication, IDataBase[] items, string[] paths)
        {
            var eventLog = EventLogBuilder.BuildMany(authentication, this, nameof(InvokeItemsDeletedEvent), paths);
            var comment  = EventMessageBuilder.DeleteDataBase(authentication, paths);

            this.CremaHost.Debug(eventLog);
            this.cremaHost.RepositoryDispatcher.Invoke(() =>
            {
                this.repository.Commit(this.commitPath, comment, authentication, eventLog);
            });
            this.CremaHost.Info(comment);
            this.OnItemsDeleted(new ItemsDeletedEventArgs <IDataBase>(authentication, items, paths));
        }
示例#4
0
        public void InvokeTablesCreatedEvent(Authentication authentication, Table[] tables)
        {
            var args     = tables.Select(item => (object)item.TableInfo).ToArray();
            var eventLog = EventLogBuilder.BuildMany(authentication, this, nameof(InvokeTablesCreatedEvent), tables);
            var comment  = EventMessageBuilder.CreateTable(authentication, tables);

            this.CremaHost.Debug(eventLog);
            this.CremaHost.Info(comment);
            this.UpdateRevision(tables);
            this.UpdateTableDetailInfo(tables);
            this.OnTablesCreated(new ItemsCreatedEventArgs <ITable>(authentication, tables, args));
            this.Context.InvokeItemsCreatedEvent(authentication, tables, args);
        }
示例#5
0
        public void InvokeDomainMemberRemovedEvent(Authentication authentication, Domain domain, DomainMember domainMember, RemoveInfo removeInfo, Guid taskID)
        {
            var args = new DomainMemberRemovedEventArgs(authentication, domain, domainMember, removeInfo)
            {
                TaskID = taskID
            };
            var eventLog = EventLogBuilder.Build(authentication, this, nameof(InvokeDomainMemberRemovedEvent), domain, domainMember, removeInfo.Reason, removeInfo.Message);
            var comment  = removeInfo.Reason == RemoveReason.Kick
                ? EventMessageBuilder.KickDomainMember(authentication, domain, domainMember)
                : EventMessageBuilder.LeaveDomainMember(authentication, domain);

            this.CremaHost.Debug(eventLog);
            this.CremaHost.Info(comment);
            this.OnDomainMemberRemoved(args);
        }
示例#6
0
        public void InvokeDomainCreatedEvent(Authentication authentication, Domain[] domains)
        {
            var domainInfos = domains.Select(item => (object)item.DomainInfo).ToArray();
            var metaDatas   = domains.Select(item => item.GetMetaData(authentication)).ToArray();
            var args        = new DomainsCreatedEventArgs(authentication, domains, metaDatas);

            foreach (var item in domains)
            {
                var eventLog = EventLogBuilder.Build(authentication, this, nameof(InvokeDomainCreatedEvent), item);
                var comment  = EventMessageBuilder.BeginDomain(authentication, item);
                this.CremaHost.Debug(eventLog);
                this.CremaHost.Info(comment);
            }
            this.OnDomainsCreated(args);
            this.Context.InvokeItemsCreatedEvent(authentication, domains, domainInfos);
        }
示例#7
0
        public void InvokeDomainDeletedEvent(Authentication authentication, Domain[] domains, bool[] isCanceleds)
        {
            var itemPaths = domains.Select(item => item.Path).ToArray();
            var args      = new DomainsDeletedEventArgs(authentication, domains, isCanceleds);

            for (var i = 0; i < domains.Length; i++)
            {
                var item       = domains[i];
                var isCanceled = isCanceleds[i];
                var eventLog   = EventLogBuilder.Build(authentication, this, nameof(InvokeDomainDeletedEvent), item, isCanceled);
                var comment    = isCanceled == false?EventMessageBuilder.EndDomain(authentication, item) : EventMessageBuilder.CancelDomain(authentication, item);

                this.CremaHost.Debug(eventLog);
                this.CremaHost.Info(comment);
            }
            this.OnDomainsDeleted(args);
            this.Context.InvokeItemsDeleteEvent(authentication, domains, itemPaths);
        }
示例#8
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;
                }
            }));
        }
示例#9
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;
                }
            }));
        }
示例#10
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;
                }
            }));
        }
示例#12
0
        public Task InvokeUserDeleteAsync(Authentication authentication, UserDeleteArguments args)
        {
            var context    = this.Context;
            var repository = this.Repository;
            var message    = EventMessageBuilder.DeleteUser(authentication, args.UserID);

            return(repository.Dispatcher.InvokeAsync(() =>
            {
                using var locker = new RepositoryHostLock(repository, authentication, this, nameof(InvokeUserDeleteAsync), args.LockPaths);
                try
                {
                    var userSet = args.Read(authentication, repository);
                    var userContextSet = new UserContextSet(context, userSet, false);
                    repository.DeleteUser(userContextSet, args.UserPath);
                    repository.Commit(authentication, message);
                }
                catch
                {
                    repository.Revert();
                    throw;
                }
            }));
        }
示例#13
0
        public Task InvokeCategoryCreateAsync(Authentication authentication, string categoryPath)
        {
            var context    = this.Context;
            var repository = this.Repository;
            var itemPaths  = new string[] { categoryPath };
            var message    = EventMessageBuilder.CreateUserCategory(authentication, categoryPath);

            return(repository.Dispatcher.InvokeAsync(() =>
            {
                using var locker = new RepositoryHostLock(repository, authentication, this, nameof(InvokeCategoryCreateAsync), itemPaths);
                try
                {
                    var userContextSet = UserContextSet.CreateEmpty(authentication, context, itemPaths);
                    repository.CreateUserCategory(categoryPath);
                    repository.Commit(authentication, message);
                }
                catch
                {
                    repository.Revert();
                    throw;
                }
            }));
        }