Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 11937ad7c9 | |||
| 8210fde69a | |||
| fa6f90621e | |||
| b3f4190614 | |||
| 2fc0024cd2 | |||
| 300a5627fd | |||
| 22f029fe33 | |||
| c728266c88 | |||
| 7f2d57cdad | |||
| 4e84766be9 | |||
| 73a95aded0 | |||
| ac0ab3904c | |||
| 5c9d672a2b |
+13
-5
@@ -12,7 +12,6 @@ const string BUILD = "build";
|
||||
const string TEST = "test";
|
||||
const string INTEGRATION = "integration";
|
||||
const string PACK = "pack";
|
||||
const string PACK_LOCAL = "pack-local";
|
||||
const string CLEAN_LOCKS = "clean-locks";
|
||||
const string PERF = "perf";
|
||||
const string DEEP_CLEAN = "deep-clean";
|
||||
@@ -169,10 +168,19 @@ Target(
|
||||
}
|
||||
);
|
||||
|
||||
static Task RunPack() => RunAsync("dotnet", "pack Speckle.Sdk.sln -c Release -o output --no-build");
|
||||
|
||||
Target(PACK, DependsOn(BUILD), RunPack);
|
||||
Target(PACK_LOCAL, DependsOn(BUILD), RunPack);
|
||||
Target(
|
||||
PACK,
|
||||
DependsOn(BUILD),
|
||||
async () =>
|
||||
{
|
||||
{
|
||||
var (version, fileVersion) = await GetVersions().ConfigureAwait(false);
|
||||
Console.WriteLine($"Version: {version} & {fileVersion}");
|
||||
await RunAsync("dotnet", $"pack Speckle.Sdk.sln -c Release -o output --no-build -p:Version={version}")
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Target("default", DependsOn(FORMAT, TEST, INTEGRATION), () => Console.WriteLine("Done!"));
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
using Speckle.Objects.Other;
|
||||
using Speckle.Sdk.Common;
|
||||
using Speckle.Sdk.Models;
|
||||
|
||||
namespace Speckle.Objects.Geometry;
|
||||
|
||||
/// <summary>
|
||||
/// Flat polygon, defined by an outer boundary and inner loops.
|
||||
/// </summary>
|
||||
[SpeckleType("Objects.Geometry.Region")]
|
||||
public class Region : Base, IHasArea, IHasBoundingBox, ITransformable, IDisplayValue<List<Mesh>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Boundary of a region.
|
||||
/// Should be a planar, closed, non-self-intersecting ICurve.
|
||||
/// </summary>
|
||||
public required ICurve boundary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Loops (voids) in the region.
|
||||
/// Each loop should be planar, closed, non-self-intersecting ICurve, located inside the boundary.
|
||||
/// The loops should not intersect or touch each other.
|
||||
/// </summary>
|
||||
public required List<ICurve> innerLoops { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// The units of object's coordinates.
|
||||
/// This should be one of <see cref="Units"/>
|
||||
/// </summary>
|
||||
public required string units { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indication whether the region is just a geometry (false) or has a hatch pattern (true).
|
||||
/// It's a distinction for receiving in apps that support both Region and Hatch (aka region with hatch pattern)
|
||||
/// </summary>
|
||||
public required bool hasHatchPattern { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public double area { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Box? bbox { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
[DetachProperty]
|
||||
public List<Mesh> displayValue { get; set; } = new();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool TransformTo(Transform transform, out ITransformable transformed)
|
||||
{
|
||||
// assign self to the returned object, in case transformation fails
|
||||
transformed = this;
|
||||
|
||||
// transform boundary
|
||||
if (boundary is ITransformable boundaryTransformable)
|
||||
{
|
||||
boundaryTransformable.TransformTo(transform, out ITransformable transformedBoundaryResult);
|
||||
var transformedBoundary = (ICurve)transformedBoundaryResult;
|
||||
|
||||
// transform inner loops
|
||||
var transformedLoops = new List<ICurve>();
|
||||
foreach (var loop in innerLoops)
|
||||
{
|
||||
if (loop is ITransformable loopTransformable)
|
||||
{
|
||||
loopTransformable.TransformTo(transform, out ITransformable transformedLoop);
|
||||
transformedLoops.Add((ICurve)transformedLoop);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// transform display meshes
|
||||
var transformedMeshes = new List<Mesh>();
|
||||
foreach (var mesh in displayValue)
|
||||
{
|
||||
mesh.TransformTo(transform, out ITransformable transformedMesh);
|
||||
transformedMeshes.Add((Mesh)transformedMesh);
|
||||
}
|
||||
|
||||
// if boundary and loops transformations succeeded
|
||||
transformed = new Region
|
||||
{
|
||||
boundary = transformedBoundary,
|
||||
innerLoops = transformedLoops,
|
||||
hasHatchPattern = hasHatchPattern,
|
||||
displayValue = transformedMeshes,
|
||||
units = units,
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -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,7 +431,7 @@ public sealed class AccountManager(
|
||||
}
|
||||
catch (Exception ex) when (!ex.IsFatal())
|
||||
{
|
||||
account.isOnline = false;
|
||||
await RefreshAndSetAccountToken(account, app).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
ct.ThrowIfCancellationRequested();
|
||||
@@ -445,6 +439,27 @@ public sealed class AccountManager(
|
||||
}
|
||||
}
|
||||
|
||||
/// <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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes an account
|
||||
/// </summary>
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user