示例#1
0
 /// <summary>Delete a collection of SiteCollection or Web Features forcefully in one site</summary>
 /// <param name="manager"></param>
 /// <param name="checkedListItems"></param>
 private int DeleteSelectedFeatures(FeatureManager manager, CheckedListBox.CheckedItemCollection checkedListItems)
 {
     int removedFeatures = 0;
     foreach (Feature checkedFeature in checkedListItems)
     {
         manager.ForceRemoveFeature(checkedFeature.Id);
         removedFeatures++;
     }
     return removedFeatures;
 }
示例#2
0
 /// <summary>Uninstall a collection of Farm Feature Definitions forcefully</summary>
 /// <param name="manager"></param>
 /// <param name="checkedListItems"></param>
 private void UninstallSelectedFeatureDefinitions(FeatureManager manager, CheckedListBox.CheckedItemCollection checkedListItems)
 {
     foreach (Feature checkedFeature in checkedListItems)
     {
         manager.ForceUninstallFeatureDefinition(checkedFeature.Id, checkedFeature.CompatibilityLevel);
     }
 }
示例#3
0
        /// <summary>Used to populate the list of Farm Feature Definitions</summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLoadFDefs_Click(object sender, EventArgs e)
        {
            using (WaitCursor wait = new WaitCursor())
            {
                this.clbFeatureDefinitions.Items.Clear();

                farmFeatureDefinitionsManager = new FeatureManager("Farm FeatureDefinitions");
                farmFeatureDefinitionsManager.AddFeatures(SPFarm.Local.FeatureDefinitions);
                farmFeatureDefinitionsManager.Features.Sort();

                // Display any errors enumerating exceptions
                foreach (Feature feature in farmFeatureDefinitionsManager.Features)
                {
                    if (!string.IsNullOrEmpty(feature.ExceptionMsg))
                    {
                        logDateMsg("Exception reading feature " + feature.Id + ": " + feature.ExceptionMsg);
                    }
                }

                //clbFeatureDefinitions.
                this.clbFeatureDefinitions.Items.AddRange(farmFeatureDefinitionsManager.Features.ToArray());
                string featlist = BuildFeatureLog(farmFeatureDefinitionsManager.Url, farmFeatureDefinitionsManager.Features);
                logTxt(featlist);

                logDateMsg("Feature Definition list updated.");
            }
            // tabControl1.Enabled = false;
            // tabControl1.Visible = false;
            // listFeatures.Items.Clear();
            // listDetails.Items.Clear();
        }
示例#4
0
        /// <summary>gets all the features from the selected Web Site and Site Collection</summary>
        private void getFeatures()
        {
            using (WaitCursor wait = new WaitCursor())
            {
                ClearLog();
                clbSPSiteFeatures.Items.Clear();
                clbSPWebFeatures.Items.Clear();

                //using (SPSite site = new SPSite(txtUrl.Text))
                using (SPSite site = m_CurrentSite)
                {
                    siteFeatureManager = new FeatureManager(site.Url);
                    siteFeatureManager.AddFeatures(site.Features, SPFeatureScope.Site);

                    //using (SPWeb web = site.OpenWeb())
                    using (SPWeb web = m_CurrentWeb)
                    {
                        webFeatureManager = new FeatureManager(web.Url);
                        webFeatureManager.AddFeatures(web.Features, SPFeatureScope.Web);
                    }
                }

                // sort the features list
                siteFeatureManager.Features.Sort();
                clbSPSiteFeatures.Items.AddRange(siteFeatureManager.Features.ToArray());
                string featlist = BuildFeatureLog(siteFeatureManager.Url, siteFeatureManager.Features);
                logTxt(featlist);

                // sort the features list
                webFeatureManager.Features.Sort();
                clbSPWebFeatures.Items.AddRange(webFeatureManager.Features.ToArray());
                featlist = BuildFeatureLog(webFeatureManager.Url, webFeatureManager.Features);
                logTxt(featlist);

                // enables the removal buttons
                // removeBtnEnabled(true);
            }
            // commented out, was too annoying
            // MessageBox.Show("Done.");
            logDateMsg("Feature list updated.");
        }