Skip to content

Commit

Permalink
DUI3-126 shared files (#12)
Browse files Browse the repository at this point in the history
* Account service to get account first from id otherwise from server Url

- And other simplications, removing dup code etc.

* Add TransportException to all bindings

* Register AccountService as singleton and add doc
  • Loading branch information
oguzhankoral authored Jul 9, 2024
1 parent 9d0635c commit 7cdf863
Show file tree
Hide file tree
Showing 42 changed files with 217 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Speckle.Connectors.Utils;
using Speckle.Connectors.Utils.Cancellation;
using Speckle.Connectors.Utils.Operations;
using Speckle.Core.Transports;

namespace Speckle.Connectors.ArcGIS.Bindings;

Expand Down Expand Up @@ -52,11 +53,7 @@ public async Task Receive(string modelCardId)
// Receive host objects
var receiveOperationResults = await unitOfWork.Service
.Execute(
modelCard.AccountId.NotNull(), // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils
modelCard.ProjectId.NotNull(),
modelCard.ProjectName.NotNull(),
modelCard.ModelName.NotNull(),
modelCard.SelectedVersionId.NotNull(),
modelCard.GetReceiveInfo(),
cts.Token,
(status, progress) =>
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts)
Expand All @@ -70,6 +67,10 @@ public async Task Receive(string modelCardId)
receiveOperationResults.ConversionResults
);
}
catch (TransportException e)
{
Commands.SetModelError(modelCardId, e);
}
// Catch here specific exceptions if they related to model card.
catch (OperationCanceledException)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Speckle.Connectors.Utils;
using Speckle.Connectors.Utils.Caching;
using Speckle.Connectors.Utils.Operations;
using Speckle.Core.Transports;

namespace Speckle.Connectors.ArcGIS.Bindings;

Expand Down Expand Up @@ -321,13 +322,6 @@ public async Task Send(string modelCardId)
// Init cancellation token source -> Manager also cancel it if exist before
CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId);

var sendInfo = new SendInfo(
modelCard.AccountId.NotNull(),
modelCard.ProjectId.NotNull(),
modelCard.ModelId.NotNull(),
"ArcGIS"
);

var sendResult = await QueuedTask
.Run(async () =>
{
Expand All @@ -349,7 +343,7 @@ public async Task Send(string modelCardId)
var result = await unitOfWork.Service
.Execute(
mapMembers,
sendInfo,
modelCard.GetSendInfo("ArcGIS"), // POC: get host app name from settings?
(status, progress) =>
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts),
cts.Token
Expand All @@ -367,6 +361,10 @@ public async Task Send(string modelCardId)
{
Commands.SetModelError(modelCardId, e);
}
catch (TransportException e)
{
Commands.SetModelError(modelCardId, e);
}
catch (OperationCanceledException)
{
// SWALLOW -> UI handles it immediately, so we do not need to handle anything
Expand Down
10 changes: 5 additions & 5 deletions Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
"Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )",
"Speckle.Autofac": "[1.0.0, )",
"Speckle.Connectors.Utils": "[1.0.0, )",
"Speckle.Core": "[3.0.1-alpha.14, )",
"Speckle.Core": "[3.0.1-alpha.15, )",
"System.Threading.Tasks.Dataflow": "[6.0.0, )"
}
},
Expand All @@ -399,7 +399,7 @@
"dependencies": {
"Serilog.Extensions.Logging": "[7.0.0, )",
"Speckle.Autofac": "[1.0.0, )",
"Speckle.Core": "[3.0.1-alpha.14, )"
"Speckle.Core": "[3.0.1-alpha.15, )"
}
},
"speckle.converters.arcgis3": {
Expand Down Expand Up @@ -455,9 +455,9 @@
},
"Speckle.Core": {
"type": "CentralTransitive",
"requested": "[3.0.1-alpha.14, )",
"resolved": "3.0.1-alpha.14",
"contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==",
"requested": "[3.0.1-alpha.15, )",
"resolved": "3.0.1-alpha.15",
"contentHash": "khv7uLeMMZ5JKJi3NZtz2nti7YPFGQiqllIDqVuNAl8hbqJ52t6OWyOJ87n0sthvGtAO2SpaLik3f+Fh5G/7ww==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.CSharp": "4.7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@
"Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )",
"Speckle.Autofac": "[1.0.0, )",
"Speckle.Connectors.Utils": "[1.0.0, )",
"Speckle.Core": "[3.0.1-alpha.14, )",
"Speckle.Core": "[3.0.1-alpha.15, )",
"System.Threading.Tasks.Dataflow": "[6.0.0, )"
}
},
Expand All @@ -452,7 +452,7 @@
"dependencies": {
"Serilog.Extensions.Logging": "[7.0.0, )",
"Speckle.Autofac": "[1.0.0, )",
"Speckle.Core": "[3.0.1-alpha.14, )"
"Speckle.Core": "[3.0.1-alpha.15, )"
}
},
"speckle.converters.autocad2023": {
Expand Down Expand Up @@ -511,9 +511,9 @@
},
"Speckle.Core": {
"type": "CentralTransitive",
"requested": "[3.0.1-alpha.14, )",
"resolved": "3.0.1-alpha.14",
"contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==",
"requested": "[3.0.1-alpha.15, )",
"resolved": "3.0.1-alpha.15",
"contentHash": "khv7uLeMMZ5JKJi3NZtz2nti7YPFGQiqllIDqVuNAl8hbqJ52t6OWyOJ87n0sthvGtAO2SpaLik3f+Fh5G/7ww==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.CSharp": "4.7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Speckle.Connectors.DUI.Models.Card;
using Speckle.Connectors.Utils;
using Speckle.Connectors.Utils.Operations;
using Speckle.Core.Transports;

namespace Speckle.Connectors.Autocad.Bindings;

Expand Down Expand Up @@ -59,11 +60,7 @@ public async Task Receive(string modelCardId)
// Receive host objects
var operationResults = await unitOfWork.Service
.Execute(
modelCard.AccountId.NotNull(), // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils
modelCard.ProjectId.NotNull(),
modelCard.ProjectName.NotNull(),
modelCard.ModelName.NotNull(),
modelCard.SelectedVersionId.NotNull(),
modelCard.GetReceiveInfo(),
cts.Token,
(status, progress) =>
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts)
Expand All @@ -78,6 +75,10 @@ public async Task Receive(string modelCardId)
// SWALLOW -> UI handles it immediately, so we do not need to handle anything
return;
}
catch (TransportException e)
{
Commands.SetModelError(modelCardId, e);
}
finally
{
// renable document activation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Speckle.Connectors.DUI.Models.Card.SendFilter;
using Speckle.Connectors.Utils;
using Speckle.Connectors.Utils.Caching;
using Speckle.Core.Transports;

namespace Speckle.Connectors.Autocad.Bindings;

Expand Down Expand Up @@ -156,17 +157,10 @@ private async Task SendInternal(string modelCardId)
throw new SpeckleSendFilterException("No objects were found to convert. Please update your publish filter!");
}

