当前位置: 首页>>代码示例>>C#>>正文


C# SPWebApplication.Update方法代码示例

本文整理汇总了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
            });
        }
开发者ID:avishnyakov,项目名称:spmeta2,代码行数:31,代码来源:PeoplePickerSettingsModelHandler.cs

示例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();
        }
开发者ID:powareverb,项目名称:Autofac.Integration.SharePoint,代码行数:11,代码来源:AutofacIntegrationInstaller.cs

示例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();
        }
开发者ID:GSoft-SharePoint,项目名称:PowerShell-SPCmdlets,代码行数:18,代码来源:UnExtendWebApp.cs

示例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();
        }
开发者ID:infinitimods,项目名称:clif-sharepoint,代码行数:22,代码来源:WebConfigModifications.cs

示例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();
        }
开发者ID:powareverb,项目名称:Autofac.Integration.SharePoint,代码行数:19,代码来源:AutofacIntegrationInstaller.cs

示例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();
        }
开发者ID:GSoft-SharePoint,项目名称:PowerShell-SPCmdlets,代码行数:20,代码来源:AddUserPolicyForWebApp.cs

示例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();
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:39,代码来源:WebConfigModificationModelHandler.cs

示例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)
                    {
//.........这里部分代码省略.........
开发者ID:andresglx,项目名称:Dynamite,代码行数:101,代码来源:WebConfigModificationHelper.cs

示例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();
            }
        }
开发者ID:GAlexandreBastien,项目名称:Dynamite-2010,代码行数:31,代码来源:WebConfigModificationHelper.cs

示例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();
     }
 }
开发者ID:chutinhha,项目名称:aiaintranet,代码行数:18,代码来源:AIA.Intranet.UpdateWebConfig.EventReceiver.cs

示例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();
        }
开发者ID:GSoft-SharePoint,项目名称:PowerShell-SPCmdlets,代码行数:38,代码来源:ExtendWebApplication.cs

示例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;
            }
        }
开发者ID:ivankozyrev,项目名称:fls-internal-portal,代码行数:26,代码来源:MvcFeature.EventReceiver.cs

示例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();
            }
        }
开发者ID:ivankozyrev,项目名称:fls-internal-portal,代码行数:12,代码来源:MvcFeature.EventReceiver.cs


注:本文中的SPWebApplication.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。