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

Threading revamp: add ThreadContext and remove Dataflow usage #400

Open
wants to merge 202 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
202 commits
Select commit Hold shift + click to select a range
1f1d5d2
Merge branch 'dev' into jsdb/navisworks
jsdbroughton Nov 5, 2024
4e3aa2f
Merge branch 'dev' into jsdb/navisworks
jsdbroughton Nov 5, 2024
3a4c1c7
Navisworks Connector Init
jsdbroughton Nov 5, 2024
f843767
Build crap
jsdbroughton Nov 6, 2024
ade588f
Moar Init
jsdbroughton Nov 6, 2024
01d5c9b
WIP - not yet working
jsdbroughton Nov 8, 2024
dec5ac0
Merge branch 'dev' into jsdb/navisworks
jsdbroughton Nov 8, 2024
088dfb9
Minor fixes
oguzhankoral Nov 14, 2024
a49d858
Fix missing constuctors
oguzhankoral Nov 14, 2024
6c97e4b
unfix
jsdbroughton Nov 16, 2024
e6314ec
Test commit
jsdbroughton Nov 19, 2024
7c9674a
Test commit
jsdbroughton Nov 19, 2024
c09fd83
Remove Dataflow usage
adamhathcock Nov 21, 2024
01cd963
format and remove dep
adamhathcock Nov 21, 2024
f251e4a
Merge branch 'dev' into remove-dataflow
adamhathcock Nov 22, 2024
6074b2c
merge fixes
adamhathcock Nov 22, 2024
49de3d1
Fix serializer
adamhathcock Nov 22, 2024
0ffdf6c
Add MainThreadContext
adamhathcock Nov 22, 2024
684a295
add some main context detection
adamhathcock Nov 22, 2024
ecbaed1
add RevitMainThreadContext
adamhathcock Nov 22, 2024
c1ddbc3
remove revit async?
adamhathcock Nov 22, 2024
8b2a437
Handle Document Events
jsdbroughton Nov 22, 2024
252f1a5
Document Model Store
jsdbroughton Nov 22, 2024
fe28352
Proper implementation
jsdbroughton Nov 22, 2024
7cef65f
Merge branch 'dev' into jsdb/navisworks
jsdbroughton Nov 22, 2024
43a77c0
package updates
jsdbroughton Nov 22, 2024
bb83476
updated to dev
jsdbroughton Nov 22, 2024
fc41f62
Document Events binding ???
jsdbroughton Nov 23, 2024
15978ce
registration order
jsdbroughton Nov 23, 2024
1b61748
Minimised events subscribed and handle new document state to clear mo…
jsdbroughton Nov 23, 2024
36f0abd
Stub Send command
jsdbroughton Nov 23, 2024
dcab8e3
Refactor Connector class to change access modifier of Container property
jsdbroughton Nov 23, 2024
3b2954b
Fix NavisworksDocumentStore model list initialization and document va…
jsdbroughton Nov 23, 2024
55af7dc
Effectively debouncing on the SDI changes events
jsdbroughton Nov 23, 2024
a85a687
Get Selected Objects
jsdbroughton Nov 23, 2024
bb88925
ElementSelectionExtension is a collection of helpers to aid the resol…
jsdbroughton Nov 23, 2024
775a011
[Navisworks] Manage document and model state changes
jsdbroughton Nov 23, 2024
d03a3f1
formatting
adamhathcock Nov 25, 2024
cc5e99f
use mainThreadContext
adamhathcock Nov 25, 2024
5a5de75
Use more MainThreadContext
adamhathcock Nov 25, 2024
e35107b
Update Navisworks API references and fix typos
jsdbroughton Nov 25, 2024
4cf46fe
Add Navisworks2024 converter dependencies and update project references
jsdbroughton Nov 25, 2024
24f9331
feat: Add NavisworksSendBinding changes
jsdbroughton Nov 25, 2024
c893d8c
Update namespace in Navisworks plugin files
jsdbroughton Nov 26, 2024
e28a0e8
Add Navisworks sending operations and converters
jsdbroughton Nov 26, 2024
474a316
Add folder to project items
jsdbroughton Nov 26, 2024
934f829
Refactor NavisworksConversionSettings class to use properties instead…
jsdbroughton Nov 26, 2024
378faef
Add Navisworks conversion settings factory and store initialization
jsdbroughton Nov 26, 2024
146af34
Change element selection path separator from '.' to '/' in ElementSel…
jsdbroughton Nov 26, 2024
486ec47
Add Navisworks model item to Speckle converter
jsdbroughton Nov 26, 2024
0940fe7
some rearranging
adamhathcock Nov 26, 2024
4ee6d04
renaming
adamhathcock Nov 26, 2024
a7699f0
Revit needs new run async
adamhathcock Nov 26, 2024
21441cd
Merge branch 'dev' into remove-dataflow
adamhathcock Nov 26, 2024
25cbbb4
merge fixes
adamhathcock Nov 26, 2024
e38102f
gather on worker, convert on main
adamhathcock Nov 26, 2024
ca2ab46
Merge branch 'dev' into jsdb/navisworks
jsdbroughton Nov 26, 2024
81b7aec
Update Speckle.Objects and Speckle.Sdk versions to 3.1.0-dev.200
jsdbroughton Nov 26, 2024
3644054
operations know threading but not host apps
adamhathcock Nov 26, 2024
9a88f0b
Add Navisworks and 2024 projects, along with their connectors and con…
jsdbroughton Nov 26, 2024
d416e76
rhino options
adamhathcock Nov 27, 2024
9c83cee
revit can receive
adamhathcock Nov 27, 2024
8708779
autocad in progress
adamhathcock Nov 27, 2024
ca6ce6c
need to yield for UI thread async
adamhathcock Nov 27, 2024
ea45057
revamp yield
adamhathcock Nov 27, 2024
2971a5e
Found APIContext and removed it
adamhathcock Nov 27, 2024
05eba25
ArcGIS runs all workers on MCT thread
adamhathcock Nov 27, 2024
7450a29
Merge branch 'dev' into remove-dataflow
adamhathcock Nov 27, 2024
b59b37d
Refactor ThreadContext and ArcGIS saving is always on a worker
adamhathcock Nov 28, 2024
d826a3e
Revit threading is simplier?
adamhathcock Nov 28, 2024
2e437cb
ArcGIS can not always go to the queued task
adamhathcock Nov 28, 2024
4b24584
format
adamhathcock Nov 28, 2024
7a71b5d
fix tekla compile errors
adamhathcock Nov 28, 2024
d0dae86
Merge remote-tracking branch 'origin/dev' into remove-dataflow
adamhathcock Nov 29, 2024
9bdcdeb
Merge branch 'dev' into remove-dataflow
adamhathcock Nov 29, 2024
3c0a84e
update etabs
adamhathcock Nov 29, 2024
20ecbad
thread context
adamhathcock Nov 29, 2024
54dfd05
autocad threading?
adamhathcock Nov 29, 2024
bdf698a
Add Navisworks conversion settings and modes
jsdbroughton Nov 30, 2024
1aacc4a
Add ArrayExtensions.cs for converting arrays to generic type arrays
jsdbroughton Nov 30, 2024
810e6c6
Delete Navisworks converters
jsdbroughton Nov 30, 2024
8e0584f
Add new classes for double-precision geometric primitives and transfo…
jsdbroughton Nov 30, 2024
85666c4
Add NavisworksObject and NavisworksGeometryObject classes
jsdbroughton Nov 30, 2024
cc5a402
Add ClassPropertiesExtractor, DisplayValueExtractor, and PropertySets…
jsdbroughton Nov 30, 2024
e46bebb
feat: Add ExcludeProperties option to NavisworksConversionSettings
jsdbroughton Nov 30, 2024
98d7e4d
feat: Add ModelItemTopLevelConverterToSpeckle
jsdbroughton Nov 30, 2024
1981269
Add ModelPropertiesExtractor to NavisworksShared
jsdbroughton Nov 30, 2024
7c708d6
Refactor PropertyHelpers to handle property conversion and sanitization
jsdbroughton Dec 1, 2024
9954bca
feat: Add property set extraction logic
jsdbroughton Dec 1, 2024
86c8052
Refactor ModelItemTopLevelConverterToSpeckle: Add IRootToSpeckleConve…
jsdbroughton Dec 1, 2024
720d522
Add Navisworks 2020 - 2025
jsdbroughton Dec 1, 2024
d3c9cfc
Update DocumentModelStore.cs
jsdbroughton Dec 1, 2024
5ab69c1
Add BoundingBoxToSpeckleRawConverter
jsdbroughton Dec 1, 2024
a445dea
Fix null reference exception in NavisworksRootObjectBuilder.cs
jsdbroughton Dec 1, 2024
2152714
Refactor NavisworksBasicConnectorBinding and NavisworksSendBinding
jsdbroughton Dec 1, 2024
3c97749
Update NavisworksServiceRegistration.cs
jsdbroughton Dec 1, 2024
2382a38
Refactor NavisworksDocumentModelStore to updated API
jsdbroughton Dec 1, 2024
78219c3
Refactor data extractors in Navisworks converter
jsdbroughton Dec 1, 2024
0678562
Update GlobalUsing.cs: Remove unnecessary global using statement
jsdbroughton Dec 1, 2024
5c3da64
Add NavisworksPrimitiveProcessor and PrimitiveProcessor classes
jsdbroughton Dec 1, 2024
30042ac
feat: Add internal modifier to VectorMatch method
jsdbroughton Dec 1, 2024
4f593ea
Change origin mode constants to use camel case and update related cal…
jsdbroughton Dec 1, 2024
42e61dd
Add NavisworksPrimitiveProcessor and BoundingBoxToSpeckleRawConverter
jsdbroughton Dec 1, 2024
72cd2d4
Add support for Speckle connectors in Navisworks versions 2020 to 2025.
jsdbroughton Dec 1, 2024
f8333c0
Add database transaction for table creation in NavisworksDocumentMode…
jsdbroughton Dec 1, 2024
028f21f
Update Navisworks connectors to include Speckle.Connectors.DUI depend…
jsdbroughton Dec 1, 2024
5275f07
Refactor NavisworksSendBinding constructor parameters and dependencies
jsdbroughton Dec 1, 2024
7ffd7b4
Bruh!!
jsdbroughton Dec 1, 2024
023e068
Add NavisworksRootObjectBuilder and related settings classes for send…
jsdbroughton Dec 1, 2024
b290b83
Refactor conversion mode and origin mode enums
jsdbroughton Dec 1, 2024
9b022ef
feat: Add new settings to NavisworksSendBinding and remove unused import
jsdbroughton Dec 1, 2024
48fb155
Update Navisworks connector service registration and settings manager
jsdbroughton Dec 2, 2024
6f796ce
Add project references to DUI and Navisworks converters in Navisworks…
jsdbroughton Dec 2, 2024
e5b30d6
here we go again
jsdbroughton Dec 2, 2024
4113d30
FFS - Cyclical relationships or missing assemblies
jsdbroughton Dec 2, 2024
2af2305
FFS
jsdbroughton Dec 2, 2024
1827079
Update NavisworksConnectorServiceRegistration.cs
jsdbroughton Dec 2, 2024
910d4ea
Update NavisworksSendBinding to use ToSpeckleSettingsManagerNaviswork…
jsdbroughton Dec 2, 2024
e7e6df0
Merge branch 'dev' into remove-dataflow
adamhathcock Dec 2, 2024
287b719
merge fixes
adamhathcock Dec 2, 2024
cf6383d
Refactor NavisworksObjects.cs: Improve object representation and prop…
jsdbroughton Dec 2, 2024
3c15786
Refactor display value extraction and object creation in Navisworks c…
jsdbroughton Dec 2, 2024
4b5e945
Merge branch 'dev' into jsdb/navisworks
jsdbroughton Dec 2, 2024
01abbb9
Update Speckle SDK and Objects to version 3.1.0-dev.203 in Navisworks…
jsdbroughton Dec 2, 2024
8b3fb98
remove more async
adamhathcock Dec 2, 2024
0ae2676
clean up
adamhathcock Dec 2, 2024
6f23d90
Merge branch 'dev' into remove-dataflow
adamhathcock Dec 3, 2024
8954a93
Merge branch 'dev' into remove-dataflow
adamhathcock Dec 3, 2024
d5f6323
can build agian
adamhathcock Dec 3, 2024
caac2a7
Use valuetask
adamhathcock Dec 3, 2024
4a7a961
Merge remote-tracking branch 'origin/dev' into remove-dataflow
adamhathcock Dec 3, 2024
1ea4acb
fmt
adamhathcock Dec 3, 2024
027b0cc
fix up some bridge execution to be sync
adamhathcock Dec 3, 2024
54d3db1
Refactor NavisworksRootObjectBuilder.cs: Improve initialization of ro…
jsdbroughton Dec 3, 2024
2442990
Fix logger import in NavisworksRootObjectBuilder.cs
jsdbroughton Dec 3, 2024
c0cc150
Refactor ClassPropertiesExtractor to simplify GetClassProperties method
jsdbroughton Dec 3, 2024
cd6d595
Fix static method in DisplayValueExtractor
jsdbroughton Dec 3, 2024
5086f45
Add BasePropertyHandler, HierarchicalPropertyHandler, IPropertyHandle…
jsdbroughton Dec 3, 2024
df99d96
Refactor class hierarchy and method signatures for Navisworks conversion
jsdbroughton Dec 4, 2024
90e5398
Add ElementSelectionHelper class for working with Navisworks ModelIte…
jsdbroughton Dec 4, 2024
7f61d95
cleanup
adamhathcock Dec 4, 2024
9730b6d
WIP on jsdb/navisworks
jsdbroughton Dec 4, 2024
0301b57
Merge branch 'dev' into jsdb/navisworks
jsdbroughton Dec 4, 2024
58ef164
Update Speckle.Objects to version 3.1.0-dev.205 in Navisworks connect…
jsdbroughton Dec 4, 2024
2dfc5b2
Fix reserved term replacement in PropertyHelpers.cs
jsdbroughton Dec 4, 2024
114064a
Refactor property handlers and model objects
jsdbroughton Dec 4, 2024
3ea7080
Refactor model item name retrieval logic in ModelItemTopLevelConverte…
jsdbroughton Dec 4, 2024
14c85a9
Whitespace in property name conversion to _ in PropertyHelpers.cs
jsdbroughton Dec 4, 2024
b6711b7
Add GeometryNodeMerger class to handle merging of sibling geometry no…
jsdbroughton Dec 4, 2024
d59f95f
modify GeometryNodeMerger.cs and NavisworksRootObjectBuilder.cs
jsdbroughton Dec 5, 2024
7927d5a
add some non async paths for progress
adamhathcock Dec 5, 2024
5548ac8
format
adamhathcock Dec 5, 2024
10d9f3b
remove needless selection
adamhathcock Dec 5, 2024
b79f34a
Initialize root collection, convert and store model items, process an…
jsdbroughton Dec 5, 2024
0c6c884
Add NavisworksMaterialUnpacker class for unpacking render materials
jsdbroughton Dec 5, 2024
7679963
Add `NavisworksMaterialUnpacker` to `NavisworksRootObjectBuilder` con…
jsdbroughton Dec 5, 2024
623b3d9
Merge branch 'dev' into jsdb/navisworks
jsdbroughton Dec 5, 2024
5cb81ce
Update Speckle.Objects to version 3.1.0-dev.212 in Navisworks connect…
jsdbroughton Dec 6, 2024
72b7833
Add NavisworksObject to finalElements in NavisworksRootObjectBuilder
jsdbroughton Dec 6, 2024
ab21e54
Add applicationId to NavisworksRootObjectBuilder
jsdbroughton Dec 6, 2024
173fbfe
RunOnMainThreadAsync implemented
jsdbroughton Dec 6, 2024
99a4ec5
Merge branch 'dev' into jsdb/navisworks
jsdbroughton Dec 6, 2024
381d50d
Restore DocumentModelStore.cs accessibility - not sure when that changed
jsdbroughton Dec 6, 2024
5274335
Refactor NavisworksConnectorServiceRegistration and NavisworksDocumen…
jsdbroughton Dec 6, 2024
5cb379f
Delete Navisworks solution file
jsdbroughton Dec 6, 2024
eed4dcc
Delete packages.lock.json
jsdbroughton Dec 7, 2024
bf387df
Remove Navisworks 2025
jsdbroughton Dec 7, 2024
1c2801f
Reset Navisworks project references and project names
jsdbroughton Dec 7, 2024
263dfac
Update Microsoft.Web.WebView2 package to version 1.0.2088.41 in Autoc…
jsdbroughton Dec 7, 2024
8893c7f
Reset Navisworks project references and project names
jsdbroughton Dec 7, 2024
e690786
Update Microsoft.Web.WebView2 version to [1.0.1938.49, ) in Autocad a…
jsdbroughton Dec 7, 2024
8a40017
Refactor to avoid the early disposal of COM objects
jsdbroughton Dec 7, 2024
06b86de
feat: Add geometry conversion functionality
jsdbroughton Dec 7, 2024
7ff7af3
Rename GeomtryNodeMerger.cs to GeometryNodeMerger.cs
jsdbroughton Dec 7, 2024
889acb2
Remove redundant code shared by both projects
jsdbroughton Dec 8, 2024
ae4b9db
Merge branch 'dev' into remove-dataflow
adamhathcock Dec 9, 2024
2210506
fix lock files
adamhathcock Dec 9, 2024
4225d6d
cannot make null valuetasks
adamhathcock Dec 9, 2024
1fe7fb4
Merge branch 'dev' into jsdb/navisworks
jsdbroughton Dec 10, 2024
5417225
Merge branch 'dev' into remove-dataflow
adamhathcock Dec 11, 2024
4e80c0b
Merge branch 'dev' into jsdb/navisworks
adamhathcock Dec 11, 2024
60b2a74
merge dev
adamhathcock Dec 12, 2024
738f75f
merge fixes
adamhathcock Dec 12, 2024
88f45f4
update to latest SDK
adamhathcock Dec 13, 2024
55dbc1e
Merge branch 'update-sdk' into remove-dataflow
adamhathcock Dec 13, 2024
c7f95be
scope the classes correctly for the deserialization process
adamhathcock Dec 13, 2024
739f372
Navisworks proj cleanup (#443)
adamhathcock Dec 13, 2024
f6a377e
We shouldn't be using ConfigureAwait false
adamhathcock Dec 16, 2024
524f875
Merge remote-tracking branch 'origin/dev' into jsdb/navisworks
adamhathcock Dec 16, 2024
4e5898b
Fix lock files for NW
adamhathcock Dec 16, 2024
062a5a6
Rhino doesn't need explicit run on main threads?
adamhathcock Dec 16, 2024
9ae9f99
add back layers and materials on ui thread with comment
adamhathcock Dec 17, 2024
d7afe9b
Update to SDK 3.1.0-218
adamhathcock Dec 17, 2024
0c97e16
Merge branch 'update-sdk' into jsdb/navisworks
adamhathcock Dec 17, 2024
9c59b43
update locks
adamhathcock Dec 17, 2024
6874753
Merge remote-tracking branch 'origin/dev' into jsdb/navisworks
adamhathcock Dec 17, 2024
dacfdbc
Merge branch 'jsdb/navisworks' into remove-dataflow
adamhathcock Dec 17, 2024
846ac3f
Merge remote-tracking branch 'origin/dev' into remove-dataflow
adamhathcock Dec 17, 2024
676a7e8
rationalize NW and usage of cancellation token
adamhathcock Dec 17, 2024
6ebcc3f
format
adamhathcock Dec 17, 2024
ca0ac59
remove .ConfigureAwait(false)
adamhathcock Dec 17, 2024
cf33ef1
Remove ValueTask and fix ArcGIS doc saving
adamhathcock Dec 17, 2024
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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ dotnet_diagnostic.ca1508.severity = warning # Avoid dead conditional code
dotnet_diagnostic.ca1509.severity = warning # Invalid entry in code metrics configuration file
dotnet_diagnostic.ca1861.severity = none # Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

# CA2007: Consider calling ConfigureAwait on the awaited task (this is not needed for application code, in fact we don't want to call anything but ConfigureAwait(true) which is the default)
dotnet_diagnostic.CA2007.severity = none

dotnet_diagnostic.cs8618.severity = suggestion # nullable problem


Expand Down
4 changes: 2 additions & 2 deletions Build/Github.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public static async Task BuildInstallers(string token, string runId, string vers
Content = content
};
request.Headers.Add("X-GitHub-Api-Version", "2022-11-28");
var response = await client.SendAsync(request).ConfigureAwait(false);
var response = await client.SendAsync(request);
if (!response.IsSuccessStatusCode)
{
throw new InvalidOperationException(
$"{response.StatusCode} {response.ReasonPhrase} {await response.Content.ReadAsStringAsync().ConfigureAwait(false)}"
$"{response.StatusCode} {response.ReasonPhrase} {await response.Content.ReadAsStringAsync()}"
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void RemoveDirectory(string d)
VERSION,
async () =>
{
var (output, _) = await ReadAsync("dotnet", "minver -v w").ConfigureAwait(false);
var (output, _) = await ReadAsync("dotnet", "minver -v w");
output = output.Trim();
Console.WriteLine($"Version: {output}");
Run("echo", $"\"version={output}\" >> $GITHUB_OUTPUT");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,14 @@ public async Task Receive(string modelCardId)
modelCard.GetReceiveInfo("ArcGIS"), // POC: get host app name from settings? same for GetSendInfo
_operationProgressManager.CreateOperationProgressEventHandler(Parent, modelCardId, cancellationToken),
cancellationToken
)
.ConfigureAwait(false);
);

modelCard.BakedObjectIds = receiveOperationResults.BakedObjectIds.ToList();
await Commands
.SetModelReceiveResult(
modelCardId,
receiveOperationResults.BakedObjectIds,
receiveOperationResults.ConversionResults
)
.ConfigureAwait(false);
await Commands.SetModelReceiveResult(
modelCardId,
receiveOperationResults.BakedObjectIds,
receiveOperationResults.ConversionResults
);
}
catch (OperationCanceledException)
{
Expand All @@ -100,7 +97,7 @@ await Commands
catch (Exception ex) when (!ex.IsFatal()) // UX reasons - we will report operation exceptions as model card error. We may change this later when we have more exception documentation
{
_logger.LogModelCardHandledError(ex);
await Commands.SetModelError(modelCardId, ex).ConfigureAwait(false);
await Commands.SetModelError(modelCardId, ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using ArcGIS.Core.Data;
using ArcGIS.Desktop.Core;
using ArcGIS.Desktop.Editing.Events;
using ArcGIS.Desktop.Framework.Threading.Tasks;
using ArcGIS.Desktop.Mapping;
using ArcGIS.Desktop.Mapping.Events;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -93,32 +92,22 @@ MapMembersUtils mapMemberUtils
private void SubscribeToArcGISEvents()
{
LayersRemovedEvent.Subscribe(
a =>
_topLevelExceptionHandler.FireAndForget(async () => await GetIdsForLayersRemovedEvent(a).ConfigureAwait(false)),
a => _topLevelExceptionHandler.FireAndForget(async () => await GetIdsForLayersRemovedEvent(a)),
true
);

StandaloneTablesRemovedEvent.Subscribe(
a =>
_topLevelExceptionHandler.FireAndForget(
async () => await GetIdsForStandaloneTablesRemovedEvent(a).ConfigureAwait(false)
),
a => _topLevelExceptionHandler.FireAndForget(async () => await GetIdsForStandaloneTablesRemovedEvent(a)),
true
);

MapPropertyChangedEvent.Subscribe(
a =>
_topLevelExceptionHandler.FireAndForget(
async () => await GetIdsForMapPropertyChangedEvent(a).ConfigureAwait(false)
),
a => _topLevelExceptionHandler.FireAndForget(async () => await GetIdsForMapPropertyChangedEvent(a)),
true
); // Map units, CRS etc.

MapMemberPropertiesChangedEvent.Subscribe(
a =>
_topLevelExceptionHandler.FireAndForget(
async () => await GetIdsForMapMemberPropertiesChangedEvent(a).ConfigureAwait(false)
),
a => _topLevelExceptionHandler.FireAndForget(async () => await GetIdsForMapMemberPropertiesChangedEvent(a)),
true
); // e.g. Layer name

Expand All @@ -139,28 +128,24 @@ private void SubscribeToArcGISEvents()

private void SubscribeToMapMembersDataSourceChange()
{
var task = QueuedTask.Run(() =>
if (MapView.Active == null)
{
if (MapView.Active == null)
{
return;
}
return;
}

// subscribe to layers
foreach (Layer layer in MapView.Active.Map.Layers)
{
if (layer is FeatureLayer featureLayer)
{
SubscribeToFeatureLayerDataSourceChange(featureLayer);
}
}
// subscribe to tables
foreach (StandaloneTable table in MapView.Active.Map.StandaloneTables)
// subscribe to layers
foreach (Layer layer in MapView.Active.Map.Layers)
{
if (layer is FeatureLayer featureLayer)
{
SubscribeToTableDataSourceChange(table);
SubscribeToFeatureLayerDataSourceChange(featureLayer);
}
});
task.Wait();
}
// subscribe to tables
foreach (StandaloneTable table in MapView.Active.Map.StandaloneTables)
{
SubscribeToTableDataSourceChange(table);
}
}

private void SubscribeToFeatureLayerDataSourceChange(FeatureLayer layer)
Expand Down Expand Up @@ -197,23 +182,23 @@ private void SubscribeToAnyDataSourceChange(Table layerTable)
(args) =>
Parent.TopLevelExceptionHandler.FireAndForget(async () =>
{
await OnRowChanged(args).ConfigureAwait(false);
await OnRowChanged(args);
}),
layerTable
);
RowChangedEvent.Subscribe(
(args) =>
Parent.TopLevelExceptionHandler.FireAndForget(async () =>
{
await OnRowChanged(args).ConfigureAwait(false);
await OnRowChanged(args);
}),
layerTable
);
RowDeletedEvent.Subscribe(
(args) =>
Parent.TopLevelExceptionHandler.FireAndForget(async () =>
{
await OnRowChanged(args).ConfigureAwait(false);
await OnRowChanged(args);
}),
layerTable
);
Expand Down Expand Up @@ -258,7 +243,7 @@ private async Task OnRowChanged(RowChangedEventArgs args)
}
}

await RunExpirationChecks(false).ConfigureAwait(false);
await RunExpirationChecks(false);
}

