コード例 #1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (Authenticator.Current == null)
            {
                return(value);
            }

            if (parameter == null)
            {
                parameter = this.PropertyName;
            }

            if (value != null && parameter is string propertyName)
            {
                if (value is ITableDescriptor descriptor)
                {
                    if (propertyName == IsBeingEdited)
                    {
                        return(TableDescriptorUtility.IsBeingEdited(Authenticator.Current, descriptor));
                    }
                    else if (propertyName == IsContentEditor)
                    {
                        throw new NotImplementedException();
                        //return TableDescriptorUtility.IsContentEditor(Authenticator.Current, descriptor);
                    }
                    else if (propertyName == IsBeingSetup)
                    {
                        return(TableDescriptorUtility.IsBeingSetup(Authenticator.Current, descriptor));
                    }
                    else if (propertyName == IsTemplateEditor)
                    {
                        throw new NotImplementedException();
                        //return TableDescriptorUtility.IsTemplateEditor(Authenticator.Current, descriptor);
                    }
                    else if (propertyName == IsInherited)
                    {
                        return(TableDescriptorUtility.IsInherited(Authenticator.Current, descriptor));
                    }
                    else if (propertyName == IsBaseTemplate)
                    {
                        return(TableDescriptorUtility.IsBaseTemplate(Authenticator.Current, descriptor));
                    }
                }
                else
                {
                    var prop = value.GetType().GetProperty(propertyName);
                    if (prop != null)
                    {
                        return(prop.GetValue(value));
                    }
                }
            }
            return(value);
        }
コード例 #2
0
 protected override bool OnCanExecute(object parameter)
 {
     if (parameter is ITableDescriptor descriptor)
     {
         if (TableDescriptorUtility.IsBeingEdited(this.authenticator, descriptor) == false)
         {
             return(false);
         }
         return(descriptor.IsContentOwner == true || this.authenticator.Authority == Authority.Admin);
     }
     return(false);
 }
コード例 #3
0
        protected override bool OnCanExecute(object parameter)
        {
            if (parameter is ITableDescriptor descriptor)
            {
                if (TableDescriptorUtility.IsBeingSetup(this.authenticator, descriptor) == false)
                {
                    return(false);
                }
                return(descriptor.TableState.HasFlag(TableState.IsOwner) || this.authenticator.Authority == Authority.Admin);
            }

            return(false);
        }
コード例 #4
0
        public override async Task PreviewAsync(CremaDataSet dataSet)
        {
            var preview = await TableDescriptorUtility.GetDataAsync(authentication, this.descriptor, null);

            foreach (TableTreeViewItemViewModel item in this.Items)
            {
                if (item.IsChecked == true)
                {
                    continue;
                }

                var table = preview.Tables[item.TableName];
                preview.Tables.Remove(table);
            }

            foreach (var item in preview.Tables.Where(i => i.Parent == null))
            {
                item.CopyTo(dataSet);
            }
        }
コード例 #5
0
        private async void Initialize()
        {
            try
            {
                this.BeginProgress(Resources.Message_LoadingData);


                var dataSet = await TableDescriptorUtility.GetDataAsync(this.authentication, this.descriptor, null);

                foreach (var item in this.Tables)
                {
                    item.Source = dataSet.Tables[item.Name];
                }
            }
            catch (Exception e)
            {
                await AppMessageBox.ShowErrorAsync(e);

                this.EndProgress();
                this.DetachEvent();
                this.Tables.Clear();
                await this.TryCloseAsync();

                return;
            }

            //if (this.selectedItem == null this.selectedTableName != null)
            //    this.SelectedItem = this.tableItems.Where(item => item.DisplayName == this.selectedTableName).First();
            //else
            //    this.SelectedItem = this.tableItems.First();

            //this.selectedTableName = null;

            this.EndProgress();
            this.NotifyOfPropertyChange(nameof(this.Tables));
            this.NotifyOfPropertyChange(nameof(this.SelectedTable));
            this.NotifyOfPropertyChange(nameof(this.IsProgressing));
        }