Example #1
0
        public void InvokeCategoriesDeletedEvent(Authentication authentication, TableCategory[] categories, string[] categoryPaths)
        {
            var dataSet  = CremaDataSet.Create(new SignatureDateProvider(authentication.ID));
            var eventLog = EventLogBuilder.BuildMany(authentication, this, nameof(InvokeCategoriesDeletedEvent), categoryPaths);
            var comment  = EventMessageBuilder.DeleteTableCategory(authentication, categories);

            this.CremaHost.Debug(eventLog);
            this.Repository.Commit(authentication, comment, eventLog);
            this.CremaHost.Info(comment);
            this.OnCategoriesDeleted(new ItemsDeletedEventArgs <ITableCategory>(authentication, categories, categoryPaths, dataSet));
            this.Context.InvokeItemsDeletedEvent(authentication, categories, categoryPaths, dataSet);
        }
        public void InvokeCategoriesCreatedEvent(Authentication authentication, TableCategory[] categories)
        {
            var args     = categories.Select(item => (object)null).ToArray();
            var dataSet  = CremaDataSet.Create(new SignatureDateProvider(authentication.ID));
            var eventLog = EventLogBuilder.BuildMany(authentication, this, nameof(InvokeCategoriesCreatedEvent), categories);
            var message  = EventMessageBuilder.CreateTableCategory(authentication, categories);

            this.CremaHost.Debug(eventLog);
            this.CremaHost.Info(message);
            this.OnCategoriesCreated(new ItemsCreatedEventArgs <ITableCategory>(authentication, categories, args));
            this.Context.InvokeItemsCreatedEvent(authentication, categories, args, dataSet);
        }
Example #3
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.OnTablesCreated(new ItemsCreatedEventArgs <ITable>(authentication, tables, args));
            this.Context.InvokeItemsCreatedEvent(authentication, tables, args);
        }
Example #4
0
        public void InvokeTablesContentChangedEvent(Authentication authentication, TableContent content, Table[] tables)
        {
            var eventLog = EventLogBuilder.BuildMany(authentication, this, nameof(InvokeTablesContentChangedEvent), tables);
            var comment  = EventMessageBuilder.ChangeTableContent(authentication, tables);

            this.CremaHost.Debug(eventLog);
            this.CremaHost.Info(comment);
            this.UpdateRevision(tables);
            this.UpdateTableDetailInfo(tables);
            this.OnTablesChanged(new ItemsEventArgs <ITable>(authentication, tables));
            this.Context.InvokeItemsChangedEvent(authentication, tables);
        }
Example #5
0
        public void InvokeTablesMovedEvent(Authentication authentication, Table[] tables, string[] oldPaths, string[] oldCategoryPaths)
        {
            var eventLog = EventLogBuilder.BuildMany(authentication, this, nameof(InvokeTablesMovedEvent), tables, oldPaths, oldCategoryPaths);
            var comment  = EventMessageBuilder.MoveTable(authentication, tables, oldCategoryPaths);

            this.CremaHost.Debug(eventLog);
            this.CremaHost.Info(comment);
            this.UpdateRevision(tables);
            this.UpdateTableDetailInfo(tables);
            this.OnTablesMoved(new ItemsMovedEventArgs <ITable>(authentication, tables, oldPaths, oldCategoryPaths));
            this.Context.InvokeItemsMovedEvent(authentication, tables, oldPaths, oldCategoryPaths);
        }
Example #6
0
        public void InvokeCategoriesCreatedEvent(Authentication authentication, UserCategory[] categories)
        {
            var args     = categories.Select(item => (object)null).ToArray();
            var eventLog = EventLogBuilder.BuildMany(authentication, this, nameof(InvokeCategoriesCreatedEvent), categories);
            var comment  = EventMessageBuilder.CreateUserCategory(authentication, categories);

            this.CremaHost.Debug(eventLog);
            this.Repository.Commit(authentication, comment, eventLog);
            this.CremaHost.Info(comment);
            this.OnCategoriesCreated(new ItemsCreatedEventArgs <IUserCategory>(authentication, categories, args));
            this.Context.InvokeItemsCreatedEvent(authentication, categories, args);
        }
Example #7
0
        public void InvokeTablesTemplateChangedEvent(Authentication authentication, Table[] tables, CremaDataSet dataSet)
        {
            var eventLog = EventLogBuilder.BuildMany(authentication, this, nameof(InvokeTablesTemplateChangedEvent), tables);
            var comment  = EventMessageBuilder.ChangeTableTemplate(authentication, tables);

            this.CremaHost.Debug(eventLog);
            this.Repository.Commit(authentication, comment, eventLog);
            this.CremaHost.Info(comment);
            this.UpdateRevision(authentication, tables, dataSet);
            this.OnTablesChanged(new ItemsEventArgs <ITable>(authentication, tables, dataSet));
            this.Context.InvokeItemsChangedEvent(authentication, tables, dataSet);
        }
