Compare commits

...

12 Commits

Author SHA1 Message Date
Adam Hathcock f4cc4bc77e Merge pull request #272 from specklesystems/adam/add-2026
.NET Build and Publish / build (push) Has been cancelled
fix: Update HostAppVersion.cs for 2026
2025-04-07 10:55:25 +01:00
Jonathon Broughton d395f03219 fix: Update HostAppVersion.cs
Adding v2026 for next autodesk releases support.
2025-04-07 10:10:18 +01:00
Oğuzhan Koral 3cad57ceb3 Update object instead save (#266)
.NET Build and Publish / build (push) Has been cancelled
2025-03-24 20:24:15 +03:00
Oğuzhan Koral 11937ad7c9 Handle refresh token on catch (#265)
.NET Build and Publish / build (push) Has been cancelled
2025-03-24 13:39:23 +03:00
Adam Hathcock 8210fde69a Merge pull request #264 from specklesystems/oguzhan/parameter-for-app-id-secret
.NET Build and Publish / build (push) Has been cancelled
Chore(accounts): Extract hard coded app as parameter into function
2025-03-20 15:29:50 +00:00
oguzhankoral fa6f90621e Extract hard coded app as parameter into function 2025-03-20 18:18:23 +03:00
Adam Hathcock b3f4190614 Merge pull request #260 from specklesystems/adam/fix-cancel-check
.NET Build and Publish / build (push) Has been cancelled
Cancellation check for sending needs to not be wrapped
2025-03-17 12:21:44 +00:00
Adam Hathcock 2fc0024cd2 Cancellation check for sending needs to not be wrapped 2025-03-17 12:08:42 +00:00
Adam Hathcock 300a5627fd Merge pull request #259 from specklesystems/revit-levels
.NET Build and Publish / build (push) Has been cancelled
feat(objects): adds level to revitobject
2025-03-17 11:06:13 +00:00
Claire Kuang 22f029fe33 Update RevitObject.cs 2025-03-17 10:32:47 +00:00
Claire Kuang c728266c88 Update RevitObject.cs 2025-03-17 10:31:43 +00:00
Claire Kuang 7f2d57cdad adds level 2025-03-17 10:05:41 +00:00
4 changed files with 41 additions and 17 deletions
+7
View File
@@ -12,6 +12,13 @@ public class RevitObject : DataObject, IRevitObject
public required string family { get; set; }
public required string category { get; set; }
/// <summary>
/// The level constraint of the object.
/// For objects constrained by multiple levels, this represents the base constraint.
/// For objects with no level constraint, this should be null.
/// </summary>
public required string? level { get; set; }
/// <summary>
/// A Curve or Point object representing the location of a Revit element.
/// </summary>
+31 -16
View File
@@ -399,8 +399,9 @@ public sealed class AccountManager(
/// <summary>
/// Refetches user and server info for each account
/// </summary>
/// <param name="app"> It is defaultAppId in the server. By default it is "sca" to not break existing parts that this function involves.</param>
/// <returns></returns>
public async Task UpdateAccounts(CancellationToken ct = default)
public async Task UpdateAccounts(CancellationToken ct = default, string app = "sca")
{
// need to ToList() the GetAccounts call or the UpdateObject call at the end of this method
// will not work because sqlite does not support concurrent db calls
@@ -415,16 +416,9 @@ public sealed class AccountManager(
//TODO: once we get a token expired exception from the server use that instead
if (userServerInfo?.activeUser == null || userServerInfo.serverInfo == null)
{
var tokenResponse = await GetRefreshedToken(account.refreshToken, url).ConfigureAwait(false);
userServerInfo = await GetUserServerInfo(tokenResponse.token, url, ct).ConfigureAwait(false);
if (userServerInfo?.activeUser == null || userServerInfo.serverInfo == null)
{
throw new SpeckleException("Could not refresh token");
}
account.token = tokenResponse.token;
account.refreshToken = tokenResponse.refreshToken;
// We were initially was handling refresh token here bc quite a while ago server was returning null
// for activeUser and serverInfo instead of throwing exception. In short, our logic moved into catch block to cover both.
throw new SpeckleException("Token is expired");
}
account.isOnline = true;
@@ -437,11 +431,32 @@ public sealed class AccountManager(
}
catch (Exception ex) when (!ex.IsFatal())
{
account.isOnline = false;
await RefreshAndSetAccountToken(account, app).ConfigureAwait(false);
}
ct.ThrowIfCancellationRequested();
_accountStorage.SaveObject(account.id, JsonConvert.SerializeObject(account));
_accountStorage.UpdateObject(account.id, JsonConvert.SerializeObject(account));
}
}
/// <summary>
/// Mutates the account with new tokens.
/// </summary>
/// <param name="account"></param>
/// <param name="app"></param>
private async Task RefreshAndSetAccountToken(Account account, string app)
{
try
{
Uri url = new(account.serverInfo.url);
var tokenResponse = await GetRefreshedToken(account.refreshToken, url, app).ConfigureAwait(false);
account.token = tokenResponse.token;
account.refreshToken = tokenResponse.refreshToken;
account.isOnline = true;
}
catch (Exception ex) when (!ex.IsFatal())
{
account.isOnline = false;
}
}
@@ -766,7 +781,7 @@ public sealed class AccountManager(
}
}
private async Task<TokenExchangeResponse> GetRefreshedToken(string refreshToken, Uri server)
private async Task<TokenExchangeResponse> GetRefreshedToken(string refreshToken, Uri server, string app = "sca")
{
try
{
@@ -774,8 +789,8 @@ public sealed class AccountManager(
var body = new
{
appId = "sca",
appSecret = "sca",
appId = app,
appSecret = app,
refreshToken,
};
+1
View File
@@ -13,6 +13,7 @@ public enum HostAppVersion
v2023,
v2024,
v2025,
v2026,
v21,
v22,
v25,
@@ -89,11 +89,12 @@ public sealed class SerializeProcess(
public void ThrowIfFailed()
{
//always check for cancellation first
cancellationToken.ThrowIfCancellationRequested();
if (Exception is not null)
{
throw new SpeckleException("Error while sending", Exception);
}
cancellationToken.ThrowIfCancellationRequested();
}
private async Task WaitForSchedulerCompletion()