Skip to content

Commit

Permalink
Merge pull request #247 from specklesystems/dev
Browse files Browse the repository at this point in the history
Update release branch with latest dev changes
  • Loading branch information
AlanRynne authored Sep 25, 2024
2 parents ac1e402 + d8f3fa7 commit 94117e0
Show file tree
Hide file tree
Showing 484 changed files with 10,126 additions and 13,624 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ dotnet_diagnostic.ide0290.severity = suggestion # primary constructors: subjecti
dotnet_diagnostic.ide0290.severity = suggestion # Use primary constructor: Subjective
dotnet_diagnostic.ide0037.severity = suggestion # Use inferred member names: Sometimes its nice to be explicit
dotnet_diagnostic.ide0301.severity = suggestion # Use collection expression for empty: Subjective, intent
dotnet_diagnostic.ide0021.severity = suggestion # Use expression body for constructors : Subjective
dotnet_diagnostic.ide0090.severity = suggestion # Simplify new expression : Subjective

dotnet_diagnostic.ide0047.severity = suggestion # Parentheses preferences: IDEs don't properly pick it up

# Maintainability rules
Expand Down
28 changes: 28 additions & 0 deletions Build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
const string BUILD_SERVER_VERSION = "build-server-version";
const string CLEAN_LOCKS = "clean-locks";
const string CHECK_SOLUTIONS = "check-solutions";
const string DEEP_CLEAN = "deep-clean";

//need to pass arguments
/*var arguments = new List<string>();
Expand All @@ -40,6 +41,33 @@
}
);

Target(
DEEP_CLEAN,
() =>
{
foreach (var f in Glob.Directories(".", "**/bin"))
{
if (f.StartsWith("Build"))
{
continue;
}
Console.WriteLine("Found and will delete: " + f);
Directory.Delete(f, true);
}
foreach (var f in Glob.Directories(".", "**/obj"))
{
if (f.StartsWith("Build"))
{
continue;
}
Console.WriteLine("Found and will delete: " + f);
Directory.Delete(f, true);
}
Console.WriteLine("Running restore now.");
Run("dotnet", "restore .\\Speckle.Connectors.sln --no-cache");
}
);

