Example #1
0
        public async Task <Domain> CreateAsync(Authentication authentication, DomainMetaData metaData)
        {
            return(await this.Dispatcher.InvokeAsync(() =>
            {
                var domain = this[metaData.DomainID];
                if (domain == null)
                {
                    if (metaData.DomainInfo.DomainType == typeof(TableContentDomain).Name)
                    {
                        domain = new TableContentDomain(metaData.DomainInfo);
                    }
                    else if (metaData.DomainInfo.DomainType == typeof(TableTemplateDomain).Name)
                    {
                        domain = new TableTemplateDomain(metaData.DomainInfo);
                    }
                    else if (metaData.DomainInfo.DomainType == typeof(TypeDomain).Name)
                    {
                        domain = new TypeDomain(metaData.DomainInfo);
                    }

                    this.Add(domain);
                    domain.Category = this.Context.Categories.Prepare(metaData.DomainInfo.CategoryPath);
                    this.InvokeDomainCreatedEvent(authentication, new Domain[] { domain });
                    domain.Initialize(authentication, metaData);
                }
                else
                {
                    domain.Initialize(authentication, metaData);
                }

                return domain;
            }));
        }
Example #2
0
        public DomainMetaData GetMetaData(Authentication authentication)
        {
            try
            {
                this.dispatcher.VerifyAccess();

                var metaData = new DomainMetaData()
                {
                    DomainID    = Guid.Parse(this.Name),
                    DomainInfo  = base.DomainInfo,
                    Users       = this.users.Select <DomainUser, DomainUserMetaData>(item => item.GetMetaData(authentication)).ToArray(),
                    DomainState = base.DomainState,
                };

                if (this.users.Contains(authentication.ID) == true)
                {
                    if (this.data == null)
                    {
                        this.data = this.SerializeSource();
                    }
                    metaData.Data = this.data;
                }

                return(metaData);
            }
            catch (Exception e)
            {
                this.CremaHost.Error(e);
                throw;
            }
        }
Example #3
0
        public Domain Create(Authentication authentication, DomainMetaData metaData)
        {
            var domain = this[metaData.DomainID];

            if (domain == null)
            {
                if (metaData.DomainInfo.DomainType == typeof(TableContentDomain).Name)
                {
                    domain = new TableContentDomain(metaData.DomainInfo, this.Context.CremaHost.Dispatcher);
                }
                else if (metaData.DomainInfo.DomainType == typeof(TableTemplateDomain).Name)
                {
                    domain = new TableTemplateDomain(metaData.DomainInfo, this.Context.CremaHost.Dispatcher);
                }
                else if (metaData.DomainInfo.DomainType == typeof(TypeDomain).Name)
                {
                    domain = new TypeDomain(metaData.DomainInfo, this.Context.CremaHost.Dispatcher);
                }

                this.Add(domain);
                domain.Category = this.Context.Categories.Prepare(metaData.DomainInfo.CategoryPath);
                domain.Initialize(authentication, metaData);
                this.InvokeDomainCreatedEvent(authentication, domain);
            }
            else
            {
                domain.Initialize(authentication, metaData);
            }

            return(domain);
        }
Example #4
0
 protected override void OnBeginEdit(Authentication authentication, DomainMetaData metaData)
 {
     this.Container.InvokeTypeBeginTemplateEdit(authentication, this.type);
     base.OnBeginEdit(authentication, metaData);
     this.type.IsBeingEdited = true;
     this.Container.InvokeTypesStateChangedEvent(authentication, new Type[] { this.type, });
 }
Example #5
0
        protected override void OnInitialize(DomainMetaData metaData)
        {
            base.OnInitialize(metaData);

            var xml = Encoding.UTF8.GetString(metaData.Data).Decompress();

            this.template = XmlSerializerUtility.ReadString <CremaTemplate>(xml);
            this.view     = this.template.View;
        }
Example #6
0
        protected override void OnInitialize(DomainMetaData metaData)
        {
            base.OnInitialize(metaData);

            var text     = Encoding.UTF8.GetString(metaData.Data).Decompress();
            var index    = text.IndexOf(";");
            var path     = text.Remove(index);
            var itemName = new ItemName(path);
            var xml      = text.Substring(index + 1);
            var dataSet  = XmlSerializerUtility.ReadString <CremaDataSet>(xml);

            this.dataType = dataSet.Types[itemName.Name];
            this.view     = this.dataType.AsDataView();
        }
Example #7
0
        protected virtual void OnBeginEdit(Authentication authentication, DomainMetaData metaData)
        {
            this.domain       = this.DomainContext.Create(authentication, metaData) as TypeDomain;
            this.domain.IsNew = this.IsNew;
            this.domain.Host  = this;
            this.AttachDomainEvent();

            this.dataType = this.domain.Source as CremaDataType;
            this.table    = this.dataType.View.Table;
            for (var i = 0; i < this.table.Rows.Count; i++)
            {
                var item = this.table.Rows[i];
                this.members.Add(new TypeMember(this, item));
            }
            this.table.RowDeleted += Table_RowDeleted;
            this.table.RowChanged += Table_RowChanged;
        }
