public UserUnbanArguments(User user) { var items = EnumerableUtility.One(user).ToArray(); var userInfo = user.UserInfo; var userPath = user.Path; var lockPaths = new[] { userPath }; this.UserID = userInfo.ID; this.UserName = userInfo.Name; this.Items = items; this.UserInfo = userInfo; this.UserPath = userPath; this.LockPaths = lockPaths; }
public override void OnValidateDelete(IAuthentication authentication, object target) { base.OnValidateDelete(authentication, target); if (this.templateList.Any() == true) { throw new CremaException("새로운 테이블을 생성중일때는 삭제할 수 없습니다."); } var tables = EnumerableUtility.Descendants <IItem, Table>(this as IItem, item => item.Childs).ToArray(); if (tables.Any() == true) { throw new CremaException("테이블이 있는 폴더는 삭제할 수 없습니다."); } }
public override void OnValidateDelete(IAuthentication authentication, object target) { base.OnValidateDelete(authentication, target); if (this.templateList.Any() == true) { throw new InvalidOperationException(Resources.Exception_CannotDeleteOnCreateTable); } var tables = EnumerableUtility.Descendants <IItem, Table>(this as IItem, item => item.Childs).ToArray(); if (tables.Any() == true) { throw new InvalidOperationException(Resources.Exception_CannotDeletePathWithItems); } }
public void ValidateLeave(Authentication authentication) { if (this.table.Parent != null) { throw new CremaException(); } var items = EnumerableUtility.Friends(this, this.Childs); foreach (var item in items) { item.OnValidateLeave(authentication, this); } }
public void Delete(Authentication authentication) { this.DataBase.ValidateBeginInDataBase(authentication); this.CremaHost.DebugMethod(authentication, this, nameof(Delete), this); base.ValidateDelete(authentication); this.Sign(authentication); var items = EnumerableUtility.One(this).ToArray(); var oldPaths = items.Select(item => item.Path).ToArray(); var container = this.Container; container.InvokeCategoryDelete(authentication, this); base.Delete(authentication); container.InvokeCategoriesDeletedEvent(authentication, items, oldPaths); }
protected override void OnEndEdit(Authentication authentication, CremaTemplate template) { this.Container.InvokeTableEndTemplateEdit(authentication, this.table, this.TemplateSource); base.OnEndEdit(authentication, template); this.table.UpdateTemplate(template.TableInfo); this.table.UpdateTags(template.Tags); this.table.UpdateComment(template.Comment); this.table.SetTableState(TableState.None); var items = EnumerableUtility.One(this.table).ToArray(); this.Container.InvokeTablesStateChangedEvent(authentication, items); this.Container.InvokeTablesTemplateChangedEvent(authentication, items, this.TemplateSource.TargetTable.DataSet); }
public void Move(Authentication authentication, string parentPath) { this.Dispatcher.VerifyAccess(); this.CremaHost.DebugMethod(authentication, this, nameof(Move), this, parentPath); var items = EnumerableUtility.One(this).ToArray(); var oldPaths = items.Select(item => item.Path).ToArray(); var oldParentPaths = items.Select(item => item.Parent.Path).ToArray(); var result = this.Service.MoveUserItem(this.Path, parentPath); result.Validate(authentication); this.Parent = this.Container[parentPath]; this.Container.InvokeCategoriesMovedEvent(authentication, items, oldPaths, oldParentPaths); }
public void Delete(Authentication authentication) { this.Dispatcher.VerifyAccess(); this.CremaHost.DebugMethod(authentication, this, nameof(Delete), this); var items = EnumerableUtility.One(this).ToArray(); var oldPaths = items.Select(item => item.Path).ToArray(); var container = this.Container; var result = this.Service.DeleteUserItem(this.Path); result.Validate(authentication); this.Dispose(); container.InvokeCategoriesDeletedEvent(authentication, items, oldPaths); }
public void ValidateBeginEdit(Authentication authentication) { if (this.table.Parent != null) { throw new CremaException("자식 테이블은 편집을 시작할 수 없습니다."); } var isAdmin = authentication.Types.HasFlag(AuthenticationType.Administrator); var items = EnumerableUtility.Friends(this, this.Childs); foreach (var item in items) { item.OnValidateBeginEdit(authentication, this); } }
public void Rename(Authentication authentication, string name) { this.Dispatcher.VerifyAccess(); this.CremaHost.DebugMethod(authentication, this, nameof(Rename), this, name); var items = EnumerableUtility.One(this).ToArray(); var oldNames = items.Select(item => item.Name).ToArray(); var oldPaths = items.Select(item => item.Path).ToArray(); var result = this.Service.RenameUserItem(this.Path, name); result.Validate(authentication); base.Name = name; this.Container.InvokeCategoriesRenamedEvent(authentication, items, oldNames, oldPaths); }
public TableEditorViewModel(Authentication authentication, TableDescriptor descriptor) { this.authentication = authentication; this.authentication.Expired += (s, e) => this.Dispatcher.InvokeAsync(() => this.Tables.Clear()); this.descriptor = descriptor; this.contentDescriptor = descriptor.ContentDescriptor; this.AttachEvent(); this.DisplayName = descriptor.DisplayName; this.Target = descriptor.Target; foreach (var item in EnumerableUtility.FamilyTree(this.descriptor, item => item.Childs)) { this.Tables.Add(new TableItemViewModel(this.authentication, item, this)); } this.Initialize(); }
public void Move(Authentication authentication, string categoryPath) { this.Dispatcher.VerifyAccess(); this.CremaHost.DebugMethod(authentication, this, nameof(Move), this, categoryPath); var result = this.Service.MoveUserItem(this.Path, categoryPath); this.Sign(authentication, result); var items = EnumerableUtility.One(this).ToArray(); var oldPaths = items.Select(item => item.Path).ToArray(); var oldCategoryPaths = items.Select(item => item.Category.Path).ToArray(); this.Container.InvokeUserMove(authentication, this, categoryPath); base.Move(authentication, categoryPath); this.Container.InvokeUsersMovedEvent(authentication, items, oldPaths, oldCategoryPaths); }
public void Rename(Authentication authentication, string name) { this.DataBase.ValidateBeginInDataBase(authentication); this.CremaHost.DebugMethod(authentication, this, nameof(Rename), this, name); base.ValidateRename(authentication, name); this.Sign(authentication); var items = EnumerableUtility.One(this).ToArray(); var oldNames = items.Select(item => item.Name).ToArray(); var oldPaths = items.Select(item => item.Path).ToArray(); var dataSet = this.ReadAllData(authentication, true); this.Container.InvokeCategoryRename(authentication, this, name, dataSet); base.Rename(authentication, name); this.Container.InvokeCategoriesRenamedEvent(authentication, items, oldNames, oldPaths, dataSet); }
public FindResultInfo[] Find(Authentication authentication, string text, FindOptions options) { this.DataBase.ValidateAsyncBeginInDataBase(authentication); this.CremaHost.DebugMethod(authentication, this, nameof(Find), this, text, options); var items = this.Dispatcher.Invoke(() => { this.ValidateAccessType(authentication, AccessType.Guest); this.Sign(authentication); var descendants = EnumerableUtility.Descendants<ITypeItem>(this, item => item.Childs); return EnumerableUtility.Friends(this, descendants).Select(item => item.Path).ToArray(); }); var service = this.GetService(typeof(DataFindService)) as DataFindService; var result = service.Dispatcher.Invoke(() => service.FindFromType(this.DataBase.ID, items, text, options)); return result; }
public void Rename(Authentication authentication, string name) { this.DataBase.ValidateBeginInDataBase(authentication); this.CremaHost.DebugMethod(authentication, this, nameof(Rename), this, name); var result = this.Context.Service.RenameTypeItem(base.Path, name); this.Sign(authentication, result); var items = EnumerableUtility.One(this).ToArray(); var oldNames = items.Select(item => item.Name).ToArray(); var oldPaths = items.Select(item => item.Path).ToArray(); this.Container.InvokeTypeRename(authentication, this, name); base.Rename(authentication, name); this.Container.InvokeTypesRenamedEvent(authentication, items, oldNames, oldPaths); }
public UserResetPasswordArguments(User user) { var items = EnumerableUtility.One(user).ToArray(); var userInfo = user.UserInfo; var userPath = user.Path; var lockPaths = new[] { userPath }; this.UserID = userInfo.ID; this.UserName = userInfo.Name; this.Password = $"{userInfo.Authority}".ToLower().ToSecureString(); this.Items = items; this.UserInfo = userInfo; this.UserPath = userPath; this.LockPaths = lockPaths; }
public void Move(Authentication authentication, string categoryPath) { this.DataBase.ValidateBeginInDataBase(authentication); this.CremaHost.DebugMethod(authentication, this, nameof(Move), this, categoryPath); var result = this.Service.MoveTableItem(base.Path, categoryPath); this.Sign(authentication, result); var items = EnumerableUtility.Friends(this, this.Childs).ToArray(); var oldPaths = items.Select(item => item.Path).ToArray(); var oldCategoryPaths = items.Select(item => item.Category.Path).ToArray(); this.Container.InvokeTableMove(authentication, this, categoryPath); base.Move(authentication, categoryPath); this.Container.InvokeTablesMovedEvent(authentication, items, oldPaths, oldCategoryPaths); }
public void Move(Authentication authentication, string parentPath) { this.DataBase.ValidateBeginInDataBase(authentication); this.CremaHost.DebugMethod(authentication, this, nameof(Move), this, parentPath); base.ValidateMove(authentication, parentPath); this.Sign(authentication); var items = EnumerableUtility.One(this).ToArray(); var oldPaths = items.Select(item => item.Path).ToArray(); var oldParentPaths = items.Select(item => item.Parent.Path).ToArray(); var dataSet = this.ReadAllData(authentication, true); this.Container.InvokeCategoryMove(authentication, this, parentPath, dataSet); base.Move(authentication, parentPath); this.Container.InvokeCategoriesMovedEvent(authentication, items, oldPaths, oldParentPaths, dataSet); }
public void ReadAll(Authentication authentication, CremaDataSet dataSet) { if (this.Parent != null) { this.Parent.ReadAll(authentication, dataSet); return; } var types = this.GetService(typeof(TypeCollection)) as TypeCollection; var typeFiles = (from Type item in types select item.SchemaPath).ToArray(); var tableFiles = EnumerableUtility.Friends(this, this.DerivedTables).Select(item => item.XmlPath).ToArray(); dataSet.ReadMany(typeFiles, tableFiles); dataSet.AcceptChanges(); }
/// <summary> /// Gets a sorted (base-to-derived) sequence of ancestor-and-descendant-or-self types from the <paramref name="source"/>. /// </summary> /// <param name="source">The source type to locate ancestor-and-descendant-or-self types from.</param> /// <param name="assemblies">The assemblies to search for the <paramref name="source"/>.</param> /// <returns>An <see cref="IEnumerable{Type}"/> holding the ancestor-and-descendant-or-self types from the <paramref name="source"/>.</returns> public static IEnumerable <Type> GetAncestorAndDescendantsOrSelfTypes(Type source, params Assembly[] assemblies) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (assemblies == null) { throw new ArgumentNullException(nameof(assemblies)); } IEnumerable <Type> ancestorOrSelfTypes = GetAncestorOrSelfTypes(source); IEnumerable <Type> derivedOrSelfTypes = GetDescendantOrSelfTypes(source, assemblies); return(EnumerableUtility.SortDescending(EnumerableUtility.Concat(derivedOrSelfTypes, ancestorOrSelfTypes).Distinct(), new ReferenceComparer <Type>())); }
public UserDeleteArguments(User user) { var items = EnumerableUtility.One(user).ToArray(); var oldPaths = items.Select(item => item.Path).ToArray(); var userInfo = user.UserInfo; var targetName = new ItemName(userInfo.Path); var(userPath, lockPaths) = GetPathForData(user.Path, targetName); this.UserID = userInfo.ID; this.Items = items; this.OldPaths = oldPaths; this.UserInfo = userInfo; this.UserPath = userPath; this.LockPaths = lockPaths; }
private void CancelContent(Authentication authentication) { var items = EnumerableUtility.Friends(this.table, this.table.Childs); foreach (var item in items.Select(i => i.Content)) { item.domain = null; item.isModified = false; item.dataSet = null; item.dataTable = null; item.table.SetTableState(TableState.None); } this.Container.InvokeTablesStateChangedEvent(authentication, items.ToArray()); }
static IEnumerable <string> QueryParents(string path) { return(EnumerableUtility.Ancestors(path, item => { if (item == PathUtility.Separator) { return null; } if (NameValidator.VerifyItemPath(item) == true) { return new ItemName(item).CategoryPath; } return new CategoryName(item).ParentPath; })); }
protected static (string[] userPaths, string[] lockPaths) GetPathForData(UserCategory uesrCategory, CategoryName targetName) { var targetPaths = new string[] { targetName.ParentPath, targetName, }; var items = EnumerableUtility.FamilyTree(uesrCategory as IUserItem, item => item.Childs); var users = items.Where(item => item is User).Select(item => item as User).ToArray(); var userPaths = users.Select(item => item.Path).ToArray(); var itemPaths = items.Select(item => item.Path).ToArray(); var lockPaths = itemPaths.Concat(targetPaths).Distinct().OrderBy(item => item).ToArray(); return(userPaths, lockPaths); }
private void CreateTables(CremaDataSet dataSet, string[] names) { var tableCollection = this.dataBase.TableContext.Tables; var tableList = new List <ITable>(names.Length); foreach (var item in names) { if (tableCollection.Contains(item) == false) { throw new TableNotFoundException(item); } tableList.Add(tableCollection[item]); } var tables = tableList.ToArray(); var types = from item in tables from i in EnumerableUtility.Friends(item, item.Childs) from c in i.TableInfo.Columns where c.DataType.StartsWith("/") select c.DataType; var types1 = types.Distinct().ToArray(); dataSet.BeginLoad(); foreach (var item in types1) { var typeItem = dataBase.TypeContext[item]; if (typeItem is IType == false) { continue; } var type = typeItem as IType; dataSet.Types.Add(type.TypeInfo); } dataSet.EndLoad(); foreach (var item in tables) { if (item.Parent != null) { continue; } this.CreateTable(dataSet, item); } }
public void LockedTableFailTest() { var tableContext = this.dataBase.TableContext; var table = tableContext.Tables.RandomSample(); var child = table.Childs.Random(); var category = EnumerableUtility.Ancestors(table as IItem).Random(item => item.Parent != null) as ITableCategory; table.Lock(this.admin, string.Empty); try { this.InvokeFail <PermissionException>(() => table.SetPublic(this.member)); this.InvokeFail <PermissionDeniedException>(() => table.SetPrivate(this.member)); this.InvokeFail <PermissionException>(() => table.AddAccessMember(this.member, this.someone.UserID, AccessType.ReadWrite)); this.InvokeFail <PermissionException>(() => table.RemoveAccessMember(this.member, this.someone.UserID)); this.InvokeFail <PermissionException>(() => table.Lock(this.member, RandomUtility.NextString())); this.InvokeFail <PermissionDeniedException>(() => table.Unlock(this.member)); this.InvokeFail <PermissionDeniedException>(() => table.RenameTest(this.member)); this.InvokeFail <PermissionDeniedException>(() => table.MoveTest(this.member)); this.InvokeFail <PermissionDeniedException>(() => table.Delete(this.member)); this.InvokeFail <PermissionDeniedException>(() => table.NewTable(this.member)); this.InvokeFail <PermissionDeniedException>(() => table.Revert(this.member, 0)); this.InvokeFail <CremaException>(() => category.SetPublic(this.member)); this.InvokeFail <CremaException>(() => category.SetPrivate(this.member)); this.InvokeFail <CremaException>(() => category.AddAccessMember(this.member, this.someone.UserID, AccessType.ReadWrite)); this.InvokeFail <CremaException>(() => category.RemoveAccessMember(this.member, this.someone.UserID)); this.InvokeFail <CremaException>(() => category.Lock(this.member, RandomUtility.NextString())); this.InvokeFail <CremaException>(() => category.Unlock(this.member)); this.InvokeFail <CremaException>(() => category.RenameTest(this.member)); this.InvokeFail <CremaException>(() => category.MoveTest(this.member)); this.InvokeFail <CremaException>(() => category.Delete(this.member)); this.InvokeFail <PermissionException>(() => child.SetPublic(this.member)); this.InvokeFail <PermissionDeniedException>(() => child.SetPrivate(this.member)); this.InvokeFail <PermissionException>(() => child.AddAccessMember(this.member, this.someone.UserID, AccessType.ReadWrite)); this.InvokeFail <PermissionException>(() => child.RemoveAccessMember(this.member, this.someone.UserID)); this.InvokeFail <PermissionException>(() => child.Lock(this.member, RandomUtility.NextString())); this.InvokeFail <PermissionException>(() => child.Unlock(this.member)); this.InvokeFail <PermissionDeniedException>(() => child.RenameTest(this.member)); this.InvokeFail <PermissionDeniedException>(() => child.MoveTest(this.member)); this.InvokeFail <PermissionDeniedException>(() => child.Delete(this.member)); } finally { table.Unlock(this.admin); } }
public void Delete(Authentication authentication) { this.DataBase.ValidateBeginInDataBase(authentication); this.CremaHost.DebugMethod(authentication, this, nameof(Delete), this, base.Path); var result = this.Service.DeleteTableItem(base.Path); this.Sign(authentication, result); var items = this.Parent == null?EnumerableUtility.Friends(this, this.Childs).ToArray() : EnumerableUtility.Friends(this, this.DerivedTables).ToArray(); var oldPaths = items.Select(item => item.Path).ToArray(); var container = this.Container; container.InvokeTableDelete(authentication, this); base.Delete(authentication); container.InvokeTablesDeletedEvent(authentication, items, oldPaths); }
public void Rename(Authentication authentication, string name) { this.DataBase.ValidateBeginInDataBase(authentication); this.CremaHost.DebugMethod(authentication, this, nameof(Rename), this, name); base.ValidateRename(authentication, name); this.Sign(authentication); var items = this.Parent == null?EnumerableUtility.Friends(this, this.Childs).ToArray() : EnumerableUtility.Friends(this, this.DerivedTables).ToArray(); var oldNames = items.Select(item => item.Name).ToArray(); var oldPaths = items.Select(item => item.Path).ToArray(); var dataSet = this.ReadAll(authentication); this.Container.InvokeTableRename(authentication, this, name, dataSet); base.Rename(authentication, name); this.Container.InvokeTablesRenamedEvent(authentication, items, oldNames, oldPaths, dataSet); }
private List <Vector3> allDirections() { List <Vector3> res = new List <Vector3>(); foreach (int i in EnumerableUtility.Range(-1, 2)) { foreach (int j in EnumerableUtility.Range(-1, 2)) { if (!(i == 0 && j == 0)) { res.Add(new Vector3(i, j, 0)); } } } return(res); }
public void SelectRecursiveDepthFirst_Nested() { var item0a = new RecursiveItem(); var item0b = new RecursiveItem(); var item0c = new RecursiveItem(); var item1a = new RecursiveItem(item0a, item0b); var item1b = new RecursiveItem(); var item1c = new RecursiveItem(item0c); var item2a = new RecursiveItem(item1a); var item2b = new RecursiveItem(item1b, item1c); var item3 = new RecursiveItem(item2a, item2b); var result = EnumerableUtility.SelectRecursiveDepthFirst(item3, i => i.Children).ToArray(); Assert.That(result, Is.EqualTo(new[] { item3, item2a, item1a, item0a, item0b, item2b, item1b, item1c, item0c })); }