Exemplo n.º 1
0
        public IExplorerRepositoryResult RenameFolder(string path, string newPath, Guid workSpaceId)
        {
            try
            {
                if (!Directory.Exists(DirectoryStructureFromPath(path)))
                {
                    return(new ExplorerRepositoryResult(ExecStatus.NoMatch, "Requested folder does not exist on server. Folder: " + path));
                }
                var resourceCatalogResult = ResourceCatalogue.RenameCategory(workSpaceId, path, newPath);

                if (resourceCatalogResult.Status == ExecStatus.Success)
                {
                    MoveVersionFolder(path, newPath);
                    Directory.Delete(DirectoryStructureFromPath(path), true);
                    return(new ExplorerRepositoryResult(ExecStatus.Success, ""));
                }
                if (resourceCatalogResult.Status == ExecStatus.NoMatch)
                {
                    Directory.Move(DirectoryStructureFromPath(path), DirectoryStructureFromPath(newPath));
                    MoveVersionFolder(path, newPath);
                    return(new ExplorerRepositoryResult(ExecStatus.Success, ""));
                }
                return(new ExplorerRepositoryResult(ExecStatus.Fail, resourceCatalogResult.Message));
            }
            catch (Exception err)
            {
                return(new ExplorerRepositoryResult(ExecStatus.AccessViolation, err.Message));
            }
        }
        private ResourceCatalogResult RenameChildrenPaths(string oldPath, string newName)
        {
            var resourcesToRename =
                ResourceCatalogue.GetResourceList(GlobalConstants.ServerWorkspaceID)
                .Where(a => a.GetResourcePath(GlobalConstants.ServerWorkspaceID).StartsWith(oldPath)).ToList();

            if (resourcesToRename.Count == 0)
            {
                var resourceCatalogResult = new ResourceCatalogResult {
                    Status = ExecStatus.Success
                };
                return(resourceCatalogResult);
            }
            ResourceCatalogResult result = ResourceCatalogue.RenameCategory(GlobalConstants.ServerWorkspaceID, oldPath, newName, resourcesToRename);

            return(result);
        }
Exemplo n.º 3
0
        public IExplorerRepositoryResult MoveItem(IExplorerItem itemToMove, string newPath, Guid workSpaceId)
        {
            IEnumerable <IResource> item =
                ResourceCatalogue.GetResourceList(workSpaceId)
                .Where(
                    a =>
                    (a.ResourcePath == newPath));

            if (item.Any())
            {
                return(new ExplorerRepositoryResult(ExecStatus.Fail, "There is an item that exists with the same name and path"));
            }
            MoveVersions(itemToMove, newPath);
            ResourceCatalogResult result = ResourceCatalogue.RenameCategory(workSpaceId, itemToMove.ResourcePath, newPath, new List <IResource> {
                ResourceCatalogue.GetResource(workSpaceId, itemToMove.ResourceId)
            });

            _file.Delete(string.Format("{0}.xml", DirectoryStructureFromPath(itemToMove.ResourcePath)));

            return(new ExplorerRepositoryResult(result.Status, result.Message));
        }
        IExplorerRepositoryResult MoveSingeItem(IExplorerItem itemToMove, string newPath, Guid workSpaceId)
        {
            var newResourcePath = newPath;

            if (!string.IsNullOrEmpty(itemToMove.ResourcePath))
            {
                newResourcePath = itemToMove.ResourcePath.Replace(itemToMove.ResourcePath, newPath);
            }
            var resource    = ResourceCatalogue.GetResource(workSpaceId, itemToMove.ResourceId);
            var source      = $"{DirectoryStructureFromPath(resource.GetResourcePath(GlobalConstants.ServerWorkspaceID))}.xml";
            var destination = $"{DirectoryStructureFromPath(newResourcePath)+"\\"+resource.ResourceName+".xml"}";

            if (_file.Exists(source))
            {
                _file.Move(source, destination);
            }
            ResourceCatalogResult result = ResourceCatalogue.RenameCategory(workSpaceId, resource.GetSavePath(), newResourcePath, new List <IResource> {
                resource
            });

            itemToMove.ResourcePath = newResourcePath;
            return(new ExplorerRepositoryResult(result.Status, result.Message));
        }