Example #8
0
        protected virtual void OnBeginEdit(Authentication authentication, DomainMetaData metaData)
        {
            this.domain       = this.DomainContext.Create(authentication, metaData) as TableTemplateDomain;
            this.domain.IsNew = this.IsNew;
            this.domain.Host  = this;
            this.AttachDomainEvent();

            this.templateSource = this.domain.TemplateSource;
            this.table          = this.templateSource.View.Table;
            for (var i = 0; i < this.table.Rows.Count; i++)
            {
                var item = this.table.Rows[i];
                this.columns.Add(new TableColumn(this, item));
            }
            this.table.RowDeleted += Table_RowDeleted;
            this.table.RowChanged += Table_RowChanged;
        }
Example #9
0
        protected override void OnInitialize(DomainMetaData metaData)
        {
            base.OnInitialize(metaData);

            var xml = Encoding.UTF8.GetString(metaData.Data).Decompress();

            this.dataSet = XmlSerializerUtility.ReadString <CremaDataSet>(xml);
            this.dataSet.AcceptChanges();
            this.views.Clear();
            foreach (var item in this.dataSet.Tables)
            {
                var view = item.AsDataView();
                //view.AllowDelete = false;
                //view.AllowEdit = false;
                //view.AllowNew = false;
                this.views.Add(item.TableName, view);
                this.tables.Add(view, item);
            }
        }
Example #10
0
        public DomainMetaData GetMetaData(Authentication authentication)
        {
            this.dispatcher.VerifyAccess();

            var metaData = new DomainMetaData()
            {
                DomainID = Guid.Parse(this.Name),
                DomainInfo = base.DomainInfo,

                Users = this.users.Select<DomainUser, DomainUserMetaData>(item => item.GetMetaData(authentication)).ToArray(),
                DomainState = this.DomainState,
            };

            if (this.users.Contains(authentication.ID) == true)
            {
                metaData.Data = this.SerializeSource();
            }

            return metaData;
        }
Example #11
0
 public void Initialize(Authentication authentication, DomainMetaData metaData)
 {
     base.DomainState = metaData.DomainState;
     if (metaData.Data == null)
     {
         foreach (var item in metaData.Users)
         {
             this.InvokeUserAdded(authentication, item.DomainUserInfo, item.DomainUserState);
         }
     }
     else
     {
         this.OnInitialize(metaData);
         this.initialized = true;
         foreach (var item in metaData.Users)
         {
             if (this.users.Contains(item.DomainUserInfo.UserID) == false)
                 this.InvokeUserAdded(authentication, item.DomainUserInfo, item.DomainUserState);
         }
     }
 }
Example #12
0
        public void Release(Authentication authentication, DomainMetaData metaData)
        {
            this.OnRelease();
            this.initialized = false;

            foreach (var item in this.users.ToArray<DomainUser>())
            {
                if (metaData.Users.Any(i => i.DomainUserInfo.UserID == item.DomainUserInfo.UserID) == false)
                {
                    this.InvokeUserRemoved(authentication, item.DomainUserInfo, RemoveInfo.Empty);
                }
            }

            foreach (var item in metaData.Users)
            {
                if (item.DomainUserState.HasFlag(DomainUserState.IsOwner) == true)
                {
                    var master = this.users[item.DomainUserInfo.UserID];
                    this.users.Owner = master;
                    this.InvokeUserChanged(authentication, item.DomainUserInfo, item.DomainUserState);
                }
            }
        }
Example #13
0
 public Domain Create(Authentication authentication, DomainMetaData metaData)
 {
     return(this.Domains.Create(authentication, metaData));
 }
Example #14
0
 protected override void OnBeginEdit(Authentication authentication, DomainMetaData metaData)
 {
     base.OnBeginEdit(authentication, metaData);
     this.table.SetTableState(TableState.IsBeingSetup | TableState.IsMember);
     this.Container.InvokeTablesStateChangedEvent(authentication, new Table[] { this.table, });
 }
Example #15
0
        protected virtual void OnInitialize(DomainMetaData metaData)
        {

        }
Example #16
0
 protected override void OnBeginEdit(Authentication authentication, DomainMetaData metaData)
 {
     base.OnBeginEdit(authentication, metaData);
 }
Example #17
0
        public async Task <Domain> CreateAsync(Authentication authentication, DomainMetaData metaData)
        {
            await this.creationEvent.WaitAsync(metaData.DomainID);

            return(await this.Dispatcher.InvokeAsync(() => this.GetDomain(metaData.DomainID)));
        }