From 0f8b928f7527f8ad992e33e611893fc74197479d Mon Sep 17 00:00:00 2001 From: Ashish Aggarwal Date: Thu, 30 Jan 2025 17:22:13 -0500 Subject: [PATCH] DYN-7268 Improve UX when IDSDK is not installed on system running Dynamo (#15790) --- src/DynamoCore/Core/IDSDKManager.cs | 57 ++++++++++++------- .../Properties/Resources.Designer.cs | 19 +++++++ .../Properties/Resources.en-US.resx | 7 +++ src/DynamoCoreWpf/Properties/Resources.resx | 7 +++ src/DynamoCoreWpf/PublicAPI.Unshipped.txt | 2 + .../UI/GuidedTour/CustomRichTextBox.cs | 3 + .../ViewModels/Core/DynamoViewModel.cs | 23 ++++++++ 7 files changed, 98 insertions(+), 20 deletions(-) diff --git a/src/DynamoCore/Core/IDSDKManager.cs b/src/DynamoCore/Core/IDSDKManager.cs index 533b0768cc2..52666abe369 100644 --- a/src/DynamoCore/Core/IDSDKManager.cs +++ b/src/DynamoCore/Core/IDSDKManager.cs @@ -23,6 +23,20 @@ public class IDSDKManager : IOAuth2AuthProvider, IOAuth2AccessTokenProvider, IOA /// public event Action LoginStateChanged; + /// + /// The event is fired when IDSDK initialization fails + /// + internal event EventHandler ErrorInitializingIDSDK; + + /// + /// The flag is used to prevent multiple error messages from being shown, since initialization error can be thrown multiple times. + /// + internal bool isErrorInitializingMsgShown; + private void OnErrorInitializingIDSDK() + { + ErrorInitializingIDSDK?.Invoke(this, EventArgs.Empty); + } + /// /// Returns the login status of the current session. /// @@ -228,38 +242,41 @@ private bool Initialize() { try { - if (Client.IsInitialized()) return true; - idsdk_status_code bRet = Client.Init(); + if (Client.IsInitialized()) + { + isErrorInitializingMsgShown = false; + return true; + } - if (Client.IsSuccess(bRet)) + idsdk_status_code bRet = Client.Init(); + if (Client.IsSuccess(bRet) && Client.IsInitialized()) { - if (Client.IsInitialized()) + IntPtr hWnd = Process.GetCurrentProcess().MainWindowHandle; + if (hWnd != null) { - IntPtr hWnd = Process.GetCurrentProcess().MainWindowHandle; - if (hWnd != null) - { - Client.SetHost(hWnd); - } + Client.SetHost(hWnd); + } - bool ret = GetClientIDAndServer(out idsdk_server server, out string client_id); - if (ret) - { - Client.LogoutCompleteEvent += AuthCompleteEventHandler; - Client.LoginCompleteEvent += AuthCompleteEventHandler; - ret = SetProductConfigs(Configurations.DynamoAsString, server, client_id); - Client.SetServer(server); - return ret; - } + bool ret = GetClientIDAndServer(out idsdk_server server, out string client_id); + if (ret) + { + Client.LogoutCompleteEvent += AuthCompleteEventHandler; + Client.LoginCompleteEvent += AuthCompleteEventHandler; + ret = SetProductConfigs(Configurations.DynamoAsString, server, client_id); + Client.SetServer(server); + isErrorInitializingMsgShown = false; + return ret; } } DynamoConsoleLogger.OnLogMessageToDynamoConsole("Auth Service (IDSDK) could not be initialized!"); - return false; } catch (Exception) { DynamoConsoleLogger.OnLogMessageToDynamoConsole("An error occurred while initializing Auth Service (IDSDK)."); - return false; } + + OnErrorInitializingIDSDK(); + return false; } private bool Deinitialize() { diff --git a/src/DynamoCoreWpf/Properties/Resources.Designer.cs b/src/DynamoCoreWpf/Properties/Resources.Designer.cs index 2aea4a65d07..12ae85a788d 100644 --- a/src/DynamoCoreWpf/Properties/Resources.Designer.cs +++ b/src/DynamoCoreWpf/Properties/Resources.Designer.cs @@ -3731,6 +3731,25 @@ public static string HideWiresPopupMenuItem { } } + /// + /// Looks up a localized string similar to It seems like Autodesk Identity Manager is not set up on your system. To ensure full access to all features, please sign in to your Autodesk account using Autodesk Identity Manager. + ///#Download and install=https://manage.autodesk.com/products/updates it here or through Autodesk Access, then sign in.. + /// + public static string IDSDKErrorMessage { + get { + return ResourceManager.GetString("IDSDKErrorMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Download Autodesk Identity Manager. + /// + public static string IDSDKErrorMessageTitle { + get { + return ResourceManager.GetString("IDSDKErrorMessageTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Import Library. /// diff --git a/src/DynamoCoreWpf/Properties/Resources.en-US.resx b/src/DynamoCoreWpf/Properties/Resources.en-US.resx index 2335adba2ba..308a3856e7f 100644 --- a/src/DynamoCoreWpf/Properties/Resources.en-US.resx +++ b/src/DynamoCoreWpf/Properties/Resources.en-US.resx @@ -4105,4 +4105,11 @@ To make this file into a new template, save it to a different folder, then move The compatibility of this version with your setup has not been verified. It may or may not work as expected. + + It seems like Autodesk Identity Manager is not set up on your system. To ensure full access to all features, please sign in to your Autodesk account using Autodesk Identity Manager. +#Download and install=https://manage.autodesk.com/products/updates it here or through Autodesk Access, then sign in. + + + Download Autodesk Identity Manager + \ No newline at end of file diff --git a/src/DynamoCoreWpf/Properties/Resources.resx b/src/DynamoCoreWpf/Properties/Resources.resx index 41f89c7c712..32677073e41 100644 --- a/src/DynamoCoreWpf/Properties/Resources.resx +++ b/src/DynamoCoreWpf/Properties/Resources.resx @@ -4092,4 +4092,11 @@ To make this file into a new template, save it to a different folder, then move The compatibility of this version with your setup has not been verified. It may or may not work as expected. + + It seems like Autodesk Identity Manager is not set up on your system. To ensure full access to all features, please sign in to your Autodesk account using Autodesk Identity Manager. +#Download and install=https://manage.autodesk.com/products/updates it here or through Autodesk Access, then sign in. + + + Download Autodesk Identity Manager + \ No newline at end of file diff --git a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt index 916e9e92b74..937c6acc708 100644 --- a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt +++ b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt @@ -4815,6 +4815,8 @@ static Dynamo.Wpf.Properties.Resources.GroupStylesCancelButtonText.get -> string static Dynamo.Wpf.Properties.Resources.GroupStylesSaveButtonText.get -> string static Dynamo.Wpf.Properties.Resources.HideClassicNodeLibrary.get -> string static Dynamo.Wpf.Properties.Resources.HideWiresPopupMenuItem.get -> string +static Dynamo.Wpf.Properties.Resources.IDSDKErrorMessage.get -> string +static Dynamo.Wpf.Properties.Resources.IDSDKErrorMessageTitle.get -> string static Dynamo.Wpf.Properties.Resources.ImportLibraryDialogTitle.get -> string static Dynamo.Wpf.Properties.Resources.ImportPreferencesInfo.get -> string static Dynamo.Wpf.Properties.Resources.ImportPreferencesText.get -> string diff --git a/src/DynamoCoreWpf/UI/GuidedTour/CustomRichTextBox.cs b/src/DynamoCoreWpf/UI/GuidedTour/CustomRichTextBox.cs index 1b2e28cec27..ad6ff9dee56 100644 --- a/src/DynamoCoreWpf/UI/GuidedTour/CustomRichTextBox.cs +++ b/src/DynamoCoreWpf/UI/GuidedTour/CustomRichTextBox.cs @@ -130,7 +130,10 @@ private static FlowDocument GetCustomDocument(string Text) } //The hyperlink name is the next word followed by the # char (empty spaces are allowed) and the URL value is the one followed after the = char else + { hyperlinkName += word.Replace("#", "") + " "; + continue; + } } else if (bBoldActive) { diff --git a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs index 0de7a0bd877..634637d2c01 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs @@ -863,6 +863,10 @@ protected DynamoViewModel(StartConfiguration startConfiguration) FileTrustViewModel = new FileTrustWarningViewModel(); MLDataPipelineExtension = model.ExtensionManager.Extensions.OfType().FirstOrDefault(); + if (Model.AuthenticationManager?.AuthProvider is IDSDKManager idsdkProvider) + { + idsdkProvider.ErrorInitializingIDSDK += OnErrorInitializingIDSDK; + } } private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) @@ -1083,6 +1087,21 @@ internal void OnNodeViewReady(object nodeView) } } + /// + /// The event handler for cases when IDSDK fails to initialize, probably because of missing Adsk Identity Manager. + /// A flag is used to show the error message only once per session. + /// + private void OnErrorInitializingIDSDK(object sender, EventArgs e) + { + if (Model.AuthenticationManager?.AuthProvider is IDSDKManager idsdkProvider) + { + if (idsdkProvider.isErrorInitializingMsgShown) return; + + DynamoMessageBox.Show(Owner, WpfResources.IDSDKErrorMessage, WpfResources.IDSDKErrorMessageTitle, true, MessageBoxButton.OK, MessageBoxImage.Information); + idsdkProvider.isErrorInitializingMsgShown = true; + } + } + #region Event handler destroy/create protected virtual void UnsubscribeAllEvents() @@ -1104,6 +1123,10 @@ protected virtual void UnsubscribeAllEvents() DynamoSelection.Instance.Selection.CollectionChanged -= SelectionOnCollectionChanged; UsageReportingManager.Instance.PropertyChanged -= CollectInfoManager_PropertyChanged; + if (Model.AuthenticationManager?.AuthProvider is IDSDKManager idsdkProvider) + { + idsdkProvider.ErrorInitializingIDSDK -= OnErrorInitializingIDSDK; + } } private void InitializeRecentFiles()