示例#1
0
        public async Task <GetFoldersResponse> GetFolders([Required] string path, [Range(1, int.MaxValue)] int count = 5, bool suppressAccessErrors = false, CancellationToken cancellation = default)
        {
            var folders = await _fileService.GetBigFolders(path, count,
                                                           suppressAccessErrors, cancellation);

            var result = new GetFoldersResponse()
            {
                Paths = folders
            };

            return(result);
        }
示例#2
0
        private static async Task <List <string> > GetSubFolderIDsAsync(MarketoClient client, string rootFolderId)
        {
            //var client = new MarketoClient(apiConfig.Host, apiConfig.ClientId, apiConfig.ClientSecret);
            GetFoldersResponse result = await client.GetFolders(rootFolderId);

            List <string> folderIDs = new List <string>();

            if (result.Result == null)
            {
                return(folderIDs);
            }
            folderIDs.AddRange(result.Result.Select(folder => folder.Id.ToString()));
            return(folderIDs);
        }
示例#3
0
        private List <string> GetSubFolderIDs(string host, string clientId, string clientSecret, string rootFolderId)
        {
            MarketoClient      client    = new MarketoClient(host, clientId, clientSecret);
            GetFoldersResponse result    = client.GetFolders(rootFolderId).Result;
            List <string>      folderIDs = new List <string>();

            if (result.Result != null)
            {
                foreach (MarketoFolder folder in result.Result)
                {
                    folderIDs.Add(folder.Id.ToString());
                }
            }
            return(folderIDs);
        }
示例#4
0
 private static List<string> GetSubFolderIDs(string host, string clientId, string clientSecret, string rootFolderId)
 {
     MarketoClient client = new MarketoClient(host, clientId, clientSecret);
     GetFoldersResponse result = client.GetFolders(rootFolderId).Result;
     List<string> folderIDs = new List<string>();
     if (result.Result != null)
     {
         foreach (MarketoFolder folder in result.Result)
         {
             folderIDs.Add(folder.Id.ToString());
         }
     }
     return folderIDs;
     //string prettyJson = JToken.Parse(result).ToString(Formatting.Indented);
 }
        public IActionResult GetFolder(Guid folderId)
        {
            string folderName = "root";

            if (folderId != Guid.Empty)
            {
                var currentFolder = _folderRepo.Where(f => f.Id == folderId).FirstOrDefault();

                if (currentFolder == null)
                {
                    return(BadRequest("Папка не найдена!"));
                }

                folderId   = currentFolder.Id;
                folderName = currentFolder.FolderName;
            }

            if (folderId != Guid.Empty && !UserHasRole(folderId, AccessLevel.Read))
            {
                return(BadRequest("Не достаточно уровня прав доступа!"));
            }

            var childFolders = _folderService.GetSubFolders(folderId, UserContext.Id);

            var response = new GetFoldersResponse
            {
                Folder = new FolderDescription
                {
                    FolderId   = folderId,
                    FolderName = folderName,
                    Folders    = childFolders.Select(f => new ChildFolder {
                        FolderName = f.FolderName, FolderId = f.Id
                    }).ToList(),
                    FullPath = _folderService.GetFullPath(folderId),
                    Files    = _folderService.GetFiles(folderId),
                    Owners   = _db.Set <UsersFolders>().Where(uf => uf.FolderId == folderId && uf.AccessLevel == AccessLevel.Owner).Select(uf => _db.Users.First(u => u.Id == uf.UserId).Username).ToList()
                }
            };

            return(Ok(response));
        }