/// <summary> /// The class constructor. /// </summary> /// <param name="client"> Reference to to the PackageManagerClient object for the app </param> public PackageManagerLoginViewModel(PackageManagerClient client) { Client = client; BrowserUri = new Uri("http://www.google.com"); Visible = Visibility.Collapsed; BrowserVisible = Visibility.Collapsed; }
/// <summary> /// Validate the package manager url and initialize the PackageManagerClient object /// </summary> public void Startup(StartupParams startupParams) { var path = this.GetType().Assembly.Location; var config = ConfigurationManager.OpenExeConfiguration(path); var key = config.AppSettings.Settings["packageManagerAddress"]; string url = null; if (key != null) { url = key.Value; } OnMessageLogged(LogMessage.Info("Dynamo will use the package manager server at : " + url)); if (!Uri.IsWellFormedUriString(url, UriKind.Absolute)) { throw new ArgumentException("Incorrectly formatted URL provided for Package Manager address.", "url"); } this.packageLoader = new PackageLoader(startupParams.PathManager.PackagesDirectory); this.packageLoader.MessageLogged += OnMessageLogged; this.packageLoader.RequestLoadNodeLibrary += OnRequestLoadNodeLibrary; this.packageLoader.RequestLoadCustomNodeDirectory += (dir) => startupParams.CustomNodeManager .AddUninitializedCustomNodesInPath(dir, DynamoModel.IsTestMode, true); var dirBuilder = new PackageDirectoryBuilder( new MutatingFileSystem(), new CustomNodePathRemapper(startupParams.CustomNodeManager, DynamoModel.IsTestMode)); var uploadBuilder = new PackageUploadBuilder(dirBuilder, new MutatingFileCompressor()); this.packageManagerClient = new PackageManagerClient(new GregClient(startupParams.AuthProvider, url), uploadBuilder, PackageLoader.RootPackagesDirectory); }
/// <summary> /// The class constructor. </summary> /// <param name="client"> Reference to to the PackageManagerClient object for the app </param> public PublishPackageViewModel(PackageManagerClient client) { Client = client; this.SubmitCommand = new DelegateCommand(this.Submit, this.CanSubmit); this.ShowAddFileDialogAndAddCommand = new DelegateCommand(this.ShowAddFileDialogAndAdd, this.CanShowAddFileDialogAndAdd); this.Dependencies = new ObservableCollection <PackageDependency>(); }
public PackageManagerClientViewModel(DynamoViewModel dynamoViewModel, PackageManagerClient packageManagerClient ) { this.dynamoViewModel = dynamoViewModel; this.packageManagerClient = packageManagerClient; this.CachedPackageList = new List<PackageManagerSearchElement>(); this.packageManagerClient.RequestAuthentication += dynamoViewModel.OnRequestAuthentication; }
/// <summary> /// Validate the package manager url and initialize the PackageManagerClient object /// </summary> public void Startup(StartupParams startupParams) { var path = this.GetType().Assembly.Location; var config = ConfigurationManager.OpenExeConfiguration(path); var key = config.AppSettings.Settings["packageManagerAddress"]; string url = null; if (key != null) { url = key.Value; } OnMessageLogged(LogMessage.Info("Dynamo will use the package manager server at : " + url)); if (!Uri.IsWellFormedUriString(url, UriKind.Absolute)) { throw new ArgumentException("Incorrectly formatted URL provided for Package Manager address.", "url"); } PackageLoader = new PackageLoader(startupParams.PathManager); PackageLoader.MessageLogged += OnMessageLogged; PackageLoader.PackgeLoaded += OnPackageLoaded; PackageLoader.PackageRemoved += OnPackageRemoved; RequestLoadNodeLibraryHandler = (startupParams.LibraryLoader as ExtensionLibraryLoader).LoadLibraryAndSuppressZTSearchImport; //TODO: Add LoadPackages to ILibraryLoader interface in 3.0 LoadPackagesHandler = (startupParams.LibraryLoader as ExtensionLibraryLoader).LoadPackages; customNodeManager = (startupParams.CustomNodeManager as Core.CustomNodeManager); //TODO - in 3.0 we can add the other overload of AddUninitializedCustomNodesInPath to the ICustomNodeManager interface. RequestLoadCustomNodeDirectoryHandler = (dir, pkgInfo) => customNodeManager .AddUninitializedCustomNodesInPath(dir, DynamoModel.IsTestMode, pkgInfo); //when the customNodeManager requests to know the owner of a customNode handle this query. customNodeManager.RequestCustomNodeOwner += handleCustomNodeOwnerQuery; //raise the public events on this extension when the package loader requests. PackageLoader.RequestLoadExtension += RequestLoadExtension; PackageLoader.RequestAddExtension += RequestAddExtension; PackageLoader.PackagesLoaded += LoadPackagesHandler; PackageLoader.RequestLoadNodeLibrary += RequestLoadNodeLibraryHandler; PackageLoader.RequestLoadCustomNodeDirectory += RequestLoadCustomNodeDirectoryHandler; var dirBuilder = new PackageDirectoryBuilder( new MutatingFileSystem(), new CustomNodePathRemapper(startupParams.CustomNodeManager, DynamoModel.IsTestMode)); PackageUploadBuilder.SetEngineVersion(startupParams.DynamoVersion); var uploadBuilder = new PackageUploadBuilder(dirBuilder, new MutatingFileCompressor()); var packageUploadDirectory = startupParams.PathManager.DefaultPackagesDirectory; PackageManagerClient = new PackageManagerClient( new GregClient(startupParams.AuthProvider, url), uploadBuilder, packageUploadDirectory); LoadPackages(startupParams.Preferences, startupParams.PathManager); }
/// <summary> /// The class constructor. /// </summary> /// <param name="bench"> Reference to dynBench object for logging </param> public PackageManagerSearchViewModel(PackageManagerClient client) { PackageManagerClient = client; SearchResults = new ObservableCollection<PackageManagerSearchElement>(); MaxNumSearchResults = 1000; ClearCompletedCommand = new DelegateCommand(ClearCompleted, CanClearCompleted); PackageManagerClient.Downloads.CollectionChanged += DownloadsOnCollectionChanged; this.SearchResults.CollectionChanged += SearchResultsOnCollectionChanged; SearchAndUpdateResults(""); }
/// <summary> /// The class constructor. /// </summary> /// <param name="bench"> Reference to dynBench object for logging </param> public PackageManagerSearchViewModel(PackageManagerClient client) { PackageManagerClient = client; SearchResults = new ObservableCollection <PackageManagerSearchElement>(); MaxNumSearchResults = 1000; ClearCompletedCommand = new DelegateCommand(ClearCompleted, CanClearCompleted); PackageManagerClient.Downloads.CollectionChanged += DownloadsOnCollectionChanged; this.SearchResults.CollectionChanged += SearchResultsOnCollectionChanged; SearchAndUpdateResults(""); }
/// <summary> /// Class constructor /// </summary> public DynamoController(ExecutionEnvironment env) { dynSettings.Controller = this; this.RunEnabled = true; this.CanRunDynamically = true; Bench = new dynBench(this); dynSettings.Bench = Bench; // custom node loader string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string pluginsPath = Path.Combine(directory, "definitions"); CustomNodeLoader = new CustomNodeLoader(pluginsPath); SearchViewModel = new SearchViewModel(); PackageManagerClient = new PackageManagerClient(this); PackageManagerLoginViewModel = new PackageManagerLoginViewModel(PackageManagerClient); PackageManagerPublishViewModel = new PackageManagerPublishViewModel(PackageManagerClient); FSchemeEnvironment = env; HomeSpace = CurrentSpace = new HomeWorkspace(); Bench.CurrentOffset = new Point(dynBench.CANVAS_OFFSET_X, dynBench.CANVAS_OFFSET_Y); Bench.InitializeComponent(); Bench.Log(String.Format( "Dynamo -- Build {0}.", Assembly.GetExecutingAssembly().GetName().Version)); DynamoLoader.LoadBuiltinTypes(SearchViewModel, this, Bench); DynamoLoader.LoadSamplesMenu(Bench); Bench.settings_curves.IsChecked = true; Bench.settings_curves.IsChecked = false; Bench.LockUI(); Bench.Activated += OnBenchActivated; dynSettings.Workbench = Bench.WorkBench; //run tests if (FScheme.RunTests(Bench.Log)) { if (Bench != null) Bench.Log("All Tests Passed. Core library loaded OK."); } }
/// <summary> /// The class constructor. /// </summary> /// <param name="bench"> Reference to dynBench object for logging </param> public PackageManagerSearchViewModel(PackageManagerClient client) { PackageManagerClient = client; SearchResults = new ObservableCollection <PackageManagerSearchElement>(); MaxNumSearchResults = 12; SearchDictionary = new SearchDictionary <PackageManagerSearchElement>(); ClearCompletedCommand = new DelegateCommand(ClearCompleted, CanClearCompleted); SortCommand = new DelegateCommand(Sort, CanSort); SetSortingKeyCommand = new DelegateCommand <object>(SetSortingKey, CanSetSortingKey); SetSortingDirectionCommand = new DelegateCommand <object>(SetSortingDirection, CanSetSortingDirection); PackageManagerClient.Downloads.CollectionChanged += DownloadsOnCollectionChanged; SearchResults.CollectionChanged += SearchResultsOnCollectionChanged; SearchText = ""; SortingKey = PackageSortingKey.LAST_UPDATE; SortingDirection = PackageSortingDirection.ASCENDING; }
/// <summary> /// Class constructor /// </summary> public DynamoController(ExecutionEnvironment env, Type viewModelType, string context) { dynSettings.Controller = this; this.Context = context; //create the view model to which the main window will bind //the DynamoModel is created therein this.DynamoViewModel = (DynamoViewModel)Activator.CreateInstance(viewModelType,new object[]{this}); // custom node loader string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string pluginsPath = Path.Combine(directory, "definitions"); CustomNodeManager = new CustomNodeManager(pluginsPath); SearchViewModel = new SearchViewModel(); PackageManagerClient = new PackageManagerClient(); dynSettings.PackageManagerClient = PackageManagerClient; PublishPackageViewModel = new PublishPackageViewModel(PackageManagerClient); dynSettings.PackageLoader = new PackageLoader(); dynSettings.PackageLoader.DoCachedPackageUninstalls(); dynSettings.PackageLoader.LoadPackages(); FSchemeEnvironment = env; DynamoViewModel.Model.CurrentSpace.X = DynamoView.CANVAS_OFFSET_X; DynamoViewModel.Model.CurrentSpace.Y = DynamoView.CANVAS_OFFSET_Y; dynSettings.Controller.DynamoViewModel.Log(String.Format( "Dynamo -- Build {0}", Assembly.GetExecutingAssembly().GetName().Version)); DynamoLoader.ClearCachedAssemblies(); DynamoLoader.LoadBuiltinTypes(); //run tests if (FScheme.RunTests(dynSettings.Controller.DynamoViewModel.Log)) { dynSettings.Controller.DynamoViewModel.Log("All Tests Passed. Core library loaded OK."); } NodeSubmittedForRendering += new EventHandler(Controller_NodeSubmittedForRendering); NodeRemovedFromRendering += new EventHandler(Controller_NodeRemovedFromRendering); }
public void Refresh() { var pkgs = PackageManagerClient.ListAll(); pkgs.Sort((e1, e2) => e1.Name.ToLower().CompareTo(e2.Name.ToLower())); LastSync = pkgs; SearchDictionary = new SearchDictionary <PackageManagerSearchElement>(); foreach (var pkg in pkgs) { SearchDictionary.Add(pkg, pkg.Name); SearchDictionary.Add(pkg, pkg.Description); SearchDictionary.Add(pkg, pkg.Maintainers); SearchDictionary.Add(pkg, pkg.Keywords); } }
public TermsOfUseHelper(TermsOfUseHelperParams touParams) { if (touParams == null) throw new ArgumentNullException("touParams"); if (touParams.PackageManagerClient == null) throw new ArgumentNullException("PackageManagerClient"); if (touParams.AuthenticationManager == null) throw new ArgumentNullException("AuthenticationManager"); if (touParams.AcceptanceCallback == null) throw new ArgumentNullException("AcceptanceCallback"); if (touParams.ResourceProvider == null) throw new ArgumentNullException("ResourceProvider"); resourceProvider = touParams.ResourceProvider; packageManagerClient = touParams.PackageManagerClient; callbackAction = touParams.AcceptanceCallback; authenticationManager = touParams.AuthenticationManager; }
/// <summary> /// The class constructor. </summary> /// <param name="header">The PackageHeader object describing the element</param> public PackageManagerSearchElement(PackageManagerClient client, Greg.Responses.PackageHeader header) { this.client = client; this.IsExpanded = false; this.Header = header; this.Weight = header.deprecated ? 0.1 : 1; if (header.keywords != null && header.keywords.Count > 0) { this.Keywords = String.Join(" ", header.keywords); } else { this.Keywords = ""; } this.Votes = header.votes; }
/// <summary> /// Performs a search using the given string as query, but does not update /// the SearchResults object. /// </summary> /// <returns> Returns a list with a maximum MaxNumSearchResults elements.</returns> /// <param name="search"> The search query </param> internal List <PackageManagerSearchElement> Search(string search) { bool emptySearch = false; if (search == "") { search = "dyn*"; emptySearch = true; } else { search = String.Join("* ", search.Split(' ')) + "*"; // append wild card to each search } var results = PackageManagerClient.Search(search, MaxNumSearchResults); if (emptySearch) { results.Sort((e1, e2) => e1.Name.ToLower().CompareTo(e2.Name.ToLower())); } return(results); }
public PackageViewModel(DynamoViewModel dynamoViewModel, Package model) { this.dynamoViewModel = dynamoViewModel; var pmExtension = dynamoViewModel.Model.GetPackageManagerExtension(); this.packageManagerClient = pmExtension.PackageManagerClient; Model = model; ToggleTypesVisibleInManagerCommand = new DelegateCommand(ToggleTypesVisibleInManager, CanToggleTypesVisibleInManager); GetLatestVersionCommand = new DelegateCommand(GetLatestVersion, CanGetLatestVersion); PublishNewPackageVersionCommand = new DelegateCommand(() => ExecuteWithTou(PublishNewPackageVersion), CanPublishNewPackageVersion); PublishNewPackageCommand = new DelegateCommand(() => ExecuteWithTou(PublishNewPackage), CanPublishNewPackage); UninstallCommand = new DelegateCommand(Uninstall, CanUninstall); DeprecateCommand = new DelegateCommand(Deprecate, CanDeprecate); UndeprecateCommand = new DelegateCommand(Undeprecate, CanUndeprecate); UnmarkForUninstallationCommand = new DelegateCommand(UnmarkForUninstallation, CanUnmarkForUninstallation); GoToRootDirectoryCommand = new DelegateCommand(GoToRootDirectory, CanGoToRootDirectory); Model.LoadedAssemblies.CollectionChanged += LoadedAssembliesOnCollectionChanged; Model.PropertyChanged += ModelOnPropertyChanged; this.dynamoViewModel.Model.WorkspaceAdded += WorkspaceAdded; this.dynamoViewModel.Model.WorkspaceRemoved += WorkspaceRemoved; }
/// <summary> /// Performs a search using the given string as query, but does not update /// the SearchResults object. /// </summary> /// <returns> Returns a list with a maximum MaxNumSearchResults elements.</returns> /// <param name="search"> The search query </param> internal List <PackageManagerSearchElement> SearchOnline(string search) { bool emptySearch = false; if (search == "") { search = "dyn*"; emptySearch = true; } else { search = String.Join("* ", search.Split(' ')) + "*"; // append wild card to each search } var results = PackageManagerClient.Search(search, MaxNumSearchResults); if (emptySearch) { Sort(results, this.SortingKey); } return(results); }
/// <summary> /// The class constructor. </summary> /// <param name="client"> Reference to to the PackageManagerClient object for the app </param> public PackageManagerPublishViewModel(PackageManagerClient client) { Client = client; this.SubmitCommand = new DelegateCommand<object>(this.OnSubmit, this.CanSubmit); this.Clear(); this.Visible = Visibility.Collapsed; }
public void Execute(object parameters) { this._client = dynSettings.Controller.PackageManagerClient; var nodeList = DynamoSelection.Instance.Selection.Where(x => x is dynNodeModel && ((dynNodeModel)x) is dynFunction ) .Select(x => ( ((dynNodeModel)x) as dynFunction ).Definition.FunctionId ).ToList(); if (nodeList.Count != 1) { MessageBox.Show("You must select a single user-defined node. You selected " + nodeList.Count + " nodes." , "Selection Error", MessageBoxButton.OK, MessageBoxImage.Question); return; } if ( dynSettings.Controller.CustomNodeLoader.Contains( nodeList[0] ) ) { DynamoCommands.ShowNodeNodePublishInfoCmd.Execute( dynSettings.Controller.CustomNodeLoader.GetFunctionDefinition( nodeList[0]) ); } else { MessageBox.Show("The selected symbol was not found in the workspace", "Selection Error", MessageBoxButton.OK, MessageBoxImage.Question); } }
/// <summary> /// The class constructor. </summary> /// <param name="client"> Reference to to the PackageManagerClient object for the app </param> public PublishPackageViewModel(PackageManagerClient client) { Client = client; this.SubmitCommand = new DelegateCommand(this.Submit, this.CanSubmit); this.ShowAddFileDialogAndAddCommand = new DelegateCommand(this.ShowAddFileDialogAndAdd, this.CanShowAddFileDialogAndAdd); this.Dependencies = new ObservableCollection<PackageDependency>(); }
protected DynamoModel(StartConfiguration configuration) { string context = configuration.Context; IPreferences preferences = configuration.Preferences; string corePath = configuration.DynamoCorePath; DynamoRunner runner = configuration.Runner; bool isTestMode = configuration.StartInTestMode; DynamoPathManager.Instance.InitializeCore(corePath); UsageReportingManager.Instance.InitializeCore(this); Runner = runner; Context = context; IsTestMode = isTestMode; Logger = new DynamoLogger(this, DynamoPathManager.Instance.Logs); DebugSettings = new DebugSettings(); #if ENABLE_DYNAMO_SCHEDULER var thread = configuration.SchedulerThread ?? new DynamoSchedulerThread(); scheduler = new DynamoScheduler(thread); #endif if (preferences is PreferenceSettings) { this.PreferenceSettings = preferences as PreferenceSettings; PreferenceSettings.PropertyChanged += PreferenceSettings_PropertyChanged; } InitializePreferences(preferences); InitializeInstrumentationLogger(); UpdateManager.UpdateManager.Instance.CheckForProductUpdate(new UpdateRequest(new Uri(Configurations.UpdateDownloadLocation))); SearchModel = new SearchModel(this); InitializeCurrentWorkspace(); this.CustomNodeManager = new CustomNodeManager(this, DynamoPathManager.Instance.UserDefinitions); this.Loader = new DynamoLoader(this); this.Loader.PackageLoader.DoCachedPackageUninstalls(); this.Loader.PackageLoader.LoadPackages(); DisposeLogic.IsShuttingDown = false; this.EngineController = new EngineController(this, DynamoPathManager.Instance.GeometryFactory); this.CustomNodeManager.RecompileAllNodes(EngineController); // Reset virtual machine to avoid a race condition by causing a // thread join inside the vm exec. Since DynamoModel is being called // on the main/idle thread, it is safe to call ResetEngineInternal // directly (we cannot call virtual method ResetEngine here). // ResetEngineInternal(); Nodes.ForEach(n => n.RequiresRecalc = true); Logger.Log(String.Format( "Dynamo -- Build {0}", Assembly.GetExecutingAssembly().GetName().Version)); this.Loader.ClearCachedAssemblies(); this.Loader.LoadNodeModels(); MigrationManager.Instance.MigrationTargets.Add(typeof(WorkspaceMigrations)); PackageManagerClient = new PackageManagerClient(this); }
/// <summary> /// The class constructor. </summary> /// <param name="client"> Reference to to the PackageManagerClient object for the app </param> public PublishPackageViewModel(PackageManagerClient client) { Client = client; this.SubmitCommand = new DelegateCommand<object>(this.Submit, this.CanSubmit); this.Dependencies = new ObservableCollection<PackageDependency>(); }
/// <summary> /// The class constructor. </summary> /// <param name="client"> Reference to to the PackageManagerClient object for the app </param> public PublishPackageViewModel(PackageManagerClient client) { Client = client; this.SubmitCommand = new DelegateCommand <object>(this.Submit, this.CanSubmit); this.Dependencies = new ObservableCollection <PackageDependency>(); }
/// <summary> /// Callback for registering an authentication provider with the package manager /// </summary> /// <param name="client">The client, to which the provider will be attached</param> void RegisterSingleSignOn(PackageManagerClient client) { if (_singleSignOnAssembly == null) _singleSignOnAssembly = LoadSSONet(); client.Client.Provider = new RevitOxygenProvider(new DispatcherSynchronizationContext(this.UIDispatcher)); }
public PackageManagerClientViewModel(DynamoViewModel dynamoViewModel, PackageManagerClient model ) { this.dynamoViewModel = dynamoViewModel; this.Model = model; this.CachedPackageList = new List<PackageManagerSearchElement>(); }
internal PackageManagerClientViewModel(DynamoViewModel dynamoViewModel, PackageManagerClient model ) { this.DynamoViewModel = dynamoViewModel; this.AuthenticationManager = dynamoViewModel.Model.AuthenticationManager; Model = model; CachedPackageList = new List<PackageManagerSearchElement>(); this.ToggleLoginStateCommand = new DelegateCommand(ToggleLoginState, CanToggleLoginState); AuthenticationManager.LoginStateChanged += (loginState) => { RaisePropertyChanged("LoginState"); RaisePropertyChanged("Username"); }; }
/// <summary> /// Callback for registering an authentication provider with the package manager /// </summary> /// <param name="client">The client, to which the provider will be attached</param> private void RegisterSingleSignOn(PackageManagerClient client) { _singleSignOnAssembly = _singleSignOnAssembly ?? LoadSSONet(); client.Client.Provider = client.Client.Provider ?? new RevitOxygenProvider(new DispatcherSynchronizationContext(this.UIDispatcher)); }
public void ClearCompleted() { PackageManagerClient.ClearCompletedDownloads(); }
/// <summary> /// Callback for registering an authentication provider with the package manager /// </summary> /// <param name="client">The client, to which the provider will be attached</param> void RegisterSingleSignOn(PackageManagerClient client) { if (_singleSignOnAssembly == null) _singleSignOnAssembly = LoadSSONet(); client.Client.Provider = new RevitOxygenProvider(); }
/// <summary> /// The class constructor. /// </summary> /// <param name="bench"> Reference to dynBench object for logging </param> public PackageManagerSearchViewModel(PackageManagerClient client) { PackageManagerClient = client; SearchResults = new ObservableCollection<PackageManagerSearchElement>(); MaxNumSearchResults = 12; SearchDictionary = new SearchDictionary<PackageManagerSearchElement>(); ClearCompletedCommand = new DelegateCommand(ClearCompleted, CanClearCompleted); SortCommand = new DelegateCommand(Sort, CanSort); SetSortingKeyCommand = new DelegateCommand<object>(SetSortingKey, CanSetSortingKey); SetSortingDirectionCommand = new DelegateCommand<object>(SetSortingDirection, CanSetSortingDirection); PackageManagerClient.Downloads.CollectionChanged += DownloadsOnCollectionChanged; SearchResults.CollectionChanged += SearchResultsOnCollectionChanged; SearchText = ""; SortingKey = PackageSortingKey.LAST_UPDATE; SortingDirection = PackageSortingDirection.ASCENDING; }
public void PackageManagerConflictsWithStdLib() { var pkgLoader = GetPackageLoader(); pkgLoader.StandardLibraryDirectory = StandardLibraryTestDirectory; // Load a std lib package var stdPackageLocation = Path.Combine(StandardLibraryTestDirectory, "SignedPackage2"); pkgLoader.ScanPackageDirectory(stdPackageLocation); var stdLibPkg = pkgLoader.LocalPackages.Where(x => x.Name == "SignedPackage").FirstOrDefault(); Assert.IsNotNull(stdLibPkg); // Simulate the user downloading the same package from PM var mockGreg = new Mock <IGregClient>(); mockGreg.Setup(x => x.Execute(It.IsAny <PackageDownload>())).Throws(new Exception("Failed to get your package!")); var client = new Dynamo.PackageManager.PackageManagerClient(mockGreg.Object, MockMaker.Empty <IPackageUploadBuilder>(), string.Empty); var pmVm = new PackageManagerClientViewModel(ViewModel, client); var dlgMock = new Mock <MessageBoxService.IMessageBox>(); dlgMock.Setup(m => m.Show(It.IsAny <string>(), It.IsAny <string>(), It.Is <MessageBoxButton>(x => x == MessageBoxButton.OKCancel || x == MessageBoxButton.OK), It.IsAny <MessageBoxImage>())) .Returns(MessageBoxResult.OK); MessageBoxService.OverrideMessageBoxDuringTests(dlgMock.Object); // // 1. User downloads the exact version of a std lib package // { var id = "test-123"; var deps = new List <Dependency>() { new Dependency() { _id = id, name = stdLibPkg.Name } }; var depVers = new List <string>() { stdLibPkg.VersionName }; mockGreg.Setup(m => m.ExecuteAndDeserializeWithContent <PackageVersion>(It.IsAny <Request>())) .Returns(new ResponseWithContentBody <PackageVersion>() { content = new PackageVersion() { version = stdLibPkg.VersionName, engine_version = stdLibPkg.EngineVersion, name = stdLibPkg.Name, id = id, full_dependency_ids = deps, full_dependency_versions = depVers }, success = true }); var pkgInfo = new Dynamo.Graph.Workspaces.PackageInfo(stdLibPkg.Name, VersionUtilities.PartialParse(stdLibPkg.VersionName)); pmVm.DownloadAndInstallPackage(pkgInfo); // Users should get 2 warnings : // 1. To confirm that they want to download the specified package. // 2. That a package with the same name and version already exists as part of the Standard Library. dlgMock.Verify(x => x.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>()), Times.Exactly(2)); dlgMock.ResetCalls(); } // // 2. User downloads a different version of a std lib package // { var id = "test-234"; var deps = new List <Dependency>() { new Dependency() { _id = id, name = stdLibPkg.Name } }; var stdLibPkgVers = VersionUtilities.PartialParse(stdLibPkg.VersionName); var newPkgVers = new Version(stdLibPkgVers.Major + 1, stdLibPkgVers.Minor, stdLibPkgVers.Build); var depVers = new List <string>() { newPkgVers.ToString() }; mockGreg.Setup(m => m.ExecuteAndDeserializeWithContent <PackageVersion>(It.IsAny <Request>())) .Returns(new ResponseWithContentBody <PackageVersion>() { content = new PackageVersion() { version = newPkgVers.ToString(), engine_version = stdLibPkg.EngineVersion, name = stdLibPkg.Name, id = id, full_dependency_ids = deps, full_dependency_versions = depVers }, success = true }); var pkgInfo = new Dynamo.Graph.Workspaces.PackageInfo(stdLibPkg.Name, newPkgVers); pmVm.DownloadAndInstallPackage(pkgInfo); // Users should get 2 warnings : // 1. To confirm that they want to download the specified package. // 2. That a package with a different version already exists as part of the Standard Library. dlgMock.Verify(x => x.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>()), Times.Exactly(2)); dlgMock.ResetCalls(); } // // 3. User downloads a package that is not part of a std lib package // { var id = "test-345"; var deps = new List <Dependency>() { new Dependency() { _id = id, name = "non-std-libg" } }; var pkgVersion = new Version(1, 0, 0); var depVers = new List <string>() { pkgVersion.ToString() }; mockGreg.Setup(m => m.ExecuteAndDeserializeWithContent <PackageVersion>(It.IsAny <Request>())) .Returns(new ResponseWithContentBody <PackageVersion>() { content = new PackageVersion() { version = pkgVersion.ToString(), engine_version = stdLibPkg.EngineVersion, name = "non-std-libg", id = id, full_dependency_ids = deps, full_dependency_versions = depVers }, success = true }); var pkgInfo = new Dynamo.Graph.Workspaces.PackageInfo("Non-stdlib-package", new Version(1, 0, 0)); pmVm.DownloadAndInstallPackage(pkgInfo); // Users should get 1 warning : // 1. To confirm that they want to download the specified package. dlgMock.Verify(x => x.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>()), Times.Exactly(1)); dlgMock.ResetCalls(); } }
/// <summary> /// Class constructor /// </summary> public DynamoController(ExecutionEnvironment env, bool withUI, Type viewModelType, string context) { dynSettings.Controller = this; this.Context = context; //MVVM: don't construct the main window with a reference to the controller //dynSettings.Bench = new dyndynSettings.Bench(this); //MVVM : create the view model to which the main window will bind //the DynamoModel is created therein //this.DynamoViewModel = new DynamoViewModel(this); this.DynamoViewModel = (DynamoViewModel)Activator.CreateInstance(viewModelType,new object[]{this}); // custom node loader string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string pluginsPath = Path.Combine(directory, "definitions"); CustomNodeLoader = new CustomNodeLoader(pluginsPath); if (withUI) { dynSettings.Bench = new DynamoView(); dynSettings.Bench = dynSettings.Bench; dynSettings.Bench.DataContext = DynamoViewModel; } SearchViewModel = new SearchViewModel(); PackageManagerClient = new PackageManagerClient(this); PackageManagerLoginViewModel = new PackageManagerLoginViewModel(PackageManagerClient); PackageManagerPublishViewModel = new PackageManagerPublishViewModel(PackageManagerClient); FSchemeEnvironment = env; //MVVM : moved to proper view constructor on dyndynSettings.Bench //DynamoViewModel.Model.CurrentSpace.CurrentOffset = new Point(DynamoView.CANVAS_OFFSET_X, DynamoView.CANVAS_OFFSET_Y); DynamoViewModel.Model.CurrentSpace.X = DynamoView.CANVAS_OFFSET_X; DynamoViewModel.Model.CurrentSpace.Y = DynamoView.CANVAS_OFFSET_Y; //dynSettings.Bench.CurrentOffset = new Point(dyndynSettings.Bench.CANVAS_OFFSET_X, dyndynSettings.Bench.CANVAS_OFFSET_Y); //dynSettings.Bench.InitializeComponent(); dynSettings.Controller.DynamoViewModel.Log(String.Format( "Dynamo -- Build {0}.", Assembly.GetExecutingAssembly().GetName().Version)); //MVVM : removed parameter dynSettings.Bench DynamoLoader.LoadBuiltinTypes(SearchViewModel, this);//, dynSettings.Bench); if(dynSettings.Bench != null) DynamoLoader.LoadSamplesMenu(dynSettings.Bench); //dynSettings.Bench.settings_curves.IsChecked = true; //dynSettings.Bench.settings_curves.IsChecked = false; if (dynSettings.Bench != null) { //dynSettings.Bench.LockUI(); //MVVM : callback has been restructured so that it sends a command back to the view model //dynSettings.Bench.Activated += OndynSettings.BenchActivated; //MVVM: we've gone to using a model and a model view of a workspace //do not reference a specific workdynSettings.Bench here. //dynSettings.WorkdynSettings.Bench = dynSettings.Bench.WorkdynSettings.Bench; } //run tests if (FScheme.RunTests(dynSettings.Controller.DynamoViewModel.Log)) { if (dynSettings.Bench != null) this.DynamoViewModel.Log("All Tests Passed. Core library loaded OK."); } }
public void Execute(object parameters) { this._client = dynSettings.Controller.PackageManagerClient; if ( dynSettings.Controller.DynamoViewModel.ViewingHomespace ) { MessageBox.Show("You can only publish Custom Node workspaces.", "Workspace Error", MessageBoxButton.OK, MessageBoxImage.Question); return; } var currentFunDef = dynSettings.Controller.CustomNodeManager.GetDefinitionFromWorkspace(dynSettings.Controller.DynamoViewModel.CurrentSpace); if ( currentFunDef != null ) { DynamoCommands.ShowNodeNodePublishInfoCmd.Execute(new List<FunctionDefinition> {currentFunDef}); } else { MessageBox.Show("The selected symbol was not found in the workspace", "Selection Error", MessageBoxButton.OK, MessageBoxImage.Question); } }
public void Execute(object parameters) { this._client = dynSettings.Controller.PackageManagerClient; var nodeList = DynamoSelection.Instance.Selection .Where(x => x is dynFunction) .Cast<dynFunction>() .Select(x => x.Definition.FunctionId ) .ToList(); if (!nodeList.Any()) { MessageBox.Show("You must select at least one custom node.", "Selection Error", MessageBoxButton.OK, MessageBoxImage.Question); return; } var defs = nodeList.Select(dynSettings.CustomNodeManager.GetFunctionDefinition).ToList(); if (defs.Any(x=> x == null)) MessageBox.Show("There was a problem getting the node from the workspace.", "Selection Error", MessageBoxButton.OK, MessageBoxImage.Question); DynamoCommands.ShowNodeNodePublishInfoCmd.Execute(defs); }
/// <summary> /// Validate the package manager url and initialize the PackageManagerClient object /// </summary> public void Startup(StartupParams startupParams) { var path = this.GetType().Assembly.Location; var config = ConfigurationManager.OpenExeConfiguration(path); var key = config.AppSettings.Settings["packageManagerAddress"]; string url = null; if (key != null) { url = key.Value; } OnMessageLogged(LogMessage.Info("Dynamo will use the package manager server at : " + url)); if (!Uri.IsWellFormedUriString(url, UriKind.Absolute)) { throw new ArgumentException("Incorrectly formatted URL provided for Package Manager address.", "url"); } PackageLoader = new PackageLoader(startupParams.PathManager.PackagesDirectories); PackageLoader.MessageLogged += OnMessageLogged; RequestLoadNodeLibraryHandler = startupParams.LibraryLoader.LoadNodeLibrary; RequestLoadCustomNodeDirectoryHandler = (dir) => startupParams.CustomNodeManager .AddUninitializedCustomNodesInPath(dir, DynamoModel.IsTestMode, true); PackageLoader.RequestLoadNodeLibrary += RequestLoadNodeLibraryHandler; PackageLoader.RequestLoadCustomNodeDirectory += RequestLoadCustomNodeDirectoryHandler; var dirBuilder = new PackageDirectoryBuilder( new MutatingFileSystem(), new CustomNodePathRemapper(startupParams.CustomNodeManager, DynamoModel.IsTestMode)); var uploadBuilder = new PackageUploadBuilder(dirBuilder, new MutatingFileCompressor()); PackageManagerClient = new PackageManagerClient( new GregClient(startupParams.AuthProvider, url), uploadBuilder, PackageLoader.DefaultPackagesDirectory); }
void RegisterSingleSignOn(PackageManagerClient client) { var ads = Autodesk.Revit.AdWebServicesBase.GetInstance(); client.Client.Provider = new Greg.RevitOxygenProvider(ads); }