private async Task GetIdsForLayersRemovedEvent(LayerEventsArgs args)
Expand All @@ -267,7 +252,7 @@ private async Task GetIdsForLayersRemovedEvent(LayerEventsArgs args)
{
ChangedObjectIds[layer.URI] = 1;
}
await RunExpirationChecks(true).ConfigureAwait(false);
await RunExpirationChecks(true);
}

private async Task GetIdsForStandaloneTablesRemovedEvent(StandaloneTableEventArgs args)
Expand All @@ -276,7 +261,7 @@ private async Task GetIdsForStandaloneTablesRemovedEvent(StandaloneTableEventArg
{
ChangedObjectIds[table.URI] = 1;
}
await RunExpirationChecks(true).ConfigureAwait(false);
await RunExpirationChecks(true);
}

private async Task GetIdsForMapPropertyChangedEvent(MapPropertyChangedEventArgs args)
Expand All @@ -289,7 +274,7 @@ private async Task GetIdsForMapPropertyChangedEvent(MapPropertyChangedEventArgs
ChangedObjectIds[member.URI] = 1;
}
}
await RunExpirationChecks(false).ConfigureAwait(false);
await RunExpirationChecks(false);
}

private void GetIdsForLayersAddedEvent(LayerEventsArgs args)
Expand Down Expand Up @@ -339,7 +324,7 @@ private async Task GetIdsForMapMemberPropertiesChangedEvent(MapMemberPropertiesC
{
ChangedObjectIds[member.URI] = 1;
}
await RunExpirationChecks(false).ConfigureAwait(false);
await RunExpirationChecks(false);
}
}

