public async Task UpdateFolderInformation_ValidRequest_Timeout()
 {
     BoxFolderRequest folderReq = new BoxFolderRequest()
     {
         Id = "0"
     };
     var       timeout = new TimeSpan(0, 0, 0, 0, 1); // 1ms timeout, should always cancel the request
     BoxFolder f       = await _client.FoldersManager.UpdateInformationAsync(folderRequest : folderReq, timeout : timeout);
 }
Exemplo n.º 2
0
 private static async Task MoveFolder(BoxItem item, BoxFolder topFolder, BoxClient auClient,
                                      TimeLimiter throttle)
 {
     var folderRequest = new BoxFolderRequest()
     {
         Id     = item.Id,
         Parent = new BoxRequestEntity()
         {
             Id = topFolder.Id
         }
     };
     await throttle;
     await auClient.FoldersManager.UpdateInformationAsync(folderRequest);
 }
Exemplo n.º 3
0
        public async Task <BoxFolder> CreateFolderWithIncreasingCount(BoxClient client, string name, string parentId, bool isIdOnly = false)
        {
            var       finished      = false;
            BoxFolder createdFolder = new BoxFolder();
            var       count         = 0;

            while (!finished)
            {
                try
                {
                    if (count > 0)
                    {
                        createdFolder = await client.FoldersManager.CreateAsync(new BoxFolderRequest()
                        {
                            Parent = new BoxRequestEntity()
                            {
                                Id = parentId
                            }, Name = $"{name} ({count})"
                        });
                    }
                    else
                    {
                        createdFolder = await client.FoldersManager.CreateAsync(new BoxFolderRequest()
                        {
                            Parent = new BoxRequestEntity()
                            {
                                Id = parentId
                            }, Name = name
                        });
                    }
                    finished = true;
                }
                catch (BoxConflictException <BoxFolder> )
                {
                    count++;
                    if (!isIdOnly)
                    {
                        Reporter.WriteInformation("Found existing folder with that name.");
                        Reporter.WriteInformation($"Adding {count} to the name and trying again");
                    }
                }
                catch (Exception e)
                {
                    Reporter.WriteError($"Couldn't create this folder.");
                    throw e;
                }
            }
            return(createdFolder);
        }