/// <summary>Adds features to the custom Feature class</summary>
        /// <param name="spFeatureDefinitions"></param>
        public void AddFeatures(SPFeatureCollection spfeatures, SPFeatureScope scope)
        {
            this._spfeatures = spfeatures;

            foreach (SPFeature spfeature in spfeatures)
            {
                Feature feature = new Feature(spfeature.DefinitionId, scope);
                try
                {
                    feature.Name = spfeature.Definition.DisplayName;
                }
                catch (Exception exc)
                {
                    feature.AppendExceptionMsg(exc);
                }

                this._features.Add(feature);
            }
        }
        /// <summary>Adds feature definitions to the custom Feature class</summary>
        /// <param name="spFeatureDefinitions"></param>
        public void AddFeatures(SPFeatureDefinitionCollection spFeatureDefinitions)
        {
            this._spfeatureDefinitions = spFeatureDefinitions;

            foreach (SPFeatureDefinition spfeatureDef in spFeatureDefinitions)
            {
                Feature feature = new Feature(spfeatureDef.Id);
                try
                {
                    feature.Scope = spfeatureDef.Scope;
                    feature.Name  = spfeatureDef.GetTitle(System.Threading.Thread.CurrentThread.CurrentCulture);
                }
                catch (Exception exc)
                {
                    feature.AppendExceptionMsg(exc);
                }

                this._features.Add(feature);
            }
        }
示例#3
0
 private static string GetFeatureNameOrId(Feature feature)
 {
     if (!string.IsNullOrEmpty(feature.Name))
     {
         return feature.Name;
     }
     else
     {
         return feature.Id.ToString();
     }
 }
示例#4
0
 private void ReviewActivationsOfFeature(Feature feature)
 {
     FeatureLocationSet set = new FeatureLocationSet();
     set[feature] = GetFeatureLocations(feature.Id);
     ReviewActivationsOfFeatures(set);
 }
示例#5
0
 private void gridFeatureDefinitions_MouseDown(object sender, MouseEventArgs e)
 {
     gridFeatureDefinitions.ContextMenuStrip = null;
     m_featureDefGridContextFeature = null;
 }
