Esempio n. 1
0
        public static bool ChangeColumn(this ITableTemplate template, Authentication authentication)
        {
            var column = template.RandomOrDefault();

            if (column == null)
            {
                return(false);
            }

            if (RandomUtility.Within(25) == true)
            {
                column.SetName(authentication, RandomUtility.NextIdentifier());
            }

            if (RandomUtility.Within(75) == true)
            {
                column.SetTags(authentication, TagInfo.All);
            }
            else
            {
                column.SetTags(authentication, tags.Random());
            }

            if (RandomUtility.Within(25) == true)
            {
                column.SetComment(authentication, RandomUtility.NextString());
            }

            return(true);
        }
Esempio n. 2
0
 public static void AddRandomColumns(this ITableTemplate template, Authentication authentication, int tryCount)
 {
     for (var i = 0; i < tryCount; i++)
     {
         AddRandomColumn(template, authentication);
     }
 }
Esempio n. 3
0
 public NewChildTableViewModel(Authentication authentication, ITable parent, ITableTemplate template)
     : base(authentication, template, true)
 {
     this.parent = parent;
     this.parent.Dispatcher.VerifyAccess();
     this.DisplayName = Resources.Title_NewChildTable;
 }
Esempio n. 4
0
        public static TemplateTerminal Create(Authentication authentication, ITableTemplate template, string prompt)
        {
            var serviceProvider = template.Dispatcher.Invoke(() => template.Table as IServiceProvider);
            var commands        = (serviceProvider.GetService(typeof(IEnumerable <ITemplateCommand>)) as IEnumerable <ITemplateCommand>);

            var commandContext = new TemplateCommandContext(authentication, template, commands);
            var terminal       = new TemplateTerminal(commandContext, prompt)
            {
                Postfix = "$ "
            };

            foreach (var item in commands)
            {
                if (item is SaveCommand saveCommand)
                {
                    saveCommand.CloseAction = () => terminal.Cancel();
                }
                else if (item is CancelCommand cancelCommand)
                {
                    cancelCommand.CloseAction = () => terminal.Cancel();
                }
            }

            return(terminal);
        }
Esempio n. 5
0
 public static async Task AddRandomColumnsAsync(this ITableTemplate template, Authentication authentication, int tryCount)
 {
     for (var i = 0; i < tryCount; i++)
     {
         await AddRandomColumnAsync(template, authentication);
     }
 }
Esempio n. 6
0
        public async void Change()
        {
            try
            {
                this.BeginProgress(this.IsNew ? Resources.Message_Creating : Resources.Message_Changing);
                await this.template.Dispatcher.InvokeAsync(() =>
                {
                    this.template.EndEdit(this.authentication);
                    this.template.EditEnded    -= Template_EditEnded;
                    this.template.EditCanceled -= Template_EditCanceled;
                    this.template.Changed      -= Template_Changed;
                });

                this.domain     = null;
                this.template   = null;
                this.isModified = false;
                this.EndProgress();
                this.TryClose(true);
            }
            catch (Exception e)
            {
                this.EndProgress();
                AppMessageBox.ShowError(e);
            }
        }
Esempio n. 7
0
        public static ITableTemplate CreateAddNew(this ITableTemplate template, Authentication authentication, string columnName,
                                                  string defaultValue = null, bool isKey = false, string dataType = null, bool?allowNull = null)
        {
            var column = template.AddNew(authentication);

            column.SetName(authentication, columnName);
            column.SetIsKey(authentication, isKey);
            if (dataType != null)
            {
                column.SetDataType(authentication, dataType);
            }

            if (allowNull != null)
            {
                column.SetAllowNull(authentication, allowNull.Value);
            }

            if (defaultValue != null)
            {
                column.SetDefaultValue(authentication, defaultValue);
            }

            template.EndNew(authentication, column);
            return(template);
        }
