Skip to content

Commit

Permalink
DYN-7268 Improve UX when IDSDK is not installed on system running Dyn…
Browse files Browse the repository at this point in the history
…amo (#15790)
  • Loading branch information
zeusongit authored Jan 30, 2025
1 parent 9cdd9f3 commit 0f8b928
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 20 deletions.
57 changes: 37 additions & 20 deletions src/DynamoCore/Core/IDSDKManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ public class IDSDKManager : IOAuth2AuthProvider, IOAuth2AccessTokenProvider, IOA
/// </summary>
public event Action<LoginState> LoginStateChanged;

/// <summary>
/// The event is fired when IDSDK initialization fails
/// </summary>
internal event EventHandler ErrorInitializingIDSDK;

/// <summary>
/// The flag is used to prevent multiple error messages from being shown, since initialization error can be thrown multiple times.
/// </summary>
internal bool isErrorInitializingMsgShown;
private void OnErrorInitializingIDSDK()
{
ErrorInitializingIDSDK?.Invoke(this, EventArgs.Empty);
}

/// <summary>
/// Returns the login status of the current session.
/// </summary>
Expand Down Expand Up @@ -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()
{
Expand Down
19 changes: 19 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4105,4 +4105,11 @@ To make this file into a new template, save it to a different folder, then move
<data name="PackageUnknownCompatibilityVersionDownloadMsg" xml:space="preserve">
<value>The compatibility of this version with your setup has not been verified. It may or may not work as expected.</value>
</data>
<data name="IDSDKErrorMessage" xml:space="preserve">
<value>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.</value>
</data>
<data name="IDSDKErrorMessageTitle" xml:space="preserve">
<value>Download Autodesk Identity Manager</value>
</data>
</root>
7 changes: 7 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4092,4 +4092,11 @@ To make this file into a new template, save it to a different folder, then move
<data name="PackageUnknownCompatibilityVersionDownloadMsg" xml:space="preserve">
<value>The compatibility of this version with your setup has not been verified. It may or may not work as expected. </value>
</data>
<data name="IDSDKErrorMessage" xml:space="preserve">
<value>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.</value>
</data>
<data name="IDSDKErrorMessageTitle" xml:space="preserve">
<value>Download Autodesk Identity Manager</value>
</data>
</root>
2 changes: 2 additions & 0 deletions src/DynamoCoreWpf/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/DynamoCoreWpf/UI/GuidedTour/CustomRichTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
23 changes: 23 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,10 @@ protected DynamoViewModel(StartConfiguration startConfiguration)

FileTrustViewModel = new FileTrustWarningViewModel();
MLDataPipelineExtension = model.ExtensionManager.Extensions.OfType<DynamoMLDataPipelineExtension>().FirstOrDefault();
if (Model.AuthenticationManager?.AuthProvider is IDSDKManager idsdkProvider)
{
idsdkProvider.ErrorInitializingIDSDK += OnErrorInitializingIDSDK;
}
}

private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
Expand Down Expand Up @@ -1083,6 +1087,21 @@ internal void OnNodeViewReady(object nodeView)
}
}

/// <summary>
/// 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.
/// </summary>
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()
Expand All @@ -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()
Expand Down

0 comments on commit 0f8b928

Please sign in to comment.