A helper class to check asynchronously whether the Terms of Use has been accepted, and if so, continue to execute the provided Action.
Example #1
0
        /// <summary>
        /// Download and install a specific package from the package manager
        /// </summary>
        /// <param name="packageInfo"></param>
        /// <param name="downloadPath"></param>
        public void DownloadAndInstallPackage(IPackageInfo packageInfo, string downloadPath = null)
        {
            // User needs to accept terms of use before any packages can be downloaded from package manager
            var prefSettings = DynamoViewModel.Model.PreferenceSettings;
            var touAccepted  = prefSettings.PackageDownloadTouAccepted;

            if (!touAccepted)
            {
                touAccepted = TermsOfUseHelper.ShowTermsOfUseDialog(false, null);
                prefSettings.PackageDownloadTouAccepted = touAccepted;
                if (!touAccepted)
                {
                    return;
                }
            }

            // Try to get the package version for this package
            PackageVersion version;

            try
            {
                version = Model.GetPackageVersionHeader(packageInfo);
            }
            catch
            {
                MessageBox.Show(
                    string.Format(Resources.MessagePackageVersionNotFound, packageInfo.Version.ToString(), packageInfo.Name),
                    Resources.PackageDownloadErrorMessageBoxTitle,
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
                return;
            }

            ExecutePackageDownload(packageInfo.Name, version, downloadPath);
        }
Example #2
0
        public void PublishNewPackage(object m)
        {
            var termsOfUseCheck = new TermsOfUseHelper(new TermsOfUseHelperParams
            {
                PackageManagerClient = Model,
                ResourceProvider     = DynamoViewModel.BrandingResourceProvider,
                AcceptanceCallback   = ShowNodePublishInfo
            });

            termsOfUseCheck.Execute();
        }
Example #3
0
        private void ExecuteWithTou(Action acceptanceCallback)
        {
            // create TermsOfUseHelper object to check asynchronously whether the Terms of Use has
            // been accepted, and if so, continue to execute the provided Action.
            var termsOfUseCheck = new TermsOfUseHelper(new TermsOfUseHelperParams
            {
                PackageManagerClient  = dynamoModel.GetPackageManagerExtension().PackageManagerClient,
                AuthenticationManager = dynamoModel.AuthenticationManager,
                ResourceProvider      = dynamoViewModel.BrandingResourceProvider,
                AcceptanceCallback    = acceptanceCallback
            });

            termsOfUseCheck.Execute(false);
        }
Example #4
0
        public void PublishSelectedNodes(object m)
        {
            var nodeList = DynamoSelection.Instance.Selection
                           .Where(x => x is Function)
                           .Cast <Function>()
                           .Select(x => x.Definition.FunctionId)
                           .ToList();

            if (!nodeList.Any())
            {
                MessageBox.Show(Resources.MessageSelectAtLeastOneNode,
                                Resources.SelectionErrorMessageBoxTitle,
                                MessageBoxButton.OK, MessageBoxImage.Question);
                return;
            }

            var manager = DynamoViewModel.Model.CustomNodeManager;

            var defs = new List <Tuple <CustomNodeInfo, CustomNodeDefinition> >();

            foreach (var node in nodeList)
            {
                CustomNodeInfo info;
                if (manager.TryGetNodeInfo(node, out info))
                {
                    CustomNodeDefinition def;
                    if (manager.TryGetFunctionDefinition(node, DynamoModel.IsTestMode, out def))
                    {
                        defs.Add(Tuple.Create(info, def));
                        continue;
                    }
                }
                MessageBox.Show(Resources.MessageGettingNodeError,
                                Resources.SelectionErrorMessageBoxTitle,
                                MessageBoxButton.OK, MessageBoxImage.Question);
            }

            var termsOfUseCheck = new TermsOfUseHelper(new TermsOfUseHelperParams
            {
                PackageManagerClient  = Model,
                AuthenticationManager = AuthenticationManager,
                ResourceProvider      = DynamoViewModel.BrandingResourceProvider,
                AcceptanceCallback    = () => ShowNodePublishInfo(defs)
            });

            termsOfUseCheck.Execute();
        }
Example #5
0
        public void PublishCustomNode(Dynamo.Nodes.Function m)
        {
            CustomNodeInfo currentFunInfo;

            if (DynamoViewModel.Model.CustomNodeManager.TryGetNodeInfo(
                    m.Definition.FunctionId,
                    out currentFunInfo))
            {
                var termsOfUseCheck = new TermsOfUseHelper(new TermsOfUseHelperParams
                {
                    PackageManagerClient = Model,
                    ResourceProvider     = DynamoViewModel.BrandingResourceProvider,
                    AcceptanceCallback   = () => ShowNodePublishInfo(new[]
                    {
                        Tuple.Create(currentFunInfo, m.Definition)
                    })
                });

                termsOfUseCheck.Execute();
            }
        }
Example #6
0
        public void PublishCurrentWorkspace(object m)
        {
            var ws = (CustomNodeWorkspaceModel)DynamoViewModel.CurrentSpace;

            CustomNodeDefinition currentFunDef;

            if (DynamoViewModel.Model.CustomNodeManager.TryGetFunctionDefinition(
                    ws.CustomNodeId,
                    DynamoModel.IsTestMode,
                    out currentFunDef))
            {
                CustomNodeInfo currentFunInfo;
                if (DynamoViewModel.Model.CustomNodeManager.TryGetNodeInfo(
                        ws.CustomNodeId,
                        out currentFunInfo))
                {
                    var touParams = new TermsOfUseHelperParams
                    {
                        PackageManagerClient  = Model,
                        AuthenticationManager = DynamoViewModel.Model.AuthenticationManager,
                        ResourceProvider      = DynamoViewModel.BrandingResourceProvider,
                        AcceptanceCallback    = () => ShowNodePublishInfo(new[]
                        {
                            Tuple.Create(currentFunInfo, currentFunDef)
                        })
                    };

                    var termsOfUseCheck = new TermsOfUseHelper(touParams);
                    termsOfUseCheck.Execute();
                    return;
                }
            }

            MessageBox.Show(Resources.MessageSelectSymbolNotFound,
                            Resources.SelectionErrorMessageBoxTitle,
                            MessageBoxButton.OK, MessageBoxImage.Question);
        }
        public void PublishSelectedNodes(object m)
        {
            var nodeList = DynamoSelection.Instance.Selection
                                .Where(x => x is Function)
                                .Cast<Function>()
                                .Select(x => x.Definition.FunctionId)
                                .ToList();

            if (!nodeList.Any())
            {
                MessageBox.Show(Resources.MessageSelectAtLeastOneNode,
                   Resources.SelectionErrorMessageBoxTitle,
                   MessageBoxButton.OK, MessageBoxImage.Question);
                return;
            }

            var manager = DynamoViewModel.Model.CustomNodeManager;

            var defs = new List<Tuple<CustomNodeInfo, CustomNodeDefinition>>();
            foreach (var node in nodeList)
            {
                CustomNodeInfo info;
                if (manager.TryGetNodeInfo(node, out info))
                {
                    CustomNodeDefinition def;
                    if (manager.TryGetFunctionDefinition(node, DynamoModel.IsTestMode, out def))
                    {
                        defs.Add(Tuple.Create(info, def));
                        continue;
                    }
                }
                MessageBox.Show(Resources.MessageGettingNodeError, 
                    Resources.SelectionErrorMessageBoxTitle, 
                    MessageBoxButton.OK, MessageBoxImage.Question);
            }

            var termsOfUseCheck = new TermsOfUseHelper(new TermsOfUseHelperParams
            {
                PackageManagerClient = Model,
                AuthenticationManager = AuthenticationManager,
                ResourceProvider = DynamoViewModel.BrandingResourceProvider,
                AcceptanceCallback = () => ShowNodePublishInfo(defs)
            });

            termsOfUseCheck.Execute();
        }
        public void PublishCustomNode(Function m)
        {
            CustomNodeInfo currentFunInfo;
            if (DynamoViewModel.Model.CustomNodeManager.TryGetNodeInfo(
                m.Definition.FunctionId,
                out currentFunInfo))
            {
                var termsOfUseCheck = new TermsOfUseHelper(new TermsOfUseHelperParams
                {
                    PackageManagerClient = Model,
                    AuthenticationManager = AuthenticationManager,
                    ResourceProvider = DynamoViewModel.BrandingResourceProvider,
                    AcceptanceCallback = () => ShowNodePublishInfo(new[]
                    {
                        Tuple.Create(currentFunInfo, m.Definition)
                    })
                });

                termsOfUseCheck.Execute();
            }
        }
        public void PublishNewPackage(object m)
        {
            var termsOfUseCheck = new TermsOfUseHelper(new TermsOfUseHelperParams
            {
                PackageManagerClient = Model,
                AuthenticationManager = AuthenticationManager,
                ResourceProvider = DynamoViewModel.BrandingResourceProvider,
                AcceptanceCallback = ShowNodePublishInfo
            });

            termsOfUseCheck.Execute();
        }
        public void PublishCurrentWorkspace(object m)
        {
            var ws = (CustomNodeWorkspaceModel)DynamoViewModel.CurrentSpace;

            CustomNodeDefinition currentFunDef;
            if (DynamoViewModel.Model.CustomNodeManager.TryGetFunctionDefinition(
                ws.CustomNodeId,
                DynamoModel.IsTestMode,
                out currentFunDef))
            {
                CustomNodeInfo currentFunInfo;
                if (DynamoViewModel.Model.CustomNodeManager.TryGetNodeInfo(
                    ws.CustomNodeId,
                    out currentFunInfo))
                {
                    var touParams = new TermsOfUseHelperParams
                    {
                        PackageManagerClient = Model,
                        AuthenticationManager = DynamoViewModel.Model.AuthenticationManager,
                        ResourceProvider = DynamoViewModel.BrandingResourceProvider,
                        AcceptanceCallback = () => ShowNodePublishInfo(new[]
                        {
                            Tuple.Create(currentFunInfo, currentFunDef)
                        })
                    };

                    var termsOfUseCheck = new TermsOfUseHelper(touParams);
                    termsOfUseCheck.Execute();
                    return;
                }
            }
            
            MessageBox.Show(Resources.MessageSelectSymbolNotFound, 
                    Resources.SelectionErrorMessageBoxTitle,
                    MessageBoxButton.OK, MessageBoxImage.Question);
        }
Example #11
0
        private void ExecuteWithTou(Action acceptanceCallback)
        {
            var dModel = dynamoViewModel.Model;
            // create TermsOfUseHelper object to check asynchronously whether the Terms of Use has 
            // been accepted, and if so, continue to execute the provided Action.
            var termsOfUseCheck = new TermsOfUseHelper(new TermsOfUseHelperParams
            {
                PackageManagerClient = dModel.GetPackageManagerExtension().PackageManagerClient,
                AuthenticationManager = dModel.AuthenticationManager,
                ResourceProvider = dynamoViewModel.BrandingResourceProvider,
                AcceptanceCallback = acceptanceCallback
            });

            termsOfUseCheck.Execute();
        }