示例#6
0
 private void gridFeatureDefinitions_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
 {
     m_featureDefGridContextFeature = null;
     if (e.RowIndex < 0 || e.ColumnIndex < 0) { return; } // Ignore if out of data area
     if (e.Button == MouseButtons.Right)
     {
         // Find feature def on which user right-clicked
         DataGridView grid = sender as DataGridView;
         DataGridViewRow row = grid.Rows[e.RowIndex];
         m_featureDefGridContextFeature = row.DataBoundItem as Feature;
         if (GetIntValue(m_featureDefGridContextFeature.Activations, 0) == 0)
         {
             // no context menu if feature has no activations
             // because the context menu gets stuck up if the no activations
             // message box appears
             return;
         }
         if (m_featureDefGridContextFeature.Id == Guid.Empty)
         {
             // no context menu if no valid id
             return;
         }
         gridFeatureDefinitions.ContextMenuStrip = m_featureDefGridContextMenu;
         UpdateGridContextMenu();
     }
 }
 /// <summary>
 /// Flag all specified features as faulty
 /// (& add to our master definition list any that are missing)
 /// </summary>
 public void MarkFaulty(List<Guid> featureIds)
 {
     foreach (Guid featureId in featureIds)
     {
         Feature feature = null;
         if (_AllFeatureDefinitions.ContainsKey(featureId))
         {
             feature = _AllFeatureDefinitions[featureId];
         }
         else
         {
             feature = new Feature(featureId);
         }
         feature.IsFaulty = true;
         _AllFeatureDefinitions[featureId] = feature;
     }
 }
 /// <summary>
 /// Add record to our _FeaturesLocation
 /// </summary>
 private void AddToFeatureLocations(Feature feature, Location location)
 {
     if (!_FeatureLocations.ContainsKey(feature.Id))
     {
         _FeatureLocations.Add(feature.Id, new List<Location>());
     }
     List<Location> locations = _FeatureLocations[feature.Id];
     if (!locations.Contains(location))
     {
         locations.Add(location);
         UpdateFeatureLocationCount(feature.Id);
     }
 }
 /// <summary>
 /// Remove record from our _FeaturesLocation
 /// </summary>
 private void RemoveFromFeatureLocations(Feature feature, Location location)
 {
     if (_FeatureLocations.ContainsKey(feature.Id))
     {
         List<Location> locations = _FeatureLocations[feature.Id];
         if (locations.Contains(location))
         {
             locations.Remove(location);
         }
         UpdateFeatureLocationCount(feature.Id);
     }
 }
 private void LoadAllFeatureDefinitions()
 {
     foreach (SPFeatureDefinition spfeatureDef in SPFarm.Local.FeatureDefinitions)
     {
         Feature feature = new Feature(spfeatureDef.Id);
         try
         {
             // Id
             GetFeatureScopeFromDefinition(spfeatureDef, ref feature);
             GetFeatureCompatibilityFromDefinition(spfeatureDef, ref feature);
             GetFeatureNameFromDefinition(spfeatureDef, ref feature);
             // Faulty
             // ExceptionMessage
             // Activations
             // Locations
         }
         catch (Exception exc)
         {
             feature.AppendExceptionMsg(exc);
             feature.IsFaulty = true;
         }
         _AllFeatureDefinitions[feature.Id] = feature;
     }
 }
 /// <summary>
 /// Look up & return feature from our master definition list
 /// (Create a placeholder entry if we're lacking it)
 /// </summary>
 private Feature GetOrAddFeatureFromDefinitions(Guid featureId, SPFeatureScope scope)
 {
     Feature feature = null;
     if (!_AllFeatureDefinitions.ContainsKey(featureId))
     {
         // Not sure if this can happen (an undefined feature is activated)
         // but in case, manufacture an empty definition for it in our list
         feature = new Feature(featureId, scope);
         _AllFeatureDefinitions.Add(featureId, feature);
     }
     else
     {
         feature = _AllFeatureDefinitions[featureId];
     }
     return feature;
 }
 private void GetFeatureScopeFromDefinition(SPFeatureDefinition fdef, ref Feature feature)
 {
     try
     {
         feature.Scope = fdef.Scope;
     }
     catch (Exception exc)
     {
         feature.AppendExceptionMsg(exc);
         feature.IsFaulty = true;
     }
 }
 private void GetFeatureNameFromDefinition(SPFeatureDefinition fdef, ref Feature feature)
 {
     try
     {
         feature.Name = fdef.GetTitle(System.Threading.Thread.CurrentThread.CurrentCulture);
         return;
     }
     catch (Exception exc)
     {
         feature.AppendExceptionMsg(exc);
         feature.IsFaulty = true;
     }
     try
     {
         feature.Name = fdef.DisplayName;
         return;
     }
     catch (Exception exc)
     {
         feature.AppendExceptionMsg(exc);
         feature.IsFaulty = true;
     }
 }
 private void GetFeatureCompatibilityFromDefinition(SPFeatureDefinition fdef, ref Feature feature)
 {
     try
     {
         feature.CompatibilityLevel = FeatureManager.GetFeatureCompatibilityLevel(fdef);
     }
     catch (Exception exc)
     {
         feature.AppendExceptionMsg(exc);
         feature.IsFaulty = true;
     }
 }
 /// <summary>
 /// Add record to our _LocationFeatures
 /// </summary>
 private void AddToLocationFeatures(Location location, Feature feature)
 {
     string lkey = location.Key;
     if (!_LocationFeatures.ContainsKey(lkey))
     {
         _LocationFeatures.Add(lkey, new List<Feature>());
     }
     List<Feature> features = _LocationFeatures[lkey];
     if (!features.Contains(feature))
     {
         features.Add(feature);
     }
 }
示例#16
0
 private void ForceUninstallFeatureDefinition(Feature feature)
 {
 }
 private void PerformAction(object locobj, SPFeatureCollection spFeatureCollection, Feature feature)
 {
     try
     {
         if (_action == Action.Activating)
         {
             if (!(spFeatureCollection[feature.Id] is SPFeature))
             {
                 ++ActivationAttempts;
                 spFeatureCollection.Add(feature.Id);
                 if ((spFeatureCollection[feature.Id] is SPFeature))
                 {
                     _featureDb.RecordFeatureActivation(locobj, feature.Id);
                     ++Activations;
                 }
             }
         }
         else
         {
             if ((spFeatureCollection[feature.Id] is SPFeature))
             {
                 ++ActivationAttempts;
                 spFeatureCollection.Remove(feature.Id);
                 if (!(spFeatureCollection[feature.Id] is SPFeature))
                 {
                     _featureDb.RecordFeatureDeactivation(locobj, feature.Id);
                     ++Activations;
                 }
             }
         }
     }
     catch (Exception exc)
     {
         LogException(exc, string.Format(
             "{0} feature {1} on {2}: {3}",
             _action,
             feature.Id,
             feature.Scope,
             LocationManager.SafeDescribeObject(locobj)
             ));
     }
 }
 /// <summary>
 /// Remove record from our _LocationFeatures
 /// </summary>
 private void RemoveFromLocationFeatures(Location location, Feature feature)
 {
     string lkey = location.Key;
     if (_LocationFeatures.ContainsKey(lkey))
     {
         List<Feature> features = _LocationFeatures[lkey];
         if (features.Contains(feature))
         {
             features.Remove(feature);
         }
     }
 }
 public List<Location> GetLocationsOfFeature(Feature feature)
 {
     return GetLocationsOfFeature(feature.Id);
 }
示例#20
0
 public List <Location> GetLocationsOfFeature(Feature feature)
 {
     return(GetLocationsOfFeature(feature.Id));
 }