var sendInfo = new SendInfo(
modelCard.AccountId.NotNull(),
modelCard.ProjectId.NotNull(),
modelCard.ModelId.NotNull(),
_autocadSettings.HostAppInfo.Name
);

var sendResult = await uow.Service
.Execute(
autocadObjects,
sendInfo,
modelCard.GetSendInfo(_autocadSettings.HostAppInfo.Name),
(status, progress) =>
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts),
cts.Token
Expand All @@ -181,6 +175,10 @@ private async Task SendInternal(string modelCardId)
// SWALLOW -> UI handles it immediately, so we do not need to handle anything
return;
}
catch (TransportException e)
{
Commands.SetModelError(modelCardId, e);
}
catch (SpeckleSendFilterException e)
{
Commands.SetModelError(modelCardId, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@
"Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )",
"Speckle.Autofac": "[1.0.0, )",
"Speckle.Connectors.Utils": "[1.0.0, )",
"Speckle.Core": "[3.0.1-alpha.14, )",
"Speckle.Core": "[3.0.1-alpha.15, )",
"System.Threading.Tasks.Dataflow": "[6.0.0, )"
}
},
Expand All @@ -461,7 +461,7 @@
"dependencies": {
"Serilog.Extensions.Logging": "[7.0.0, )",
"Speckle.Autofac": "[1.0.0, )",
"Speckle.Core": "[3.0.1-alpha.14, )"
"Speckle.Core": "[3.0.1-alpha.15, )"
}
},
"speckle.converters.civil3d2024": {
Expand Down Expand Up @@ -521,9 +521,9 @@
},
"Speckle.Core": {
"type": "CentralTransitive",
"requested": "[3.0.1-alpha.14, )",
"resolved": "3.0.1-alpha.14",
"contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==",
"requested": "[3.0.1-alpha.15, )",
"resolved": "3.0.1-alpha.15",
"contentHash": "khv7uLeMMZ5JKJi3NZtz2nti7YPFGQiqllIDqVuNAl8hbqJ52t6OWyOJ87n0sthvGtAO2SpaLik3f+Fh5G/7ww==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.CSharp": "4.7.0",
Expand Down
10 changes: 5 additions & 5 deletions Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@
"Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )",
"Speckle.Autofac": "[1.0.0, )",
"Speckle.Connectors.Utils": "[1.0.0, )",
"Speckle.Core": "[3.0.1-alpha.14, )",
"Speckle.Core": "[3.0.1-alpha.15, )",
"System.Threading.Tasks.Dataflow": "[6.0.0, )"
}
},
Expand All @@ -463,7 +463,7 @@
"dependencies": {
"Serilog.Extensions.Logging": "[7.0.0, )",
"Speckle.Autofac": "[1.0.0, )",
"Speckle.Core": "[3.0.1-alpha.14, )"
"Speckle.Core": "[3.0.1-alpha.15, )"
}
},
"speckle.converters.common": {
Expand Down Expand Up @@ -517,9 +517,9 @@
},
"Speckle.Core": {
"type": "CentralTransitive",
"requested": "[3.0.1-alpha.14, )",
"resolved": "3.0.1-alpha.14",
"contentHash": "RzQPVIGFFkKvG56YLr8ACtiwdWJE6IJ9vCQ4qHa0PIsUEpfzAIAi59jnzqtByOFC0FiFrFPow9bkfzylaZorAA==",
"requested": "[3.0.1-alpha.15, )",
"resolved": "3.0.1-alpha.15",
"contentHash": "khv7uLeMMZ5JKJi3NZtz2nti7YPFGQiqllIDqVuNAl8hbqJ52t6OWyOJ87n0sthvGtAO2SpaLik3f+Fh5G/7ww==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.CSharp": "4.7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Speckle.Connectors.Utils.Operations;
using Speckle.Autofac.DependencyInjection;
using Speckle.Connectors.Utils;
using Speckle.Core.Transports;

namespace Speckle.Connectors.Revit.Bindings;

Expand Down Expand Up @@ -54,11 +55,7 @@ public async Task Receive(string modelCardId)
// Receive host objects
HostObjectBuilderResult conversionResults = await unitOfWork.Service
.Execute(
modelCard.AccountId.NotNull(), // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils
modelCard.ProjectId.NotNull(),
modelCard.ProjectName.NotNull(),
modelCard.ModelName.NotNull(),
modelCard.SelectedVersionId.NotNull(),
modelCard.GetReceiveInfo(),
cts.Token,
(status, progress) =>
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts)
Expand All @@ -72,6 +69,10 @@ public async Task Receive(string modelCardId)
conversionResults.ConversionResults
);
}
catch (TransportException e)
{
Commands.SetModelError(modelCardId, e);
}
// Catch here specific exceptions if they related to model card.
catch (OperationCanceledException)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Speckle.Connectors.Utils.Caching;
using Speckle.Connectors.Utils.Cancellation;
using Speckle.Connectors.Utils.Operations;
using Speckle.Core.Transports;