Target(
CLEAN,
ForEach("**/output"),
Expand Down
1 change: 0 additions & 1 deletion Build/Solutions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ void CheckAndRemoveKnown(string projectName)

CheckAndRemoveKnown("Speckle.Objects");
CheckAndRemoveKnown("Speckle.Sdk");
CheckAndRemoveKnown("Speckle.Sdk.Logging");
if (localProjects.Count != 0)
{
throw new InvalidOperationException(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
using ArcGIS.Desktop.Core;
using ArcGIS.Desktop.Mapping;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Speckle.Autofac.DependencyInjection;
using Speckle.Connectors.Common.Cancellation;
using Speckle.Connectors.Common.Operations;
using Speckle.Connectors.DUI.Bindings;
using Speckle.Connectors.DUI.Bridge;
using Speckle.Connectors.DUI.Logging;
using Speckle.Connectors.DUI.Models;
using Speckle.Connectors.DUI.Models.Card;
using Speckle.Connectors.Utils.Cancellation;
using Speckle.Connectors.Utils.Operations;
using Speckle.Converters.ArcGIS3;
using Speckle.Converters.ArcGIS3.Utils;
using Speckle.Converters.Common;
using Speckle.Sdk;

namespace Speckle.Connectors.ArcGIS.Bindings;
Expand All @@ -16,29 +21,32 @@ public sealed class ArcGISReceiveBinding : IReceiveBinding
public string Name { get; } = "receiveBinding";
private readonly CancellationManager _cancellationManager;
private readonly DocumentModelStore _store;
private readonly IUnitOfWorkFactory _unitOfWorkFactory;
private readonly IServiceProvider _serviceProvider;
private readonly IOperationProgressManager _operationProgressManager;
private readonly ILogger<ArcGISReceiveBinding> _logger;
private readonly IArcGISConversionSettingsFactory _arcGISConversionSettingsFactory;

private ReceiveBindingUICommands Commands { get; }
public IBridge Parent { get; }
public IBrowserBridge Parent { get; }

public ArcGISReceiveBinding(
DocumentModelStore store,
IBridge parent,
IBrowserBridge parent,
CancellationManager cancellationManager,
IUnitOfWorkFactory unitOfWorkFactory,
IServiceProvider serviceProvider,
IOperationProgressManager operationProgressManager,
ILogger<ArcGISReceiveBinding> logger
ILogger<ArcGISReceiveBinding> logger,
IArcGISConversionSettingsFactory arcGisConversionSettingsFactory
)
{
_store = store;
_cancellationManager = cancellationManager;
Parent = parent;
Commands = new ReceiveBindingUICommands(parent);
_unitOfWorkFactory = unitOfWorkFactory;
_serviceProvider = serviceProvider;
_operationProgressManager = operationProgressManager;
_logger = logger;
_arcGISConversionSettingsFactory = arcGisConversionSettingsFactory;
}

public async Task Receive(string modelCardId)
Expand All @@ -53,12 +61,20 @@ public async Task Receive(string modelCardId)
}

CancellationToken cancellationToken = _cancellationManager.InitCancellationTokenSource(modelCardId);

using IUnitOfWork<ReceiveOperation> unitOfWork = _unitOfWorkFactory.Resolve<ReceiveOperation>();

using var scope = _serviceProvider.CreateScope();
scope
.ServiceProvider.GetRequiredService<IConverterSettingsStore<ArcGISConversionSettings>>()
.Initialize(
_arcGISConversionSettingsFactory.Create(
Project.Current,
MapView.Active.Map,
new CRSoffsetRotation(MapView.Active.Map)
)
);
// Receive host objects
var receiveOperationResults = await unitOfWork
.Service.Execute(
var receiveOperationResults = await scope
.ServiceProvider.GetRequiredService<ReceiveOperation>()
.Execute(
modelCard.GetReceiveInfo("ArcGIS"), // POC: get host app name from settings? same for GetSendInfo
cancellationToken,
(status, progress) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace Speckle.Connectors.ArcGIS.Bindings;
public class ArcGISSelectionBinding : ISelectionBinding
{
public string Name => "selectionBinding";
public IBridge Parent { get; }
public IBrowserBridge Parent { get; }

public ArcGISSelectionBinding(IBridge parent)
public ArcGISSelectionBinding(IBrowserBridge parent)
{
Parent = parent;
var topLevelHandler = parent.TopLevelExceptionHandler;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
using System.Collections.Concurrent;
using System.Diagnostics.CodeAnalysis;
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;
using Microsoft.Extensions.Logging;
using Speckle.Autofac.DependencyInjection;
using Speckle.Connectors.ArcGIS.Filters;
using Speckle.Connectors.ArcGIS.Utils;
using Speckle.Connectors.Common.Caching;
using Speckle.Connectors.Common.Cancellation;
using Speckle.Connectors.Common.Operations;
using Speckle.Connectors.DUI.Bindings;
using Speckle.Connectors.DUI.Bridge;
using Speckle.Connectors.DUI.Exceptions;
Expand All @@ -17,9 +20,9 @@
using Speckle.Connectors.DUI.Models.Card;
using Speckle.Connectors.DUI.Models.Card.SendFilter;
using Speckle.Connectors.DUI.Settings;
using Speckle.Connectors.Utils.Caching;
using Speckle.Connectors.Utils.Cancellation;
using Speckle.Connectors.Utils.Operations;
using Speckle.Converters.ArcGIS3;
using Speckle.Converters.ArcGIS3.Utils;
using Speckle.Converters.Common;
using Speckle.Sdk;
using Speckle.Sdk.Common;

Expand All @@ -29,17 +32,17 @@ public sealed class ArcGISSendBinding : ISendBinding
{
public string Name => "sendBinding";
public SendBindingUICommands Commands { get; }
public IBridge Parent { get; }
public IBrowserBridge Parent { get; }

private readonly DocumentModelStore _store;
private readonly IUnitOfWorkFactory _unitOfWorkFactory; // POC: unused? :D
private readonly IServiceProvider _serviceProvider;
private readonly List<ISendFilter> _sendFilters;
private readonly CancellationManager _cancellationManager;
private readonly ISendConversionCache _sendConversionCache;
private readonly IOperationProgressManager _operationProgressManager;
private readonly ILogger<ArcGISSendBinding> _logger;
private readonly ITopLevelExceptionHandler _topLevelExceptionHandler;
private readonly MapMembersUtils _mapMemberUtils;
private readonly IArcGISConversionSettingsFactory _arcGISConversionSettingsFactory;

/// <summary>
/// Used internally to aggregate the changed objects' id. Note we're using a concurrent dictionary here as the expiry check method is not thread safe, and this was causing problems. See:
Expand All @@ -54,25 +57,25 @@ public sealed class ArcGISSendBinding : ISendBinding

public ArcGISSendBinding(
DocumentModelStore store,
IBridge parent,
IBrowserBridge parent,
IEnumerable<ISendFilter> sendFilters,
IUnitOfWorkFactory unitOfWorkFactory,
IServiceProvider serviceProvider,
CancellationManager cancellationManager,
ISendConversionCache sendConversionCache,
IOperationProgressManager operationProgressManager,
ILogger<ArcGISSendBinding> logger,
MapMembersUtils mapMemberUtils
IArcGISConversionSettingsFactory arcGisConversionSettingsFactory
)
{
_store = store;
_unitOfWorkFactory = unitOfWorkFactory;
_serviceProvider = serviceProvider;
_sendFilters = sendFilters.ToList();
_cancellationManager = cancellationManager;
_sendConversionCache = sendConversionCache;
_operationProgressManager = operationProgressManager;
_logger = logger;
_topLevelExceptionHandler = parent.TopLevelExceptionHandler;
_mapMemberUtils = mapMemberUtils;
_arcGISConversionSettingsFactory = arcGisConversionSettingsFactory;

Parent = parent;
Commands = new SendBindingUICommands(parent);
Expand Down Expand Up @@ -357,7 +360,7 @@ private void GetIdsForMapMemberPropertiesChangedEvent(MapMemberPropertiesChanged
public async Task Send(string modelCardId)
{
//poc: dupe code between connectors
using var unitOfWork = _unitOfWorkFactory.Resolve<SendOperation<MapMember>>();

try
{
if (_store.GetModelById(modelCardId) is not SenderModelCard modelCard)
Expand All @@ -371,6 +374,16 @@ public async Task Send(string 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()
.GetObjectIds()
Expand Down Expand Up @@ -399,8 +412,9 @@ public async Task Send(string modelCardId)
}
}

var result = await unitOfWork
.Service.Execute(
var result = await scope
.ServiceProvider.GetRequiredService<SendOperation<MapMember>>()
.Execute(
mapMembers,
modelCard.GetSendInfo("ArcGIS"), // POC: get host app name from settings? same for GetReceiveInfo
(status, progress) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Speckle.Connectors.DUI.Bridge;
using Speckle.Connectors.DUI.Models;
using Speckle.Connectors.DUI.Models.Card;
using Speckle.Connectors.Utils.Common;
using Speckle.Sdk;
using Speckle.Sdk.Common;
using ArcProject = ArcGIS.Desktop.Core.Project;

Expand All @@ -16,14 +16,16 @@ namespace Speckle.Connectors.ArcGIS.Bindings;
public class BasicConnectorBinding : IBasicConnectorBinding
{
public string Name => "baseBinding";
public IBridge Parent { get; }
public IBrowserBridge Parent { get; }

public BasicConnectorBindingCommands Commands { get; }
private readonly DocumentModelStore _store;
private readonly ISpeckleApplication _speckleApplication;

public BasicConnectorBinding(DocumentModelStore store, IBridge parent)
public BasicConnectorBinding(DocumentModelStore store, IBrowserBridge parent, ISpeckleApplication speckleApplication)
{
_store = store;
_speckleApplication = speckleApplication;
Parent = parent;
Commands = new BasicConnectorBindingCommands(parent);

Expand All @@ -33,11 +35,11 @@ public BasicConnectorBinding(DocumentModelStore store, IBridge parent)
};
}

public string GetSourceApplicationName() => Speckle.Connectors.Utils.Connector.Slug;
public string GetSourceApplicationName() => _speckleApplication.Slug;

public string GetSourceApplicationVersion() => Speckle.Connectors.Utils.Connector.VersionString;
public string GetSourceApplicationVersion() => _speckleApplication.HostApplicationVersion;

public string GetConnectorVersion() => typeof(BasicConnectorBinding).Assembly.GetVersion();
public string GetConnectorVersion() => _speckleApplication.SpeckleVersion;

public DocumentInfo? GetDocumentInfo()
{
Expand Down
Loading

0 comments on commit 94117e0

Please sign in to comment.