Esempio n. 1
0
        private void MoveUserCategory(Authentication authentication, IUserCategory sourceCategory, string destPath)
        {
            var destObject = this.GetObject(destPath);

            this.UserContext.Dispatcher.Invoke(MoveUserCategory);

            void MoveUserCategory()
            {
                //var dataBase = sourceCategory.GetService(typeof(IDataBase)) as IDataBase;
                var users = sourceCategory.GetService(typeof(IUserCollection)) as IUserCollection;

                //if (destPath.DataBaseName != dataBase.Name)
                //    throw new InvalidOperationException($"cannot move to : {destPath}");
                //if (destPath.Context != CremaSchema.UserDirectory)
                //    throw new InvalidOperationException($"cannot move to : {destPath}");
                if (destObject is IUser)
                {
                    throw new InvalidOperationException($"cannot move to : {destPath}");
                }

                if (destObject is IUserCategory destCategory)
                {
                    if (sourceCategory.Parent != destCategory)
                    {
                        sourceCategory.Move(authentication, destCategory.Path);
                    }
                }
                else
                {
                    if (NameValidator.VerifyCategoryPath(destPath) == true)
                    {
                        throw new InvalidOperationException($"cannot move to : {destPath}");
                    }
                    var itemName   = new ItemName(destPath);
                    var categories = sourceCategory.GetService(typeof(IUserCategoryCollection)) as IUserCategoryCollection;
                    if (categories.Contains(itemName.CategoryPath) == false)
                    {
                        throw new InvalidOperationException($"cannot move to : {destPath}");
                    }
                    if (sourceCategory.Name != itemName.Name && users.Contains(itemName.Name) == true)
                    {
                        throw new InvalidOperationException($"cannot move to : {destPath}");
                    }
                    if (sourceCategory.Parent.Path != itemName.CategoryPath)
                    {
                        sourceCategory.Move(authentication, itemName.CategoryPath);
                    }
                    if (sourceCategory.Name != itemName.Name)
                    {
                        sourceCategory.Rename(authentication, itemName.Name);
                    }
                }
            }
        }
Esempio n. 2
0
 public void Rename(IUserCategory category, TaskContext context)
 {
     category.Dispatcher.Invoke(() =>
     {
         if (category.Parent == null)
         {
             return;
         }
         var categoryName = RandomUtility.NextIdentifier();
         category.Rename(context.Authentication, categoryName);
     });
 }
Esempio n. 3
0
 public void Rename()
 {
     category.Rename(authentication, RandomUtility.NextIdentifier());
 }