namespace Speckle.Connectors.Revit.Bindings;

Expand Down Expand Up @@ -101,17 +102,10 @@ public async Task Send(string modelCardId)
throw new SpeckleSendFilterException("No objects were found to convert. Please update your publish filter!");
}

var sendInfo = new SendInfo(
modelCard.AccountId.NotNull(),
modelCard.ProjectId.NotNull(),
modelCard.ModelId.NotNull(),
_revitSettings.HostSlug.NotNull()
);

var sendResult = await sendOperation.Service
.Execute(
revitObjects,
sendInfo,
modelCard.GetSendInfo(_revitSettings.HostSlug.NotNull()),
(status, progress) =>
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts),
cts.Token
Expand All @@ -125,6 +119,10 @@ public async Task Send(string modelCardId)
{
Commands.SetModelError(modelCardId, e);
}
catch (TransportException e)
{
Commands.SetModelError(modelCardId, e);
}
catch (OperationCanceledException)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Speckle.Connectors.Utils.Builders;
using Speckle.Connectors.Utils.Cancellation;
using Speckle.Connectors.Utils.Operations;
using Speckle.Core.Transports;

namespace Speckle.Connectors.Rhino7.Bindings;

Expand Down Expand Up @@ -54,11 +55,7 @@ public async Task Receive(string modelCardId)
// Receive host objects
HostObjectBuilderResult conversionResults = await unitOfWork.Service
.Execute(
modelCard.AccountId.NotNull(), // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils
modelCard.ProjectId.NotNull(),
modelCard.ProjectName.NotNull(),
modelCard.ModelName.NotNull(),
modelCard.SelectedVersionId.NotNull(),
modelCard.GetReceiveInfo(),
cts.Token,
(status, progress) =>
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts)
Expand All @@ -72,6 +69,10 @@ public async Task Receive(string modelCardId)
conversionResults.ConversionResults
);
}
catch (TransportException e)
{
Commands.SetModelError(modelCardId, e);
}
// Catch here specific exceptions if they related to model card.
catch (OperationCanceledException)
{
Expand Down
Loading

0 comments on commit 7cdf863

Please sign in to comment.