Skip to content

Commit

Permalink
fix: sysManager.LookupTreeItem is not working with the latest 4026 beta
Browse files Browse the repository at this point in the history
  • Loading branch information
iadonkey committed Jan 30, 2024
1 parent 6f7837a commit 091fbbe
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions TwinpackVsixShared/Dialogs/CatalogWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -957,13 +957,10 @@ public bool IsLicenseDialogRequired(ITcPlcLibraryManager libManager, Models.Pack
(!string.IsNullOrEmpty(packageVersion.LicenseBinary) || (!string.IsNullOrEmpty(packageVersion.LicenseTmcBinary) && (ForceShowLicense || !shownLicenses.Contains(licenseId))));
}

public HashSet<string> ShowLicensesIfNeeded(IEnumerable<PackageVersionGetResponse> packageVersions, HashSet<string> knownLicenseIds, bool showLicenseDialog, HashSet<string> shownLicenseIds = null)
public HashSet<string> ShowLicensesIfNeeded(ITcPlcLibraryManager libManager, IEnumerable<PackageVersionGetResponse> packageVersions, HashSet<string> knownLicenseIds, bool showLicenseDialog, HashSet<string> shownLicenseIds = null)
{
Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

var plc = _plc.Object as dynamic;
var sysManager = plc.SystemManager as ITcSysManager2;
var libManager = sysManager.LookupTreeItem(plc.PathName + "^References") as ITcPlcLibraryManager;
shownLicenseIds = shownLicenseIds ?? (ForceShowLicense ? new HashSet<string>() : new HashSet<string>(knownLicenseIds));

// todo: flatten dependencies and versions and iterate over this
Expand Down Expand Up @@ -999,13 +996,18 @@ public async Task AddOrUpdatePackageAsync(IEnumerable<PackageVersionGetResponse>
throw new Exception("Invalid package(s) should be added or updated!");

var cachePath = $@"{Path.GetDirectoryName(_context.Solution.FullName)}\.Zeugwerk\libraries";

var plc = _plc.Object as dynamic;
var sysManager = plc.SystemManager as ITcSysManager2;
var libManager = sysManager.LookupTreeItem(plc.PathName + "^References") as ITcPlcLibraryManager;
var libManagerItem = plc.LookupChild("References");
var libManager = libManagerItem as ITcPlcLibraryManager;

//var sysManager = plc.SystemManager as ITcSysManager16;
// var libManager = sysManager.LookupTreeItem(plc.PathName + "^References") as ITcPlcLibraryManager;

var knownLicenseIds = TwinpackUtils.KnownLicenseIds();

// license handling
ShowLicensesIfNeeded(packageVersions, knownLicenseIds, showLicenseDialog);
ShowLicensesIfNeeded(libManager, packageVersions, knownLicenseIds, showLicenseDialog);
TwinpackUtils.CopyLicenseTmcIfNeeded(packageVersions, knownLicenseIds);

// download packages and close Library Manager and all windows that are related to the library. These windows cause race conditions
Expand Down

0 comments on commit 091fbbe

Please sign in to comment.