Esempio n. 8
0
 public static void GenerateColumns(this ITableTemplate template, Authentication authentication, int tryCount)
 {
     for (var i = 0; i < tryCount; i++)
     {
         CreateColumn(template, authentication);
     }
 }
Esempio n. 9
0
 private void setDefaultTemplate()
 {
     if (_defaultTemplate == null)
     {
         return;
     }
     _template = new BasicTemplateProvider(_defaultTemplate.Value);
 }
Esempio n. 10
0
 public void SetTableName(ITableTemplate template, TaskContext context)
 {
     template.Dispatcher.Invoke(() =>
     {
         var tableName = RandomUtility.NextIdentifier();
         template.SetTableName(context.Authentication, tableName);
     });
 }
Esempio n. 11
0
        public static ITableColumn AddRandomColumn(this ITableTemplate template, Authentication authentication)
        {
            var column = template.AddNew(authentication);

            column.InitializeRandom(authentication);
            template.EndNew(authentication, column);
            return(column);
        }
Esempio n. 12
0
 public void SetComment(ITableTemplate template, TaskContext context)
 {
     template.Dispatcher.Invoke(() =>
     {
         var comment = RandomUtility.NextString();
         template.SetComment(context.Authentication, comment);
     });
 }
Esempio n. 13
0
 public void SetTags(ITableTemplate template, TaskContext context)
 {
     template.Dispatcher.Invoke(() =>
     {
         var tags = (TagInfo)TagInfoUtility.Names.Random();
         template.SetTags(context.Authentication, tags);
     });
 }
Esempio n. 14
0
        public static void AddColumn(this ITableTemplate template, Authentication authentication, string name, string typeName)
        {
            var column = template.AddNew(authentication);

            column.SetName(authentication, name);
            column.SetDataType(authentication, typeName);
            template.EndNew(authentication, column);
        }
Esempio n. 15
0
        public static async Task <ITableColumn> AddRandomColumnAsync(this ITableTemplate template, Authentication authentication)
        {
            var column = await template.AddNewAsync(authentication);

            await column.InitializeRandomAsync(authentication);

            await template.EndNewAsync(authentication, column);

            return(column);
        }
Esempio n. 16
0
        public static void AddKey(this ITableTemplate template, Authentication authentication, string name, string typeName)
        {
            var column = template.AddNew(authentication);

            column.SetName(authentication, name);
            column.SetIsKey(authentication, true);
            column.SetDataType(authentication, typeName);
            column.SetComment(authentication, string.Format("Key : {0}", typeName));
            template.EndNew(authentication, column);
        }
Esempio n. 17
0
 protected TemplateViewModel(Authentication authentication, ITableTemplate template, bool isNew)
 {
     this.authentication         = authentication;
     this.isNew                  = isNew;
     this.template               = template;
     this.template.EditEnded    += Template_EditEnded;
     this.template.EditCanceled += Template_EditCanceled;
     this.template.Changed      += Template_Changed;
     this.DisplayName            = Resources.Title_TableTemplateEditing;
 }
 private void setLocalCache()
 {
     _bodyDataSource        = PdfRptData.MainTableDataSource();
     _rptTemplate           = PdfRptData.Template ?? new BasicTemplateProvider(BasicTemplate.NullTemplate);
     _pdfRptSummarySettings = PdfRptData.SummarySettings;
     _rptEvents             = PdfRptData.MainTableEvents;
     _pdfRptFont            = PdfRptData.PdfFont;
     _pdfRptHeader          = PdfRptData.Header;
     _conventions           = PdfRptData.AdHocColumnsConventions;
 }
Esempio n. 19
0
        private static string GenerateTableName(ITableTemplate template)
        {
            var tableName = RandomUtility.NextIdentifier();

            if (template.Target is ITable table && table.Parent != null)
            {
                while (tableName == table.Parent.TableName)
                {
                    tableName = RandomUtility.NextIdentifier();
                }
            }
            return(tableName);
        }
