本文整理汇总了C#中SPWebApplication.Update方法的典型用法代码示例。如果您正苦于以下问题:C# SPWebApplication.Update方法的具体用法?C# SPWebApplication.Update怎么用?C# SPWebApplication.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPWebApplication
的用法示例。
在下文中一共展示了SPWebApplication.Update方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeployPeoplePickerSettings
private void DeployPeoplePickerSettings(object modelHost, SPWebApplication webApplication, PeoplePickerSettingsDefinition definition)
{
var settings = GetCurrentPeoplePickerSettings(webApplication);
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioning,
Object = settings,
ObjectType = typeof(SPPeoplePickerSettings),
ObjectDefinition = definition,
ModelHost = modelHost
});
MapPeoplePickerSettings(settings, definition);
// reSP doesn't like updating SPWebApplication here, don't see an other way though
webApplication.Update();
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioned,
Object = settings,
ObjectType = typeof(SPPeoplePickerSettings),
ObjectDefinition = definition,
ModelHost = modelHost
});
}
示例2: Install
public static void Install(SPWebApplication webApp)
{
foreach (var entry in AutofacConfigEntries)
{
webApp.WebConfigModifications.Add(entry.Prepare());
}
// set flag specifying, that DI of autofac is enabled on that site
webApp.Properties[Constants.AUTOFAC_DI_ENABLED] = true;
webApp.Update();
}
示例3: UnExtend
/// <summary>
/// Uns the extend.
/// </summary>
/// <param name="webApp">The web app.</param>
/// <param name="zone">The zone.</param>
/// <param name="deleteIis">if set to <c>true</c> [delete IIS].</param>
public static void UnExtend(SPWebApplication webApp, SPUrlZone zone, bool deleteIis)
{
webApp.UnprovisionGlobally(deleteIis);
webApp.IisSettings.Remove(zone);
if (zone != SPUrlZone.Default)
{
webApp.AlternateUrls.UnsetResponseUrl(zone);
webApp.AlternateUrls.Update();
}
webApp.Update();
}
示例4: AddWebConfigNode
/// <summary>
/// Adds the key/value pair as an appSettings entry in the web application's
/// SPWebConfigModification collection
/// </summary>
/// <param name="webApp">Current web application context</param>
/// <param name="key">appSettings node key</param>
/// <param name="value">appSettings node value</param>
public void AddWebConfigNode(SPWebApplication webApp, string webConfigModxPath, XmlNode node, XmlAttributeCollection attributes)
{
SPWebConfigModification webConfigMod;
string webConfigModName;
webConfigModName = GetWebConfigModName(node.Name, attributes);
webConfigMod = new SPWebConfigModification(webConfigModName, webConfigModxPath);
webConfigMod.Owner = this.Owner;
webConfigMod.Sequence = 0;
webConfigMod.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
webConfigMod.Value = node.OuterXml;
webApp.WebConfigModifications.Add(webConfigMod);
webApp.Update();
}
示例5: Uninstall
public static void Uninstall(SPWebApplication webApp)
{
var modsCollection = webApp.WebConfigModifications;
for (var i = modsCollection.Count - 1; i > -1; i--)
{
if (modsCollection[i].Owner == ConfigModsOwnerName)
{
// Remove it and save the change to the configuration database
modsCollection.Remove(modsCollection[i]);
}
}
// remove flag
if (webApp.Properties.ContainsKey(Constants.AUTOFAC_DI_ENABLED))
webApp.Properties.Remove(Constants.AUTOFAC_DI_ENABLED);
webApp.Update();
}
示例6: AddUserPolicy
internal static void AddUserPolicy(string login, string username, string[] permissions, SPWebApplication webApp, SPPolicyCollection policies)
{
login = Utilities.TryGetNT4StyleAccountName(login, webApp);
List<SPPolicyRole> roles = new List<SPPolicyRole>();
foreach (string roleName in permissions)
{
SPPolicyRole role = webApp.PolicyRoles[roleName.Trim()];
if (role == null)
throw new SPException(string.Format("The policy permission '{0}' was not found.", roleName.Trim()));
roles.Add(role);
}
SPPolicy policy = policies.Add(login, username);
foreach (SPPolicyRole role in roles)
policy.PolicyRoleBindings.Add(role);
webApp.Update();
}
示例7: DeployDefinition
private void DeployDefinition(WebApplicationModelHost modelHost, SPWebApplication webApp, WebConfigModificationDefinition definition)
{
var existingWebConfig = GetCurrentSPWebConfigModification(webApp, definition);
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioning,
Object = existingWebConfig,
ObjectType = typeof(SPWebConfigModification),
ObjectDefinition = definition,
ModelHost = modelHost
});
if (existingWebConfig != null)
webApp.WebConfigModifications.Remove(existingWebConfig);
existingWebConfig = new SPWebConfigModification();
MapConfig(existingWebConfig, definition);
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioned,
Object = existingWebConfig,
ObjectType = typeof(SPWebConfigModification),
ObjectDefinition = definition,
ModelHost = modelHost
});
webApp.WebConfigModifications.Add(existingWebConfig);
webApp.Update();
//webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
webApp.WebService.ApplyWebConfigModifications();
}
示例8: RemoveExistingModificationsFromOwner
public void RemoveExistingModificationsFromOwner(SPWebApplication webApplication, IList<string> ownersOfModificationsToRemove)
{
if (webApplication == null)
{
throw new ArgumentNullException("webApplication");
}
var indicesOfNullWebConfigModifications = new List<int>();
var modificationsToRemove = new Collection<SPWebConfigModification>();
var modificationCollection = webApplication.WebConfigModifications;
if (modificationCollection == null)
{
this.logger.Warn(
"WebConfigModificationHelper: Attempted to remove web.config modification from web app with ID {0} but no existing modification exists.",
webApplication.Id);
}
else
{
int currentIndex = 0;
foreach (SPWebConfigModification modification in modificationCollection)
{
if (modification != null)
{
if (!string.IsNullOrEmpty(modification.Owner))
{
if (ownersOfModificationsToRemove.Contains(modification.Owner))
{
// collect modifications to delete
modificationsToRemove.Add(modification);
}
}
else
{
this.logger.Warn(
"WebConfigModificationHelper: owner for existing modification {0} is empty. Cannot attempt removal.",
modification.Name);
}
}
else
{
indicesOfNullWebConfigModifications.Add(currentIndex);
this.logger.Warn(
"WebConfigModificationHelper: web application with ID {0} has a NULL modification.",
webApplication.Id);
}
currentIndex++;
}
// Now delete the modifications from the web application (and also clean up NULL values from web app's WebConfigModifications collection)
if (modificationsToRemove.Count > 0 || indicesOfNullWebConfigModifications.Count > 0)
{
var webAppConfigModifications = webApplication.WebConfigModifications;
if (indicesOfNullWebConfigModifications.Count > 0)
{
// WEIRD EDGE CASE: we detected NULL items in the web app's WebConfigModifications collection.
// Let's clean those up before moving on (otherwise further additions to the collection might fail
// to propagate correctly).
this.logger.Warn(
"WebConfigModificationHelper: web application with ID {0} has at least one NULL modification in its WebConfigModification collection. "
+ "Attempting to delete those NULL entries now because they might interfere with new additions to WebConfigModifications.",
webApplication.Id);
foreach (int indexOfNullWebConfigModification in indicesOfNullWebConfigModifications)
{
webAppConfigModifications.RemoveAt(indexOfNullWebConfigModification);
}
}
// Remove the Owner's web config modification we want to clean up
foreach (SPWebConfigModification modificationItem in modificationsToRemove)
{
webAppConfigModifications.Remove(modificationItem);
}
// Commit modification removals to the specified web application
webApplication.Update();
if (webApplication.WebService == null)
{
throw new InvalidOperationException("Parent WebService of webApplication is unexpectedly NULL. Cannot attempt to ApplyWebConfigModifications.");
}
if (webApplication.Farm == null)
{
throw new InvalidOperationException("Parent Farm of webApplication is unexpectedly NULL. Cannot attempt to ApplyWebConfigModifications.");
}
// Push modifications through the farm
webApplication.WebService.ApplyWebConfigModifications();
// Wait for timer job
try
{
WaitForWebConfigPropagation(webApplication.Farm);
}
catch (Exception exception)
{
//.........这里部分代码省略.........
示例9: RemoveExistingModificationsFromOwner
public void RemoveExistingModificationsFromOwner(SPWebApplication webApplication, string owner)
{
var removeCollection = new Collection<SPWebConfigModification>();
var modificationCollection = webApplication.WebConfigModifications;
int count = modificationCollection.Count;
for (int i = 0; i < count; i++)
{
SPWebConfigModification modification = modificationCollection[i];
if (modification.Owner == owner)
{
// collect modifications to delete
removeCollection.Add(modification);
}
}
// now delete the modifications from the web application
if (removeCollection.Count > 0)
{
foreach (SPWebConfigModification modificationItem in removeCollection)
{
webApplication.WebConfigModifications.Remove(modificationItem);
}
// Commit modification removals to the specified web application
webApplication.Update();
// Push modifications through the farm
webApplication.WebService.ApplyWebConfigModifications();
}
}
示例10: RemoveWebConfigEntries
protected void RemoveWebConfigEntries(SPWebApplication oWebApp, string owner)
{
Collection<SPWebConfigModification> webConfigModifications = oWebApp.WebConfigModifications;
int num = webConfigModifications.Count;
for (int i = num - 1; i >= 0; i--)
{
SPWebConfigModification modification = webConfigModifications[i];
if (modification.Owner == owner)
{
webConfigModifications.Remove(modification);
}
}
if (num > webConfigModifications.Count)
{
oWebApp.Update();
SPFarm.Local.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
}
}
示例11: ExtendWebApp
/// <summary>
/// Extends the web app.
/// </summary>
/// <param name="webApplication">The web application.</param>
/// <param name="description">The description.</param>
/// <param name="hostHeader">The host header.</param>
/// <param name="port">The port.</param>
/// <param name="loadBalancedUrl">The load balanced URL.</param>
/// <param name="path">The path.</param>
/// <param name="allowAnonymous">if set to <c>true</c> [allow anonymous].</param>
/// <param name="useNtlm">if set to <c>true</c> [use NTLM].</param>
/// <param name="useSsl">if set to <c>true</c> [use SSL].</param>
/// <param name="zone">The zone.</param>
public static void ExtendWebApp(SPWebApplication webApplication, string description, string hostHeader, int port, string loadBalancedUrl, string path, bool allowAnonymous, bool useNtlm, bool useSsl, SPUrlZone zone)
{
SPServerBinding serverBinding = null;
SPSecureBinding secureBinding = null;
if (!useSsl)
{
serverBinding = new SPServerBinding();
serverBinding.Port = port;
serverBinding.HostHeader = hostHeader;
}
else
{
secureBinding = new SPSecureBinding();
secureBinding.Port = port;
}
SPIisSettings settings = new SPIisSettings(description, allowAnonymous, useNtlm, serverBinding, secureBinding, new DirectoryInfo(path.Trim()));
settings.PreferredInstanceId = GetPreferredInstanceId(description);
webApplication.IisSettings.Add(zone, settings);
webApplication.AlternateUrls.SetResponseUrl(new SPAlternateUrl(new Uri(loadBalancedUrl), zone));
webApplication.AlternateUrls.Update();
webApplication.Update();
webApplication.ProvisionGlobally();
}
示例12: ModifyWebConfig
private static void ModifyWebConfig(SPWebApplication webApp, string name, string path, string value, SPWebConfigModification.SPWebConfigModificationType type)
{
if (AlreadyExists(webApp, name))
{
return;
}
var modification = new SPWebConfigModification(name, path)
{
Value = value,
Sequence = 0,
Type = type,
Owner = SPWebConfigModificationOwner
};
try
{
webApp.WebConfigModifications.Add(modification);
webApp.Update();
}
catch (Exception ex)
{
Log.Error(ex);
throw;
}
}
示例13: RemoveAllModifications
private static void RemoveAllModifications(SPWebApplication application)
{
var modificationsToRemove = application.WebConfigModifications
.Where(modification => modification.Owner == SPWebConfigModificationOwner)
.ToList();
foreach (var modification in modificationsToRemove)
{
application.WebConfigModifications.Remove(modification);
application.Update();
}
}