Example #8
0
        public void InvokeTypesCreatedEvent(Authentication authentication, Type[] types, CremaDataSet dataSet)
        {
            var args     = types.Select(item => (object)item.TypeInfo).ToArray();
            var eventLog = EventLogBuilder.BuildMany(authentication, this, nameof(InvokeTypesCreatedEvent), types);
            var comment  = EventMessageBuilder.CreateType(authentication, types);

            this.CremaHost.Debug(eventLog);
            this.Repository.Commit(authentication, comment, eventLog);
            this.CremaHost.Info(comment);
            this.UpdateRevision(authentication, types, dataSet);
            this.OnTypesCreated(new ItemsCreatedEventArgs <IType>(authentication, types, args, dataSet));
            this.Context.InvokeItemsCreatedEvent(authentication, types, args, dataSet);
        }
Example #9
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);
            });
        }
Example #10
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);
        }
Example #11
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));
        }
Example #12
0
        public void InvokeTablesRenamedEvent(Authentication authentication, Table[] tables, string[] oldNames, string[] oldPaths, CremaDataSet dataSet)
        {
            var eventLog = EventLogBuilder.BuildMany(authentication, this, nameof(InvokeTablesRenamedEvent), tables, oldNames, oldPaths);
            var comment  = EventMessageBuilder.RenameTable(authentication, tables, oldNames);

            this.CremaHost.Debug(eventLog);
            this.Repository.Commit(authentication, comment, eventLog);
            this.CremaHost.Info(comment);
            this.UpdateRevision(authentication, tables, dataSet);
            this.UpdateTableDetailInfo(authentication, tables, dataSet);
            this.OnTablesRenamed(new ItemsRenamedEventArgs <ITable>(authentication, tables, oldNames, oldPaths, dataSet));
            this.Context.InvokeItemsRenamedEvent(authentication, tables, oldNames, oldPaths, dataSet);
        }
Example #13
0
        public void InvokeDomainDeletedEvent(Authentication authentication, Domain domain, bool isCanceled)
        {
            var args     = new DomainDeletedEventArgs(authentication, domain, isCanceled);
            var eventLog = EventLogBuilder.Build(authentication, this, nameof(InvokeDomainDeletedEvent), domain, isCanceled);
            var comment  = isCanceled == false?EventMessageBuilder.EndDomain(authentication, domain) : EventMessageBuilder.CancelDomain(authentication, domain);

            this.Dispatcher.InvokeAsync(() =>
            {
                this.CremaHost.Debug(eventLog);
                this.CremaHost.Info(comment);
                this.OnDomainDeleted(args);
                this.Context.InvokeItemsDeleteEvent(authentication, new IDomainItem[] { domain }, new string[] { domain.Path });
            });
        }
Example #14
0
        public void InvokeDomainCreatedEvent(Authentication authentication, Domain domain)
        {
            var args       = new DomainEventArgs(authentication, domain);
            var eventLog   = EventLogBuilder.Build(authentication, this, nameof(InvokeDomainCreatedEvent), domain);
            var comment    = EventMessageBuilder.BeginDomain(authentication, domain);
            var domainInfo = domain.DomainInfo;

            this.Dispatcher.InvokeAsync(() =>
            {
                this.CremaHost.Debug(eventLog);
                this.CremaHost.Info(comment);
                this.OnDomainCreated(args);
                this.Context.InvokeItemsCreatedEvent(authentication, new IDomainItem[] { domain }, new object[] { domainInfo });
            });
        }
Example #15
0
        public void InvokeDomainUserRemovedEvent(Authentication authentication, Domain domain, DomainUser domainUser, RemoveInfo removeInfo)
        {
            var args     = new DomainUserRemovedEventArgs(authentication, domain, domainUser, removeInfo);
            var eventLog = EventLogBuilder.Build(authentication, this, nameof(InvokeDomainUserRemovedEvent), domain, domainUser, removeInfo.Reason, removeInfo.Message);
            var comment  = removeInfo.Reason == RemoveReason.Kick
                ? EventMessageBuilder.KickDomainUser(authentication, domain, domainUser)
                : EventMessageBuilder.LeaveDomainUser(authentication, domain);

            this.Dispatcher.InvokeAsync(() =>
            {
                this.CremaHost.Debug(eventLog);
                this.CremaHost.Info(comment);
                this.OnDomainUserRemoved(args);
            });
        }
Example #16
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);
        }
Example #17
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);
        }
Example #18
0
        public void InvokeItemsCreateEvent(Authentication authentication, DataBase[] items, string comment)
        {
            var args           = items.Select(item => (object)item.DataBaseInfo).ToArray();
            var eventLog       = EventLogBuilder.BuildMany(authentication, this, nameof(InvokeItemsCreateEvent), items);
            var commentMessage = EventMessageBuilder.CreateDataBase(authentication, items) + Environment.NewLine + comment;

            this.CremaHost.Debug(eventLog);
            this.cremaHost.RepositoryDispatcher.Invoke(() =>
            {
                this.repository.Commit(this.commitPath, commentMessage, authentication, eventLog);
            });
            foreach (var item in items)
            {
                item.Initialize();
            }
            this.CremaHost.Info(commentMessage);
            this.OnItemsCreated(new ItemsCreatedEventArgs <IDataBase>(authentication, items, args, null));
        }
Example #19
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);
        }
Example #20
0
 private void InsertHeadLog(string msg)
 {
     EventLogBuilder.Insert(0, msg + Environment.NewLine);
     NotifyPropertyChanged(nameof(EventLogBuilder));
 }
Example #21
0
        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);
            }
        }