Expand All @@ -366,64 +351,52 @@ public async Task Send(string modelCardId)

CancellationToken cancellationToken = _cancellationManager.InitCancellationTokenSource(modelCardId);

var sendResult = await QueuedTask
.Run(async () =>
using var scope = _serviceProvider.CreateScope();
scope
.ServiceProvider.GetRequiredService<IConverterSettingsStore<ArcGISConversionSettings>>()
.Initialize(
_arcGISConversionSettingsFactory.Create(
Project.Current,
MapView.Active.Map,
new CRSoffsetRotation(MapView.Active.Map)
)
);
List<MapMember> mapMembers = modelCard
.SendFilter.NotNull()
.RefreshObjectIds()
.Select(id => (MapMember)MapView.Active.Map.FindLayer(id) ?? MapView.Active.Map.FindStandaloneTable(id))
.Where(obj => obj != null)
.ToList();

if (mapMembers.Count == 0)
{
// Handle as CARD ERROR in this function
throw new SpeckleSendFilterException("No objects were found to convert. Please update your publish filter!");
}

// subscribe to the selected layer events
foreach (MapMember mapMember in mapMembers)
{
if (mapMember is FeatureLayer featureLayer)
{
using var scope = _serviceProvider.CreateScope();
scope
.ServiceProvider.GetRequiredService<IConverterSettingsStore<ArcGISConversionSettings>>()
.Initialize(
_arcGISConversionSettingsFactory.Create(
Project.Current,
MapView.Active.Map,
new CRSoffsetRotation(MapView.Active.Map)
)
);
List<MapMember> mapMembers = modelCard
.SendFilter.NotNull()
.RefreshObjectIds()
.Select(id => (MapMember)MapView.Active.Map.FindLayer(id) ?? MapView.Active.Map.FindStandaloneTable(id))
.Where(obj => obj != null)
.ToList();

if (mapMembers.Count == 0)
{
// Handle as CARD ERROR in this function
throw new SpeckleSendFilterException(
"No objects were found to convert. Please update your publish filter!"
);
}

// subscribe to the selected layer events
foreach (MapMember mapMember in mapMembers)
{
if (mapMember is FeatureLayer featureLayer)
{
SubscribeToFeatureLayerDataSourceChange(featureLayer);
}
else if (mapMember is StandaloneTable table)
{
SubscribeToTableDataSourceChange(table);
}
}

var result = await scope
.ServiceProvider.GetRequiredService<SendOperation<MapMember>>()
.Execute(
mapMembers,
modelCard.GetSendInfo("ArcGIS"), // POC: get host app name from settings? same for GetReceiveInfo
_operationProgressManager.CreateOperationProgressEventHandler(Parent, modelCardId, cancellationToken),
cancellationToken
)
.ConfigureAwait(false);

return result;
})
.ConfigureAwait(false);

await Commands
.SetModelSendResult(modelCardId, sendResult.RootObjId, sendResult.ConversionResults)
.ConfigureAwait(false);
SubscribeToFeatureLayerDataSourceChange(featureLayer);
}
else if (mapMember is StandaloneTable table)
{
SubscribeToTableDataSourceChange(table);
}
}

var sendResult = await scope
.ServiceProvider.GetRequiredService<SendOperation<MapMember>>()
.Execute(
mapMembers,
modelCard.GetSendInfo("ArcGIS"), // POC: get host app name from settings? same for GetReceiveInfo
_operationProgressManager.CreateOperationProgressEventHandler(Parent, modelCardId, cancellationToken),
cancellationToken
);

await Commands.SetModelSendResult(modelCardId, sendResult.RootObjId, sendResult.ConversionResults);
}
catch (OperationCanceledException)
{
Expand All @@ -435,7 +408,7 @@ await Commands
catch (Exception ex) when (!ex.IsFatal()) // UX reasons - we will report operation exceptions as model card error. We may change this later when we have more exception documentation
{
_logger.LogModelCardHandledError(ex);
await Commands.SetModelError(modelCardId, ex).ConfigureAwait(false);
await Commands.SetModelError(modelCardId, ex);
}
}

Expand Down Expand Up @@ -470,7 +443,7 @@ private async Task RunExpirationChecks(bool idsDeleted)
}
}

await Commands.SetModelsExpired(expiredSenderIds).ConfigureAwait(false);
await Commands.SetModelsExpired(expiredSenderIds);
ChangedObjectIds = new();
}
}
Loading
Loading