Esempio n. 20
0
        public TemplateCommandContext(Authentication authentication, ITableTemplate template, IEnumerable <ITemplateCommand> commands)
            : base(commands.Select(item => item.Command), Enumerable.Empty <ICommandProvider>())
        {
            this.authentication = authentication;
            this.template       = template;

            foreach (var item in commands)
            {
                if (item is TemplateCommandBase command)
                {
                    command.CommandContext = this;
                }
            }
        }
        public static async Task AddColumnAsync(this ITableTemplate template, Authentication authentication, string name, string typeName, string comment)
        {
            var column = await template.AddNewAsync(authentication);

            await column.SetNameAsync(authentication, name);

            await column.SetDataTypeAsync(authentication, typeName);

            if (comment != string.Empty)
            {
                await column.SetCommentAsync(authentication, comment);
            }
            await template.EndNewAsync(authentication, column);
        }
Esempio n. 22
0
        public static void InitializeRandom(this ITableTemplate template, Authentication authentication)
        {
            var tableName = RandomUtility.NextIdentifier();

            template.SetTableName(authentication, tableName);
            if (RandomUtility.Within(50) == true)
            {
                template.SetTags(authentication, (TagInfo)TagInfoUtility.Names.Random());
            }
            if (RandomUtility.Within(50) == true)
            {
                template.SetComment(authentication, RandomUtility.NextString());
            }
            template.AddRandomColumns(authentication);
        }
        private void setLocalCache()
        {
            if (PdfRptData.MainTableDataSource == null)
            {
                throw new InvalidOperationException("MainTableDataSource is null or empty.");
            }

            _bodyDataSource        = PdfRptData.MainTableDataSource();
            _rptTemplate           = PdfRptData.Template ?? new BasicTemplateProvider(BasicTemplate.NullTemplate);
            _pdfRptSummarySettings = PdfRptData.SummarySettings;
            _rptEvents             = PdfRptData.MainTableEvents;
            _pdfRptFont            = PdfRptData.PdfFont;
            _pdfRptHeader          = PdfRptData.Header;
            _conventions           = PdfRptData.AdHocColumnsConventions;
        }
Esempio n. 24
0
        public static async Task InitializeRandomAsync(this ITableTemplate template, Authentication authentication)
        {
            var tableName = GenerateTableName(template);
            await template.SetTableNameAsync(authentication, tableName);

            if (RandomUtility.Within(50) == true)
            {
                await template.SetTagsAsync(authentication, (TagInfo)TagInfoUtility.Names.Random());
            }
            if (RandomUtility.Within(50) == true)
            {
                await template.SetCommentAsync(authentication, RandomUtility.NextString());
            }
            await template.AddRandomColumnsAsync(authentication);
        }
Esempio n. 25
0
        protected async override void OnDeactivate(bool close)
        {
            base.OnDeactivate(close);

            if (this.template != null)
            {
                await this.template.Dispatcher.InvokeAsync(() =>
                {
                    this.template.CancelEdit(this.authentication);
                    this.template.EditEnded    -= Template_EditEnded;
                    this.template.EditCanceled -= Template_EditCanceled;
                    this.template.Changed      -= Template_Changed;
                });
            }
            this.template = null;
        }
