Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing an Error Preventing the web app from running the remaining jobs after exceeding the API Quota #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions Controllers/DataManagementController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
using MongoDB.Bson;
using System.Linq;
using hubsRecursiveExtraction.Hubs;
using Autodesk.Forge.Client;

namespace hubsRecursiveExtraction.Controllers
{
Expand Down Expand Up @@ -97,21 +98,38 @@ public object GetResourceInfo()
return new { Success = true };
}

public async Task GatherData(string connectionId, string hubId, string projectId, string currentFolderId, string dataType, string projectGuid, string token)
public async Task GatherData(string connectionId, string hubId, string projectId, string currentFolderId,
string dataType, string projectGuid, string token)
{
switch (dataType)
{
case "topFolders":
await GetProjectContents(hubId, projectId, connectionId, dataType, projectGuid, token);
break;
case "folder":
await GetFolderContents(projectId, currentFolderId, connectionId, dataType, projectGuid, token);
break;
default:
break;
}
try
{
switch (dataType)
{
case "topFolders":
await GetProjectContents(hubId, projectId, connectionId, dataType, projectGuid, token);
break;
case "folder":
await GetFolderContents(projectId, currentFolderId, connectionId, dataType, projectGuid, token);
break;
default:
break;
}
}
catch (ApiException ex)
{
if (ex.ErrorCode == 429)
{
await Task.Delay(TimeSpan.FromSeconds(45));
await GatherData(connectionId, hubId, projectId, currentFolderId, dataType, projectGuid, token);
}
else
{
throw; // Re-throw the exception if it's not a Too Many Requests error
}
}
}


private async Task<IList<jsTreeNode>> GetHubsAsync()
{
IList<jsTreeNode> nodes = new List<jsTreeNode>();
Expand Down