Exemplo n.º 1
0
        /// <summary>
        /// Regenerate dependency table
        /// </summary>
        /// <param name="ws">workspace model</param>
        internal void DependencyRegen(WorkspaceModel ws)
        {
            RestartBanner.Visibility = Visibility.Hidden;
            var packageDependencies = ws.NodeLibraryDependencies.Where(d => d is PackageDependencyInfo).ToList();

            var pythonPackageDependencies = ws.OnRequestPackageDependencies();

            if (pythonPackageDependencies != null)
            {
                packageDependencies.AddRange(pythonPackageDependencies);
            }

            if (packageDependencies.Any(d => d.State != PackageDependencyState.Loaded))
            {
                HasDependencyIssue = true;
            }

            if (packageDependencies.Any())
            {
                Boolean hasPackageMarkedForUninstall = false;
                // If package is set to uninstall state, update the package info
                foreach (var package in dependencyViewExtension.pmExtension.PackageLoader.LocalPackages.Where(x => x.MarkedForUninstall))
                {
                    (packageDependencies.FirstOrDefault(x => x.Name == package.Name) as PackageDependencyInfo).State =
                        PackageDependencyState.RequiresRestart;
                    hasPackageMarkedForUninstall = true;
                }
                this.RestartBanner.Visibility = hasPackageMarkedForUninstall ? Visibility.Visible: Visibility.Hidden;
            }

            dataRows = packageDependencies.Select(d => new PackageDependencyRow(d as PackageDependencyInfo));
            PackageDependencyTable.ItemsSource = dataRows;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Regenerate dependency table
        /// </summary>
        /// <param name="ws">workspace model</param>
        internal void DependencyRegen(WorkspaceModel ws)
        {
            RestartBanner.Visibility = Visibility.Hidden;
            var packageDependencies = ws.NodeLibraryDependencies.Where(d => d is PackageDependencyInfo).ToList();
            var localDefinitions    = ws.NodeLocalDefinitions.Where(d => d is DependencyInfo).ToList();
            var externalFiles       = ws.ExternalFiles.Where(d => d is DependencyInfo).ToList();

            foreach (DependencyInfo info in localDefinitions)
            {
                try
                {
                    if (info.ReferenceType == ReferenceType.DYFFile)
                    {
                        // Try to get the Custom node information if possible.
                        string customNodeName = info.Name.Replace(customNodeExtension, "");
                        dependencyViewExtension.DependencyView.CustomNodeManager.TryGetNodeInfo(customNodeName, out CustomNodeInfo customNodeInfo);

                        if (customNodeInfo != null)
                        {
                            info.Path = customNodeInfo.Path;
                        }
                    }

                    info.Size = PathHelper.GetFileSize(info.Path);
                }
                catch (Exception ex)
                {
                    dependencyViewExtension.OnMessageLogged(LogMessage.Info(string.Format(Properties.Resources.DependencyViewExtensionErrorTemplate, ex.ToString())));
                }

                HasDependencyIssue = info.Path == null;
            }

            foreach (DependencyInfo info in externalFiles)
            {
                HasDependencyIssue = info.Path == null;
            }

            var pythonPackageDependencies = ws.OnRequestPackageDependencies();

            if (pythonPackageDependencies != null)
            {
                packageDependencies.AddRange(pythonPackageDependencies);
            }

            if (packageDependencies.Any(d => d.State != PackageDependencyState.Loaded))
            {
                HasDependencyIssue = true;
            }

            if (packageDependencies.Any())
            {
                Boolean hasPackageMarkedForUninstall = false;
                // If package is set to uninstall state, update the package info
                foreach (var package in dependencyViewExtension.pmExtension.PackageLoader.LocalPackages.Where(x =>
                                                                                                              x.LoadState.ScheduledState == PackageLoadState.ScheduledTypes.ScheduledForDeletion || x.LoadState.ScheduledState == PackageLoadState.ScheduledTypes.ScheduledForUnload))
                {
                    (packageDependencies.FirstOrDefault(x => x.Name == package.Name) as PackageDependencyInfo).State =
                        PackageDependencyState.RequiresRestart;
                    hasPackageMarkedForUninstall = true;
                }

                RestartBanner.Visibility = hasPackageMarkedForUninstall ? Visibility.Visible: Visibility.Hidden;
            }

            var pmExtension = dependencyViewExtension.pmExtension;

            if (pmExtension != null)
            {
                foreach (PackageDependencyInfo packageDependencyInfo in packageDependencies)
                {
                    var targetInfo = pmExtension.PackageLoader.LocalPackages.Where(x => x.Name == packageDependencyInfo.Name).FirstOrDefault();
                    if (targetInfo != null)
                    {
                        packageDependencyInfo.Path = targetInfo.RootDirectory;
                    }
                }
            }

            dataRows = packageDependencies.Select(d => new PackageDependencyRow(d as PackageDependencyInfo));
            localDefinitionDataRows = localDefinitions.Select(d => new DependencyRow(d as DependencyInfo));
            externalFilesDataRows   = externalFiles.Select(d => new DependencyRow(d as DependencyInfo));

            Packages.IsExpanded         = dataRows.Count() > 0;
            LocalDefinitions.IsExpanded = localDefinitionDataRows.Count() > 0;
            ExternalFiles.IsExpanded    = externalFilesDataRows.Count() > 0;


            PackageDependencyTable.ItemsSource = dataRows;
            LocalDefinitionsTable.ItemsSource  = localDefinitionDataRows;
            ExternalFilesTable.ItemsSource     = externalFilesDataRows;
        }