Esempio n. 26
0
        public TableTemplateDescriptor(Authentication authentication, ITableTemplate template, DescriptorTypes descriptorTypes, object owner)
            : base(authentication, template, descriptorTypes)
        {
            this.template = template;
            this.owner    = owner ?? this;
            this.template.Dispatcher.VerifyAccess();
            this.domain = this.template.Domain;

            if (this.descriptorTypes.HasFlag(DescriptorTypes.IsSubscriptable) == true)
            {
                this.template.EditBegun              += Template_EditBegun;
                this.template.EditEnded              += Template_EditEnded;
                this.template.EditCanceled           += Template_EditCanceled;
                this.template.Changed                += Template_Changed;
                this.template.Table.TableInfoChanged += Table_TableInfoChanged;
            }
        }
 public static void ClassInit(TestContext context)
 {
     app = new CremaBootstrapper();
     app.Initialize(context, nameof(ITableTemplate_DispatcherTest));
     cremaHost = app.GetService(typeof(ICremaHost)) as ICremaHost;
     cremaHost.Dispatcher.Invoke(() =>
     {
         authentication = cremaHost.Start();
         dataBase       = cremaHost.DataBases.Random();
         dataBase.Load(authentication);
         dataBase.Enter(authentication);
         dataBase.Initialize(authentication);
         template = dataBase.TableContext.Tables.Random(item => item.TemplatedParent == null).Template;
         template.BeginEdit(authentication);
         column = template.AddNew(authentication);
     });
 }
Esempio n. 28
0
        private async void Template_EditCanceled(object sender, EventArgs e)
        {
            if (e is DomainDeletedEventArgs ex)
            {
                this.template.EditEnded    -= Template_EditEnded;
                this.template.EditCanceled -= Template_EditCanceled;
                this.template.Changed      -= Template_Changed;
                this.template = null;

                await this.Dispatcher.InvokeAsync(() =>
                {
                    this.flashService?.Flash();
                    AppMessageBox.ShowInfo(Resources.Message_ExitEditByUser_Format, ex.UserID);
                    this.TryClose();
                });
            }
        }
Esempio n. 29
0
 public static async Task EditRandomAsync(this ITableTemplate template, Authentication authentication, int tryCount)
 {
     for (var i = 0; i < tryCount; i++)
     {
         if (RandomUtility.Within(40) == true)
         {
             await CreateColumnAsync(template, authentication);
         }
         else if (RandomUtility.Within(50) == true)
         {
             await ChangeColumnAsync(template, authentication);
         }
         else if (RandomUtility.Within(25) == true)
         {
             await DeleteColumnAsync(template, authentication);
         }
     }
 }
Esempio n. 30
0
 public static void EditRandom(this ITableTemplate template, Authentication authentication, int tryCount)
 {
     for (var i = 0; i < tryCount; i++)
     {
         if (RandomUtility.Within(40) == true)
         {
             CreateColumn(template, authentication);
         }
         else if (RandomUtility.Within(50) == true)
         {
             ChangeColumn(template, authentication);
         }
         else if (RandomUtility.Within(25) == true)
         {
             DeleteColumn(template, authentication);
         }
     }
 }
Esempio n. 31
0
 private void setDefaultTemplate()
 {
     if (_defaultTemplate == null) return;
     _template = new BasicTemplateProvider(_defaultTemplate.Value);
 }
Esempio n. 32
0
 /// <summary>
 /// Sets the default template. 
 /// It can be null. In this case a new BasicTemplateProvider based on the DefaultBasicTemplate will be used automatically.
 /// </summary>
 /// <param name="template">custom template</param>
 public void CustomTemplate(ITableTemplate template)
 {
     _pdfReport.DataBuilder.Template = template;
 }
Esempio n. 33
0
 private void setLocalCache()
 {
     _bodyDataSource = PdfRptData.MainTableDataSource();
     _rptTemplate = PdfRptData.Template ?? new BasicTemplateProvider(BasicTemplate.NullTemplate);
     _pdfRptSummarySettings = PdfRptData.SummarySettings;
     _rptEvents = PdfRptData.MainTableEvents;
     _pdfRptFont = PdfRptData.PdfFont;
     _pdfRptHeader = PdfRptData.Header;
     _conventions = PdfRptData.AdHocColumnsConventions;
 }
Esempio n. 34
0
 /// <summary>
 /// Sets the default template. 
 /// It can be null. In this case a new BasicTemplateProvider based on the DefaultBasicTemplate will be used automatically.
 /// </summary>
 /// <param name="template"></param>
 public void SetTemplate(ITableTemplate template)
 {
     _template = template;
 }