예제 #1
0
        protected virtual async Task OnBeginEditAsync(Authentication authentication)
        {
            var result = await this.BeginDomainAsync(authentication);

            this.CremaHost.Sign(authentication, result);
            var metaData = result.Value;

            this.domain = await this.DomainContext.CreateAsync(authentication, metaData) as TypeDomain;

            this.domain.IsNew = this.IsNew;
            this.domain.Host  = this;
            await this.domain.WaitMemberEnterAsync(authentication);

            this.TypeSource = this.domain.Source as CremaDataType;

            this.table = this.TypeSource.View.Table;
            this.items = new List <TypeMember>(this.table.Rows.Count);
            for (var i = 0; i < this.table.Rows.Count; i++)
            {
                var item = this.table.Rows[i];
                this.items.Add(new TypeMember(this, item));
            }
            this.table.RowDeleted += Table_RowDeleted;
            this.table.RowChanged += Table_RowChanged;

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

            await this.domain.Dispatcher.InvokeAsync(this.RefreshEditors);
        }
예제 #2
0
        protected virtual async Task OnBeginEditAsync(Authentication authentication)
        {
            this.TypeSource = await this.CreateSourceAsync(authentication);

            this.domain = new TypeDomain(authentication, this.TypeSource, this.DataBase, this.Path, this.GetType().Name)
            {
                IsNew = this.IsNew,
                Host  = this
            };
            this.ItemPaths = this.domain.ItemPaths;
            await this.DomainContext.AddAsync(authentication, this.domain, this.DataBase);

            this.table = this.TypeSource.View.Table;
            this.items = new List <TypeMember>(this.table.Rows.Count);
            for (var i = 0; i < this.table.Rows.Count; i++)
            {
                var item = this.table.Rows[i];
                this.items.Add(new TypeMember(this, item));
            }
            this.table.RowDeleted += Table_RowDeleted;
            this.table.RowChanged += Table_RowChanged;

            await this.domain.EnterAsync(authentication, DomainAccessType.ReadWrite);

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

            await this.domain.Dispatcher.InvokeAsync(this.RefreshEditors);
        }
예제 #3
0
 protected virtual void OnDetached()
 {
     if (this.TypeSource != null)
     {
         this.domain.Dispatcher.Invoke(this.DetachDomainEvent);
     }
     this.domain = null;
 }
예제 #4
0
 protected virtual void OnDetached()
 {
     this.domain.Dispatcher.Invoke(() =>
     {
         this.DetachDomainEvent();
     });
     this.domain = null;
 }
예제 #5
0
 protected virtual async Task OnCancelEditAsync(Authentication authentication)
 {
     if (this.domain.Host != null)
     {
         await this.CancelDomainAsync(authentication);
     }
     this.domain = null;
     if (this.table != null)
     {
         this.table.RowDeleted -= Table_RowDeleted;
         this.table.RowChanged -= Table_RowChanged;
     }
     this.IsModified = false;
     this.table      = null;
     this.items      = null;
     this.editor     = null;
 }
예제 #6
0
 protected virtual void OnCancelEdit(Authentication authentication)
 {
     this.domain?.Dispatcher?.Invoke(() =>
     {
         this.DetachDomainEvent();
         this.domain.Dispose(authentication, true);
     });
     this.isModified = false;
     this.domain     = null;
     if (this.table != null)
     {
         this.table.RowDeleted -= Table_RowDeleted;
         this.table.RowChanged -= Table_RowChanged;
     }
     this.table = null;
     this.members.Clear();
 }
예제 #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;
        }
예제 #8
0
        protected virtual async Task OnCancelEditAsync(Authentication authentication)
        {
            if (this.domain.Host != null)
            {
                await this.domain.Dispatcher.InvokeAsync(this.DetachDomainEvent);

                await this.domain.LeaveAsync(authentication);

                await this.DomainContext.RemoveAsync(authentication, this.domain, true);
            }
            this.domain            = null;
            this.table.RowDeleted -= Table_RowDeleted;
            this.table.RowChanged -= Table_RowChanged;
            this.IsModified        = false;
            this.table             = null;
            this.items             = null;
            this.editor            = null;
        }
예제 #9
0
 protected virtual void OnAttach(Domain domain)
 {
     this.TypeSource = domain.Source as CremaDataType;
     this.domain     = domain as TypeDomain;
     if (this.TypeSource != null)
     {
         this.table = this.TypeSource.View.Table;
         this.items = new List <TypeMember>(this.table.Rows.Count);
         for (var i = 0; i < this.table.Rows.Count; i++)
         {
             var item = this.table.Rows[i];
             this.items.Add(new TypeMember(this, item));
         }
         this.table.RowDeleted += Table_RowDeleted;
         this.table.RowChanged += Table_RowChanged;
         this.IsModified        = this.domain.IsModified;
         this.domain.Dispatcher.Invoke(this.AttachDomainEvent);
         this.domain.Dispatcher.Invoke(this.RefreshEditors);
     }
 }
예제 #10
0
        protected virtual void OnRestore(Domain domain)
        {
            this.dataType = domain.Source as CremaDataType;
            this.domain   = domain as TypeDomain;

            if (this.dataType != null)
            {
                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;
            }

            this.domain.Dispatcher.Invoke(() =>
            {
                this.isModified = this.domain.IsModified;
                this.AttachDomainEvent();
            });
        }
예제 #11
0
        protected virtual void OnBeginEdit(Authentication authentication)
        {
            this.dataType     = this.CreateSource(authentication);
            this.domain       = new TypeDomain(authentication, this.dataType, this.DataBase, this.ItemPath, this.GetType().Name);
            this.domain.IsNew = this.IsNew;
            this.domain.Host  = this;

            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;

            this.DomainContext.Domains.Add(authentication, this.domain);
            this.domain.Dispatcher.Invoke(() =>
            {
                this.AttachDomainEvent();
                this.domain.AddUser(authentication, DomainAccessType.ReadWrite);
            });
        }
예제 #12
0
        protected virtual void OnAttach(Domain domain)
        {
            this.TypeSource = domain.Source as CremaDataType;
            this.domain     = domain as TypeDomain;
            this.ItemPaths  = this.domain.ItemPaths;
            this.Repository.Dispatcher.Invoke(() => this.Repository.Lock(Authentication.System, this, nameof(OnAttach), this.ItemPaths));
            if (this.TypeSource != null)
            {
                this.table = this.TypeSource.View.Table;
                this.items = new List <TypeMember>(this.table.Rows.Count);
                for (var i = 0; i < this.table.Rows.Count; i++)
                {
                    var item = this.table.Rows[i];
                    this.items.Add(new TypeMember(this, item));
                }
                this.table.RowDeleted += Table_RowDeleted;
                this.table.RowChanged += Table_RowChanged;
            }

            this.IsModified = this.domain.IsModified;
            this.domain.Dispatcher.Invoke(this.AttachDomainEvent);
            this.domain.Dispatcher.Invoke(this.RefreshEditors);
            this.ServiceState = ServiceState.Open;
        }
예제 #13
0
 protected virtual void OnDetach()
 {
     this.domain.Dispatcher.Invoke(this.DetachDomainEvent);
     this.domain = null;
 }