public void Rename(ITableCategory category, TaskContext context) { category.Dispatcher.Invoke(() => { var categoryName = RandomUtility.NextIdentifier(); if (Verify() == false) { return; } category.Rename(context.Authentication, categoryName); }); bool Verify() { if (context.AllowException == true) { return(true); } if (category.Parent == null) { return(false); } return(true); } }
public PreviewTableCategoryViewModel(Authentication authentication, ITableCategory category, long revision) { this.authentication = authentication; this.category = category; this.revision = revision; this.Initialize(); }
public void Move(ITableCategory category, TaskContext context) { category.Dispatcher.Invoke(() => { if (category.Parent == null) { return; } var categories = category.GetService(typeof(ITableCategoryCollection)) as ITableCategoryCollection; var categoryPath = categories.Random().Path; if (Verify(categoryPath) == false) { return; } category.Move(context.Authentication, categoryPath); }); bool Verify(string categoryPath) { if (context.AllowException == true) { return(true); } if (categoryPath.StartsWith(category.Path) == true) { return(false); } if (category.Parent.Path == categoryPath) { return(false); } return(true); } }
public async Task FindAsync(ITableCategory category, TaskContext context) { var authentication = context.Authentication; var text = RandomUtility.NextWord(); var option = RandomUtility.NextEnum <FindOptions>(); await category.FindAsync(authentication, text, option); }
public void Preview(ITableCategory category, TaskContext context) { category.Dispatcher.Invoke(() => { category.GetDataSet(context.Authentication, -1); }); }
public async Task DeleteAsync(ITableCategory category, TaskContext context) { var authentication = context.Authentication; if (context.AllowException == false) { if (await VerifyAsync() == true) { return; } } await category.DeleteAsync(authentication); context.Pop(category); async Task <bool> VerifyAsync() { if ((await category.GetAllTablesAsync(item => true)).Any() == true) { return(false); } return(await category.Dispatcher.InvokeAsync(() => { if (category.Parent == null) { return false; } return true; })); } }
public async Task NewTableAsync(ITableCategory category, TaskContext context) { var authentication = context.Authentication; var template = await category.AddNewTableAsync(authentication); context.Push(template); }
public async Task RenameAsync(ITableCategory category, TaskContext context) { var authentication = context.Authentication; var categoryName = RandomUtility.NextIdentifier(); if (context.AllowException == false) { if (await VerifyAsync() == false) { return; } } await category.RenameAsync(authentication, categoryName); async Task <bool> VerifyAsync() { if ((await category.GetAllRelationTablesAsync(item => item.TableState != TableState.None)).Any() == true) { return(false); } return(await category.Dispatcher.InvokeAsync(() => { if (category.Parent == null) { return false; } if (category.Name == categoryName) { return false; } return true; })); } }
public void GetAccessType(ITableCategory category, TaskContext context) { category.Dispatcher.Invoke(() => { category.GetAccessType(context.Authentication); }); }
public void Lock(ITableCategory category, TaskContext context) { category.Dispatcher.Invoke(() => { if (category.Parent == null) { return; } var comment = RandomUtility.NextString(); if (Verify(comment) == false) { return; } category.Lock(context.Authentication, comment); }); bool Verify(string comment) { if (context.AllowException == true) { return(true); } if (comment == string.Empty) { return(false); } if (category.IsLocked == true) { return(false); } return(true); } }
public void SetPublic(ITableCategory category, TaskContext context) { category.Dispatcher.Invoke(() => { if (category.Parent == null) { return; } if (Verify() == false) { return; } category.SetPublic(context.Authentication); }); bool Verify() { if (context.AllowException == true) { return(true); } if (category.IsPrivate == false) { return(false); } return(true); } }
private void Category_Deleted(object sender, EventArgs e) { this.category = null; this.Dispatcher.InvokeAsync(() => { this.OnDisposed(EventArgs.Empty); }); }
public static void RenameTest(this ITableCategory category, Authentication authentication) { Assert.AreNotEqual(null, category.Parent); var parent = category.Parent; var newName = NameUtility.GenerateNewName(RandomUtility.NextIdentifier(), parent.Categories.Select(item => item.Name)); category.Rename(authentication, newName); }
private MoveTableCategoryViewModel(Authentication authentication, ITableCategory category, string[] targetPaths) : base(category, currentPath: category.Path, targetPaths: targetPaths) { this.authentication = authentication; this.category = category; this.category.Dispatcher.VerifyAccess(); this.DisplayName = Resources.Title_MoveTableFolder; }
private NewTableCategoryViewModel(Authentication authentication, ITableCategory category) : base(category.Path) { this.authentication = authentication; this.category = category; this.category.Dispatcher.VerifyAccess(); this.DisplayName = Resources.Title_NewTableFolder; }
public static Task <string> GenerateNewCategoryNameAsync(this ITableCategory tableCategory, string name) { return(tableCategory.Dispatcher.InvokeAsync(() => { var names = tableCategory.Categories.Select(item => item.Name); return NameUtility.GenerateNewName(name, names); })); }
public NewTableViewModel(Authentication authentication, ITableCategory category, ITableTemplate template) : base(authentication, template, true) { this.category = category; this.category.Dispatcher.VerifyAccess(); this.tableContext = category.GetService(typeof(ITableContext)) as ITableContext; this.DisplayName = Resources.Title_NewTable; }
private DeleteTableCategoryViewModel(Authentication authentication, ITableCategory category) { this.authentication = authentication; this.category = category; this.category.Dispatcher.VerifyAccess(); this.Target = this.category.Path; this.DisplayName = Resources.Title_DeleteTableFolder; }
public void NewTable(ITableCategory category, TaskContext context) { category.Dispatcher.Invoke(() => { var template = category.NewTable(context.Authentication); context.Push(template); }); }
public void AddNewCategory(ITableCategory category, TaskContext context) { category.Dispatcher.Invoke(() => { var categoryNanme = RandomUtility.NextIdentifier(); category.AddNewCategory(context.Authentication, categoryNanme); }); }
public void Find(ITableCategory category, TaskContext context) { category.Dispatcher.Invoke(() => { var text = RandomUtility.NextWord(); var option = RandomUtility.NextEnum <FindOptions>(); category.Find(context.Authentication, text, option); }); }
private async Task MoveTableCategoryAsync(Authentication authentication, ITableCategory sourceCategory, string newPath) { var destPath = new DataBasePath(newPath); var destObject = await this.GetObjectAsync(authentication, destPath.Path); var dataBase = sourceCategory.GetService(typeof(IDataBase)) as IDataBase; var tables = sourceCategory.GetService(typeof(ITableCollection)) as ITableCollection; if (destPath.DataBaseName != dataBase.Name) { throw new InvalidOperationException($"cannot move to : {destPath}"); } if (destPath.Context != CremaSchema.TableDirectory) { throw new InvalidOperationException($"cannot move to : {destPath}"); } if (destObject is ITable) { throw new InvalidOperationException($"cannot move to : {destPath}"); } using (await UsingDataBase.SetAsync(dataBase, authentication)) { if (destObject is ITableCategory destCategory) { if (sourceCategory.Parent != destCategory) { await sourceCategory.MoveAsync(authentication, destCategory.Path); } } else { if (NameValidator.VerifyCategoryPath(destPath.ItemPath) == true) { throw new InvalidOperationException($"cannot move to : {destPath}"); } var itemName = new ItemName(destPath.ItemPath); var categories = sourceCategory.GetService(typeof(ITableCategoryCollection)) as ITableCategoryCollection; if (await categories.ContainsAsync(itemName.CategoryPath) == false) { throw new InvalidOperationException($"cannot move to : {destPath}"); } if (sourceCategory.Name != itemName.Name && await tables.ContainsAsync(itemName.Name) == true) { throw new InvalidOperationException($"cannot move to : {destPath}"); } if (sourceCategory.Parent.Path != itemName.CategoryPath) { await sourceCategory.MoveAsync(authentication, itemName.CategoryPath); } if (sourceCategory.Name != itemName.Name) { await sourceCategory.RenameAsync(authentication, itemName.Name); } } } }
public static ITable AddRandomDerivedTable(this ITableCategory category, Authentication authentication) { var tableName = RandomUtility.NextIdentifier(); var copyData = RandomUtility.NextBoolean(); var tableContext = category.GetService(typeof(ITableContext)) as ITableContext; var table = tableContext.Tables.Random(item => item.TemplatedParent == null && item.Parent == null); return(table.Inherit(authentication, tableName, category.Path, copyData)); }
/// <summary> /// 대상 카테고리의 테이블 및 와 하위 카테고리의 테이블의 모든 목록을 가져옵니다. /// </summary> public static Task <ITable[]> GetAllTablesAsync(this ITableCategory category, Func <ITable, bool> predicate) { return(category.Dispatcher.InvokeAsync(() => { var query = from item in EnumerableUtility.FamilyTree <ITableItem, ITable>(category as ITableItem, item => item.Childs) where predicate(item) select item; return query.ToArray(); })); }
//[TaskMethod(Weight = 10)] public async Task SetPrivateAsync(ITableCategory category, TaskContext context) { var authentication = context.Authentication; if (category.Parent == null) { return; } await category.SetPrivateAsync(authentication); }
public static async Task <ITable[]> AddRandomDerivedTableAsync(this ITableCategory category, Authentication authentication) { var tableCollection = category.GetService(typeof(ITableCollection)) as ITableCollection; var tableName = RandomUtility.NextIdentifier(); var copyData = RandomUtility.NextBoolean(); var tableContext = category.GetService(typeof(ITableContext)) as ITableContext; var table = await tableCollection.GetRandomTableAsync(item => item.TemplatedParent == null && item.Parent == null); return(await table.InheritAsync(authentication, tableName, category.Path, copyData)); }
public static async Task <ITable> GenerateStandardTableAsync(this ITableCategory category, Authentication authentication, string prefix, IEnumerable <string> keyTypes, IEnumerable <string> columnTypes) { var tables = category.GetService(typeof(ITableCollection)) as ITableCollection; var tableName = string.Join("_", EnumerableUtility.Friends(prefix, keyTypes)); if (tables.Contains(tableName) == true) { return(null); } var template = await category.AddNewTableAsync(authentication); await template.SetTableNameAsync(authentication, tableName); foreach (var item in keyTypes) { await template.AddKeyAsync(authentication, item, item); } foreach (var item in columnTypes) { await template.AddColumnAsync(authentication, item, item); } try { await template.EndEditAsync(authentication); return(template.Target as ITable); } catch { await template.CancelEditAsync(authentication); return(null); } //var table = template.Table; //var content = table.Content; //content.BeginEdit(authentication); //content.EnterEdit(authentication); //try //{ // content.GenerateRowsAsync(authentication, RandomUtility.Next(10, 1000)); // content.LeaveEdit(authentication); // content.EndEdit(authentication); //} //catch //{ // content.CancelEdit(authentication); //} //return table; }
public static ITable AddRandomTable(this ITableCategory category, Authentication authentication) { var template = category.NewTable(authentication); template.InitializeRandom(authentication); template.EndEdit(authentication); var table = template.Table; AddRandomRows(table, authentication, RandomUtility.Next(MinRowCount, MaxRowCount)); return(table); }
public void SetPrivate(ITableCategory category, TaskContext context) { category.Dispatcher.Invoke(() => { if (category.Parent == null) { return; } category.SetPrivate(context.Authentication); }); }
/// <summary> /// 대상 카테고리의 테이블 및 와 하위 카테고리의 테이블에서 사용되고 있는 타입의 목록을 가져옵니다. /// </summary> public static Task <IType[]> GetAllUsingTypesAsync(this ITableCategory category, Func <IType, bool> predicate) { return(category.Dispatcher.InvokeAsync(() => { var tables = EnumerableUtility.FamilyTree <ITableItem, ITable>(category as ITableItem, item => item.Childs); var types = tables.SelectMany(item => TableExtensions.GetTypes(item)).Distinct(); var query = from item in types where predicate(item) select item; return query.ToArray(); })); }