diff --git a/.circleci/config.yml b/.circleci/config.yml index 9a7fce8a86..cc3878ed61 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -32,7 +32,7 @@ jobs: - run: git branch internal_circleci - path-filtering/set-parameters: mapping: | - Core/.* run_core true + Core/.* core true (Core|Objects|ConnectorRhino|ConnectorGrasshopper|.*/ConverterRhinoGh)/.* rhino true (Core|Objects|ConnectorRevit|.*/ConverterRevit)/.* revit true (Core|Objects|ConnectorDynamo|.*/ConverterDynamo)/.* dynamo true diff --git a/.circleci/scripts/config-template.yml b/.circleci/scripts/config-template.yml index d20604df46..731672252f 100644 --- a/.circleci/scripts/config-template.yml +++ b/.circleci/scripts/config-template.yml @@ -128,17 +128,26 @@ jobs: # Each project will have individual jobs for each specific task it has to if(-Not [string]::IsNullOrEmpty($env:CIRCLE_TAG) -And -Not $semver.Contains('-')) { New-Item -Force "speckle-sharp-ci-tools/Installers/<< parameters.slug >>/latest.yml" -ItemType File -Value "version: $semver" } environment: WORKFLOW_NUM: << pipeline.number >> - - - run: # Creates the inno installer + - run: name: Build Installer command: speckle-sharp-ci-tools\InnoSetup\ISCC.exe speckle-sharp-ci-tools\%SLUG%.iss /Sbyparam=$p shell: cmd.exe #does not work in powershell environment: SLUG: << parameters.slug >> - - persist_to_workspace: - root: ./ - paths: - - speckle-sharp-ci-tools/Installers + - when: + condition: + equal: [teklastructures, << parameters.slug >>] # Tekla Structures has it's own "plugin packager", so we do this instead of the ISS step + steps: + - run: + name: Build TSEP + command: speckle-sharp-ci-tools/TSEPBuilder/TeklaExtensionPackage.BatchBuilder.exe -I C:/Users/circleci/project/ConnectorTeklaStructures/ConnectorTeklaStructures2021/ManifestGenerator.xml -O C:/Users/circleci/project/speckle-sharp-ci-tools/Installers/<>/<>.tsep + - when: + condition: << pipeline.git.tag >> + steps: + - persist_to_workspace: + root: ./ + paths: + - speckle-sharp-ci-tools/Installers deploy-connector-new: docker: @@ -246,10 +255,13 @@ jobs: # Each project will have individual jobs for each specific task it has to TAG=$(if [ "${CIRCLE_TAG}" ]; then echo $CIRCLE_TAG; else echo "0.0.0"; fi;) SEMVER=$(echo "$TAG" | sed -e 's/\/[a-zA-Z-]*//') cp speckle-sharp-ci-tools/Mac/<>/bin/Release/netcoreapp3.1/osx-x64/<>.zip speckle-sharp-ci-tools/Installers/<< parameters.slug >>/<>-$SEMVER.zip - - persist_to_workspace: - root: ./ - paths: - - speckle-sharp-ci-tools/Installers + - when: + condition: << pipeline.git.tag >> + steps: + - persist_to_workspace: + root: ./ + paths: + - speckle-sharp-ci-tools/Installers get-ci-tools: # Clones our ci tools and persists them to the workspace docker: diff --git a/.circleci/scripts/connector-jobs.yml b/.circleci/scripts/connector-jobs.yml index 4c7f96dd6d..aac0c59342 100644 --- a/.circleci/scripts/connector-jobs.yml +++ b/.circleci/scripts/connector-jobs.yml @@ -106,7 +106,6 @@ teklastructures: slug: teklastructures requires: - build-desktopui - csi: - build-connector: slnname: ConnectorCSI diff --git a/ConnectorGrasshopper/.config/dotnet-tools.json b/.config/dotnet-tools.json similarity index 100% rename from ConnectorGrasshopper/.config/dotnet-tools.json rename to .config/dotnet-tools.json diff --git a/.gitignore b/.gitignore index 3821519313..90b24e1de0 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ *.user *.userosscache *.sln.docstates +*.tsep # Intellij Crap .idea diff --git a/All.sln b/All.sln index 2217c3ee71..deaa259355 100644 --- a/All.sln +++ b/All.sln @@ -13,7 +13,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorDynamoExtension", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorDynamoFunctions", "ConnectorDynamo\ConnectorDynamoFunctions\ConnectorDynamoFunctions.csproj", "{8F4D907B-A2DF-4B40-8EA6-D79F9ED6D906}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorGrasshopper", "ConnectorGrasshopper\ConnectorGrasshopper\ConnectorGrasshopper.csproj", "{109B3382-634B-408A-8A5C-4CD09CB92641}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorGrasshopper", "ConnectorGrasshopper\ConnectorGrasshopper\ConnectorGrasshopper.csproj", "{109B3382-634B-408A-8A5C-4CD09CB92641}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DesktopUI", "DesktopUI\DesktopUI\DesktopUI.csproj", "{A97C3046-2D55-4C49-AB40-A3C2194B82FA}" EndProject @@ -31,7 +31,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Objects", "Objects", "{E391 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Converters", "Converters", "{4DE5ED81-2A55-4C23-A05F-3C9B9B06F85D}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ConnectorRevit", "ConnectorRevit", "{42A86931-7497-4A34-B2FD-060231CD0A8F}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Revit", "Revit", "{42A86931-7497-4A34-B2FD-060231CD0A8F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorRevit2021", "ConnectorRevit\ConnectorRevit2021\ConnectorRevit2021.csproj", "{27A79ACA-7EA8-4406-8BB8-216578CC3AB7}" EndProject @@ -191,6 +191,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorAutocad2023", "Con EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorCivil2023", "ConnectorAutocadCivil\ConnectorCivil2023\ConnectorCivil2023.csproj", "{2639E37D-80D3-415A-B4D1-20D7F321F27F}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DesktopUI", "DesktopUI", "{59764E6A-8366-4AF3-AB0A-BA28BD0318FA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DesktopUI2.Launcher", "DesktopUI2\DesktopUI2.Launcher\DesktopUI2.Launcher.csproj", "{BDBB6B68-1DF8-4C41-B4AD-55037F81543D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DesktopUI2.WPF", "DesktopUI2\DesktopUI2.WPF\DesktopUI2.WPF.csproj", "{3D066801-9823-48ED-8FB3-273B53825808}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConverterDxf", "Objects\Converters\ConverterDxf\ConverterDxf\ConverterDxf.csproj", "{B5A7A2E9-B46A-44FC-9D6F-42BE2773C51F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaHwndHost", "DesktopUI2\AvaloniaHwndHost\AvaloniaHwndHost.csproj", "{050E8BAB-773E-4FE6-BD38-F71CF65FC257}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution Objects\Converters\ConverterTeklaStructures\ConverterTeklaStructuresShared\ConverterTeklaStructuresShared.projitems*{02a24dd8-e0ca-4657-baa7-b033a4563709}*SharedItemsImports = 5 @@ -199,6 +209,7 @@ Global Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{21223ba5-c6e8-405d-b581-106c4726edc0}*SharedItemsImports = 5 ConnectorCSI\ConnectorCSIShared\ConnectorCSIShared.projitems*{23be6e54-96c1-4373-89f3-e18a1c9807fd}*SharedItemsImports = 4 Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{23be6e54-96c1-4373-89f3-e18a1c9807fd}*SharedItemsImports = 4 + ConnectorAutocadCivil\ConnectorAutocadCivil\ConnectorAutocadCivilShared.projitems*{2639e37d-80d3-415a-b4d1-20d7f321f27f}*SharedItemsImports = 4 Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{26eca1be-f5b2-4a41-9658-46a4a917bfe6}*SharedItemsImports = 5 ConnectorRevit\ConnectorRevit\ConnectorRevit.projitems*{27a79aca-7ea8-4406-8bb8-216578cc3ab7}*SharedItemsImports = 4 ConnectorTeklaStructures\ConnectorTeklaStructuresShared\ConnectorTeklaStructuresShared.projitems*{28e2ea7f-ffd1-4e13-9165-0243b5ac82f5}*SharedItemsImports = 13 @@ -254,6 +265,7 @@ Global Objects\Converters\ConverterAutocadCivil\ConverterAutocadCivilShared\ConverterAutocadCivilShared.projitems*{d9f443b5-c55b-4ad8-9c70-bc3d2be781be}*SharedItemsImports = 5 ConnectorRevit\ConnectorRevit\ConnectorRevit.projitems*{dfdfdbb8-018b-4dcb-a012-54227abf53a7}*SharedItemsImports = 4 ConnectorRevit\ConnectorRevit\ConnectorRevit.projitems*{ef418256-8118-47b4-8386-a945946fb92d}*SharedItemsImports = 4 + ConnectorAutocadCivil\ConnectorAutocadCivil\ConnectorAutocadCivilShared.projitems*{f4bfb155-7ba9-4e46-8240-9c825060c904}*SharedItemsImports = 4 ConnectorMicroStation\ConnectorMicroStationOpenShared\ConnectorMicroStationOpenShared.projitems*{fc044d89-0ff3-441d-b35d-87454a693c16}*SharedItemsImports = 4 ConnectorAutocadCivil\ConnectorAutocadCivil\ConnectorAutocadCivilShared.projitems*{ff1793e1-77f5-4a92-b3f2-6d8b104e479b}*SharedItemsImports = 4 Objects\Converters\ConverterMicroStation\ConverterMicroStationOpenShared\ConverterMicroStationOpenShared.projitems*{ffbc46f0-1874-42e9-8270-bbf962ef32d1}*SharedItemsImports = 5 @@ -745,6 +757,38 @@ Global {2639E37D-80D3-415A-B4D1-20D7F321F27F}.Release|Any CPU.Build.0 = Release|Any CPU {2639E37D-80D3-415A-B4D1-20D7F321F27F}.Release|x64.ActiveCfg = Release|Any CPU {2639E37D-80D3-415A-B4D1-20D7F321F27F}.Release|x64.Build.0 = Release|Any CPU + {BDBB6B68-1DF8-4C41-B4AD-55037F81543D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BDBB6B68-1DF8-4C41-B4AD-55037F81543D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BDBB6B68-1DF8-4C41-B4AD-55037F81543D}.Debug|x64.ActiveCfg = Debug|Any CPU + {BDBB6B68-1DF8-4C41-B4AD-55037F81543D}.Debug|x64.Build.0 = Debug|Any CPU + {BDBB6B68-1DF8-4C41-B4AD-55037F81543D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BDBB6B68-1DF8-4C41-B4AD-55037F81543D}.Release|Any CPU.Build.0 = Release|Any CPU + {BDBB6B68-1DF8-4C41-B4AD-55037F81543D}.Release|x64.ActiveCfg = Release|Any CPU + {BDBB6B68-1DF8-4C41-B4AD-55037F81543D}.Release|x64.Build.0 = Release|Any CPU + {3D066801-9823-48ED-8FB3-273B53825808}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3D066801-9823-48ED-8FB3-273B53825808}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3D066801-9823-48ED-8FB3-273B53825808}.Debug|x64.ActiveCfg = Debug|Any CPU + {3D066801-9823-48ED-8FB3-273B53825808}.Debug|x64.Build.0 = Debug|Any CPU + {3D066801-9823-48ED-8FB3-273B53825808}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3D066801-9823-48ED-8FB3-273B53825808}.Release|Any CPU.Build.0 = Release|Any CPU + {3D066801-9823-48ED-8FB3-273B53825808}.Release|x64.ActiveCfg = Release|Any CPU + {3D066801-9823-48ED-8FB3-273B53825808}.Release|x64.Build.0 = Release|Any CPU + {B5A7A2E9-B46A-44FC-9D6F-42BE2773C51F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B5A7A2E9-B46A-44FC-9D6F-42BE2773C51F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B5A7A2E9-B46A-44FC-9D6F-42BE2773C51F}.Debug|x64.ActiveCfg = Debug|Any CPU + {B5A7A2E9-B46A-44FC-9D6F-42BE2773C51F}.Debug|x64.Build.0 = Debug|Any CPU + {B5A7A2E9-B46A-44FC-9D6F-42BE2773C51F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B5A7A2E9-B46A-44FC-9D6F-42BE2773C51F}.Release|Any CPU.Build.0 = Release|Any CPU + {B5A7A2E9-B46A-44FC-9D6F-42BE2773C51F}.Release|x64.ActiveCfg = Release|Any CPU + {B5A7A2E9-B46A-44FC-9D6F-42BE2773C51F}.Release|x64.Build.0 = Release|Any CPU + {050E8BAB-773E-4FE6-BD38-F71CF65FC257}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {050E8BAB-773E-4FE6-BD38-F71CF65FC257}.Debug|Any CPU.Build.0 = Debug|Any CPU + {050E8BAB-773E-4FE6-BD38-F71CF65FC257}.Debug|x64.ActiveCfg = Debug|Any CPU + {050E8BAB-773E-4FE6-BD38-F71CF65FC257}.Debug|x64.Build.0 = Debug|Any CPU + {050E8BAB-773E-4FE6-BD38-F71CF65FC257}.Release|Any CPU.ActiveCfg = Release|Any CPU + {050E8BAB-773E-4FE6-BD38-F71CF65FC257}.Release|Any CPU.Build.0 = Release|Any CPU + {050E8BAB-773E-4FE6-BD38-F71CF65FC257}.Release|x64.ActiveCfg = Release|Any CPU + {050E8BAB-773E-4FE6-BD38-F71CF65FC257}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -755,7 +799,7 @@ Global {B494FD40-5E59-4D5E-87B0-80AAC8BDCD5A} = {CB6F8F77-4487-469B-896A-1EEEC4451A04} {8F4D907B-A2DF-4B40-8EA6-D79F9ED6D906} = {CB6F8F77-4487-469B-896A-1EEEC4451A04} {109B3382-634B-408A-8A5C-4CD09CB92641} = {9461B162-AD2F-4F60-BCE4-E72DCEFD4608} - {A97C3046-2D55-4C49-AB40-A3C2194B82FA} = {DD7DA7E3-FBB7-4216-852B-A4A5BF3AB9AB} + {A97C3046-2D55-4C49-AB40-A3C2194B82FA} = {59764E6A-8366-4AF3-AB0A-BA28BD0318FA} {60BE029E-1F31-4473-8B68-A745A43AF179} = {E3916A0F-68D5-4C84-ACAE-41547F75E454} {8BBED205-C34E-4226-8757-0B576132D2BC} = {DC6BE73D-4D60-4F90-9778-D44151CD6F98} {8FA5494A-D651-4C80-9B69-EB1808CF64F8} = {DC6BE73D-4D60-4F90-9778-D44151CD6F98} @@ -795,7 +839,7 @@ Global {B7376EC8-5D3E-47D2-96A7-748552F14C39} = {E94E7327-5A9B-48EE-93CC-E9E9A5B980F1} {6185B1A1-0A12-44B1-8AC5-0ED48147FB21} = {85C30B55-E486-49AE-B3F5-6A196D14CCB8} {85C30B55-E486-49AE-B3F5-6A196D14CCB8} = {4DE5ED81-2A55-4C23-A05F-3C9B9B06F85D} - {AC0613B5-BD0E-4DA3-B704-7BE70D17AFFE} = {DD7DA7E3-FBB7-4216-852B-A4A5BF3AB9AB} + {AC0613B5-BD0E-4DA3-B704-7BE70D17AFFE} = {59764E6A-8366-4AF3-AB0A-BA28BD0318FA} {0DA15CBF-A6C5-4EEC-BDDE-9FA403E20A17} = {DD7DA7E3-FBB7-4216-852B-A4A5BF3AB9AB} {0420D74A-2997-4B92-844B-C3769DEAA1AD} = {0DA15CBF-A6C5-4EEC-BDDE-9FA403E20A17} {372D9F0F-EDE9-4050-BF8C-758911C5C2E0} = {0DA15CBF-A6C5-4EEC-BDDE-9FA403E20A17} @@ -840,6 +884,11 @@ Global {D163D710-B946-4D50-8833-BD8B9941033A} = {DF1B3505-793C-4073-975B-04C81CC3CDC4} {F4BFB155-7BA9-4E46-8240-9C825060C904} = {890F3257-FCC2-4ED8-9180-22B3641B494C} {2639E37D-80D3-415A-B4D1-20D7F321F27F} = {890F3257-FCC2-4ED8-9180-22B3641B494C} + {59764E6A-8366-4AF3-AB0A-BA28BD0318FA} = {DD7DA7E3-FBB7-4216-852B-A4A5BF3AB9AB} + {BDBB6B68-1DF8-4C41-B4AD-55037F81543D} = {59764E6A-8366-4AF3-AB0A-BA28BD0318FA} + {3D066801-9823-48ED-8FB3-273B53825808} = {59764E6A-8366-4AF3-AB0A-BA28BD0318FA} + {B5A7A2E9-B46A-44FC-9D6F-42BE2773C51F} = {925C0BF6-A0B1-4699-9C4B-078E01D652CC} + {050E8BAB-773E-4FE6-BD38-F71CF65FC257} = {59764E6A-8366-4AF3-AB0A-BA28BD0318FA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1D43D91B-4F01-4A78-8250-CC6F9BD93A14} diff --git a/ConnectorArchicad/ConnectorArchicad/ConnectorBinding.cs b/ConnectorArchicad/ConnectorArchicad/ConnectorBinding.cs index 17cb688404..4b070e95f6 100644 --- a/ConnectorArchicad/ConnectorArchicad/ConnectorBinding.cs +++ b/ConnectorArchicad/ConnectorArchicad/ConnectorBinding.cs @@ -10,6 +10,7 @@ using DesktopUI2.Models.Filters; using DesktopUI2.Models.Settings; using DesktopUI2.ViewModels; +using static DesktopUI2.ViewModels.MappingViewModel; using Speckle.Core.Api; using Speckle.Core.Credentials; using Speckle.Core.Kits; @@ -87,32 +88,47 @@ public override List GetStreamsInFile() return new List(); } + public override void ResetDocument() + { + // TODO! + } + public override List GetReceiveModes() { return new List { ReceiveMode.Create }; } + public override bool CanPreviewReceive => false; + public override Task PreviewReceive(StreamState state, ProgressViewModel progress) + { + return null; + } + public override async Task ReceiveStream(StreamState state, ProgressViewModel progress) { Base commitObject = await Helpers.Receive(IdentifyStream(state)); if (commitObject is null) - { return null; - } state.SelectedObjectIds = await ElementConverterManager.Instance.ConvertToNative(commitObject, progress.CancellationTokenSource.Token); return state; } - public override void SelectClientObjects(string args) { } + public override void SelectClientObjects(List args, bool deselect = false) + { + // TODO! + } + public override bool CanPreviewSend => false; + public override void PreviewSend(StreamState state, ProgressViewModel progress) + { + return; + } public override async Task SendStream(StreamState state, ProgressViewModel progress) { if (state.Filter is null) - { return null; - } state.SelectedObjectIds = state.Filter.Selection; @@ -132,5 +148,11 @@ private static string IdentifyStream(StreamState state) var stream = new StreamWrapper { StreamId = state.StreamId, ServerUrl = state.ServerUrl, BranchName = state.BranchName, CommitId = state.CommitId != "latest" ? state.CommitId : null }; return stream.ToString(); } + + public override async Task>> ImportFamilyCommand(Dictionary> Mapping) + { + await Task.Delay(TimeSpan.FromMilliseconds(500)); + return new Dictionary>(); + } } } diff --git a/ConnectorArchicad/ConnectorArchicad/Program.cs b/ConnectorArchicad/ConnectorArchicad/Program.cs index e347da6e10..eff0447cd5 100644 --- a/ConnectorArchicad/ConnectorArchicad/Program.cs +++ b/ConnectorArchicad/ConnectorArchicad/Program.cs @@ -14,7 +14,7 @@ class Program public static Window? MainWindow { get; private set; } public static ArchicadBinding? Bindings { get; set; } - public static void Main(string[ ] args) + public static void Main(string[] args) { if (args.Length == 0) { @@ -35,7 +35,7 @@ public static void Main(string[ ] args) // BuildAvaloniaApp().StartWithClassicDesktopLifetime(args, Avalonia.Controls.ShutdownMode.OnMainWindowClose); } - public static void CreateOrFocusSpeckle(string[ ] args) + public static void CreateOrFocusSpeckle(string[] args) { if (MainWindow == null) BuildAvaloniaApp().Start(AppMain, args); @@ -54,7 +54,7 @@ public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 1.3.0 diff --git a/ConnectorAutocadCivil/ConnectorAutocad2021/Properties/AssemblyInfo.cs b/ConnectorAutocadCivil/ConnectorAutocad2021/Properties/AssemblyInfo.cs index cc3a89ce30..5e6a3e366f 100644 --- a/ConnectorAutocadCivil/ConnectorAutocad2021/Properties/AssemblyInfo.cs +++ b/ConnectorAutocadCivil/ConnectorAutocad2021/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -32,6 +32,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.0.0")] -[assembly: AssemblyFileVersion("2.0.0.0")] -[assembly: AssemblyInformationalVersion("2.0.0-beta")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0.0")] diff --git a/ConnectorAutocadCivil/ConnectorAutocad2022/ConnectorAutocad2022.csproj b/ConnectorAutocadCivil/ConnectorAutocad2022/ConnectorAutocad2022.csproj index d2de711377..c71a33bf6f 100644 --- a/ConnectorAutocadCivil/ConnectorAutocad2022/ConnectorAutocad2022.csproj +++ b/ConnectorAutocadCivil/ConnectorAutocad2022/ConnectorAutocad2022.csproj @@ -56,13 +56,13 @@ - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 1.3.0 diff --git a/ConnectorAutocadCivil/ConnectorAutocad2022/Properties/AssemblyInfo.cs b/ConnectorAutocadCivil/ConnectorAutocad2022/Properties/AssemblyInfo.cs index 90b6885077..ad66daf149 100644 --- a/ConnectorAutocadCivil/ConnectorAutocad2022/Properties/AssemblyInfo.cs +++ b/ConnectorAutocadCivil/ConnectorAutocad2022/Properties/AssemblyInfo.cs @@ -34,4 +34,4 @@ // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: AssemblyInformationalVersion("2.0.0-beta")] +[assembly: AssemblyInformationalVersion("1.0.0.0")] diff --git a/ConnectorAutocadCivil/ConnectorAutocad2023/ConnectorAutocad2023.csproj b/ConnectorAutocadCivil/ConnectorAutocad2023/ConnectorAutocad2023.csproj index 38db5e7497..4cab9d3451 100644 --- a/ConnectorAutocadCivil/ConnectorAutocad2023/ConnectorAutocad2023.csproj +++ b/ConnectorAutocadCivil/ConnectorAutocad2023/ConnectorAutocad2023.csproj @@ -57,13 +57,13 @@ - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 1.3.0 diff --git a/ConnectorAutocadCivil/ConnectorAutocad2023/Properties/AssemblyInfo.cs b/ConnectorAutocadCivil/ConnectorAutocad2023/Properties/AssemblyInfo.cs index 01a64ed029..e47d833036 100644 --- a/ConnectorAutocadCivil/ConnectorAutocad2023/Properties/AssemblyInfo.cs +++ b/ConnectorAutocadCivil/ConnectorAutocad2023/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/ConnectorAutocadCivil/ConnectorAutocadCivil/UI/ConnectorBindingsAutocadCivil.cs b/ConnectorAutocadCivil/ConnectorAutocadCivil/UI/ConnectorBindingsAutocadCivil.cs index d2386343a4..c98012089f 100644 --- a/ConnectorAutocadCivil/ConnectorAutocadCivil/UI/ConnectorBindingsAutocadCivil.cs +++ b/ConnectorAutocadCivil/ConnectorAutocadCivil/UI/ConnectorBindingsAutocadCivil.cs @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using static DesktopUI2.ViewModels.MappingViewModel; namespace Speckle.ConnectorAutocadCivil.UI { @@ -127,9 +128,38 @@ public override List GetSelectionFilters() }; } + + private List CurrentSettings { get; set; } // used to store the Stream State settings when sending/receiving + // CAUTION: these strings need to have the same values as in the converter + const string InternalOrigin = "Internal Origin (default)"; + const string UCS = "Current User Coordinate System"; public override List GetSettings() { - return new List(); + List referencePoints = new List() { InternalOrigin }; + + // add the current UCS if it exists + if (Doc.Editor.CurrentUserCoordinateSystem != null) + referencePoints.Add(UCS); + + // add any named UCS if they exist + var namedUCS = new List(); + using (Transaction tr = Doc.Database.TransactionManager.StartTransaction()) + { + var UCSTable = tr.GetObject(Doc.Database.UcsTableId, OpenMode.ForRead) as UcsTable; + foreach (var entry in UCSTable) + { + var ucs = tr.GetObject(entry, OpenMode.ForRead) as UcsTableRecord; + namedUCS.Add(ucs.Name); + } + tr.Commit(); + } + if (namedUCS.Any()) + referencePoints.AddRange(namedUCS); + + return new List + { + new ListBoxSetting {Slug = "reference-point", Name = "Reference Point", Icon ="LocationSearching", Values = referencePoints, Selection = InternalOrigin, Description = "Sends or receives stream objects in relation to this document point"}, + }; } //TODO @@ -138,14 +168,30 @@ public override List GetCustomStreamMenuItems() return new List(); } - public override void SelectClientObjects(string args) + public override void SelectClientObjects(List args, bool deselect = false) + { + // TODO! + } + + public override void ResetDocument() { - throw new NotImplementedException(); + // TODO! + } + + public override async Task>> ImportFamilyCommand(Dictionary> Mapping) + { + await Task.Delay(TimeSpan.FromMilliseconds(500)); + return new Dictionary>(); } #endregion #region receiving + public override bool CanPreviewReceive => false; + public override async Task PreviewReceive(StreamState state, ProgressViewModel progress) + { + return null; + } public override async Task ReceiveStream(StreamState state, ProgressViewModel progress) { var kit = KitManager.GetDefaultKit(); @@ -228,6 +274,13 @@ private void ConvertReceiveCommit(Base commitObject, ISpeckleConverter converter // set the context doc for conversion - this is set inside the transaction loop because the converter retrieves this transaction for all db editing when the context doc is set! converter.SetContextDocument(Doc); + // set converter settings as tuples (setting slug, setting selection) + var settings = new Dictionary(); + CurrentSettings = state.Settings; + foreach (var setting in state.Settings) + settings.Add(setting.Slug, setting.Selection); + converter.SetConverterSettings(settings); + // keep track of conversion progress here var conversionProgressDict = new ConcurrentDictionary(); conversionProgressDict["Conversion"] = 1; @@ -307,6 +360,17 @@ private void ConvertReceiveCommit(Base commitObject, ISpeckleConverter converter if (display == null) display = obj[@"renderMaterial"] as Base; if (display != null) Utils.SetStyle(display, convertedEntity, lineTypeDictionary); + // add property sets if this is Civil3D +#if CIVIL2021 || CIVIL2022 || CIVIL2023 + if (obj["propertySets"] is IReadOnlyList list) + { + var propertySets = new List>(); + foreach (var listObj in list) + propertySets.Add(listObj as Dictionary); + convertedEntity.SetPropertySets(Doc, propertySets); + } +#endif + tr.TransactionManager.QueueForGraphicsFlush(); } else @@ -485,6 +549,11 @@ private bool GetOrMakeLayer(string layerName, Transaction tr, out string cleanNa #endregion #region sending + public override bool CanPreviewSend => false; + public override async void PreviewSend(StreamState state, ProgressViewModel progress) + { + // TODO! + } public override async Task SendStream(StreamState state, ProgressViewModel progress) { var kit = KitManager.GetDefaultKit(); @@ -581,6 +650,13 @@ private void ConvertSendCommit(Base commitObject, ISpeckleConverter converter, S // set the context doc for conversion - this is set inside the transaction loop because the converter retrieves this transaction for all db editing when the context doc is set! converter.SetContextDocument(Doc); + // set converter settings as tuples (setting slug, setting selection) + var settings = new Dictionary(); + CurrentSettings = state.Settings; + foreach (var setting in state.Settings) + settings.Add(setting.Slug, setting.Selection); + converter.SetConverterSettings(settings); + var conversionProgressDict = new ConcurrentDictionary(); conversionProgressDict["Conversion"] = 0; diff --git a/ConnectorAutocadCivil/ConnectorAutocadCivil/Utils.cs b/ConnectorAutocadCivil/ConnectorAutocadCivil/Utils.cs index c389df0e4e..765983d4b9 100644 --- a/ConnectorAutocadCivil/ConnectorAutocadCivil/Utils.cs +++ b/ConnectorAutocadCivil/ConnectorAutocadCivil/Utils.cs @@ -193,6 +193,79 @@ public static bool Visible(this DBObject obj) } #if CIVIL2021 || CIVIL2022 || CIVIL2023 + private static Autodesk.Aec.PropertyData.DataType? GetPropertySetType(object prop) + { + switch (prop) + { + case IEnumerable _: + case IEnumerable _: + case IEnumerable _: + case IEnumerable _: + return Autodesk.Aec.PropertyData.DataType.List; + + case string _: + return Autodesk.Aec.PropertyData.DataType.Text; + case int _: + return Autodesk.Aec.PropertyData.DataType.Integer; + case double _: + return Autodesk.Aec.PropertyData.DataType.Real; + case bool _: + return Autodesk.Aec.PropertyData.DataType.TrueFalse; + + default: + return null; + } + } + + public static void SetPropertySets(this Entity entity, Document doc, List> propertySetDicts) + { + // create a dictionary for property sets for this object + var name = $"Speckle {entity.Handle} Property Set"; + int count = 0; + foreach (var propertySetDict in propertySetDicts) + { + // create the property set definition for this set. + var propSetDef = new PropertySetDefinition(); + propSetDef.SetToStandard(doc.Database); + propSetDef.SubSetDatabaseDefaults(doc.Database); + var propSetDefName = name += $" - {count}"; + propSetDef.Description = "Property Set Definition added with Speckle"; + propSetDef.AppliesToAll = true; + + // Create the definition for each property + foreach (var entry in propertySetDict) + { + var propDef = new PropertyDefinition(); + propDef.SetToStandard(doc.Database); + propDef.SubSetDatabaseDefaults(doc.Database); + propDef.Name = entry.Key; + var dataType = GetPropertySetType(entry.Value); + if (dataType != null) + propDef.DataType = (Autodesk.Aec.PropertyData.DataType)dataType; + propDef.DefaultData = entry.Value; + propSetDef.Definitions.Add(propDef); + } + + // add the property sets to the object + try + { + // add property set to the database + // todo: add logging if the property set couldnt be added because a def already exists + using (Transaction tr = doc.Database.TransactionManager.StartTransaction()) + { + var dictPropSetDef = new DictionaryPropertySetDefinitions(doc.Database); + dictPropSetDef.AddNewRecord(propSetDefName, propSetDef); + tr.AddNewlyCreatedDBObject(propSetDef, true); + + entity.UpgradeOpen(); + PropertyDataServices.AddPropertySet(entity, propSetDef.ObjectId); + tr.Commit(); + } + } + catch { } + } + } + /// /// Get the property sets of DBObject /// diff --git a/ConnectorAutocadCivil/ConnectorCivil2021/ConnectorCivil2021.csproj b/ConnectorAutocadCivil/ConnectorCivil2021/ConnectorCivil2021.csproj index 38c82c89ef..b4676413ac 100644 --- a/ConnectorAutocadCivil/ConnectorCivil2021/ConnectorCivil2021.csproj +++ b/ConnectorAutocadCivil/ConnectorCivil2021/ConnectorCivil2021.csproj @@ -69,13 +69,13 @@ - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 1.3.0 diff --git a/ConnectorAutocadCivil/ConnectorCivil2021/Properties/AssemblyInfo.cs b/ConnectorAutocadCivil/ConnectorCivil2021/Properties/AssemblyInfo.cs index befe2c6582..75d62f28f4 100644 --- a/ConnectorAutocadCivil/ConnectorCivil2021/Properties/AssemblyInfo.cs +++ b/ConnectorAutocadCivil/ConnectorCivil2021/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -32,6 +32,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.0.0")] -[assembly: AssemblyFileVersion("2.0.0.0")] -[assembly: AssemblyInformationalVersion("2.0.0-beta")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0.0")] diff --git a/ConnectorAutocadCivil/ConnectorCivil2022/ConnectorCivil2022.csproj b/ConnectorAutocadCivil/ConnectorCivil2022/ConnectorCivil2022.csproj index 13b0474222..0109e488ea 100644 --- a/ConnectorAutocadCivil/ConnectorCivil2022/ConnectorCivil2022.csproj +++ b/ConnectorAutocadCivil/ConnectorCivil2022/ConnectorCivil2022.csproj @@ -59,13 +59,13 @@ - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 1.3.0 diff --git a/ConnectorAutocadCivil/ConnectorCivil2022/Properties/AssemblyInfo.cs b/ConnectorAutocadCivil/ConnectorCivil2022/Properties/AssemblyInfo.cs index 8a84314fa0..cc32515821 100644 --- a/ConnectorAutocadCivil/ConnectorCivil2022/Properties/AssemblyInfo.cs +++ b/ConnectorAutocadCivil/ConnectorCivil2022/Properties/AssemblyInfo.cs @@ -34,4 +34,4 @@ // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: AssemblyInformationalVersion("2.0.0-beta")] +[assembly: AssemblyInformationalVersion("1.0.0.0")] diff --git a/ConnectorAutocadCivil/ConnectorCivil2023/ConnectorCivil2023.csproj b/ConnectorAutocadCivil/ConnectorCivil2023/ConnectorCivil2023.csproj index d7538729e8..e9b0cd24bb 100644 --- a/ConnectorAutocadCivil/ConnectorCivil2023/ConnectorCivil2023.csproj +++ b/ConnectorAutocadCivil/ConnectorCivil2023/ConnectorCivil2023.csproj @@ -58,13 +58,13 @@ - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 1.3.0 diff --git a/ConnectorAutocadCivil/ConnectorCivil2023/Properties/AssemblyInfo.cs b/ConnectorAutocadCivil/ConnectorCivil2023/Properties/AssemblyInfo.cs index 274d5ee6f0..35bdb60d23 100644 --- a/ConnectorAutocadCivil/ConnectorCivil2023/Properties/AssemblyInfo.cs +++ b/ConnectorAutocadCivil/ConnectorCivil2023/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/ConnectorCSI/ConnectorCSI.sln b/ConnectorCSI/ConnectorCSI.sln index 746000041d..ab4578ac63 100644 --- a/ConnectorCSI/ConnectorCSI.sln +++ b/ConnectorCSI/ConnectorCSI.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31624.102 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32616.157 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorETABS", "ConnectorETABS\ConnectorETABS.csproj", "{81299D15-5788-414D-A962-1A568C251323}" EndProject @@ -42,23 +42,6 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DriverPluginCSharp", "DriverPluginCSharp\DriverPluginCSharp.csproj", "{C59939F6-D383-44E3-A7EF-4E160E3DFB73}" EndProject Global - GlobalSection(SharedMSBuildProjectFiles) = preSolution - ..\Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{14d40a8a-9f8f-44f6-b256-21b7f5cc4fb6}*SharedItemsImports = 5 - ConnectorCSIShared\ConnectorCSIShared.projitems*{23be6e54-96c1-4373-89f3-e18a1c9807fd}*SharedItemsImports = 4 - ..\Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{23be6e54-96c1-4373-89f3-e18a1c9807fd}*SharedItemsImports = 4 - ConnectorCSIShared\ConnectorCSIShared.projitems*{31e0c098-6813-4571-ab96-a245e0fc1c23}*SharedItemsImports = 4 - ..\Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{31e0c098-6813-4571-ab96-a245e0fc1c23}*SharedItemsImports = 4 - ..\Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{5bbde14e-50f8-4d6e-8e35-747667ad4a09}*SharedItemsImports = 13 - ConnectorCSIShared\ConnectorCSIShared.projitems*{61374cd0-e774-4dcd-bfab-6356b0931283}*SharedItemsImports = 13 - ..\Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{7572e400-c007-48e4-98fc-614fdee0b572}*SharedItemsImports = 5 - ConnectorCSIShared\ConnectorCSIShared.projitems*{81299d15-5788-414d-a962-1a568c251323}*SharedItemsImports = 4 - ..\Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{81299d15-5788-414d-a962-1a568c251323}*SharedItemsImports = 4 - ..\Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{8431e383-838b-4f0a-8065-979c3dae9ccb}*SharedItemsImports = 5 - ConnectorCSIShared\ConnectorCSIShared.projitems*{9d188843-8841-4a76-a844-efbe8e32ee05}*SharedItemsImports = 4 - ..\Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{9d188843-8841-4a76-a844-efbe8e32ee05}*SharedItemsImports = 4 - ConnectorCSIShared\ConnectorCSIShared.projitems*{c091e499-597d-4077-b83f-08e069091090}*SharedItemsImports = 4 - ..\Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{c95c0d85-50c2-46d1-9e27-f86d0d40058c}*SharedItemsImports = 5 - EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU @@ -146,4 +129,17 @@ Global GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {61234D5B-1E5E-4C97-89A1-FA97E4B63D95} EndGlobalSection + GlobalSection(SharedMSBuildProjectFiles) = preSolution + ..\Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{14d40a8a-9f8f-44f6-b256-21b7f5cc4fb6}*SharedItemsImports = 5 + ConnectorCSIShared\ConnectorCSIShared.projitems*{23be6e54-96c1-4373-89f3-e18a1c9807fd}*SharedItemsImports = 4 + ConnectorCSIShared\ConnectorCSIShared.projitems*{31e0c098-6813-4571-ab96-a245e0fc1c23}*SharedItemsImports = 4 + ..\Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{5bbde14e-50f8-4d6e-8e35-747667ad4a09}*SharedItemsImports = 13 + ConnectorCSIShared\ConnectorCSIShared.projitems*{61374cd0-e774-4dcd-bfab-6356b0931283}*SharedItemsImports = 13 + ..\Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{7572e400-c007-48e4-98fc-614fdee0b572}*SharedItemsImports = 5 + ConnectorCSIShared\ConnectorCSIShared.projitems*{81299d15-5788-414d-a962-1a568c251323}*SharedItemsImports = 4 + ..\Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{8431e383-838b-4f0a-8065-979c3dae9ccb}*SharedItemsImports = 5 + ConnectorCSIShared\ConnectorCSIShared.projitems*{9d188843-8841-4a76-a844-efbe8e32ee05}*SharedItemsImports = 4 + ConnectorCSIShared\ConnectorCSIShared.projitems*{c091e499-597d-4077-b83f-08e069091090}*SharedItemsImports = 4 + ..\Objects\Converters\ConverterCSI\ConverterCSIShared\ConverterCSIShared.projitems*{c95c0d85-50c2-46d1-9e27-f86d0d40058c}*SharedItemsImports = 5 + EndGlobalSection EndGlobal diff --git a/ConnectorCSI/ConnectorCSIBridge/ConnectorCSIBridge.csproj b/ConnectorCSI/ConnectorCSIBridge/ConnectorCSIBridge.csproj index cd7581abc7..cbcbe834e1 100644 --- a/ConnectorCSI/ConnectorCSIBridge/ConnectorCSIBridge.csproj +++ b/ConnectorCSI/ConnectorCSIBridge/ConnectorCSIBridge.csproj @@ -87,13 +87,13 @@ - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 1.0.0 @@ -104,7 +104,7 @@ all - 3.19.0 + 3.20.1 12.0.3.1 @@ -114,6 +114,5 @@ - \ No newline at end of file diff --git a/ConnectorCSI/ConnectorCSIBridge/Properties/AssemblyInfo.cs b/ConnectorCSI/ConnectorCSIBridge/Properties/AssemblyInfo.cs index 4091876830..1dce9872b6 100644 --- a/ConnectorCSI/ConnectorCSIBridge/Properties/AssemblyInfo.cs +++ b/ConnectorCSI/ConnectorCSIBridge/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -32,6 +32,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.0.0")] -[assembly: AssemblyFileVersion("2.0.0.0")] -[assembly: AssemblyInformationalVersion("2.0.0-beta")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0.0")] \ No newline at end of file diff --git a/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.ClientOperations.cs b/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.ClientOperations.cs index 377a639a70..232d109367 100644 --- a/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.ClientOperations.cs +++ b/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.ClientOperations.cs @@ -29,7 +29,6 @@ public override void WriteStreamsToFile(List streams) DocumentStreams.Add(s); WriteStateToFile(); } - //throw new NotImplementedException(); } //public override void AddNewStream(StreamState state) diff --git a/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.Recieve.cs b/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.Recieve.cs index 76107aacde..15962ca377 100644 --- a/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.Recieve.cs +++ b/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.Recieve.cs @@ -15,9 +15,13 @@ namespace Speckle.ConnectorCSI.UI { public partial class ConnectorBindingsCSI : ConnectorBindings - { - #region receiving + public override bool CanPreviewReceive => false; + public override Task PreviewReceive(StreamState state, ProgressViewModel progress) + { + return null; + } + public override async Task ReceiveStream(StreamState state, ProgressViewModel progress) { Exceptions.Clear(); @@ -41,9 +45,7 @@ public override async Task ReceiveStream(StreamState state, Progres var stream = await state.Client.StreamGet(state.StreamId); if (progress.CancellationTokenSource.Token.IsCancellationRequested) - { return null; - } var transport = new ServerTransport(state.Client.Account, state.StreamId); @@ -71,14 +73,12 @@ public override async Task ReceiveStream(StreamState state, Progres progress.Report.LogOperationError(e); progress.CancellationTokenSource.Cancel(); }), - //onTotalChildrenCountKnown: count => Execute.PostToUIThread(() => state.Progress.Maximum = count), + onTotalChildrenCountKnown: count => { progress.Max = count; }, disposeTransports: true ); if (progress.Report.OperationErrorsCount != 0) - { return state; - } try { @@ -97,17 +97,13 @@ await state.Client.CommitReceived(new CommitReceivedInput if (progress.Report.OperationErrorsCount != 0) - { return state; - } if (progress.CancellationTokenSource.Token.IsCancellationRequested) - { return null; - } var conversionProgressDict = new ConcurrentDictionary(); - conversionProgressDict["Conversion"] = 0; + conversionProgressDict["Conversion"] = 1; //Execute.PostToUIThread(() => state.Progress.Maximum = state.SelectedObjectIds.Count()); Action updateProgressAction = () => @@ -116,7 +112,6 @@ await state.Client.CommitReceived(new CommitReceivedInput progress.Update(conversionProgressDict); }; - var commitObjs = FlattenCommitObject(commitObject, converter); foreach (var commitObj in commitObjs) { @@ -124,8 +119,6 @@ await state.Client.CommitReceived(new CommitReceivedInput updateProgressAction?.Invoke(); } - - try { //await state.RefreshStream(); @@ -142,11 +135,6 @@ await state.Client.CommitReceived(new CommitReceivedInput return state; } - - - - - /// /// conversion to native /// @@ -157,7 +145,7 @@ private void BakeObject(Base obj, StreamState state, ISpeckleConverter converter { try { - + converter.ReceiveMode = state.ReceiveMode; converter.ConvertToNative(obj); } catch (Exception e) @@ -183,15 +171,12 @@ private List FlattenCommitObject(object obj, ISpeckleConverter converter) if (converter.CanConvertToNative(@base)) { objects.Add(@base); - return objects; } else { foreach (var prop in @base.GetDynamicMembers()) - { objects.AddRange(FlattenCommitObject(@base[prop], converter)); - } return objects; } } @@ -199,24 +184,19 @@ private List FlattenCommitObject(object obj, ISpeckleConverter converter) if (obj is List list) { foreach (var listObj in list) - { objects.AddRange(FlattenCommitObject(listObj, converter)); - } return objects; } if (obj is IDictionary dict) { foreach (DictionaryEntry kvp in dict) - { objects.AddRange(FlattenCommitObject(kvp.Value, converter)); - } return objects; } return objects; } - #endregion } } \ No newline at end of file diff --git a/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.Selection.cs b/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.Selection.cs index da570aa9ef..7bfa950fcc 100644 --- a/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.Selection.cs +++ b/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.Selection.cs @@ -8,7 +8,6 @@ namespace Speckle.ConnectorCSI.UI { public partial class ConnectorBindingsCSI : ConnectorBindings - { public override List GetSelectedObjects() { @@ -20,14 +19,11 @@ public override List GetSelectedObjects() { (string typeName, string name) = item; if (ConnectorCSIUtils.IsTypeCSIAPIUsable(typeName)) - { names.Add(string.Concat(typeName, ": ", name)); - } } if (names.Count == 0) - { return new List() { }; - } + return names; } @@ -49,32 +45,31 @@ public override List GetSelectionFilters() } return new List() - { - new AllSelectionFilter {Slug="all", Name = "Everything", - Icon = "CubeScan", Description = "Selects all document objects." }, - new ListSelectionFilter {Slug="type", Name = "Categories", - Icon = "Category", Values = objectTypes, - Description="Adds all objects belonging to the selected types"}, - //new PropertySelectionFilter{ - // Slug="param", - // Name = "Param", - // Description="Adds all objects satisfying the selected parameter", - // Icon = "FilterList", - // HasCustomProperty = false, - // Values = objectNames, - // Operators = new List {"equals", "contains", "is greater than", "is less than"} - //}, - - new ManualSelectionFilter(), - new ListSelectionFilter { Slug = "group", Name = "Group", - Icon = "SelectGroup", Values = groups, Description = "Add all objects belonging to CSI Group" } - }; + { + new AllSelectionFilter {Slug="all", Name = "Everything", + Icon = "CubeScan", Description = "Selects all document objects." }, + new ListSelectionFilter {Slug="type", Name = "Categories", + Icon = "Category", Values = objectTypes, + Description="Adds all objects belonging to the selected types"}, + //new PropertySelectionFilter{ + // Slug="param", + // Name = "Param", + // Description="Adds all objects satisfying the selected parameter", + // Icon = "FilterList", + // HasCustomProperty = false, + // Values = objectNames, + // Operators = new List {"equals", "contains", "is greater than", "is less than"} + //}, + new ManualSelectionFilter(), + new ListSelectionFilter { Slug = "group", Name = "Group", + Icon = "SelectGroup", Values = groups, Description = "Add all objects belonging to CSI Group" } + }; } - public override void SelectClientObjects(string args) + public override void SelectClientObjects(List args, bool deselect = false) { - throw new NotImplementedException(); + // TODO! } private List GetSelectionFilterObjects(ISelectionFilter filter) @@ -89,20 +84,17 @@ private List GetSelectionFilterObjects(ISelectionFilter filter) return GetSelectedObjects(); case "all": if (ConnectorCSIUtils.ObjectIDsTypesAndNames == null) - { ConnectorCSIUtils.GetObjectIDsTypesAndNames(Model); - } + selection.AddRange(ConnectorCSIUtils.ObjectIDsTypesAndNames .Select(pair => pair.Key).ToList()); return selection; - case "type": var typeFilter = filter as ListSelectionFilter; if (ConnectorCSIUtils.ObjectIDsTypesAndNames == null) - { ConnectorCSIUtils.GetObjectIDsTypesAndNames(Model); - } + foreach (var type in typeFilter.Selection) { selection.AddRange(ConnectorCSIUtils.ObjectIDsTypesAndNames @@ -111,71 +103,16 @@ private List GetSelectionFilterObjects(ISelectionFilter filter) .ToList()); } return selection; + case "group": //Clear objects first Model.SelectObj.ClearSelection(); var groupFilter = filter as ListSelectionFilter; foreach (var group in groupFilter.Selection) - { - Model.SelectObj.Group(group); - } - return GetSelectedObjects(); - - + { Model.SelectObj.Group(group); } - /// CSI doesn't list fields of different objects. - /// For "param" search, maybe search over the name of - /// methods of each type? - - //case "param": - // try - // { - // if (ConnectorCSIUtils.ObjectTypes.Count == 0) - // { - // var _ = ConnectorCSIUtils.GetObjectTypesAndNames(Model); - // } - - // var propFilter = filter as PropertySelectionFilter; - // var query = new FilteredElementCollector(doc) - // .WhereElementIsNotElementType() - // .WhereElementIsNotElementType() - // .WhereElementIsViewIndependent() - // .Where(x => x.IsPhysicalElement()) - // .Where(fi => fi.LookupParameter(propFilter.PropertyName) != null); - - // propFilter.PropertyValue = propFilter.PropertyValue.ToLowerInvariant(); - - // switch (propFilter.PropertyOperator) - // { - // case "equals": - // query = query.Where(fi => - // GetStringValue(fi.LookupParameter(propFilter.PropertyName)) == propFilter.PropertyValue); - // break; - // case "contains": - // query = query.Where(fi => - // GetStringValue(fi.LookupParameter(propFilter.PropertyName)).Contains(propFilter.PropertyValue)); - // break; - // case "is greater than": - // query = query.Where(fi => RevitVersionHelper.ConvertFromInternalUnits( - // fi.LookupParameter(propFilter.PropertyName).AsDouble(), - // fi.LookupParameter(propFilter.PropertyName)) > - // double.Parse(propFilter.PropertyValue)); - // break; - // case "is less than": - // query = query.Where(fi => RevitVersionHelper.ConvertFromInternalUnits( - // fi.LookupParameter(propFilter.PropertyName).AsDouble(), - // fi.LookupParameter(propFilter.PropertyName)) < - // double.Parse(propFilter.PropertyValue)); - // break; - // } - - // selection = query.ToList(); - // } - // catch (Exception e) - // { - // Log.CaptureException(e); - // } - // return selection; + return GetSelectedObjects(); + } return selection; diff --git a/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.Send.cs b/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.Send.cs index 9e8997a352..721dd2f2e1 100644 --- a/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.Send.cs +++ b/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.Send.cs @@ -16,13 +16,15 @@ namespace Speckle.ConnectorCSI.UI { public partial class ConnectorBindingsCSI : ConnectorBindings - { - #region sending + public override bool CanPreviewSend => false; + public override void PreviewSend(StreamState state, ProgressViewModel progress) + { + // TODO! + } public override async Task SendStream(StreamState state, ProgressViewModel progress) { - //throw new NotImplementedException(); var kit = KitManager.GetDefaultKit(); //var converter = new ConverterCSI(); var appName = GetHostAppVersion(Model); @@ -34,9 +36,7 @@ public override async Task SendStream(StreamState state, ProgressViewMod int objCount = 0; if (state.Filter != null) - { state.SelectedObjectIds = GetSelectionFilterObjects(state.Filter); - } var totalObjectCount = state.SelectedObjectIds.Count(); @@ -51,7 +51,6 @@ public override async Task SendStream(StreamState state, ProgressViewMod conversionProgressDict["Conversion"] = 0; progress.Update(conversionProgressDict); - //if( commitObj["@Stories"] == null) //{ // commitObj["@Stories"] = converter.ConvertToSpeckle(("Stories", "CSI")); @@ -60,9 +59,7 @@ public override async Task SendStream(StreamState state, ProgressViewMod foreach (var applicationId in state.SelectedObjectIds) { if (progress.CancellationTokenSource.Token.IsCancellationRequested) - { return null; - } Base converted = null; string containerName = string.Empty; @@ -78,7 +75,6 @@ public override async Task SendStream(StreamState state, ProgressViewMod continue; } - var typeAndName = ConnectorCSIUtils.ObjectIDsTypesAndNames .Where(pair => pair.Key == applicationId) .Select(pair => pair.Value).FirstOrDefault(); @@ -92,7 +88,6 @@ public override async Task SendStream(StreamState state, ProgressViewMod continue; } - //if (converted != null) //{ // if (commitObj[selectedObjectType] == null) @@ -109,24 +104,15 @@ public override async Task SendStream(StreamState state, ProgressViewMod Base ElementCount = converter.ConvertToSpeckle(("ElementsCount", "CSI")); if (ElementCount.applicationId != null) - { objCount = Convert.ToInt32(ElementCount.applicationId); - } else - { objCount = 0; - } - if (commitObj["@Model"] == null) - { commitObj["@Model"] = converter.ConvertToSpeckle(("Model", "CSI")); - } - + if (commitObj["AnalysisResults"] == null) - { commitObj["AnalysisResults"] = converter.ConvertToSpeckle(("AnalysisResults", "CSI")); - } progress.Report.Merge(converter.Report); @@ -137,9 +123,7 @@ public override async Task SendStream(StreamState state, ProgressViewMod } if (progress.CancellationTokenSource.Token.IsCancellationRequested) - { return null; - } var streamId = state.StreamId; var client = state.Client; @@ -161,12 +145,8 @@ public override async Task SendStream(StreamState state, ProgressViewMod disposeTransports: true ); - if (progress.Report.OperationErrorsCount != 0) - { - //RaiseNotification($"Failed to send: \n {Exceptions.Last().Message}"); return null; - } var actualCommit = new CommitCreateInput { @@ -184,7 +164,6 @@ public override async Task SendStream(StreamState state, ProgressViewMod var commitId = await client.CommitCreate(actualCommit); state.PreviousCommitId = commitId; return commitId; - } catch (Exception e) { @@ -194,7 +173,5 @@ public override async Task SendStream(StreamState state, ProgressViewMod return null; //return state; } - - #endregion } } \ No newline at end of file diff --git a/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.cs b/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.cs index b26d87197c..6aa8777e4e 100644 --- a/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.cs +++ b/ConnectorCSI/ConnectorCSIShared/UI/ConnectorBindingsCSI.cs @@ -2,11 +2,13 @@ using System.Collections.Generic; using DesktopUI2; using DesktopUI2.Models; +using static DesktopUI2.ViewModels.MappingViewModel; using Speckle.Core.Models; using Speckle.ConnectorCSI.Util; using System.Timers; using CSiAPIv1; using Speckle.Core.Kits; +using System.Threading.Tasks; namespace Speckle.ConnectorCSI.UI { @@ -20,14 +22,11 @@ public ConnectorBindingsCSI(cSapModel model) Model = model; } - - public override List GetReceiveModes() { - return new List { ReceiveMode.Create }; + return new List { ReceiveMode.Create, ReceiveMode.Update }; } - #region boilerplate public override string GetActiveViewName() { @@ -65,12 +64,18 @@ public override List GetObjectsInView() throw new NotImplementedException(); } + public override async Task>> ImportFamilyCommand(Dictionary> Mapping) + { + await Task.Delay(TimeSpan.FromMilliseconds(500)); + return new Dictionary>(); + } - #endregion - - - + public override void ResetDocument() + { + // TODO! + } + #endregion } } \ No newline at end of file diff --git a/ConnectorCSI/ConnectorETABS/ConnectorETABS.csproj b/ConnectorCSI/ConnectorETABS/ConnectorETABS.csproj index 6a0adee1c3..075e3d3ef7 100644 --- a/ConnectorCSI/ConnectorETABS/ConnectorETABS.csproj +++ b/ConnectorCSI/ConnectorETABS/ConnectorETABS.csproj @@ -81,13 +81,13 @@ - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 1.0.0 @@ -98,7 +98,7 @@ all - 3.19.0 + 3.20.1 12.0.3.1 @@ -107,7 +107,6 @@ 1.3.6 - \ No newline at end of file diff --git a/ConnectorCSI/ConnectorETABS/Properties/AssemblyInfo.cs b/ConnectorCSI/ConnectorETABS/Properties/AssemblyInfo.cs index 8ed9098a86..0d2618f297 100644 --- a/ConnectorCSI/ConnectorETABS/Properties/AssemblyInfo.cs +++ b/ConnectorCSI/ConnectorETABS/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -32,6 +32,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.0.0")] -[assembly: AssemblyFileVersion("2.0.0.0")] -[assembly: AssemblyInformationalVersion("2.0.0-beta")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0.0")] \ No newline at end of file diff --git a/ConnectorCSI/ConnectorSAFE/ConnectorSAFE.csproj b/ConnectorCSI/ConnectorSAFE/ConnectorSAFE.csproj index de171abeb3..bbe95fccad 100644 --- a/ConnectorCSI/ConnectorSAFE/ConnectorSAFE.csproj +++ b/ConnectorCSI/ConnectorSAFE/ConnectorSAFE.csproj @@ -81,13 +81,13 @@ - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 1.0.0 @@ -98,7 +98,7 @@ all - 3.19.0 + 3.20.1 12.0.3.1 @@ -108,6 +108,5 @@ - \ No newline at end of file diff --git a/ConnectorCSI/ConnectorSAFE/Properties/AssemblyInfo.cs b/ConnectorCSI/ConnectorSAFE/Properties/AssemblyInfo.cs index 48022399f8..1b18d3814f 100644 --- a/ConnectorCSI/ConnectorSAFE/Properties/AssemblyInfo.cs +++ b/ConnectorCSI/ConnectorSAFE/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -32,6 +32,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.0.0")] -[assembly: AssemblyFileVersion("2.0.0.0")] -[assembly: AssemblyInformationalVersion("2.0.0-beta")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0.0")] \ No newline at end of file diff --git a/ConnectorCSI/ConnectorSAP2000/ConnectorSAP2000.csproj b/ConnectorCSI/ConnectorSAP2000/ConnectorSAP2000.csproj index 86ee5de1a1..843e9c41ae 100644 --- a/ConnectorCSI/ConnectorSAP2000/ConnectorSAP2000.csproj +++ b/ConnectorCSI/ConnectorSAP2000/ConnectorSAP2000.csproj @@ -62,14 +62,6 @@ {0c1b9ae4-1d21-4c02-bdac-287e9660b5f6} DesktopUI2 - - {bf1a4f95-acf7-4353-b60a-4d79c2f44651} - PolygonMesher - - - {f6f813fc-153b-49fe-9b33-25152be85ba8} - Objects - {c091e499-597d-4077-b83f-08e069091090} DriverCSharp @@ -81,13 +73,13 @@ - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 1.0.0 @@ -98,7 +90,7 @@ all - 3.19.0 + 3.20.1 12.0.3.1 @@ -107,7 +99,6 @@ 1.3.6 - \ No newline at end of file diff --git a/ConnectorCSI/ConnectorSAP2000/Properties/AssemblyInfo.cs b/ConnectorCSI/ConnectorSAP2000/Properties/AssemblyInfo.cs index 8d2a43018f..d698e830da 100644 --- a/ConnectorCSI/ConnectorSAP2000/Properties/AssemblyInfo.cs +++ b/ConnectorCSI/ConnectorSAP2000/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -32,6 +32,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.0.0")] -[assembly: AssemblyFileVersion("2.0.0.0")] -[assembly: AssemblyInformationalVersion("2.0.0-beta")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0.0")] \ No newline at end of file diff --git a/ConnectorCSI/DriverCSharp/DriverCSharp.csproj b/ConnectorCSI/DriverCSharp/DriverCSharp.csproj index 2d1962d2b5..db18de7990 100644 --- a/ConnectorCSI/DriverCSharp/DriverCSharp.csproj +++ b/ConnectorCSI/DriverCSharp/DriverCSharp.csproj @@ -72,13 +72,13 @@ - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 - 0.10.16 + 0.10.18 1.0.0 @@ -89,7 +89,7 @@ all - 3.19.0 + 3.20.1 12.0.3.1 diff --git a/ConnectorCSI/DriverCSharp/Properties/AssemblyInfo.cs b/ConnectorCSI/DriverCSharp/Properties/AssemblyInfo.cs index 9976fa06db..23f0e7ecc0 100644 --- a/ConnectorCSI/DriverCSharp/Properties/AssemblyInfo.cs +++ b/ConnectorCSI/DriverCSharp/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/ConnectorDynamo/ConnectorDynamoFunctions/Developer/Transport.cs b/ConnectorDynamo/ConnectorDynamoFunctions/Developer/Transport.cs index 1297198d18..f41678ee6e 100644 --- a/ConnectorDynamo/ConnectorDynamoFunctions/Developer/Transport.cs +++ b/ConnectorDynamo/ConnectorDynamoFunctions/Developer/Transport.cs @@ -1,8 +1,10 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; +using System.IO; using System.Linq; using Dynamo.Graph.Nodes; +using Speckle.Core.Api; using Speckle.Core.Credentials; using Speckle.Core.Logging; using Speckle.Core.Transports; @@ -20,7 +22,7 @@ public static class Transport public static object DiskTransport(string basePath = "") { if (string.IsNullOrEmpty(basePath)) - basePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Speckle\\DiskTransportFiles\\"; + basePath = Path.Combine(Helpers.UserSpeckleFolderPath, "DiskTransportFiles"); Analytics.TrackEvent(Analytics.Events.NodeRun, new Dictionary() { { "name", "Disk Transport" } }); @@ -86,7 +88,7 @@ public static object ServerTransport(StreamWrapper stream) public static object SQLiteTransport(string basePath = "", string applicationName = "Speckle", string scope = "UserLocalDefaultDb") { if (string.IsNullOrEmpty(basePath)) - basePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); + basePath = Helpers.UserApplicationDataPath; if (string.IsNullOrEmpty(applicationName)) applicationName = "Speckle"; if (string.IsNullOrEmpty(scope)) diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/BaseComponents/SelectKitTaskCapableComponentBase.cs b/ConnectorGrasshopper/ConnectorGrasshopper/BaseComponents/SelectKitTaskCapableComponentBase.cs index 2725b717a1..6c58e883e9 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/BaseComponents/SelectKitTaskCapableComponentBase.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/BaseComponents/SelectKitTaskCapableComponentBase.cs @@ -13,6 +13,7 @@ using Speckle.Core.Kits; using Speckle.Core.Logging; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; namespace ConnectorGrasshopper.Objects { @@ -151,7 +152,7 @@ protected override void BeforeSolveInstance() } catch (Exception e) { - AddRuntimeMessage(GH_RuntimeMessageLevel.Warning,$"Failed to set document context:\n\t{e.Message}"); + AddRuntimeMessage(GH_RuntimeMessageLevel.Warning,$"Failed to set document context:\n\t{e.ToFormattedString()}"); } base.BeforeSolveInstance(); } diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/ConnectorGrasshopper.csproj b/ConnectorGrasshopper/ConnectorGrasshopper/ConnectorGrasshopper.csproj index 229dee588e..741335606c 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/ConnectorGrasshopper.csproj +++ b/ConnectorGrasshopper/ConnectorGrasshopper/ConnectorGrasshopper.csproj @@ -28,4 +28,23 @@ + + + TextTemplatingFileGenerator + SchemaBuilderGen.cs + + + + + SchemaBuilderGen.tt + + + \ No newline at end of file diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Conversion/DeserialiseTaskCapableComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Conversion/DeserialiseTaskCapableComponent.cs index 4ddcf0e9b4..8fca789329 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Conversion/DeserialiseTaskCapableComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Conversion/DeserialiseTaskCapableComponent.cs @@ -5,6 +5,7 @@ using Grasshopper.Kernel; using Speckle.Core.Api; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; namespace ConnectorGrasshopper { @@ -63,7 +64,7 @@ private Base DoWork(string item, IGH_DataAccess DA) catch (Exception e) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, - $"Cannot deserialize object at path {{{DA.ParameterTargetPath(0)}}}[{DA.ParameterTargetIndex(0)}]: {e.InnerException?.Message ?? e.Message}"); + $"Cannot deserialize object at path {{{DA.ParameterTargetPath(0)}}}[{DA.ParameterTargetIndex(0)}]: {e.ToFormattedString()}"); return null; } } diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Conversion/SerialiseTaskCapableComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Conversion/SerialiseTaskCapableComponent.cs index d60fc5d9de..b4beafd274 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Conversion/SerialiseTaskCapableComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Conversion/SerialiseTaskCapableComponent.cs @@ -6,6 +6,7 @@ using Grasshopper.Kernel.Types; using Speckle.Core.Api; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; namespace ConnectorGrasshopper.Conversion { @@ -71,7 +72,7 @@ private string DoWork(GH_SpeckleBase item, IGH_DataAccess DA) } catch (Exception e) { - AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, e.ToFormattedString()); return null; } diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Conversion/ToNativeTaskCapableComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Conversion/ToNativeTaskCapableComponent.cs index a018fa8b48..2811f3df18 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Conversion/ToNativeTaskCapableComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Conversion/ToNativeTaskCapableComponent.cs @@ -8,6 +8,7 @@ using Grasshopper.Kernel.Types; using Speckle.Core.Logging; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; using Utilities = Speckle.Core.Models.Utilities; namespace ConnectorGrasshopper.Conversion @@ -78,7 +79,7 @@ private IGH_Goo DoWork(object item, IGH_DataAccess DA) e = aggregateException.Flatten(); Log.CaptureException(e); - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.InnerException?.Message ?? e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.ToFormattedString()); return new GH_SpeckleBase(); } } diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Conversion/ToSpeckleTaskCapableComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Conversion/ToSpeckleTaskCapableComponent.cs index adb6119be7..c359ee521e 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Conversion/ToSpeckleTaskCapableComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Conversion/ToSpeckleTaskCapableComponent.cs @@ -8,6 +8,7 @@ using Grasshopper.Kernel.Types; using Speckle.Core.Logging; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; namespace ConnectorGrasshopper.Conversion { @@ -102,7 +103,7 @@ private IGH_Goo DoWork(object item, IGH_DataAccess DA) { // If we reach this, something happened that we weren't expecting... Log.CaptureException(e); - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.InnerException?.Message ?? e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.ToFormattedString()); return new GH_SpeckleBase(); } } diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Extras/GenericAccessParam.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Extras/GenericAccessParam.cs index 6b3994da7e..7f00772c48 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Extras/GenericAccessParam.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Extras/GenericAccessParam.cs @@ -39,7 +39,8 @@ public override GH_ObjectResponse RespondToMouseDoubleClick(GH_Canvas sender, GH switch (Owner.Kind) { case GH_ParamKind.input: - (Owner as GenericAccessParam)?.InheritNickname(); + if(Owner.MutableNickName) + (Owner as SpeckleStatefulParam)?.InheritNickname(); return GH_ObjectResponse.Handled; case GH_ParamKind.output: Clipboard.SetText(DocObject.NickName); diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Extras/Speckle.IGH_Goo.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Extras/Speckle.IGH_Goo.cs index 95a576fe67..3cd004d1be 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Extras/Speckle.IGH_Goo.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Extras/Speckle.IGH_Goo.cs @@ -89,8 +89,17 @@ public override IGH_Goo Duplicate() public override string ToString() { if (Value == null) return ""; + var name = Value["Name"] ?? Value["name"]; + if (Value.GetType().IsSubclassOf(typeof(Base))) - return $"Speckle {Value.GetType().Name}"; + { + var baseString = $"Speckle {Value.GetType().Name}"; + if (name != null) + { + baseString += $" [{name}]"; + } + return baseString; + } return "Speckle Object"; //return $"{(Value != null && Value.speckle_type == "" ? "Speckle.Base" : Value?.speckle_type)}"; diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Extras/SpeckleStatefulParam.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Extras/SpeckleStatefulParam.cs index e673772202..c13bbe3824 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Extras/SpeckleStatefulParam.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Extras/SpeckleStatefulParam.cs @@ -14,6 +14,8 @@ public class SpeckleStatefulParam : Param_GenericObject { public override GH_Exposure Exposure => GH_Exposure.hidden; public bool Detachable { get; set; } = true; + + public bool CanInheritNames { get; set; } = true; public override Guid ComponentGuid => new Guid("5B5A49FC-ACDE-4C09-9317-9C466374C163"); public override GH_StateTagList StateTags @@ -82,7 +84,7 @@ public override bool Read(GH_IReader reader) public override void AddSource(IGH_Param source, int index) { base.AddSource(source, index); - if (KeyWatcher.TabPressed) + if (MutableNickName && KeyWatcher.TabPressed) InheritNickname(); } @@ -99,9 +101,9 @@ public override void AppendAdditionalMenuItems(ToolStripDropDown menu) } Menu_AppendSeparator(menu); - - Menu_AppendInheritNickname(menu); + Menu_AppendInheritNickname(menu); + Menu_AppendSeparator(menu); Menu_AppendCustomMenuItems(menu); @@ -187,7 +189,7 @@ protected void Menu_AppendInheritNickname(ToolStripDropDown menu) Menu_AppendItem( menu, "Inherit names", - (sender, args) => { InheritNickname(); }); + (sender, args) => { InheritNickname(); }, MutableNickName); } // Decompiled from Grasshopper implementation and modified for output recipient. @@ -214,7 +216,7 @@ protected void Menu_ExtractOutputParameterClicked(object sender, EventArgs e) { ghParam.NewInstanceGuid(); ghParam.Attributes.Selected = false; - ghParam.Attributes.Pivot = new PointF(this.Attributes.Pivot.X + 40f, this.Attributes.Pivot.Y); + ghParam.Attributes.Pivot = new PointF(Attributes.Parent.Bounds.Right + ghParam.Attributes.Bounds.Width/2 + 15f, Attributes.Pivot.Y); ghParam.Attributes.ExpireLayout(); ghParam.MutableNickName = true; if (ghParam.Attributes is GH_FloatingParamAttributes) diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Objects/CreateSpeckleObjectByKeyValueTaskComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Objects/CreateSpeckleObjectByKeyValueTaskComponent.cs index 672a772374..c5c76ed5dc 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Objects/CreateSpeckleObjectByKeyValueTaskComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Objects/CreateSpeckleObjectByKeyValueTaskComponent.cs @@ -7,6 +7,7 @@ using Grasshopper.Kernel.Data; using Grasshopper.Kernel.Types; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; using Logging = Speckle.Core.Logging; using Utilities = ConnectorGrasshopper.Extras.Utilities; @@ -55,7 +56,7 @@ protected override void SolveInstance(IGH_DataAccess DA) foreach (var error in Converter.Report.ConversionErrors) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, - error.Message + ": " + error.InnerException?.Message); + error.ToFormattedString()); } Converter.Report.ConversionErrors.Clear(); } @@ -102,7 +103,7 @@ public Base DoWork(List keys, GH_Structure valueTree) } catch (Exception e) { - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.ToFormattedString()); hasErrors = true; } @@ -138,7 +139,7 @@ public Base DoWork(List keys, GH_Structure valueTree) } catch (Exception e) { - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.ToFormattedString()); hasErrors = true; } } @@ -155,7 +156,7 @@ public Base DoWork(List keys, GH_Structure valueTree) { // If we reach this, something happened that we weren't expecting... Logging.Log.CaptureException(e); - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.ToFormattedString()); return null; } } diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Objects/CreateSpeckleObjectTaskComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Objects/CreateSpeckleObjectTaskComponent.cs index ee26258f53..b20eb28967 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Objects/CreateSpeckleObjectTaskComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Objects/CreateSpeckleObjectTaskComponent.cs @@ -6,6 +6,7 @@ using ConnectorGrasshopper.Extras; using Grasshopper.Kernel; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; using Logging = Speckle.Core.Logging; using Utilities = ConnectorGrasshopper.Extras.Utilities; @@ -124,7 +125,7 @@ protected override void SolveInstance(IGH_DataAccess DA) foreach (var error in Converter.Report.ConversionErrors) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, - error.Message + ": " + error.InnerException?.Message); + error.ToFormattedString()); } Converter.Report.ConversionErrors.Clear(); } @@ -173,7 +174,7 @@ public async Task DoWork(Dictionary inputData) catch (Exception e) { Logging.Log.CaptureException(e); - AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"{e.Message}"); + AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"{e.ToFormattedString()}"); hasErrors = true; } @@ -184,7 +185,7 @@ public async Task DoWork(Dictionary inputData) catch (Exception e) { Logging.Log.CaptureException(e); - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"{e.Message}"); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"{e.ToFormattedString()}"); hasErrors = true; } } @@ -202,7 +203,7 @@ public async Task DoWork(Dictionary inputData) catch (Exception e) { Logging.Log.CaptureException(e); - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"{e.Message}"); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"{e.ToFormattedString()}"); hasErrors = true; } } @@ -219,7 +220,7 @@ public async Task DoWork(Dictionary inputData) { // If we reach this, something happened that we weren't expecting... Logging.Log.CaptureException(e); - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.ToFormattedString()); } return new Base(); diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Objects/DeconstructSpeckleObjectTaskComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Objects/DeconstructSpeckleObjectTaskComponent.cs index b57ceae30c..6f78afc2aa 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Objects/DeconstructSpeckleObjectTaskComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Objects/DeconstructSpeckleObjectTaskComponent.cs @@ -9,6 +9,7 @@ using Grasshopper.Kernel.Data; using Grasshopper.Kernel.Types; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; using Logging = Speckle.Core.Logging; using Utilities = ConnectorGrasshopper.Extras.Utilities; @@ -90,7 +91,7 @@ protected override void SolveInstance(IGH_DataAccess DA) foreach (var error in Converter.Report.ConversionErrors) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, - error.Message + ": " + error.InnerException?.Message); + error.ToFormattedString()); } Converter.Report.ConversionErrors.Clear(); } @@ -274,7 +275,7 @@ protected override void BeforeSolveInstance() } catch (Exception e) { - AddRuntimeMessage(GH_RuntimeMessageLevel.Warning,$"Failed to fetch outputs:\n\t{e.Message}"); + AddRuntimeMessage(GH_RuntimeMessageLevel.Warning,$"Failed to fetch outputs:\n\t{e.ToFormattedString()}"); } base.BeforeSolveInstance(); } @@ -319,7 +320,7 @@ public Dictionary DoWork(Base @base) { // If we reach this, something happened that we weren't expecting... Logging.Log.CaptureException(e); - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.ToFormattedString()); return null; } } diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Objects/Deprecated/ExpandSpeckleObjectTaskComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Objects/Deprecated/ExpandSpeckleObjectTaskComponent.cs index bd448523bf..dfafcb9841 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Objects/Deprecated/ExpandSpeckleObjectTaskComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Objects/Deprecated/ExpandSpeckleObjectTaskComponent.cs @@ -11,6 +11,7 @@ using Grasshopper.Kernel.Parameters; using Grasshopper.Kernel.Types; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; using Logging = Speckle.Core.Logging; using Utilities = ConnectorGrasshopper.Extras.Utilities; @@ -108,7 +109,7 @@ protected override void SolveInstance(IGH_DataAccess DA) foreach (var error in Converter.Report.ConversionErrors) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, - error.Message + ": " + error.InnerException?.Message); + error.ToFormattedString()); } Converter.Report.ConversionErrors.Clear(); } @@ -317,7 +318,7 @@ public Dictionary DoWork(Base @base) { // If we reach this, something happened that we weren't expecting... Logging.Log.CaptureException(e); - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.ToFormattedString()); return null; } } diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Objects/ExtendSpeckleObjectByKeyValueTaskComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Objects/ExtendSpeckleObjectByKeyValueTaskComponent.cs index b1698e4bbb..97ce1b137b 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Objects/ExtendSpeckleObjectByKeyValueTaskComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Objects/ExtendSpeckleObjectByKeyValueTaskComponent.cs @@ -7,6 +7,7 @@ using Grasshopper.Kernel.Data; using Grasshopper.Kernel.Types; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; using Logging = Speckle.Core.Logging; using Utilities = ConnectorGrasshopper.Extras.Utilities; @@ -89,7 +90,7 @@ protected override void SolveInstance(IGH_DataAccess DA) foreach (var error in Converter.Report.ConversionErrors) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, - error.Message + ": " + error.InnerException?.Message); + error.ToFormattedString()); } Converter.Report.ConversionErrors.Clear(); } @@ -134,7 +135,7 @@ public Base DoWork(Base @base, List keys, GH_Structure valueTre } catch (Exception e) { - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.ToFormattedString()); hasErrors = true; } @@ -170,7 +171,7 @@ public Base DoWork(Base @base, List keys, GH_Structure valueTre } catch (Exception e) { - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.ToFormattedString()); hasErrors = true; } } @@ -187,7 +188,7 @@ public Base DoWork(Base @base, List keys, GH_Structure valueTre { // If we reach this, something happened that we weren't expecting... Logging.Log.CaptureException(e); - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.ToFormattedString()); return null; } } diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Objects/ExtendSpeckleObjectTaskComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Objects/ExtendSpeckleObjectTaskComponent.cs index a33f83497f..ace144a412 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Objects/ExtendSpeckleObjectTaskComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Objects/ExtendSpeckleObjectTaskComponent.cs @@ -7,6 +7,7 @@ using Grasshopper.Kernel; using Grasshopper.Kernel.Types; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; using Logging = Speckle.Core.Logging; using Utilities = ConnectorGrasshopper.Extras.Utilities; @@ -165,7 +166,7 @@ protected override void SolveInstance(IGH_DataAccess DA) foreach (var error in Converter.Report.ConversionErrors) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, - error.Message + ": " + error.InnerException?.Message); + error.ToFormattedString()); } Converter.Report.ConversionErrors.Clear(); } @@ -241,7 +242,7 @@ public Base DoWork(Base @base, Dictionary inputData) catch (Exception e) { Logging.Log.CaptureException(e); - AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"{e.Message}"); + AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"{e.ToFormattedString()}"); hasErrors = true; } @@ -252,7 +253,7 @@ public Base DoWork(Base @base, Dictionary inputData) catch (Exception e) { Logging.Log.CaptureException(e); - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"{e.Message}"); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"{e.ToFormattedString()}"); hasErrors = true; } } @@ -270,7 +271,7 @@ public Base DoWork(Base @base, Dictionary inputData) catch (Exception e) { Logging.Log.CaptureException(e); - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"{e.Message}"); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"{e.ToFormattedString()}"); hasErrors = true; } } @@ -285,7 +286,7 @@ public Base DoWork(Base @base, Dictionary inputData) { // If we reach this, something happened that we weren't expecting... Logging.Log.CaptureException(e); - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.ToFormattedString()); } return @base; diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Objects/GetObjectValueByKeyTaskComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Objects/GetObjectValueByKeyTaskComponent.cs index 2b9a0dc58c..39ecd1f4d0 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Objects/GetObjectValueByKeyTaskComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Objects/GetObjectValueByKeyTaskComponent.cs @@ -8,6 +8,7 @@ using ConnectorGrasshopper.Extras; using Grasshopper.Kernel; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; using Logging = Speckle.Core.Logging; using Utilities = ConnectorGrasshopper.Extras.Utilities; @@ -66,7 +67,7 @@ protected override void SolveInstance(IGH_DataAccess DA) foreach (var error in Converter.Report.ConversionErrors) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, - error.Message + ": " + error.InnerException?.Message); + error.ToFormattedString()); } Converter.Report.ConversionErrors.Clear(); } @@ -122,7 +123,7 @@ private object DoWork(Base @base, string key, CancellationToken token) { // If we reach this, something happened that we weren't expecting... Logging.Log.CaptureException(e); - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.ToFormattedString()); } return value; diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Deprecated/Operations.ReceiveComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Deprecated/Operations.ReceiveComponent.cs index 26587b5a30..40e7b10783 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Deprecated/Operations.ReceiveComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Deprecated/Operations.ReceiveComponent.cs @@ -22,6 +22,7 @@ using Speckle.Core.Api.SubscriptionModels; using Speckle.Core.Credentials; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; using Speckle.Core.Transports; using Logging = Speckle.Core.Logging; using Utilities = ConnectorGrasshopper.Extras.Utilities; @@ -472,7 +473,7 @@ public override void DoWork(Action ReportProgress, Action Done) // TODO: This message condition should be removed once the `link sharing` issue is resolved server-side. var msg = exception.Message.Contains("401") ? "You don't have access to this stream/transport , or it doesn't exist." - : exception.Message; + : exception.ToFormattedString(); RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, $"{transportName}: { msg }")); Done(); var asyncParent = (GH_AsyncComponent)Parent; @@ -492,7 +493,7 @@ public override void DoWork(Action ReportProgress, Action Done) } catch (Exception e) { - RuntimeMessages.Add((GH_RuntimeMessageLevel.Warning, e.InnerException?.Message ?? e.Message)); + RuntimeMessages.Add((GH_RuntimeMessageLevel.Warning, e.ToFormattedString())); Done(); return; } @@ -572,8 +573,7 @@ await client.CommitReceived(new CommitReceivedInput { // If we reach this, something happened that we weren't expecting... Logging.Log.CaptureException(e); - var msg = e.InnerException?.Message ?? e.Message; - RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, msg)); + RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, e.ToFormattedString())); Done(); } } @@ -591,7 +591,7 @@ public static async Task GetCommit(StreamWrapper InputWrapper, Client cl } catch (Exception e) { - OnFail(GH_RuntimeMessageLevel.Error, e.Message); + OnFail(GH_RuntimeMessageLevel.Error, e.ToFormattedString()); return null; } case StreamWrapperType.Object: diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Deprecated/Operations.SendComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Deprecated/Operations.SendComponent.cs index 6e88df4fbf..8fa8bb76cf 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Deprecated/Operations.SendComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Deprecated/Operations.SendComponent.cs @@ -20,6 +20,7 @@ using Speckle.Core.Api; using Speckle.Core.Credentials; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; using Speckle.Core.Transports; using Logging = Speckle.Core.Logging; using Utilities = ConnectorGrasshopper.Extras.Utilities; @@ -309,7 +310,7 @@ public override void DoWork(Action ReportProgress, Action Done) } catch (Exception e) { - RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, e.Message)); + RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, e.ToFormattedString())); Done(); return; } @@ -344,7 +345,7 @@ public override void DoWork(Action ReportProgress, Action Done) catch (Exception e) { // TODO: Check this with team. - RuntimeMessages.Add((GH_RuntimeMessageLevel.Warning, e.Message)); + RuntimeMessages.Add((GH_RuntimeMessageLevel.Warning, e.ToFormattedString())); } } @@ -375,7 +376,7 @@ public override void DoWork(Action ReportProgress, Action Done) } catch (Exception e) { - RuntimeMessages.Add((GH_RuntimeMessageLevel.Warning, e.InnerException?.Message ?? e.Message)); + RuntimeMessages.Add((GH_RuntimeMessageLevel.Warning, e.ToFormattedString())); continue; } @@ -416,7 +417,7 @@ public override void DoWork(Action ReportProgress, Action Done) // TODO: This message condition should be removed once the `link sharing` issue is resolved server-side. var msg = exception.Message.Contains("401") ? $"You don't have access to this transport , or it doesn't exist." - : exception.Message; + : exception.ToFormattedString(); RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, $"{transportName}: {msg}")); Done(); var asyncParent = (GH_AsyncComponent)Parent; @@ -522,7 +523,7 @@ public override void DoWork(Action ReportProgress, Action Done) // If we reach this, something happened that we weren't expecting... Logging.Log.CaptureException(e); - RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.Message)); + RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.ToFormattedString())); //Parent.Message = "Error"; //((SendComponent)Parent).CurrentComponentState = "expired"; Done(); diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Deprecated/Operations.SendComponentSync.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Deprecated/Operations.SendComponentSync.cs index 4ad4580313..454da594b9 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Deprecated/Operations.SendComponentSync.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Deprecated/Operations.SendComponentSync.cs @@ -14,6 +14,7 @@ using Speckle.Core.Credentials; using Speckle.Core.Kits; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; using Speckle.Core.Transports; using Logging = Speckle.Core.Logging; @@ -275,7 +276,7 @@ protected override void SolveInstance(IGH_DataAccess DA) catch (Exception e) { // TODO: Check this with team. - AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, e.ToFormattedString()); } } @@ -306,7 +307,7 @@ protected override void SolveInstance(IGH_DataAccess DA) } catch (Exception e) { - AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, e.InnerException?.Message ?? e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, e.ToFormattedString()); continue; } @@ -399,7 +400,7 @@ protected override void SolveInstance(IGH_DataAccess DA) } catch (Exception e) { - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.ToFormattedString()); return null; } } diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Deprecated/Operations.VariableInputSendComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Deprecated/Operations.VariableInputSendComponent.cs index 22ad722ba2..879b6c9f69 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Deprecated/Operations.VariableInputSendComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Deprecated/Operations.VariableInputSendComponent.cs @@ -22,6 +22,7 @@ using Speckle.Core.Credentials; using Speckle.Core.Logging; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; using Speckle.Core.Transports; using Utilities = ConnectorGrasshopper.Extras.Utilities; @@ -375,7 +376,7 @@ public override void DoWork(Action ReportProgress, Action Done) } catch (Exception e) { - RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, e.Message)); + RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, e.ToFormattedString())); Done(); return; } @@ -417,7 +418,7 @@ public override void DoWork(Action ReportProgress, Action Done) catch (Exception e) { // TODO: Check this with team. - RuntimeMessages.Add((GH_RuntimeMessageLevel.Warning, e.Message)); + RuntimeMessages.Add((GH_RuntimeMessageLevel.Warning, e.ToFormattedString())); } } @@ -448,7 +449,7 @@ public override void DoWork(Action ReportProgress, Action Done) } catch (Exception e) { - RuntimeMessages.Add((GH_RuntimeMessageLevel.Warning, e.InnerException?.Message ?? e.Message)); + RuntimeMessages.Add((GH_RuntimeMessageLevel.Warning, e.ToFormattedString())); continue; } @@ -489,7 +490,7 @@ public override void DoWork(Action ReportProgress, Action Done) // TODO: This message condition should be removed once the `link sharing` issue is resolved server-side. var msg = exception.Message.Contains("401") ? $"You don't have access to this transport , or it doesn't exist." - : exception.Message; + : exception.ToFormattedString(); RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, $"{transportName}: {msg}")); Done(); var asyncParent = (GH_AsyncComponent)Parent; @@ -595,7 +596,7 @@ public override void DoWork(Action ReportProgress, Action Done) // If we reach this, something happened that we weren't expecting... Log.CaptureException(e); - RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.Message)); + RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.ToFormattedString())); //Parent.Message = "Error"; //((SendComponent)Parent).CurrentComponentState = "expired"; Done(); diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.ReceiveLocalComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.ReceiveLocalComponent.cs index 08c1065df3..979a5ac618 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.ReceiveLocalComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.ReceiveLocalComponent.cs @@ -11,6 +11,7 @@ using Speckle.Core.Api; using Speckle.Core.Kits; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; using Logging = Speckle.Core.Logging; using Utilities = ConnectorGrasshopper.Extras.Utilities; @@ -141,7 +142,7 @@ public override void DoWork(Action ReportProgress, Action Done) { // If we reach this, something happened that we weren't expecting... Logging.Log.CaptureException(e); - RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.Message)); + RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.ToFormattedString())); Parent.Message = "Error"; } Done(); diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.SendLocalComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.SendLocalComponent.cs index 9ae637a572..31e9920254 100755 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.SendLocalComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.SendLocalComponent.cs @@ -9,6 +9,7 @@ using Speckle.Core.Api; using Speckle.Core.Kits; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; using Logging = Speckle.Core.Logging; using Utilities = ConnectorGrasshopper.Extras.Utilities; @@ -71,7 +72,7 @@ public override void DoWork(Action ReportProgress, Action Done) catch (Exception e) { Console.WriteLine(e); - RuntimeMessages.Add((GH_RuntimeMessageLevel.Warning, e.Message)); + RuntimeMessages.Add((GH_RuntimeMessageLevel.Warning, e.ToFormattedString())); } Done(); diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.SyncSendComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.SyncSendComponent.cs index b553365a4d..d6744c3669 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.SyncSendComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.SyncSendComponent.cs @@ -15,6 +15,7 @@ using Speckle.Core.Credentials; using Speckle.Core.Kits; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; using Speckle.Core.Transports; using Logging = Speckle.Core.Logging; @@ -158,7 +159,7 @@ protected override void SolveInstance(IGH_DataAccess DA) catch (Exception e) { // TODO: Check this with team. - AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, e.ToFormattedString()); } } @@ -184,7 +185,7 @@ protected override void SolveInstance(IGH_DataAccess DA) } catch (Exception e) { - AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, e.InnerException?.Message ?? e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, e.ToFormattedString()); continue; } @@ -277,7 +278,7 @@ protected override void SolveInstance(IGH_DataAccess DA) } catch (Exception e) { - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.ToFormattedString()); return null; } } diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.VariableInputReceiveComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.VariableInputReceiveComponent.cs index f41f4308df..e2a96aab34 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.VariableInputReceiveComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.VariableInputReceiveComponent.cs @@ -24,6 +24,7 @@ using Speckle.Core.Credentials; using Speckle.Core.Logging; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; using Speckle.Core.Transports; using Utilities = ConnectorGrasshopper.Extras.Utilities; @@ -395,6 +396,10 @@ private void HandleInputType(StreamWrapper wrapper) AutoReceive = false; StreamWrapper = wrapper; LastInfoMessage = null; + Task.Run(async () => + { + await ResetApiClient(wrapper); + }); return; } @@ -421,11 +426,30 @@ private void HandleInputType(StreamWrapper wrapper) private async Task ResetApiClient(StreamWrapper wrapper) { - ApiClient?.Dispose(); - var acc = await wrapper.GetAccount(); - ApiClient = new Client(acc); - ApiClient.SubscribeCommitCreated(StreamWrapper.StreamId); - ApiClient.OnCommitCreated += ApiClient_OnCommitCreated; + try + { + ApiClient?.Dispose(); + Account account = null; + try + { + account = wrapper?.GetAccount().Result; + } + catch (Exception e) + { + AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, e.ToFormattedString()); + account = new Account + { + id = wrapper?.StreamId, serverInfo = new ServerInfo() { url = wrapper?.ServerUrl }, token = "", refreshToken = "" + }; + } + ApiClient = new Client(account); + ApiClient.SubscribeCommitCreated(StreamWrapper.StreamId); + ApiClient.OnCommitCreated += ApiClient_OnCommitCreated; + } + catch (Exception e) + { + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.ToFormattedString()); + } } private void ApiClient_OnCommitCreated(object sender, CommitInfo e) @@ -524,7 +548,7 @@ public override void DoWork(Action ReportProgress, Action Done) // TODO: This message condition should be removed once the `link sharing` issue is resolved server-side. var msg = exception.Message.Contains("401") ? "You don't have access to this stream/transport , or it doesn't exist." - : exception.InnerException != null ? exception.InnerException.Message : exception.Message; + : exception.ToFormattedString(); RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, $"{transportName}: { msg }")); Done(); var asyncParent = (GH_AsyncComponent)Parent; @@ -536,22 +560,10 @@ public override void DoWork(Action ReportProgress, Action Done) } }); }; + + Speckle.Core.Logging.Analytics.TrackEvent(receiveComponent.ApiClient.Account, Speckle.Core.Logging.Analytics.Events.Receive, new Dictionary() { { "auto", receiveComponent.AutoReceive } }); - Client client; - try - { - client = new Client(InputWrapper?.GetAccount().Result); - } - catch (Exception e) - { - RuntimeMessages.Add((GH_RuntimeMessageLevel.Warning, e.InnerException?.Message ?? e.Message)); - Done(); - return; - } - - Speckle.Core.Logging.Analytics.TrackEvent(client.Account, Speckle.Core.Logging.Analytics.Events.Receive, new Dictionary() { { "auto", receiveComponent.AutoReceive } }); - - var remoteTransport = new ServerTransport(InputWrapper?.GetAccount().Result, InputWrapper?.StreamId); + var remoteTransport = new ServerTransport(receiveComponent.ApiClient.Account, InputWrapper?.StreamId); remoteTransport.TransportName = "R"; // Means it's a copy paste of an empty non-init component; set the record and exit fast unless ReceiveOnOpen is true. @@ -567,8 +579,8 @@ public override void DoWork(Action ReportProgress, Action Done) var t = Task.Run(async () => { - ((VariableInputReceiveComponent)Parent).PrevReceivedData = null; - var myCommit = await GetCommit(InputWrapper, client, (level, message) => + receiveComponent.PrevReceivedData = null; + var myCommit = await GetCommit(InputWrapper, receiveComponent.ApiClient, (level, message) => { RuntimeMessages.Add((level, message)); @@ -576,7 +588,8 @@ public override void DoWork(Action ReportProgress, Action Done) if (myCommit == null) { - throw new Exception("Failed to find a valid commit or object to get."); + Done(); + return; } ReceivedCommit = myCommit; @@ -600,7 +613,7 @@ public override void DoWork(Action ReportProgress, Action Done) try { - await client.CommitReceived(new CommitReceivedInput + await receiveComponent.ApiClient.CommitReceived(new CommitReceivedInput { streamId = InputWrapper.StreamId, commitId = myCommit.id, @@ -627,8 +640,7 @@ await client.CommitReceived(new CommitReceivedInput { // If we reach this, something happened that we weren't expecting... Log.CaptureException(e); - var msg = e.InnerException?.Message ?? e.Message; - RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, msg)); + RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, e.ToFormattedString())); Done(); } } @@ -642,11 +654,13 @@ public static async Task GetCommit(StreamWrapper InputWrapper, Client cl try { myCommit = await client.CommitGet(CancellationToken, InputWrapper.StreamId, InputWrapper.CommitId); + if (myCommit == null) + OnFail(GH_RuntimeMessageLevel.Warning, $"Commit with id {InputWrapper.CommitId} was not found in stream {InputWrapper.StreamId}."); return myCommit; } catch (Exception e) { - OnFail(GH_RuntimeMessageLevel.Error, e.Message); + OnFail(GH_RuntimeMessageLevel.Error, e.ToFormattedString()); return null; } case StreamWrapperType.Object: @@ -654,7 +668,7 @@ public static async Task GetCommit(StreamWrapper InputWrapper, Client cl return myCommit; case StreamWrapperType.Stream: case StreamWrapperType.Undefined: - var mb = await client.BranchGet(InputWrapper.StreamId, "main", 1); + var mb = await client.BranchGet(CancellationToken, InputWrapper.StreamId, "main", 1); if (mb.commits.totalCount == 0) { // TODO: Warn that we're not pulling from the main branch @@ -665,10 +679,10 @@ public static async Task GetCommit(StreamWrapper InputWrapper, Client cl return mb.commits.items[0]; } - var cms = await client.StreamGetCommits(InputWrapper.StreamId, 1); + var cms = await client.StreamGetCommits(CancellationToken, InputWrapper.StreamId, 1); if (cms.Count == 0) { - OnFail(GH_RuntimeMessageLevel.Error, $"This stream has no commits."); + OnFail(GH_RuntimeMessageLevel.Warning, $"This stream has no commits."); return null; } else @@ -676,10 +690,16 @@ public static async Task GetCommit(StreamWrapper InputWrapper, Client cl return cms[0]; } case StreamWrapperType.Branch: - var br = await client.BranchGet(InputWrapper.StreamId, InputWrapper.BranchName, 1); + var br = await client.BranchGet(CancellationToken, InputWrapper.StreamId, InputWrapper.BranchName, 1); + if (br == null) + { + OnFail(GH_RuntimeMessageLevel.Warning, + $"The branch with name '{InputWrapper.BranchName}' doesn't exist in stream {InputWrapper.StreamId} on server {InputWrapper.ServerUrl}"); + return null; + } if (br.commits.totalCount == 0) { - OnFail(GH_RuntimeMessageLevel.Error, $"This branch has no commits."); + OnFail(GH_RuntimeMessageLevel.Warning, $"This branch has no commits."); return null; } return br.commits.items[0]; diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.VariableInputSendComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.VariableInputSendComponent.cs index 57d848e16f..89a4709cf2 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.VariableInputSendComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Ops/Operations.VariableInputSendComponent.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Drawing; @@ -23,6 +23,7 @@ using Speckle.Core.Logging; using Speckle.Core.Models; using Speckle.Core.Transports; +using Speckle.Core.Models.Extensions; using Utilities = ConnectorGrasshopper.Extras.Utilities; namespace ConnectorGrasshopper.Ops @@ -158,6 +159,10 @@ public override void AppendAdditionalMenuItems(ToolStripDropDown menu) base.AppendAdditionalMenuItems(menu); } + public bool HasDuplicateKeys => Params.Input.Skip(2) + .Select(p => p.NickName) + .GroupBy(x => x).Count(group => group.Count() > 1) > 0; + protected override void SolveInstance(IGH_DataAccess DA) { @@ -167,7 +172,15 @@ protected override void SolveInstance(IGH_DataAccess DA) base.SolveInstance(DA); return; } - + + if (HasDuplicateKeys) + { + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Cannot have duplicate keys in object."); + CurrentComponentState = "needs_input"; + Message = "Expired"; + return; + } + if ((AutoSend || CurrentComponentState == "primed_to_send" || CurrentComponentState == "sending") && !JustPastedIn) { @@ -238,14 +251,15 @@ public bool CanRemoveParameter(GH_ParameterSide side, int index) public IGH_Param CreateParameter(GH_ParameterSide side, int index) { var uniqueName = GH_ComponentParamServer.InventUniqueNickname("ABCD", Params.Input); - - return new SendReceiveDataParam + var myParam = new SendReceiveDataParam { Name = uniqueName, NickName = uniqueName, MutableNickName = true, Optional = false }; + myParam.Attributes = new GenericAccessParamAttributes(myParam, Attributes); + return myParam; } public bool DestroyParameter(GH_ParameterSide side, int index) @@ -255,6 +269,11 @@ public bool DestroyParameter(GH_ParameterSide side, int index) public void VariableParameterMaintenance() { + Params.Input.Skip(2) + .Where(param => !(param.Attributes is GenericAccessParamAttributes)) + .ToList() + .ForEach(param => param.Attributes = new GenericAccessParamAttributes(param, Attributes) + ); } private DebounceDispatcher nicknameChangeDebounce = new DebounceDispatcher(); @@ -376,7 +395,7 @@ public override void DoWork(Action ReportProgress, Action Done) } catch (Exception e) { - RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, e.Message)); + RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, e.ToFormattedString())); Done(); return; } @@ -418,7 +437,7 @@ public override void DoWork(Action ReportProgress, Action Done) catch (Exception e) { // TODO: Check this with team. - RuntimeMessages.Add((GH_RuntimeMessageLevel.Warning, e.Message)); + RuntimeMessages.Add((GH_RuntimeMessageLevel.Warning, e.ToFormattedString())); } } @@ -449,7 +468,7 @@ public override void DoWork(Action ReportProgress, Action Done) } catch (Exception e) { - RuntimeMessages.Add((GH_RuntimeMessageLevel.Warning, e.InnerException?.Message ?? e.Message)); + RuntimeMessages.Add((GH_RuntimeMessageLevel.Warning, e.ToFormattedString())); continue; } @@ -490,8 +509,8 @@ public override void DoWork(Action ReportProgress, Action Done) // TODO: This message condition should be removed once the `link sharing` issue is resolved server-side. var msg = exception.Message.Contains("401") ? $"You don't have access to this transport , or it doesn't exist." - : exception.Message; - RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, $"{transportName}: {msg}")); + : exception.ToFormattedString(); + RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, $"{transportName}: {exception.ToFormattedString()}")); Done(); var asyncParent = (GH_AsyncComponent)Parent; asyncParent.CancellationSources.ForEach(source => @@ -596,7 +615,7 @@ public override void DoWork(Action ReportProgress, Action Done) // If we reach this, something happened that we weren't expecting... Log.CaptureException(e); - RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.Message)); + RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.ToFormattedString())); //Parent.Message = "Error"; //((SendComponent)Parent).CurrentComponentState = "expired"; Done(); diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Properties/AssemblyInfo.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Properties/AssemblyInfo.cs index 11818d5502..ac7b5aec47 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Properties/AssemblyInfo.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/SchemaBuilder/CreateSchemaObject.cs b/ConnectorGrasshopper/ConnectorGrasshopper/SchemaBuilder/CreateSchemaObject.cs index f2bd8c3e98..0ac6f3d348 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/SchemaBuilder/CreateSchemaObject.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/SchemaBuilder/CreateSchemaObject.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Drawing; @@ -16,6 +16,7 @@ using Speckle.Core.Kits; using Speckle.Core.Logging; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; using Logging = Speckle.Core.Logging; using Utilities = ConnectorGrasshopper.Extras.Utilities; @@ -73,7 +74,7 @@ public override void AppendAdditionalMenuItems(ToolStripDropDown menu) objectItem.ToolTipText = "The default behaviour. Output will be the specified object schema."; var tagItem = - schemaConversionHeader.DropDownItems.Add($"Convert as {mainParam.Name ?? "geometry"} with {Name} attached") as + schemaConversionHeader.DropDownItems.Add($"Convert as {mainParam?.Name ?? "geometry"} with {Name} attached") as ToolStripMenuItem; tagItem.Checked = UseSchemaTag; tagItem.Enabled = mainParam != null; @@ -214,7 +215,7 @@ private void RegisterPropertyAsInputParameter(ParameterInfo param, int index) } // Create new param based on property name - Param_GenericObject newInputParam = new Param_GenericObject(); + SpeckleStatefulParam newInputParam = new SpeckleStatefulParam(); newInputParam.Name = propName; newInputParam.NickName = propName; newInputParam.MutableNickName = false; @@ -356,7 +357,7 @@ protected override void SolveInstance(IGH_DataAccess DA) Tracker.TrackNodeRun("Create Schema Object", Name); - var units = Units.GetUnitsFromString(Rhino.RhinoDoc.ActiveDoc.GetUnitSystemName(true, false, false, false)); + var units = Units.GetUnitsFromString(Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString()); List cParamsValues = new List(); var cParams = SelectedConstructor.GetParameters(); @@ -383,7 +384,7 @@ protected override void SolveInstance(IGH_DataAccess DA) } catch (Exception e) { - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.InnerException?.Message ?? e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.ToFormattedString()); return; } } @@ -411,7 +412,7 @@ protected override void SolveInstance(IGH_DataAccess DA) } catch (Exception e) { - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.InnerException?.Message ?? e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.ToFormattedString()); return; } @@ -434,7 +435,7 @@ protected override void SolveInstance(IGH_DataAccess DA) } catch (Exception e) { - AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, e.ToFormattedString()); } } @@ -470,7 +471,7 @@ private object ExtractRealInputValue(object inputValue) { var type = inputValue.GetType(); var propertyInfo = type.GetProperty("Value"); - var value = propertyInfo.GetValue(inputValue); + var value = propertyInfo?.GetValue(inputValue); return value; } @@ -482,11 +483,11 @@ private object GetObjectListProp(IGH_Param param, List values, Type t) { if (!values.Any()) return null; - var listElementType = t.GetElementType(); - var list = (IList)Array.CreateInstance(listElementType, values.Count); - for (int i = 0; i < values.Count; i++) + var list = (IList)Activator.CreateInstance(t); + var listElementType = list.GetType().GetGenericArguments().Single(); + foreach (var value in values) { - list[i] = (ConvertType(listElementType, values[i], param.Name)); + list.Add(ConvertType(listElementType, value, param.Name)); } return list; diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/SchemaBuilder/CreateSchemaObjectBase.cs b/ConnectorGrasshopper/ConnectorGrasshopper/SchemaBuilder/CreateSchemaObjectBase.cs index e1774d1aa3..8518f74d15 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/SchemaBuilder/CreateSchemaObjectBase.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/SchemaBuilder/CreateSchemaObjectBase.cs @@ -14,6 +14,7 @@ using Grasshopper.Kernel.Special; using Speckle.Core.Kits; using Speckle.Core.Models; +using Speckle.Core.Models.Extensions; using Logging = Speckle.Core.Logging; using Utilities = ConnectorGrasshopper.Extras.Utilities; @@ -342,7 +343,7 @@ protected override void SolveInstance(IGH_DataAccess DA) Tracker.TrackNodeRun("Create Schema Object", Name); - var units = Units.GetUnitsFromString(Rhino.RhinoDoc.ActiveDoc.GetUnitSystemName(true, false, false, false)); + var units = Units.GetUnitsFromString(Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString()); List cParamsValues = new List(); var cParams = SelectedConstructor.GetParameters(); @@ -369,7 +370,7 @@ protected override void SolveInstance(IGH_DataAccess DA) } catch (Exception e) { - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.InnerException?.Message ?? e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.ToFormattedString()); return; } } @@ -399,7 +400,7 @@ protected override void SolveInstance(IGH_DataAccess DA) catch (Exception e) { - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.InnerException?.Message ?? e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.ToFormattedString()); return; } @@ -424,7 +425,7 @@ protected override void SolveInstance(IGH_DataAccess DA) } catch (Exception e) { - AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, e.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, e.ToFormattedString()); } } diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/SchemaBuilder/SchemaBuilderGen.cs b/ConnectorGrasshopper/ConnectorGrasshopper/SchemaBuilder/SchemaBuilderGen.cs index 6bfe2edc82..58181d4052 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/SchemaBuilder/SchemaBuilderGen.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/SchemaBuilder/SchemaBuilderGen.cs @@ -1,4 +1,4 @@ - + using System; using Grasshopper.Kernel; @@ -1275,27 +1275,27 @@ public override void AddedToDocument(GH_Document document){ } // This is generated code: -public class MaterialSchemaComponent: CreateSchemaObjectBase { +public class Material1SchemaComponent: CreateSchemaObjectBase { - public MaterialSchemaComponent(): base("Material", "Material", "Creates a Speckle structural material", "Speckle 2 Structural", "Materials") { } + public Material1SchemaComponent(): base("Material (with properties)", "Material (with properties)", "Creates a Speckle structural material with (isotropic) properties", "Speckle 2 Structural", "Materials") { } - public override Guid ComponentGuid => new Guid("a2ec94ca-c50c-01bf-3d12-0c8feb41004b"); + public override Guid ComponentGuid => new Guid("15412d80-2db7-dede-ddba-eed400b9d083"); public override void AddedToDocument(GH_Document document){ - SelectedConstructor = CSOUtils.FindConstructor("Objects.Structural.Materials.Material.ctor(System.String,Objects.Structural.MaterialType,System.String,System.String,System.String)","Objects.Structural.Materials.Material"); + SelectedConstructor = CSOUtils.FindConstructor("Objects.Structural.Materials.Material.ctor(System.String,Objects.Structural.MaterialType,System.String,System.String,System.String,System.Double,System.Double,System.Double,System.Double,System.Double,System.Double,System.Double,System.Double,System.Double)","Objects.Structural.Materials.Material"); base.AddedToDocument(document); } } // This is generated code: -public class Material1SchemaComponent: CreateSchemaObjectBase { +public class MaterialSchemaComponent: CreateSchemaObjectBase { - public Material1SchemaComponent(): base("Material (with properties)", "Material (with properties)", "Creates a Speckle structural material with (isotropic) properties", "Speckle 2 Structural", "Materials") { } + public MaterialSchemaComponent(): base("RevitMaterial", "RevitMaterial", "Creates a Speckle material", "Speckle 2 BIM", "Architecture") { } - public override Guid ComponentGuid => new Guid("15412d80-2db7-dede-ddba-eed400b9d083"); + public override Guid ComponentGuid => new Guid("a2ec94ca-c50c-01bf-3d12-0c8feb41004b"); public override void AddedToDocument(GH_Document document){ - SelectedConstructor = CSOUtils.FindConstructor("Objects.Structural.Materials.Material.ctor(System.String,Objects.Structural.MaterialType,System.String,System.String,System.String,System.Double,System.Double,System.Double,System.Double,System.Double,System.Double,System.Double,System.Double,System.Double)","Objects.Structural.Materials.Material"); + SelectedConstructor = CSOUtils.FindConstructor("Objects.Other.Material.ctor(System.String)","Objects.Other.Material"); base.AddedToDocument(document); } } @@ -2126,7 +2126,7 @@ public override void AddedToDocument(GH_Document document){ // This is generated code: public class RevitMaterialSchemaComponent: CreateSchemaObjectBase { - public RevitMaterialSchemaComponent(): base("RevitMaterial", "RevitMaterial", "Creates a Speckle material", "Speckle 2 BIM", "Architecture") { } + public RevitMaterialSchemaComponent(): base("RevitMaterial", "RevitMaterial", "Creates a Speckle material", "Speckle 2 Revit", "Architecture") { } public override Guid ComponentGuid => new Guid("c291d027-7a6a-8950-a2aa-77e134675750"); @@ -2245,7 +2245,7 @@ public override void AddedToDocument(GH_Document document){ // This is generated code: public class RevitWallOpening1SchemaComponent: CreateSchemaObjectBase { - public RevitWallOpening1SchemaComponent(): base("Revit Wall Opening", "Revit Wall Opening", "Creates a Speckle Wall opening for revit", "Speckle 2 BIM", "Architecture") { } + public RevitWallOpening1SchemaComponent(): base("Revit Wall Opening", "Revit Wall Opening", "Creates a Speckle Wall opening for revit", "Speckle 2 Revit", "Architecture") { } public override Guid ComponentGuid => new Guid("541bfed0-738d-e1bd-1130-de05ec4bbf9e"); diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamCreateComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamCreateComponent.cs index daa83b60cb..fd5abae4a9 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamCreateComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamCreateComponent.cs @@ -9,6 +9,7 @@ using Grasshopper.Kernel.Data; using Speckle.Core.Api; using Speckle.Core.Credentials; +using Speckle.Core.Models.Extensions; using Logging = Speckle.Core.Logging; namespace ConnectorGrasshopper.Streams @@ -126,7 +127,7 @@ protected override void SolveInstance(IGH_DataAccess DA) Rhino.RhinoApp.InvokeOnUiThread((Action)delegate { ExpireSolution(false); - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"Could not create stream at {account.serverInfo.url}:\n{e.Message}"); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"Could not create stream at {account.serverInfo.url}:\n{e.ToFormattedString()}"); }); } }); diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamDetailsComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamDetailsComponent.cs index 4b1f9bb13a..73ccdee4a8 100755 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamDetailsComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamDetailsComponent.cs @@ -9,6 +9,7 @@ using Grasshopper.Kernel.Types; using Speckle.Core.Api; using Speckle.Core.Credentials; +using Speckle.Core.Models.Extensions; using Logging = Speckle.Core.Logging; namespace ConnectorGrasshopper.Streams @@ -54,7 +55,7 @@ protected override void SolveInstance(IGH_DataAccess DA) if (error != null) { Message = null; - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, error.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, error.ToFormattedString()); error = null; streams = null; } @@ -112,7 +113,7 @@ protected override void SolveInstance(IGH_DataAccess DA) } catch (Exception e) { - error = e.InnerException ?? e; + error = e; return; } diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamGetComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamGetComponent.cs index 9eeca4b901..e92aa356f3 100755 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamGetComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamGetComponent.cs @@ -6,6 +6,7 @@ using ConnectorGrasshopper.Extras; using Grasshopper.Kernel; using Speckle.Core.Credentials; +using Speckle.Core.Models.Extensions; using Logging = Speckle.Core.Logging; namespace ConnectorGrasshopper.Streams @@ -71,7 +72,7 @@ protected override void SolveInstance(IGH_DataAccess DA) if (error != null) { Message = null; - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, error.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, error.ToFormattedString()); error = null; stream = null; } @@ -101,7 +102,7 @@ protected override void SolveInstance(IGH_DataAccess DA) catch (Exception e) { stream = null; - error = e.InnerException ?? e; + error = e; } finally { diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamListComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamListComponent.cs index 374926714a..b05994b2cb 100755 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamListComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamListComponent.cs @@ -8,6 +8,7 @@ using Grasshopper.Kernel.Data; using Speckle.Core.Api; using Speckle.Core.Credentials; +using Speckle.Core.Models.Extensions; using Logging = Speckle.Core.Logging; namespace ConnectorGrasshopper.Streams @@ -45,7 +46,7 @@ protected override void SolveInstance(IGH_DataAccess DA) if (error != null) { Message = null; - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, error.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, error.ToFormattedString()); error = null; streams = null; } diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamUpdateComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamUpdateComponent.cs index 3cf22b4663..b74aaa3a5e 100755 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamUpdateComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Streams/StreamUpdateComponent.cs @@ -5,6 +5,7 @@ using ConnectorGrasshopper.Extras; using Grasshopper.Kernel; using Speckle.Core.Api; +using Speckle.Core.Models.Extensions; using Logging = Speckle.Core.Logging; namespace ConnectorGrasshopper.Streams @@ -57,7 +58,7 @@ protected override void SolveInstance(IGH_DataAccess DA) if (error != null) { Message = null; - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, error.Message); + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, error.ToFormattedString()); error = null; } else if (stream == null) @@ -90,7 +91,7 @@ protected override void SolveInstance(IGH_DataAccess DA) } catch (Exception e) { - error = e.InnerException ?? e; + error = e; } finally { diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Transports/Transports.Sqlite.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Transports/Transports.Sqlite.cs index a2210ba397..10ad68993d 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Transports/Transports.Sqlite.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Transports/Transports.Sqlite.cs @@ -1,7 +1,9 @@ -using System; +using System; using System.Collections.Generic; using System.Drawing; +using System.IO; using Grasshopper.Kernel; +using Speckle.Core.Api; using Speckle.Core.Transports; using Logging = Speckle.Core.Logging; @@ -19,7 +21,7 @@ public SqliteTransportComponent() : base("Sqlite Transport", "Sqlite", "Creates protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddTextParameter("Base Path", "P", "The root folder where you want the sqlite db to be stored. Defaults to `%appdata%`.", GH_ParamAccess.item, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); + pManager.AddTextParameter("Base Path", "P", "The root folder where you want the sqlite db to be stored. Defaults to `%appdata%`.", GH_ParamAccess.item, Helpers.UserApplicationDataPath); pManager.AddTextParameter("Application Name", "N", "The subfolder you want the sqlite db to be stored. Defaults to `Speckle`.", GH_ParamAccess.item, "Speckle"); pManager.AddTextParameter("Database Name", "D", "The name of the actual database file. Defaults to `UserLocalDefaultDb`.", GH_ParamAccess.item, "UserLocalDefaultDb"); } diff --git a/ConnectorGrasshopper/ConnectorGrasshopperUtils/ConnectorGrasshopperUtils.csproj b/ConnectorGrasshopper/ConnectorGrasshopperUtils/ConnectorGrasshopperUtils.csproj index 8357c6d172..2d88f95baf 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopperUtils/ConnectorGrasshopperUtils.csproj +++ b/ConnectorGrasshopper/ConnectorGrasshopperUtils/ConnectorGrasshopperUtils.csproj @@ -43,10 +43,14 @@ - {b4d98d2c-e5da-463e-bf6c-68e9b77c72f3} + {6321CA2D-5275-42A3-A034-170A0040E19E} Core + + + + diff --git a/DesktopUI2/DesktopUI2/Styles/TextBox.xaml b/DesktopUI2/DesktopUI2/Styles/TextBox.xaml index f2d335624c..09280ac3f1 100644 --- a/DesktopUI2/DesktopUI2/Styles/TextBox.xaml +++ b/DesktopUI2/DesktopUI2/Styles/TextBox.xaml @@ -67,6 +67,13 @@ + + diff --git a/DesktopUI2/DesktopUI2/ViewModels/ActivityViewModel.cs b/DesktopUI2/DesktopUI2/ViewModels/ActivityViewModel.cs index ffe1ec811f..5a6a00c25c 100644 --- a/DesktopUI2/DesktopUI2/ViewModels/ActivityViewModel.cs +++ b/DesktopUI2/DesktopUI2/ViewModels/ActivityViewModel.cs @@ -29,11 +29,9 @@ private async Task GetAuthorAsync() public ActivityViewModel(ActivityItem item, Client client) { - _activity = item; _client = client; - switch (item.actionType) { case "commit_receive": @@ -64,8 +62,5 @@ public ActivityViewModel(ActivityItem item, Client client) //this.RaisePropertyChanged("Icon"); //this.RaisePropertyChanged("Align"); } - - - } } diff --git a/DesktopUI2/DesktopUI2/ViewModels/ApplicationObjectViewModel.cs b/DesktopUI2/DesktopUI2/ViewModels/ApplicationObjectViewModel.cs new file mode 100644 index 0000000000..5e2c3104ce --- /dev/null +++ b/DesktopUI2/DesktopUI2/ViewModels/ApplicationObjectViewModel.cs @@ -0,0 +1,111 @@ +using Avalonia; +using Avalonia.Layout; +using ReactiveUI; +using Speckle.Core.Api; +using Speckle.Core.Logging; +using Speckle.Core.Models; +using Splat; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DesktopUI2.ViewModels +{ + public class ApplicationObjectViewModel : ReactiveObject + { + public string Log { get; set; } + public List ApplicationIds { get; set; } + public string Name { get; set; } + public string Id { get; set; } + public string Icon { get; set; } + public string Color { get; set; } = "Gray"; + public string Status { get; set; } + public double Opacity { get; set; } = 1; + public bool PreviewEnabled { get; set; } = true; + + public string SearchText { get; set; } + + private ConnectorBindings Bindings; + private ProgressReport _Progress; + + private bool previewOn = false; + public bool PreviewOn + { + get => previewOn; + set => this.RaiseAndSetIfChanged(ref previewOn, value); + } + + public ApplicationObjectViewModel(ApplicationObject item, bool isReceiver, ProgressReport progress) + { + //use dependency injection to get bindings + Bindings = Locator.Current.GetService(); + _Progress = progress; + var cleanLog = item.Log.Where(o => !string.IsNullOrEmpty(o)).ToList(); + + Id = item.OriginalId; + Name = item.Descriptor; + Log = cleanLog.Count == 0 ? null : string.Join("\n", cleanLog); + Status = item.Status.ToString(); + ApplicationIds = isReceiver ? item.CreatedIds : new List() { item.OriginalId }; + + var logString = cleanLog.Count() != 0 ? String.Join(" ", Log) : ""; + var createdIdsString = String.Join(" ", item.CreatedIds); + SearchText = $"{Id} {Name} {Status} {logString} {createdIdsString}"; + + if (ApplicationIds.Count == 0) PreviewEnabled = false; + + switch (item.Status) + { + case ApplicationObject.State.Created: + Icon = "CheckBold"; + break; + case ApplicationObject.State.Updated: + Icon = "Refresh"; + break; + case ApplicationObject.State.Skipped: + Icon = "Refresh"; + Opacity = 0.6; + break; + case ApplicationObject.State.Removed: + Icon = "MinusThick"; + Opacity = 0.6; + break; + case ApplicationObject.State.Failed: + Icon = "Cancel"; + Color = "Red"; + Opacity = 0.6; + break; + default: + Icon = "Help"; + Opacity = 0.6; + break; + } + } + + public string GetSummary() + { + var summary = new string[2] { $"{Name} {Id} {Status}", Log }; + return string.Join("\n", summary); + } + + public async void PreviewCommand() + { + PreviewOn = !PreviewOn; + if (PreviewOn) + { + foreach (var applicationId in ApplicationIds) + if (!_Progress.SelectedReportObjects.Contains(applicationId)) + _Progress.SelectedReportObjects.Add(applicationId); + Bindings.SelectClientObjects(_Progress.SelectedReportObjects); + Analytics.TrackEvent(Analytics.Events.DUIAction, new Dictionary() { { "name", "Viewed Report Item" } }); + } + else + { + foreach (var applicationId in ApplicationIds) + _Progress.SelectedReportObjects.Remove(applicationId); + Bindings.SelectClientObjects(ApplicationIds, true); + } + } + } +} diff --git a/DesktopUI2/DesktopUI2/ViewModels/BranchViewModel.cs b/DesktopUI2/DesktopUI2/ViewModels/BranchViewModel.cs new file mode 100644 index 0000000000..3c520afa39 --- /dev/null +++ b/DesktopUI2/DesktopUI2/ViewModels/BranchViewModel.cs @@ -0,0 +1,32 @@ +using ReactiveUI; +using Speckle.Core.Api; + +namespace DesktopUI2.ViewModels +{ + public class BranchViewModel : ReactiveObject + { + + private Branch _branch; + public Branch Branch + { + get => _branch; + set => this.RaiseAndSetIfChanged(ref _branch, value); + + } + + private string _icon; + public string Icon + { + get => _icon; + set => this.RaiseAndSetIfChanged(ref _icon, value); + + } + + + public BranchViewModel(Branch branch, string icon = "SourceBranch") + { + Branch = branch; + Icon = icon; + } + } +} diff --git a/DesktopUI2/DesktopUI2/ViewModels/CommentViewModel.cs b/DesktopUI2/DesktopUI2/ViewModels/CommentViewModel.cs index 60562b4a6b..293c866c7a 100644 --- a/DesktopUI2/DesktopUI2/ViewModels/CommentViewModel.cs +++ b/DesktopUI2/DesktopUI2/ViewModels/CommentViewModel.cs @@ -22,12 +22,9 @@ public string Text get { return string.Join("", Comment.text.Doc.Content.Select(x => string.Join("", x.Content.Select(x => x.Text).ToList())).ToList()); - - } } - private async Task GetAuthorAsync() { return await ApiUtils.GetAccount(Comment.authorId, _client); @@ -57,8 +54,6 @@ public string RepliesCount } } - - public CommentViewModel(CommentItem item, string streamId, Client client) { Comment = item; @@ -72,7 +67,6 @@ public CommentViewModel(CommentItem item, string streamId, Client client) Replies.Add(reply); } } - } public void OpenComment() @@ -88,10 +82,7 @@ public void OpenComment() Process.Start(new ProcessStartInfo($"{_client.Account.serverInfo.url}/streams/{StreamId}/{r0.resourceType}s/{r0.resourceId}?cId={Comment.id}{overlay}") { UseShellExecute = true }); - Analytics.TrackEvent(null, Analytics.Events.DUIAction, new Dictionary() { { "name", "Comment View" } }); + Analytics.TrackEvent(Analytics.Events.DUIAction, new Dictionary() { { "name", "Comment View" } }); } - - - } } diff --git a/DesktopUI2/DesktopUI2/ViewModels/DesignViewModels/DesignSavedStreamsViewModel.cs b/DesktopUI2/DesktopUI2/ViewModels/DesignViewModels/DesignSavedStreamsViewModel.cs index 3525d9bbc2..947660ea1b 100644 --- a/DesktopUI2/DesktopUI2/ViewModels/DesignViewModels/DesignSavedStreamsViewModel.cs +++ b/DesktopUI2/DesktopUI2/ViewModels/DesignViewModels/DesignSavedStreamsViewModel.cs @@ -5,10 +5,8 @@ namespace DesktopUI2.ViewModels.DesignViewModels { public class DesignSavedStreamsViewModel { - public List SavedStreams { get; set; } - public DesignSavedStreamsViewModel() { SavedStreams = new List @@ -16,20 +14,16 @@ public DesignSavedStreamsViewModel() new DesignSavedStreamViewModel(), new DesignSavedStreamViewModel() { - Stream = new DesignStream { name = "BIM data is cool" }, StreamState = new DesignStreamState() { BranchName = "main", IsReceiver = false, Filter = new ListSelectionFilter { Icon = "Mouse", Name = "Category" }, - }, ShowNotification = false, - ShowReport = false, NoAccess = true, } - }; } } @@ -40,7 +34,6 @@ public class DesignStreamState public string CommitId { get; set; } public string CommitMessage { get; set; } public bool IsReceiver { get; set; } - public bool SchedulerEnabled { get; set; } public ListSelectionFilter Filter { get; set; } public object Client { get; internal set; } @@ -58,7 +51,6 @@ public class DesignStream public string role { get; set; } } - public class DesignSavedStreamViewModel { public DesignStreamState StreamState { get; set; } @@ -68,14 +60,13 @@ public class DesignSavedStreamViewModel public string LastUsed { get; set; } = "Never"; public string Notification { get; set; } = "Hello"; public bool ShowNotification { get; set; } = true; - public bool NoAccess { get; set; } = false; - public bool ShowReport { get; set; } = true; + public List MenuItems = new List(); public List Activity { get; set; } + public List Report { get; set; } public List Comments { get; set; } - public DesignSavedStreamViewModel() { Stream = new DesignStream { name = "Sample stream x", id = "1324235", role = "owner" }; @@ -87,7 +78,6 @@ public DesignSavedStreamViewModel() SchedulerEnabled = true, IsReceiver = true, Filter = new ListSelectionFilter { Icon = "Mouse", Name = "Category" } - }; Activity = new List() { @@ -100,8 +90,6 @@ public DesignSavedStreamViewModel() Margin = new Avalonia.Thickness(10,10,50,0), Icon = "ArrowTopRight", Message = "Commit created on branch main: 0ae5a01ad7 (Sent 148 objects from Revit2022.)" } }; - - } public void ReceiveCommand() diff --git a/DesktopUI2/DesktopUI2/ViewModels/HomeViewModel.cs b/DesktopUI2/DesktopUI2/ViewModels/HomeViewModel.cs index 871ba2bd50..e2902fcadd 100644 --- a/DesktopUI2/DesktopUI2/ViewModels/HomeViewModel.cs +++ b/DesktopUI2/DesktopUI2/ViewModels/HomeViewModel.cs @@ -259,7 +259,7 @@ public HomeViewModel(IScreen screen) } catch (Exception ex) { - + Log.CaptureException(ex, Sentry.SentryLevel.Error); } } @@ -279,7 +279,7 @@ internal void UpdateSavedStreams(List streams) } catch (Exception ex) { - + Log.CaptureException(ex, Sentry.SentryLevel.Error); } } @@ -292,7 +292,7 @@ internal void UpdateSelectedStream() } catch (Exception ex) { - + Log.CaptureException(ex, Sentry.SentryLevel.Error); } } @@ -332,7 +332,7 @@ internal void AddSavedStream(StreamViewModel stream) } catch (Exception ex) { - + Log.CaptureException(ex, Sentry.SentryLevel.Error); } } @@ -383,13 +383,10 @@ private async Task GetStreams() } catch (Exception ex) { - + Log.CaptureException(ex, Sentry.SentryLevel.Error); } - } - - internal async void Init() { try @@ -407,11 +404,11 @@ internal async void Init() catch { } - HasUpdate = await Helpers.IsConnectorUpdateAvailable(Bindings.GetHostAppName()); + HasUpdate = await Helpers.IsConnectorUpdateAvailable(Bindings.GetHostAppName()).ConfigureAwait(false); } catch (Exception ex) { - + Log.CaptureException(ex, Sentry.SentryLevel.Error); } } @@ -431,29 +428,28 @@ private void RemoveSavedStream(string id) } catch (Exception ex) { - + Log.CaptureException(ex, Sentry.SentryLevel.Error); } } - public async void RemoveAccountCommand(Account account) { try { AccountManager.RemoveAccount(account.id); - Analytics.TrackEvent(null, Analytics.Events.DUIAction, new Dictionary() { { "name", "Account Remove" } }); + Analytics.TrackEvent(Analytics.Events.DUIAction, new Dictionary() { { "name", "Account Remove" } }); Init(); } catch (Exception ex) { - + Log.CaptureException(ex, Sentry.SentryLevel.Error); } } public void OpenProfileCommand(Account account) { Process.Start(new ProcessStartInfo($"{account.serverInfo.url}/profile") { UseShellExecute = true }); - Analytics.TrackEvent(null, Analytics.Events.DUIAction, new Dictionary() { { "name", "Account View" } }); + Analytics.TrackEvent(account, Analytics.Events.DUIAction, new Dictionary() { { "name", "Account View" } }); } public void LaunchManagerCommand() @@ -462,7 +458,7 @@ public void LaunchManagerCommand() { string path = ""; - Analytics.TrackEvent(null, Analytics.Events.DUIAction, new Dictionary() { { "name", "Launch Manager" } }); + Analytics.TrackEvent(Analytics.Events.DUIAction, new Dictionary() { { "name", "Launch Manager" } }); if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { @@ -471,7 +467,7 @@ public void LaunchManagerCommand() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Programs", "speckle-manager", "SpeckleManager.exe"); + path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Speckle", "Manager", "Manager.exe"); } if (File.Exists(path)) @@ -479,12 +475,12 @@ public void LaunchManagerCommand() else { - Process.Start(new ProcessStartInfo($"https://speckle-releases.netlify.app/") { UseShellExecute = true }); + Process.Start(new ProcessStartInfo($"https://releases.speckle.systems/") { UseShellExecute = true }); } } catch (Exception ex) { - + Log.CaptureException(ex, Sentry.SentryLevel.Error); } } public async void AddAccountCommand() @@ -506,7 +502,7 @@ public async void AddAccountCommand() { try { - Analytics.TrackEvent(null, Analytics.Events.DUIAction, new Dictionary() { { "name", "Account Add" } }); + Analytics.TrackEvent(Analytics.Events.DUIAction, new Dictionary() { { "name", "Account Add" } }); await AccountManager.AddAccount(result); await Task.Delay(1000); @@ -514,6 +510,7 @@ public async void AddAccountCommand() } catch (Exception e) { + Log.CaptureException(e, Sentry.SentryLevel.Error); Dialogs.ShowDialog("Something went wrong...", e.Message, Material.Dialog.Icons.DialogIconKind.Error); } } @@ -523,7 +520,7 @@ public async void AddAccountCommand() } catch (Exception ex) { - + Log.CaptureException(ex, Sentry.SentryLevel.Error); } } @@ -554,12 +551,9 @@ public void ReceiveCommand(object parameter) public async void NewStreamCommand() { - var dialog = new NewStreamDialog(Accounts); var result = await dialog.ShowDialog(); - - if (result) { try @@ -577,6 +571,7 @@ public async void NewStreamCommand() } catch (Exception e) { + Log.CaptureException(e, Sentry.SentryLevel.Error); Dialogs.ShowDialog("Something went wrong...", e.Message, Material.Dialog.Icons.DialogIconKind.Error); } } @@ -629,6 +624,7 @@ public async void AddFromUrlCommand() } catch (Exception e) { + Log.CaptureException(e, Sentry.SentryLevel.Error); Dialogs.ShowDialog("Something went wrong...", e.Message, Material.Dialog.Icons.DialogIconKind.Error); } } @@ -683,7 +679,6 @@ public void ToggleDarkThemeCommand() var config = ConfigManager.Load(); config.DarkTheme = isDark; ConfigManager.Save(config); - } private void ChangeTheme(bool isDark) @@ -701,20 +696,13 @@ private void ChangeTheme(bool isDark) theme.SetBaseTheme(Theme.Dark); materialTheme.CurrentTheme = theme; - - } - public void RefreshCommand() { Analytics.TrackEvent(Analytics.Events.DUIAction, new Dictionary() { { "name", "Refresh" } }); ApiUtils.ClearCache(); Init(); } - - } - - } \ No newline at end of file diff --git a/DesktopUI2/DesktopUI2/ViewModels/MainViewModel.cs b/DesktopUI2/DesktopUI2/ViewModels/MainViewModel.cs index 5927e8ca5c..5a3e628623 100644 --- a/DesktopUI2/DesktopUI2/ViewModels/MainViewModel.cs +++ b/DesktopUI2/DesktopUI2/ViewModels/MainViewModel.cs @@ -1,4 +1,5 @@ -using DesktopUI2.ViewModels.Share; +using Avalonia.Controls; +using DesktopUI2.ViewModels.Share; using DesktopUI2.Views.Pages; using DesktopUI2.Views.Pages.ShareControls; using DesktopUI2.Views.Windows.Dialogs; @@ -25,7 +26,7 @@ public class MainViewModel : ViewModelBase, IScreen public bool DialogVisible { - get => _dialogBody!=null; + get => _dialogBody != null; } public double DialogOpacity @@ -33,11 +34,12 @@ public double DialogOpacity get => _dialogBody != null ? 1 : 0; } - private DialogUserControl _dialogBody; - public DialogUserControl DialogBody + private UserControl _dialogBody; + public UserControl DialogBody { get => _dialogBody; - set { + set + { this.RaiseAndSetIfChanged(ref _dialogBody, value); this.RaisePropertyChanged("DialogVisible"); @@ -54,12 +56,13 @@ public MainViewModel(ConnectorBindings _bindings) } public MainViewModel() { - + Init(); } private void Init() { + Instance = this; Setup.Init(Bindings.GetHostAppNameVersion(), Bindings.GetHostAppName()); @@ -79,19 +82,15 @@ private void Init() Bindings.UpdateSavedStreams = HomeViewModel.Instance.UpdateSavedStreams; Bindings.UpdateSelectedStream = HomeViewModel.Instance.UpdateSelectedStream; - Router.PropertyChanged += Router_PropertyChanged; + } //https://github.com/AvaloniaUI/Avalonia/issues/5290 private void CatchReactiveException(Exception e) { - //do nothing + Log.CaptureException(e, Sentry.SentryLevel.Error); } - private void Router_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) - { - throw new System.NotImplementedException(); - } public static void GoHome() { diff --git a/DesktopUI2/DesktopUI2/ViewModels/MappingViewModel.cs b/DesktopUI2/DesktopUI2/ViewModels/MappingViewModel.cs new file mode 100644 index 0000000000..70940d02c4 --- /dev/null +++ b/DesktopUI2/DesktopUI2/ViewModels/MappingViewModel.cs @@ -0,0 +1,249 @@ +using Avalonia; +using DesktopUI2.Views.Windows.Dialogs; +using Newtonsoft.Json; +using ReactiveUI; +using Splat; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Reactive; +using System.Runtime.Serialization; +using System.Xml.Serialization; + +namespace DesktopUI2.ViewModels +{ + public class MappingViewModel : ReactiveObject, IRoutableViewModel + { + public string UrlPathSegment => throw new NotImplementedException(); + + public IScreen HostScreen => throw new NotImplementedException(); + + public ConnectorBindings Bindings { get; set; } + + public ReactiveCommand GoBack => MainViewModel.RouterInstance.NavigateBack; + + public const string UnmappedKey = "New Incoming Types"; + private string TypeCatMisc = "Miscellaneous"; // needs to match string in connectorRevit.Mappings + + private bool isSearching = false; + private Dictionary> _hostTypeValuesDict { get; } = new Dictionary>(); + private string _searchQuery; + public string SearchQuery + { + get => _searchQuery; + set + { + isSearching = true; + this.RaiseAndSetIfChanged(ref _searchQuery, value); + + SearchResults = new List(_hostTypeValuesDict[SelectedCategory].Where(v => v.ToLower().Contains(SearchQuery.ToLower())).ToList()); + this.RaisePropertyChanged(nameof(SearchResults)); + isSearching = false; + } + } + + private List _searchResults; + public List SearchResults + { + get => _searchResults; + set => this.RaiseAndSetIfChanged(ref _searchResults, value); + } + + private string _selectedType; + public string SelectedType + { + get => _selectedType; + set + { + SelectedMappingValue.OutgoingType = value; + this.RaiseAndSetIfChanged(ref _selectedType, value); + } + } + + + public Dictionary> Mapping { get; set; } + + private string _selectedCategory; + public string SelectedCategory + { + get => _selectedCategory; + set + { + this.RaiseAndSetIfChanged(ref _selectedCategory, value); + if (value == UnmappedKey) + { + var tempList = new List(); + foreach (var key in Mapping.Keys) + { + tempList.AddRange(Mapping[key].Where(i => i.NewType == true)); + } + VisibleMappingValues = tempList; + } + else + { + VisibleMappingValues = new List(Mapping[value]); + } + SearchQuery = ""; + SearchResults = _hostTypeValuesDict[value]; + } + } + + private List _visibleMappingValues; + public List VisibleMappingValues + { + get => _visibleMappingValues; + set => this.RaiseAndSetIfChanged(ref _visibleMappingValues, value); + } + + private MappingValue _selectedMappingValue; + public MappingValue SelectedMappingValue + { + get => _selectedMappingValue; + set => this.RaiseAndSetIfChanged(ref _selectedMappingValue, value); + } + + //this constructor is purely for xaml design purposes + public MappingViewModel() + { + + Mapping = new Dictionary> + { + { + "Materials", new List + ( + new List + { + new MappingValue("W12x19", "W12x19"), + new MappingValue("Type1", "type123"), + new MappingValue("anotherType", "anotherType"), + new MappingValue("yetAnotherType", "differentType", true), + new MappingValue("short", "short"), + new MappingValue( "a very very very long type name. Oh no", "a very very very long type name. Oh no") + } + ) + }, + { + "Beams", new List + ( + new List + { + new MappingValue("W12x19", "W12x19"), + new MappingValue("Wood Beam", "type123"), + new MappingValue("Glulam", "anotherType", true), + new MappingValue("Conc Beam", "differentType" ), + new MappingValue("short", "short"), + new MappingValue( "a very very very long type name. Oh no", "a very very very long type name. Oh no") + } + ) + }, + { + "Columns", new List + ( + new List + { + new MappingValue("W12x19", "W12x19"), + new MappingValue("col", "type123", true), + } + ) + }, + }; + + Mapping[UnmappedKey] = new List(); + + _hostTypeValuesDict = new Dictionary> + { + { "Materials", new List{ + "brick","sheep","wheat","stone","brick","sheep","wheat","stone","brick","sheep","wheat","stone", + "brick","sheep","wheat","stone","brick","sheep","wheat","stone","brick","sheep","wheat","stone", + "brick","sheep","wheat","stone","brick","sheep","wheat","stone","brick","sheep","wheat","stone", + "brick","sheep","wheat","stone","brick","sheep","wheat","stone","brick","sheep","wheat","stone", + "brick","sheep","wheat","stone","brick","sheep","wheat","stone","brick","sheep","wheat","stone", + } }, + { "Beams", new List{"concrete","tile"} }, + { "Columns", new List{"brick","gyp","shearwall1" } } + }; + + var kv = Mapping.First(); + SelectedCategory = kv.Key; + } + + + public MappingViewModel(Dictionary> firstPassMapping, Dictionary> hostTypesDict, ProgressViewModel progress, bool newTypesExist = false) + { + Mapping = new Dictionary>(); + Bindings = Locator.Current.GetService(); + + Mapping = firstPassMapping; + _hostTypeValuesDict = hostTypesDict; + + // make sure hostTypeValuesDict has a key for each value category + foreach (var key in Mapping.Keys) + { + if (!_hostTypeValuesDict.ContainsKey(key)) + { + _hostTypeValuesDict.Add(key, _hostTypeValuesDict[TypeCatMisc]); + } + } + + if (newTypesExist) + { + // add key so it will show up in categories list + Mapping[UnmappedKey] = new List(); + _hostTypeValuesDict[UnmappedKey] = _hostTypeValuesDict[TypeCatMisc]; + } + + if (Mapping.ContainsKey(UnmappedKey)) + SelectedCategory = UnmappedKey; + else + SelectedCategory = Mapping.Keys.First(); + + } + + [DataContract] + public class MappingValue : ReactiveObject + { + [DataMember] + public string IncomingType { get; set; } + public bool Imported { get; set; } + public bool NewType { get; set; } + + private string _initialGuess; + [DataMember] + public string InitialGuess + { + get => _initialGuess; + set => this.RaiseAndSetIfChanged(ref _initialGuess, value); + } + private string _outgoingType; + [DataMember] + public string OutgoingType + { + get => _outgoingType; + set => this.RaiseAndSetIfChanged(ref _outgoingType, value); + } + private string _outgoingFamily; + public string OutgoingFamily + { + get => _outgoingFamily; + set => this.RaiseAndSetIfChanged(ref _outgoingFamily, value); + } + public MappingValue(string inType, string inGuess, bool inNewType = false) + { + IncomingType = inType; + InitialGuess = inGuess; + NewType = inNewType; + } + } + + public async void ImportFamilyCommand() + { + Mapping = await Bindings.ImportFamilyCommand(Mapping); + } + + public void Done() + { + MappingViewDialog.Instance.Close(Mapping); + } + } +} diff --git a/DesktopUI2/DesktopUI2/ViewModels/ProgressViewModel.cs b/DesktopUI2/DesktopUI2/ViewModels/ProgressViewModel.cs index 77b4d25308..88eaa527cd 100644 --- a/DesktopUI2/DesktopUI2/ViewModels/ProgressViewModel.cs +++ b/DesktopUI2/DesktopUI2/ViewModels/ProgressViewModel.cs @@ -1,4 +1,5 @@ -using DesktopUI2.Views; +using Avalonia.Controls.Selection; +using DesktopUI2.Views; using DesktopUI2.Views.Windows; using ReactiveUI; using Speckle.Core.Logging; @@ -12,8 +13,6 @@ namespace DesktopUI2.ViewModels { - - public class ProgressViewModel : ReactiveObject { public CancellationTokenSource CancellationTokenSource { get; set; } = new CancellationTokenSource(); @@ -50,7 +49,6 @@ public string ProgressTitle } } - private string _progressSummary; public string ProgressSummary { @@ -97,10 +95,23 @@ public bool IsProgressing } } + private bool _isPreviewProgressing = false; + public bool IsPreviewProgressing + { + get => _isPreviewProgressing; + set + { + this.RaiseAndSetIfChanged(ref _isPreviewProgressing, value); + } + } + public void Update(ConcurrentDictionary pd) { - ProgressDict = pd; - Value = pd.Values.Last(); + Avalonia.Threading.Dispatcher.UIThread.Post(() => + { + ProgressDict = pd; + Value = pd.Values.Last(); + }); } public void GetHelpCommand() @@ -112,13 +123,6 @@ public void GetHelpCommand() report += Report.OperationErrorsString; } - if (Report.ConversionErrorsCount > 0) - { - if (Report.OperationErrorsCount > 0) - report += "\n\n"; - report += "CONVERSION ERRORS\n\n"; - report += Report.ConversionErrorsString; - } var safeReport = HttpUtility.UrlEncode(report); Process.Start(new ProcessStartInfo($"https://speckle.community/new-topic?title=I%20need%20help%20with...&body={safeReport}&category=help") { UseShellExecute = true }); } @@ -128,14 +132,5 @@ public void CancelCommand() CancellationTokenSource.Cancel(); Analytics.TrackEvent(Analytics.Events.DUIAction, new Dictionary() { { "name", "Cancelled Quick Op" } }); } - - public async void OpenReportCommand() - { - var report = new Report(); - report.DataContext = this; - Analytics.TrackEvent(Analytics.Events.DUIAction, new Dictionary() { { "name", "Open Report" } }); - await report.ShowDialog(); - - } } } diff --git a/DesktopUI2/DesktopUI2/ViewModels/SettingViewModel.cs b/DesktopUI2/DesktopUI2/ViewModels/SettingViewModel.cs index 1f6c336af5..0daa012f6a 100644 --- a/DesktopUI2/DesktopUI2/ViewModels/SettingViewModel.cs +++ b/DesktopUI2/DesktopUI2/ViewModels/SettingViewModel.cs @@ -1,4 +1,5 @@ using Avalonia.Controls.Selection; +using DesktopUI2.Models; using DesktopUI2.Models.Settings; using ReactiveUI; using System.Collections.Generic; diff --git a/DesktopUI2/DesktopUI2/ViewModels/SettingsPageViewModel.cs b/DesktopUI2/DesktopUI2/ViewModels/SettingsPageViewModel.cs index 98650408b5..4eb3bc9d09 100644 --- a/DesktopUI2/DesktopUI2/ViewModels/SettingsPageViewModel.cs +++ b/DesktopUI2/DesktopUI2/ViewModels/SettingsPageViewModel.cs @@ -1,4 +1,5 @@ -using ReactiveUI; +using DesktopUI2.Models; +using ReactiveUI; using System.Collections.Generic; using System.Linq; using System.Reactive; @@ -15,7 +16,6 @@ public class SettingsPageViewModel : ReactiveObject, IRoutableViewModel private StreamViewModel _streamViewModel; - private List _settings; public List Settings { @@ -36,6 +36,5 @@ public void SaveCommand() MainViewModel.RouterInstance.NavigateBack.Execute(); } - } } diff --git a/DesktopUI2/DesktopUI2/ViewModels/Share/CollaboratorsViewModel.cs b/DesktopUI2/DesktopUI2/ViewModels/Share/CollaboratorsViewModel.cs index f4be1e28f0..43d70f2a90 100644 --- a/DesktopUI2/DesktopUI2/ViewModels/Share/CollaboratorsViewModel.cs +++ b/DesktopUI2/DesktopUI2/ViewModels/Share/CollaboratorsViewModel.cs @@ -213,7 +213,7 @@ private async void SaveCommand() { try { - await _stream.StreamState.Client.StreamGrantPermission(new StreamGrantPermissionInput { userId = user.Id, streamId = _stream.StreamState.StreamId, role = "stream:contributor" }); + await _stream.StreamState.Client.StreamGrantPermission(new StreamPermissionInput { userId = user.Id, streamId = _stream.StreamState.StreamId, role = "stream:contributor" }); } catch (Exception e) { diff --git a/DesktopUI2/DesktopUI2/ViewModels/Share/SendingViewModel.cs b/DesktopUI2/DesktopUI2/ViewModels/Share/SendingViewModel.cs index 488a4d7acc..7e4d319543 100644 --- a/DesktopUI2/DesktopUI2/ViewModels/Share/SendingViewModel.cs +++ b/DesktopUI2/DesktopUI2/ViewModels/Share/SendingViewModel.cs @@ -147,7 +147,7 @@ private async Task AddCollaborators() { try { - await FileStream.Client.StreamGrantPermission(new StreamGrantPermissionInput { userId = user.Id, streamId = FileStream.StreamId, role = "stream:contributor" }); + await FileStream.Client.StreamGrantPermission(new StreamPermissionInput { userId = user.Id, streamId = FileStream.StreamId, role = "stream:contributor" }); } catch (Exception e) { diff --git a/DesktopUI2/DesktopUI2/ViewModels/StreamViewModel.cs b/DesktopUI2/DesktopUI2/ViewModels/StreamViewModel.cs index 2279c3443a..61f84aad0f 100644 --- a/DesktopUI2/DesktopUI2/ViewModels/StreamViewModel.cs +++ b/DesktopUI2/DesktopUI2/ViewModels/StreamViewModel.cs @@ -1,12 +1,13 @@ using Avalonia; using Avalonia.Controls; +using Avalonia.Controls.Selection; using Avalonia.Metadata; using DesktopUI2.Models; using DesktopUI2.Models.Filters; using DesktopUI2.Models.Settings; using DesktopUI2.ViewModels.Share; using DesktopUI2.Views.Pages; -using DesktopUI2.Views.Windows; +using DesktopUI2.Views.Windows.Dialogs; using DynamicData; using Material.Icons; using Material.Icons.Avalonia; @@ -40,6 +41,22 @@ public class StreamViewModel : ReactiveObject, IRoutableViewModel public ICommand RemoveSavedStreamCommand { get; } + private bool _previewOn = false; + public bool PreviewOn + { + get => _previewOn; + set + { + if (value == false && value != _previewOn) + { + if (Progress.IsPreviewProgressing) + Progress.IsPreviewProgressing = false; + Bindings.ResetDocument(); + } + this.RaiseAndSetIfChanged(ref _previewOn, value); + } + } + #region bindings private Stream _stream; public Stream Stream @@ -105,19 +122,7 @@ public bool ShowNotification get => !string.IsNullOrEmpty(Notification); } - private bool _showReport; - - public bool ShowReport - { - get => _showReport; - private set - { - this.RaiseAndSetIfChanged(ref _showReport, value); - } - } - private bool _isRemovingStream; - public bool IsRemovingStream { get => _isRemovingStream; @@ -128,7 +133,6 @@ private set } private bool _isExpanded; - public bool IsExpanded { get => _isExpanded; @@ -142,7 +146,15 @@ private set private Client Client { get; } - public ReactiveCommand GoBack => MainViewModel.RouterInstance.NavigateBack; + public ReactiveCommand GoBack + { + get + { + PreviewOn = false; + Bindings.ResetDocument(); + return MainViewModel.RouterInstance.NavigateBack; + } + } //If we don't have access to this stream public bool NoAccess { get; set; } = false; @@ -153,7 +165,12 @@ public bool IsReceiver get => _isReceiver; set { + if (value != _isReceiver) + { + PreviewOn = false; + } this.RaiseAndSetIfChanged(ref _isReceiver, value); + this.RaisePropertyChanged(nameof(BranchesViewModel)); } } @@ -177,15 +194,24 @@ public ReceiveMode SelectedReceiveMode } } - private Branch _selectedBranch; - public Branch SelectedBranch + private BranchViewModel _selectedBranch; + public BranchViewModel SelectedBranch { get => _selectedBranch; set { this.RaiseAndSetIfChanged(ref _selectedBranch, value); - if (value != null) + + if (value == null) + return; + + + if (value.Branch.id == null) + AddNewBranch(); + else GetCommits(); + + } } @@ -193,10 +219,35 @@ public Branch SelectedBranch public List Branches { get => _branches; - private set => this.RaiseAndSetIfChanged(ref _branches, value); + private set + { + this.RaiseAndSetIfChanged(ref _branches, value); + _branchesViewModel = null; + this.RaisePropertyChanged(nameof(BranchesViewModel)); + } + } + private List _branchesViewModel; + public List BranchesViewModel + { + get + { + if (_branchesViewModel == null) + _branchesViewModel = Branches.Select(x => new BranchViewModel(x)).ToList(); + + //start fresh, just in case + if (_branchesViewModel.Last().Branch.id == null) + _branchesViewModel.Remove(_branchesViewModel.Last()); + + if (!IsReceiver) + _branchesViewModel.Add(new BranchViewModel(new Branch { name = "Add New Branch" }, "Plus")); + + return _branchesViewModel; + } + } + private Commit _selectedCommit; public Commit SelectedCommit { @@ -207,7 +258,7 @@ public Commit SelectedCommit if (_selectedCommit != null) { if (_selectedCommit.id == "latest") - PreviewImageUrl = Client.Account.serverInfo.url + $"/preview/{Stream.id}/branches/{SelectedBranch.name}"; + PreviewImageUrl = Client.Account.serverInfo.url + $"/preview/{Stream.id}/branches/{SelectedBranch.Branch.name}"; else PreviewImageUrl = Client.Account.serverInfo.url + $"/preview/{Stream.id}/commits/{_selectedCommit.id}"; } @@ -232,6 +283,107 @@ public List Activity private set => this.RaiseAndSetIfChanged(ref _activity, value); } + #region report + private List _report; + public List Report + { + get => _report; + private set + { + this.RaiseAndSetIfChanged(ref _report, value); + this.RaisePropertyChanged("FilteredReport"); + this.RaisePropertyChanged("HasReportItems"); + this.RaisePropertyChanged("ReportFilterItems"); + this.RaisePropertyChanged("Log"); + } + } + public List FilteredReport + { + get + { + if (SearchQuery == "" && !_reportSelectedFilterItems.Any()) + return Report; + else + { + var filterItems = _reportSelectedFilterItems.Any() ? Report.Where(o => _reportSelectedFilterItems.Any(a => o.Status == a)).ToList() : Report; + return SearchQuery == "" ? + filterItems : + filterItems.Where(o => _searchQueryItems.All(a => o.SearchText.ToLower().Contains(a.ToLower()))).ToList(); + } + } + } + public bool HasReportItems + { + get { return (Progress.Report.ReportObjects == null || Progress.Report.ReportObjects.Count == 0) ? false : true; } + } + public string Log + { + get + { + string defaultMessage = string.IsNullOrEmpty(Progress.Report.ConversionLogString) ? + "\nWelcome to the report! \n\nObjects you send or receive will appear here to help you understand how your document has changed." : + Progress.Report.ConversionLogString; + + string reportInfo = $"\nOperation: {(PreviewOn ? "Preview " : "")}{(IsReceiver ? "Received at " : "Sent at ")}{DateTime.Now.ToLocalTime().ToString("dd/MM/yy HH:mm:ss")}"; + reportInfo += $"\nTotal: {Report.Count} objects"; + reportInfo += Progress.Report.OperationErrors.Any() ? $"\n\nErrors: \n{Progress.Report.OperationErrorsString}":""; + + return Report.Any() || Progress.Report.OperationErrors.Any() ? reportInfo : defaultMessage; + } + } + + private List _searchQueryItems = new List(); + private string _searchQuery = ""; + public string SearchQuery + { + get => _searchQuery; + set + { + this.RaiseAndSetIfChanged(ref _searchQuery, value); + if (string.IsNullOrEmpty(SearchQuery)) + _searchQueryItems.Clear(); + else if (!SearchQuery.Replace(" ", "").Any()) + ClearSearchCommand(); + else + _searchQueryItems = _searchQuery.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); + this.RaisePropertyChanged("FilteredReport"); + } + } + + #region REPORT FILTER + public SelectionModel ReportSelectionModel { get; set; } + private List _reportSelectedFilterItems = new List(); + private List _reportFilterItems = new List(); + public List ReportFilterItems + { + get => _reportFilterItems; + set + { + this.RaiseAndSetIfChanged(ref _reportFilterItems, value); + } + } + void ReportFilterSelectionChanged(object sender, SelectionModelSelectionChangedEventArgs e) + { + try + { + foreach (var a in e.SelectedItems) + if (!_reportSelectedFilterItems.Contains(a as string)) + _reportSelectedFilterItems.Add(a as string); + foreach (var r in e.DeselectedItems) + if (_reportSelectedFilterItems.Contains(r as string)) + _reportSelectedFilterItems.Remove(r as string); + + this.RaisePropertyChanged("FilteredReport"); + } + catch (Exception ex) + { + + } + } + #endregion + + #endregion + private List _comments; public List Comments { @@ -310,16 +462,16 @@ private string Url //sender if (!IsReceiver) { - if (SelectedBranch != null && SelectedBranch.name != "main") - return $"{StreamState.ServerUrl.TrimEnd('/')}/streams/{StreamState.StreamId}/branches/{SelectedBranch.name}"; + if (SelectedBranch != null && SelectedBranch.Branch.name != "main") + return $"{StreamState.ServerUrl.TrimEnd('/')}/streams/{StreamState.StreamId}/branches/{SelectedBranch.Branch.name}"; } //receiver else { - if (SelectedCommit != null) + if (SelectedCommit != null && SelectedCommit.id != "latest") return $"{StreamState.ServerUrl.TrimEnd('/')}/streams/{StreamState.StreamId}/commits/{SelectedCommit.id}"; if (SelectedBranch != null) - return $"{StreamState.ServerUrl.TrimEnd('/')}/streams/{StreamState.StreamId}/branches/{SelectedBranch.name}"; + return $"{StreamState.ServerUrl.TrimEnd('/')}/streams/{StreamState.StreamId}/branches/{SelectedBranch.Branch.name}"; } return $"{StreamState.ServerUrl.TrimEnd('/')}/streams/{StreamState.StreamId}"; @@ -389,7 +541,9 @@ private void Init() GetBranchesAndRestoreState(); GetActivity(); + GetReport(); GetComments(); + } catch (Exception ex) { @@ -409,10 +563,8 @@ private void GenerateMenuItems() { var menu = new MenuItemViewModel { Header = new MaterialIcon { Kind = MaterialIconKind.EllipsisVertical, Foreground = Avalonia.Media.Brushes.Gray } }; menu.Items = new List { - //new MenuItemViewModel (EditSavedStreamCommand, "Edit", MaterialIconKind.Cog), new MenuItemViewModel (ViewOnlineSavedStreamCommand, "View online", MaterialIconKind.ExternalLink), new MenuItemViewModel (CopyStreamURLCommand, "Copy URL to clipboard", MaterialIconKind.ContentCopy), - new MenuItemViewModel (OpenReportCommand, "Open Report", MaterialIconKind.TextBox) }; var customMenues = Bindings.GetCustomStreamMenuItems(); if (customMenues != null) @@ -454,7 +606,6 @@ internal async void GetBranchesAndRestoreState() //by default the first available receive mode is selected SelectedReceiveMode = ReceiveModes.Contains(StreamState.ReceiveMode) ? StreamState.ReceiveMode : ReceiveModes[0]; - //get available settings from our bindings Settings = Bindings.GetSettings(); @@ -462,14 +613,13 @@ internal async void GetBranchesAndRestoreState() AvailableFilters = new List(Bindings.GetSelectionFilters().Select(x => new FilterViewModel(x))); SelectedFilter = AvailableFilters[0]; - var branches = await Client.StreamGetBranches(Stream.id, 100, 0); - Branches = branches; + Branches = await Client.StreamGetBranches(Stream.id, 100, 0); - var branch = Branches.FirstOrDefault(x => x.name == StreamState.BranchName); - if (branch != null) - SelectedBranch = branch; + var index = Branches.FindIndex(x => x.name == StreamState.BranchName); + if (index != -1) + SelectedBranch = BranchesViewModel[index]; else - SelectedBranch = Branches[0]; + SelectedBranch = BranchesViewModel[0]; //restore selected filter if (StreamState.Filter != null) @@ -487,7 +637,6 @@ internal async void GetBranchesAndRestoreState() SelectedFilter = selectionFilter; SelectedFilter.AddObjectSelection(); } - } if (StreamState.Settings != null) { @@ -496,7 +645,6 @@ internal async void GetBranchesAndRestoreState() var savedSetting = StreamState.Settings.FirstOrDefault(o => o.Slug == setting.Slug); if (savedSetting != null) setting.Selection = savedSetting.Selection; - } } } @@ -506,6 +654,29 @@ internal async void GetBranchesAndRestoreState() } } + private void GetReport() + { + var report = new List(); + foreach (var applicationObject in Progress.Report.ReportObjects) + { + var rvm = new ApplicationObjectViewModel(applicationObject, StreamState.IsReceiver, Progress.Report); + report.Add(rvm); + } + Report = report; + + if (HasReportItems) // activate report tab + { + var tabControl = StreamEditView.Instance.FindControl("tabStreamEdit"); + tabControl.SelectedIndex = tabControl.ItemCount - 1; + } + + // report filter selection + ReportSelectionModel = new SelectionModel(); + ReportSelectionModel.SingleSelect = false; + ReportSelectionModel.SelectionChanged += ReportFilterSelectionChanged; + ReportFilterItems = report.Select(o => o.Status).Distinct().ToList(); + } + private async void GetActivity() { try @@ -518,7 +689,6 @@ private async void GetActivity() { var avm = new ActivityViewModel(a, Client); activity.Add(avm); - } Activity = activity; ScrollToBottom(); @@ -539,7 +709,6 @@ private async void GetComments() { var cvm = new CommentViewModel(c, Stream.id, Client); comments.Add(cvm); - } Comments = comments; } @@ -549,7 +718,6 @@ private async void GetComments() } } - private async void ScrollToBottom() { try @@ -561,9 +729,7 @@ private async void ScrollToBottom() { var scroller = StreamEditView.Instance.FindControl("activityScroller"); if (scroller != null) - { scroller.ScrollToEnd(); - } }); } } @@ -580,7 +746,7 @@ private void UpdateStreamState() { try { - StreamState.BranchName = SelectedBranch.name; + StreamState.BranchName = SelectedBranch.Branch.name; StreamState.IsReceiver = IsReceiver; StreamState.AutoReceive = AutoReceive; StreamState.ReceiveMode = SelectedReceiveMode; @@ -601,9 +767,9 @@ private async void GetCommits() { try { - if (SelectedBranch.commits == null || SelectedBranch.commits.totalCount > 0) + if (SelectedBranch.Branch.commits == null || SelectedBranch.Branch.commits.totalCount > 0) { - var branch = await Client.BranchGet(Stream.id, SelectedBranch.name, 100); + var branch = await Client.BranchGet(Stream.id, SelectedBranch.Branch.name, 100); branch.commits.items.Insert(0, new Commit { id = "latest", message = "Always receive the latest commit sent to this branch." }); Commits = branch.commits.items; var commit = Commits.FirstOrDefault(x => x.id == StreamState.CommitId); @@ -687,27 +853,68 @@ private void DownloadComplete(object sender, DownloadDataCompletedEventArgs e) #region commands + private async void AddNewBranch() + { + var dialog = new NewBranchDialog(); + var nbvm = new NewBranchViewModel(Branches); + dialog.DataContext = nbvm; + + var result = await dialog.ShowDialog(); + + if (result) + { + try + { + + var branchId = await this.StreamState.Client.BranchCreate(new BranchCreateInput { streamId = Stream.id, description = nbvm.Description ?? "", name = nbvm.BranchName }); + + + Branches = await Client.StreamGetBranches(Stream.id, 100, 0); + + var index = Branches.FindIndex(x => x.name == nbvm.BranchName); + if (index != -1) + SelectedBranch = BranchesViewModel[index]; + + } + catch (Exception e) + { + Dialogs.ShowDialog("Something went wrong...", e.Message, Material.Dialog.Icons.DialogIconKind.Error); + } + } + else + { + //make sure the a branch is selected if canceled + SelectedBranch = BranchesViewModel[0]; + } + } + public async void CopyReportCommand() + { + var reportObjectSummaries = FilteredReport.Select(o => o.GetSummary()).ToArray(); + var summary = string.Join("\n", reportObjectSummaries); + + await Avalonia.Application.Current.Clipboard.SetTextAsync(summary); + Analytics.TrackEvent(Analytics.Events.DUIAction, new Dictionary() { { "name", "Copy Report" } }); + } + public void ClearSearchCommand() + { + SearchQuery = ""; + } + public void ShareCommand() { MainViewModel.RouterInstance.Navigate.Execute(new CollaboratorsViewModel(HostScreen, this)); } + public void CloseNotificationCommand() { Notification = ""; NotificationUrl = ""; - Analytics.TrackEvent(null, Analytics.Events.DUIAction, new Dictionary() { { "name", "Notification Dismiss" } }); - } - - public void CloseReportNotificationCommand() - { - ShowReport = false; - Analytics.TrackEvent(null, Analytics.Events.DUIAction, new Dictionary() { { "name", "Report Dismiss" } }); + Analytics.TrackEvent(StreamState.Client.Account, Analytics.Events.DUIAction, new Dictionary() { { "name", "Notification Dismiss" } }); } - public void LaunchNotificationCommand() { - Analytics.TrackEvent(null, Analytics.Events.DUIAction, new Dictionary() { { "name", "Notification Click" } }); + Analytics.TrackEvent(StreamState.Client.Account, Analytics.Events.DUIAction, new Dictionary() { { "name", "Notification Click" } }); if (!string.IsNullOrEmpty(NotificationUrl)) Process.Start(new ProcessStartInfo(NotificationUrl) { UseShellExecute = true }); @@ -765,11 +972,8 @@ public async void SendCommand() Notification = "Nothing sent!"; } - if (Progress.Report.ConversionErrorsCount > 0 || Progress.Report.OperationErrorsCount > 0) - ShowReport = true; - GetActivity(); - + GetReport(); } catch (Exception ex) { @@ -777,6 +981,42 @@ public async void SendCommand() } } + public async void PreviewCommand() + { + PreviewOn = !PreviewOn; + if (PreviewOn) + { + try + { + UpdateStreamState(); + + Progress.CancellationTokenSource = new System.Threading.CancellationTokenSource(); + Progress.IsPreviewProgressing = true; + if (IsReceiver) + { + Analytics.TrackEvent(Analytics.Events.DUIAction, new Dictionary() { { "name", "Preview Receive" } }); + await Task.Run(() => Bindings.PreviewReceive(StreamState, Progress)); + } + if (!IsReceiver) + { + Analytics.TrackEvent(Analytics.Events.DUIAction, new Dictionary() { { "name", "Preview Send" } }); + await Task.Run(() => Bindings.PreviewSend(StreamState, Progress)); + } + Progress.IsPreviewProgressing = false; + GetReport(); + } + catch (Exception ex) + { + + } + } + else + { + Progress.CancellationTokenSource.Cancel(); + Bindings.ResetDocument(); + } + } + public async void ReceiveCommand() { try @@ -796,11 +1036,8 @@ public async void ReceiveCommand() Analytics.TrackEvent(StreamState.Client.Account, Analytics.Events.Receive, new Dictionary() { { "mode", StreamState.ReceiveMode }, { "auto", StreamState.AutoReceive } }); } - if (Progress.Report.ConversionErrorsCount > 0 || Progress.Report.OperationErrorsCount > 0) - ShowReport = true; - - GetActivity(); + GetReport(); } catch (Exception ex) { @@ -812,7 +1049,6 @@ private void Reset() { Notification = ""; NotificationUrl = ""; - ShowReport = false; Progress = new ProgressViewModel(); } @@ -825,24 +1061,13 @@ public void CancelSendOrReceiveCommand() Notification = IsReceiver ? "Cancelled Receive" : "Cancelled Send"; } - public async void OpenReportCommand() + public void CancelPreviewCommand() { - try - { - //ensure click transition has finished - await Task.Delay(1000); - Analytics.TrackEvent(Analytics.Events.DUIAction, new Dictionary() { { "name", "Open Report" } }); - ShowReport = true; - var report = new Report(); - //report.Title = $"Report of the last operation, {LastUsed.ToLower()}"; - report.DataContext = Progress; - await report.ShowDialog(); - - } - catch (Exception ex) - { - - } + Progress.CancellationTokenSource.Cancel(); + string cancelledEvent = IsReceiver ? "Cancel Preview Receive" : "Cancel Preview Send"; + Analytics.TrackEvent(Analytics.Events.DUIAction, new Dictionary() { { "name", cancelledEvent } }); + Progress.IsPreviewProgressing = false; + PreviewOn = false; } private void SaveCommand() @@ -854,14 +1079,9 @@ private void SaveCommand() HomeViewModel.Instance.AddSavedStream(this); if (IsReceiver) - { Analytics.TrackEvent(Client.Account, Analytics.Events.DUIAction, new Dictionary() { { "name", "Stream Receiver Add" } }); - } - else - { Analytics.TrackEvent(Client.Account, Analytics.Events.DUIAction, new Dictionary() { { "name", "Stream Sender Add" } }); - } } catch (Exception ex) { @@ -869,23 +1089,17 @@ private void SaveCommand() } } - private void OpenSettingsCommand() { try { - var settingsPageViewModel = new SettingsPageViewModel(HostScreen, Settings.Select(x => new SettingViewModel(x)).ToList(), this); MainViewModel.RouterInstance.Navigate.Execute(settingsPageViewModel); - Analytics.TrackEvent(null, Analytics.Events.DUIAction, new Dictionary() { { "name", "Settings Open" } }); - - + Analytics.TrackEvent(StreamState.Client.Account, Analytics.Events.DUIAction, new Dictionary() { { "name", "Settings Open" } }); } catch (Exception e) { } - - } private void AskRemoveSavedStreamCommand() @@ -898,7 +1112,6 @@ private void CancelRemoveSavedStreamCommand() IsRemovingStream = false; } - [DependsOn(nameof(SelectedBranch))] [DependsOn(nameof(SelectedFilter))] [DependsOn(nameof(SelectedCommit))] @@ -908,8 +1121,6 @@ private bool CanSaveCommand(object parameter) return true; } - - [DependsOn(nameof(SelectedBranch))] [DependsOn(nameof(SelectedFilter))] [DependsOn(nameof(IsReceiver))] @@ -926,6 +1137,18 @@ private bool CanReceiveCommand(object parameter) return IsReady(); } + [DependsOn(nameof(SelectedBranch))] + [DependsOn(nameof(SelectedCommit))] + [DependsOn(nameof(SelectedFilter))] + [DependsOn(nameof(IsReceiver))] + private bool CanPreviewCommand(object parameter) + { + bool previewImplemented = IsReceiver ? Bindings.CanPreviewReceive : Bindings.CanPreviewSend; + if (previewImplemented) + return IsReady(); + else return false; + } + private bool IsReady() { if (NoAccess) diff --git a/DesktopUI2/DesktopUI2/Views/Controls/PreviewButton.xaml b/DesktopUI2/DesktopUI2/Views/Controls/PreviewButton.xaml new file mode 100644 index 0000000000..d46309ca5a --- /dev/null +++ b/DesktopUI2/DesktopUI2/Views/Controls/PreviewButton.xaml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DesktopUI2/DesktopUI2/Views/Controls/PreviewButton.xaml.cs b/DesktopUI2/DesktopUI2/Views/Controls/PreviewButton.xaml.cs new file mode 100644 index 0000000000..3c0dc669d5 --- /dev/null +++ b/DesktopUI2/DesktopUI2/Views/Controls/PreviewButton.xaml.cs @@ -0,0 +1,19 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace DesktopUI2.Views.Controls +{ + public partial class PreviewButton : UserControl + { + public PreviewButton() + { + InitializeComponent(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + } +} diff --git a/DesktopUI2/DesktopUI2/Controls/ReceiveButton.xaml b/DesktopUI2/DesktopUI2/Views/Controls/ReceiveButton.xaml similarity index 92% rename from DesktopUI2/DesktopUI2/Controls/ReceiveButton.xaml rename to DesktopUI2/DesktopUI2/Views/Controls/ReceiveButton.xaml index bc28eb48eb..98ec7cf11c 100644 --- a/DesktopUI2/DesktopUI2/Controls/ReceiveButton.xaml +++ b/DesktopUI2/DesktopUI2/Views/Controls/ReceiveButton.xaml @@ -1,5 +1,5 @@ diff --git a/DesktopUI2/DesktopUI2/Controls/ReceiveButton.xaml.cs b/DesktopUI2/DesktopUI2/Views/Controls/ReceiveButton.xaml.cs similarity index 88% rename from DesktopUI2/DesktopUI2/Controls/ReceiveButton.xaml.cs rename to DesktopUI2/DesktopUI2/Views/Controls/ReceiveButton.xaml.cs index 03fed6c32f..a9c1970f43 100644 --- a/DesktopUI2/DesktopUI2/Controls/ReceiveButton.xaml.cs +++ b/DesktopUI2/DesktopUI2/Views/Controls/ReceiveButton.xaml.cs @@ -2,7 +2,7 @@ using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace DesktopUI2.Controls +namespace DesktopUI2.Views.Controls { public partial class ReceiveButton : UserControl { diff --git a/DesktopUI2/DesktopUI2/Controls/SendButton.xaml b/DesktopUI2/DesktopUI2/Views/Controls/SendButton.xaml similarity index 92% rename from DesktopUI2/DesktopUI2/Controls/SendButton.xaml rename to DesktopUI2/DesktopUI2/Views/Controls/SendButton.xaml index 1ab1a3b57c..136fb3d0fe 100644 --- a/DesktopUI2/DesktopUI2/Controls/SendButton.xaml +++ b/DesktopUI2/DesktopUI2/Views/Controls/SendButton.xaml @@ -1,5 +1,5 @@ diff --git a/DesktopUI2/DesktopUI2/Controls/SendButton.xaml.cs b/DesktopUI2/DesktopUI2/Views/Controls/SendButton.xaml.cs similarity index 88% rename from DesktopUI2/DesktopUI2/Controls/SendButton.xaml.cs rename to DesktopUI2/DesktopUI2/Views/Controls/SendButton.xaml.cs index 6569ecd9c7..ae95da8e57 100644 --- a/DesktopUI2/DesktopUI2/Controls/SendButton.xaml.cs +++ b/DesktopUI2/DesktopUI2/Views/Controls/SendButton.xaml.cs @@ -2,7 +2,7 @@ using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace DesktopUI2.Controls +namespace DesktopUI2.Views.Controls { public partial class SendButton : UserControl { diff --git a/DesktopUI2/DesktopUI2/Views/Converters/RoleCanSendValueConverter.cs b/DesktopUI2/DesktopUI2/Views/Converters/RoleCanSendValueConverter.cs index 5893625e60..c42375b754 100644 --- a/DesktopUI2/DesktopUI2/Views/Converters/RoleCanSendValueConverter.cs +++ b/DesktopUI2/DesktopUI2/Views/Converters/RoleCanSendValueConverter.cs @@ -5,7 +5,6 @@ namespace DesktopUI2.Views.Converters { - public class RoleCanSendValueConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) diff --git a/DesktopUI2/DesktopUI2/Views/Converters/StreamEditHeightConverter.cs b/DesktopUI2/DesktopUI2/Views/Converters/StreamEditHeightConverter.cs new file mode 100644 index 0000000000..9572ccb63e --- /dev/null +++ b/DesktopUI2/DesktopUI2/Views/Converters/StreamEditHeightConverter.cs @@ -0,0 +1,28 @@ +using Avalonia.Data.Converters; +using System; + +namespace DesktopUI2.Views.Converters +{ + + public class StreamEditHeightConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + try + { + return (double)value - 80; + } + catch (Exception e) + { + return 1000; + } + + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotSupportedException(); + } + } +} + diff --git a/DesktopUI2/DesktopUI2/Views/Pages/HomeControls/SavedStreams.xaml b/DesktopUI2/DesktopUI2/Views/Pages/HomeControls/SavedStreams.xaml index 8a4b94f093..0410567e74 100644 --- a/DesktopUI2/DesktopUI2/Views/Pages/HomeControls/SavedStreams.xaml +++ b/DesktopUI2/DesktopUI2/Views/Pages/HomeControls/SavedStreams.xaml @@ -4,7 +4,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ap="clr-namespace:DesktopUI2.Views.AttachedProperties" xmlns:assists="clr-namespace:Material.Styles.Assists;assembly=Material.Styles" - xmlns:c="clr-namespace:DesktopUI2.Controls" + xmlns:c="clr-namespace:DesktopUI2.Views.Controls" xmlns:conv="clr-namespace:DesktopUI2.Views.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:icons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" @@ -292,56 +292,6 @@ - - - - - - - - - - - - - diff --git a/DesktopUI2/DesktopUI2/Views/Pages/SharedControls/StreamDetails.xaml b/DesktopUI2/DesktopUI2/Views/Pages/SharedControls/StreamDetails.xaml index 3ea1fb05fd..bd8b2eeb3c 100644 --- a/DesktopUI2/DesktopUI2/Views/Pages/SharedControls/StreamDetails.xaml +++ b/DesktopUI2/DesktopUI2/Views/Pages/SharedControls/StreamDetails.xaml @@ -69,10 +69,5 @@ Classes="Overline" Text="{Binding Stream.id}" TextTrimming="CharacterEllipsis" /> - - - - - diff --git a/DesktopUI2/DesktopUI2/Views/Pages/StreamEditControls/Receive.xaml b/DesktopUI2/DesktopUI2/Views/Pages/StreamEditControls/Receive.xaml index 276c3db48a..4a03bc5d25 100644 --- a/DesktopUI2/DesktopUI2/Views/Pages/StreamEditControls/Receive.xaml +++ b/DesktopUI2/DesktopUI2/Views/Pages/StreamEditControls/Receive.xaml @@ -3,7 +3,7 @@ xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:assists="clr-namespace:Material.Styles.Assists;assembly=Material.Styles" - xmlns:c="clr-namespace:DesktopUI2.Controls" + xmlns:c="clr-namespace:DesktopUI2.Views.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:icons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" xmlns:m="clr-namespace:Material.Styles;assembly=Material.Styles" @@ -26,10 +26,17 @@ - + + - + @@ -52,10 +59,10 @@ + Kind="{Binding Icon}" /> @@ -195,7 +202,7 @@ assists:ShadowAssist.ShadowDepth="Depth0" Background="Transparent" Command="{Binding SaveCommand}" - IsEnabled="{Binding Progress.IsProgressing, Converter={x:Static BoolConverters.Not}}" + IsEnabled="{Binding !Progress.IsProgressing}" ToolTip.Tip="Save this sender to the file without sending"> + + + diff --git a/DesktopUI2/DesktopUI2/Views/Pages/StreamEditControls/Report.xaml b/DesktopUI2/DesktopUI2/Views/Pages/StreamEditControls/Report.xaml new file mode 100644 index 0000000000..4f017d3868 --- /dev/null +++ b/DesktopUI2/DesktopUI2/Views/Pages/StreamEditControls/Report.xaml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DesktopUI2/DesktopUI2/Views/Pages/StreamEditControls/Report.xaml.cs b/DesktopUI2/DesktopUI2/Views/Pages/StreamEditControls/Report.xaml.cs new file mode 100644 index 0000000000..5b12f01bc2 --- /dev/null +++ b/DesktopUI2/DesktopUI2/Views/Pages/StreamEditControls/Report.xaml.cs @@ -0,0 +1,19 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace DesktopUI2.Views.Pages.StreamEditControls +{ + public partial class Report : UserControl + { + public Report() + { + InitializeComponent(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + } +} diff --git a/DesktopUI2/DesktopUI2/Views/Pages/StreamEditControls/Send.xaml b/DesktopUI2/DesktopUI2/Views/Pages/StreamEditControls/Send.xaml index 2ccf127906..47985f21dc 100644 --- a/DesktopUI2/DesktopUI2/Views/Pages/StreamEditControls/Send.xaml +++ b/DesktopUI2/DesktopUI2/Views/Pages/StreamEditControls/Send.xaml @@ -3,7 +3,7 @@ xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:assists="clr-namespace:Material.Styles.Assists;assembly=Material.Styles" - xmlns:c="clr-namespace:DesktopUI2.Controls" + xmlns:c="clr-namespace:DesktopUI2.Views.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:icons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" xmlns:m="clr-namespace:Material.Styles;assembly=Material.Styles" @@ -27,12 +27,18 @@ - - + + - + + SelectedItem="{Binding SelectedBranch, Mode=TwoWay}"> + + Kind="{Binding Icon}" /> @@ -98,7 +105,7 @@ - + + + + diff --git a/DesktopUI2/DesktopUI2/Views/Pages/StreamEditView.xaml b/DesktopUI2/DesktopUI2/Views/Pages/StreamEditView.xaml index 2ec2be87f2..a55e3f1701 100644 --- a/DesktopUI2/DesktopUI2/Views/Pages/StreamEditView.xaml +++ b/DesktopUI2/DesktopUI2/Views/Pages/StreamEditView.xaml @@ -28,9 +28,11 @@ + - + - - @@ -100,10 +100,7 @@ - - - @@ -111,9 +108,12 @@ Grid.Row="1" Margin="15,0" RowDefinitions="*,auto,auto"> - + - + @@ -155,6 +155,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -201,118 +309,69 @@ Height="15" Foreground="White" Kind="Close" /> - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Width="20" + Height="20" + Kind="CubeSend" + ToolTip.Tip="Receive"> + + + + + + + + + + + + + + diff --git a/DesktopUI2/DesktopUI2/Views/Pages/StreamEditView.xaml.cs b/DesktopUI2/DesktopUI2/Views/Pages/StreamEditView.xaml.cs index 133464562e..a8340ee95a 100644 --- a/DesktopUI2/DesktopUI2/Views/Pages/StreamEditView.xaml.cs +++ b/DesktopUI2/DesktopUI2/Views/Pages/StreamEditView.xaml.cs @@ -15,7 +15,6 @@ public StreamEditView() private void InitializeComponent() { AvaloniaXamlLoader.Load(this); - } public static StreamEditView Instance { get; private set; } diff --git a/DesktopUI2/DesktopUI2/Views/Scheduler.xaml b/DesktopUI2/DesktopUI2/Views/Scheduler.xaml index fb23cbd0a8..3db55715da 100644 --- a/DesktopUI2/DesktopUI2/Views/Scheduler.xaml +++ b/DesktopUI2/DesktopUI2/Views/Scheduler.xaml @@ -61,7 +61,7 @@ diff --git a/DesktopUI2/DesktopUI2/Views/Windows/Dialogs/DialogUserControl.cs b/DesktopUI2/DesktopUI2/Views/Windows/Dialogs/DialogUserControl.cs index ff5355c898..1cef30a623 100644 --- a/DesktopUI2/DesktopUI2/Views/Windows/Dialogs/DialogUserControl.cs +++ b/DesktopUI2/DesktopUI2/Views/Windows/Dialogs/DialogUserControl.cs @@ -2,14 +2,12 @@ using Avalonia.Input; using DesktopUI2.ViewModels; using System; -using System.Collections.Generic; using System.Reactive.Linq; -using System.Text; using System.Threading.Tasks; namespace DesktopUI2.Views.Windows.Dialogs { - public class DialogUserControl : UserControl, ICloseable + public class DialogUserControl : UserControl, ICloseable { private object? _dialogResult; @@ -43,7 +41,7 @@ public void Close(object dialogResult) { _dialogResult = dialogResult; Closed?.Invoke(this, null); - MainViewModel.Instance.DialogBody=null; + MainViewModel.Instance.DialogBody = null; } } } diff --git a/DesktopUI2/DesktopUI2/Views/Windows/Dialogs/MappingViewDialog.xaml b/DesktopUI2/DesktopUI2/Views/Windows/Dialogs/MappingViewDialog.xaml new file mode 100644 index 0000000000..c2a29a543a --- /dev/null +++ b/DesktopUI2/DesktopUI2/Views/Windows/Dialogs/MappingViewDialog.xaml @@ -0,0 +1,209 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + Incoming Type + + + Assigned To + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DesktopUI2/DesktopUI2/Views/Windows/Dialogs/MappingViewDialog.xaml.cs b/DesktopUI2/DesktopUI2/Views/Windows/Dialogs/MappingViewDialog.xaml.cs new file mode 100644 index 0000000000..e991d0fc10 --- /dev/null +++ b/DesktopUI2/DesktopUI2/Views/Windows/Dialogs/MappingViewDialog.xaml.cs @@ -0,0 +1,99 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Input; +using Avalonia.Interactivity; +using Avalonia.Markup.Xaml; +using Avalonia.ReactiveUI; +using DesktopUI2.ViewModels; +using Speckle.Core.Credentials; +using System; +using System.Collections.Generic; +using System.Reactive.Linq; +using System.Threading.Tasks; + +namespace DesktopUI2.Views.Windows.Dialogs +{ + public partial class MappingViewDialog : ReactiveUserControl, ICloseable + { + #region DialogUserControlSettings + + private object? _dialogResult; + + public event EventHandler Closed; + + + public Task ShowDialog() + { + return ShowDialog(); + } + + public Task ShowDialog() + { + MainViewModel.Instance.DialogBody = this; + Instance = this; + + var result = new TaskCompletionSource(); + + Observable.FromEventPattern( + x => Closed += x, + x => Closed -= x) + .Take(1) + .Subscribe(_ => + { + result.SetResult((TResult)(_dialogResult ?? default(TResult)!)); + }); + + return result.Task; + } + + public void Close(object dialogResult) + { + _dialogResult = dialogResult; + Closed?.Invoke(this, null); + MainViewModel.Instance.DialogBody = null; + } + #endregion + public MappingViewDialog() + { + InitializeComponent(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + + public static MappingViewDialog Instance { get; private set; } + + //public MappingViewDialog() { } + + //public MappingViewDialog(List accounts) + //{ + // InitializeComponent(); + // var combo = this.FindControl("accounts"); + // combo.Items = accounts; + // combo.SelectedIndex = 0; + //} + + //private void InitializeComponent() + //{ + // AvaloniaXamlLoader.Load(this); + //} + + //public void Create_Click(object sender, RoutedEventArgs e) + //{ + // var isPublic = this.FindControl("isPublic").IsChecked; + // //too lazy to create a view model for this or properly style the Dialogs + // Account = (this.FindControl("accounts").SelectedItem as AccountViewModel).Account; + // StreamName = this.FindControl("name").Text; + // Description = this.FindControl("description").Text; + // IsPublic = isPublic.HasValue ? isPublic.Value : false; + // this.Close(true); + //} + + //public void Close_Click(object sender, RoutedEventArgs e) + //{ + // this.Close(false); + //} + } +} diff --git a/DesktopUI2/DesktopUI2/Views/Windows/Dialogs/NewBranchDialog.xaml b/DesktopUI2/DesktopUI2/Views/Windows/Dialogs/NewBranchDialog.xaml new file mode 100644 index 0000000000..993c56cc3e --- /dev/null +++ b/DesktopUI2/DesktopUI2/Views/Windows/Dialogs/NewBranchDialog.xaml @@ -0,0 +1,47 @@ + + + + + + + + + + +