Пример #1
0
        void WebAppTreeNode_TreeNodePopulate(object sender, TreeViewCancelEventArgs e)
        {
            WebApplicationInfo webAppInfo = e.Node.Tag as WebApplicationInfo;

            if (webAppInfo != null)
            {
                if (webAppInfo.Application.Sites.Count >= SiteCollectionCountWarning)
                {
                    string msg = String.Format(FormattedSiteCollectionCountWarningMessage, webAppInfo.Application.Sites.Count);
                    if (MessageBox.Show(msg, "Large Number of Site Collections", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                    {
                        e.Cancel = true;
                    }
                }
                if (!e.Cancel)
                {
                    foreach (SPSite site in webAppInfo.Application.Sites)
                    {
                        try
                        {
                            SiteCollectionInfo siteCollInfo = new SiteCollectionInfo(site, false);
                            ExtendedTreeNode.AddNewExtendedTreeNode(e.Node.Nodes, siteCollInfo.ToString(), siteCollInfo);
                        }
                        finally
                        {
                            // guarantee SPSite is released ASAP even in face of exception
                            site.Dispose();
                        }
                    }
                }
            }
        }
Пример #2
0
 private void PopulateTreeViewForWebApps(TreeNodeCollection treeNodes, SPWebApplicationCollection webApps)
 {
     foreach (SPWebApplication application in webApps)
     {
         WebApplicationInfo webAppInfo     = new WebApplicationInfo(application, false);
         ExtendedTreeNode   webAppTreeNode = ExtendedTreeNode.AddNewExtendedTreeNode(treeNodes, webAppInfo.ToString(), true, webAppInfo);
         webAppTreeNode.TreeNodePopulate += new ExtendedTreeNode.TreeNodeEventHandler(WebAppTreeNode_TreeNodePopulate);
     }
 }
Пример #3
0
        protected internal override void Close(InstallOptions options)
        {
            foreach (TreeNode webAppTreeNode in siteCollectionsTreeView.Nodes)
            {
                // Add the web application as a target
                if (webAppTreeNode.Checked)
                {
                    WebApplicationInfo webAppInfo = webAppTreeNode.Tag as WebApplicationInfo;
                    if (webAppInfo != null)
                    {
                        options.WebApplicationTargets.Add(webAppInfo.Application);

                        ExtendedTreeNode extendedWebAppTreeNode = webAppTreeNode as ExtendedTreeNode;
                        if (extendedWebAppTreeNode != null)
                        {
                            if (!extendedWebAppTreeNode.Populated)
                            {
                                // Add ALL site collections within the web app as targets
                                foreach (SPSite siteCollection in webAppInfo.Application.Sites)
                                {
                                    try
                                    {
                                        SiteLoc siteLoc = new SiteLoc(siteCollection);
                                        siteLoc.featureList.AddRange(_featureIds); // add all known features for now (be nice to let user choose)
                                        options.SiteCollectionTargets.Add(siteLoc);
                                    }
                                    finally
                                    {
                                        // guarantee SPSite is released ASAP even in face of exception
                                        siteCollection.Dispose();
                                    }
                                }
                            }
                            else
                            {
                                // Add the checked site collections within this web application as targets
                                foreach (TreeNode siteCollTreeNode in webAppTreeNode.Nodes)
                                {
                                    if (siteCollTreeNode.Checked)
                                    {
                                        SiteCollectionInfo siteCollInfo = siteCollTreeNode.Tag as SiteCollectionInfo;
                                        if (siteCollInfo != null)
                                        {
                                            SiteLoc siteLoc = new SiteLoc(siteCollInfo.SiteCollection);
                                            siteLoc.featureList.AddRange(_featureIds); // add all known features for now (be nice to let user choose)
                                            options.SiteCollectionTargets.Add(siteLoc);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #4
0
        public static ExtendedTreeNode AddNewExtendedTreeNode(TreeNodeCollection parentNodeCollection, string text, bool populateOnDemand, object tag)
        {
            ExtendedTreeNode extendedTreeNode = new ExtendedTreeNode(text, populateOnDemand, tag);

            parentNodeCollection.Add(extendedTreeNode);

            if (extendedTreeNode.TreeView == null)
            {
                throw new InvalidOperationException("You cannot add a new ExtendedTreeNode to a node that is not already a member of a TreeView.");
            }

            extendedTreeNode.Prepare();

            return(extendedTreeNode);
        }
Пример #5
0
        private void CheckParentNode(TreeNode node, bool value)
        {
            ExtendedTreeNode extendedNode = node as ExtendedTreeNode;

            if (extendedNode != null)
            {
                extendedNode.PreventChildCheck = true;
            }
            try
            {
                node.Checked = value;
            }
            finally
            {
                if (extendedNode != null)
                {
                    extendedNode.PreventChildCheck = false;
                }
            }
        }
        public static ExtendedTreeNode AddNewExtendedTreeNode(TreeNodeCollection parentNodeCollection, string text, bool populateOnDemand, object tag)
        {
            ExtendedTreeNode extendedTreeNode = new ExtendedTreeNode(text, populateOnDemand, tag);
              parentNodeCollection.Add(extendedTreeNode);

              if (extendedTreeNode.TreeView == null)
              {
            throw new InvalidOperationException("You cannot add a new ExtendedTreeNode to a node that is not already a member of a TreeView.");
              }

              extendedTreeNode.Prepare();

              return extendedTreeNode;
        }