Exemple #1
0
        public void InvokeSendMessageEvent2(Authentication authentication, User user, string message, NotifyMessageType notifyMessageType)
        {
            var eventLog = EventLogBuilder.Build(authentication, this, nameof(InvokeSendMessageEvent), user, message);
            var comment  = EventMessageBuilder.SendMessage(authentication, user, message);

            this.CremaHost.Debug(eventLog);
            this.CremaHost.Info(comment);
            this.OnMessageReceived2(new MessageEventArgs2(authentication, new IUser[] { user, }, message, MessageType.None, notifyMessageType));
        }
Exemple #2
0
        public void InvokeNotifyMessageEvent2(Authentication authentication, User[] users, string message, NotifyMessageType notifyMessageType)
        {
            var target   = users.Any() == false ? "all users" : string.Join(",", users.Select(item => item.ID).ToArray());
            var eventLog = EventLogBuilder.Build(authentication, this, nameof(InvokeNotifyMessageEvent), target, message);
            var comment  = EventMessageBuilder.NotifyMessage(authentication, users, message);

            this.CremaHost.Debug(eventLog);
            this.CremaHost.Info(comment);
            this.OnMessageReceived2(new MessageEventArgs2(authentication, users, message, MessageType.Notification, notifyMessageType));
        }
Exemple #3
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);
            });
        }
Exemple #4
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);
        }
Exemple #5
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 });
            });
        }
Exemple #6
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 });
            });
        }
Exemple #7
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);
            });
        }
Exemple #8
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);
        }
Exemple #9
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);
        }
Exemple #10
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);
        }
Exemple #11
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);
            }
        }