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


C# SPWebApplication类代码示例

本文整理汇总了C#中SPWebApplication的典型用法代码示例。如果您正苦于以下问题:C# SPWebApplication类的具体用法?C# SPWebApplication怎么用?C# SPWebApplication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SPWebApplication类属于命名空间,在下文中一共展示了SPWebApplication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCurrentContentDatabase

        protected SPContentDatabase GetCurrentContentDatabase(SPWebApplication webApp, ContentDatabaseDefinition definition)
        {
            var dbName = definition.DbName.ToUpper();

            return webApp.ContentDatabases.OfType<SPContentDatabase>()
                                          .FirstOrDefault(d => !string.IsNullOrEmpty(d.Name) && d.Name.ToUpper() == dbName);
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:7,代码来源:ContentDatabaseModelHandler.cs

示例2: FlushBlobCache

        /// <summary>
        /// Flushes the BLOB cache for the specified Web Application.
        /// WARNING: This method needs to be run as Farm Admin and have security_admin SQL server role and the db_owner role
        /// on the web app's content DB in order to successfully flush the web app's BLOB cache.
        /// </summary>
        /// <param name="webApplication">The SharePoint web application.</param>
        public void FlushBlobCache(SPWebApplication webApplication)
        {
            try
            {
                PublishingCache.FlushBlobCache(webApplication);
            }
            catch (SPException exception)
            {
                this.logger.Error("Failed to flush the BLOB cache accross the web app. You need You need security_admin SQL server role and the db_owner role on the web app's content DB. Caught and swallowed exception: {0}", exception);
            }
            catch (AccessViolationException exception)
            {
                this.logger.Warn("Received an AccessViolationException when flushing BLOB Cache. Trying again with RemoteAdministratorAccessDenied set to true. Caught and swallowed exception: {0}", exception);

                bool initialRemoteAdministratorAccessDenied = true;
                SPWebService myService = SPWebService.ContentService;

                try
                {
                    initialRemoteAdministratorAccessDenied = myService.RemoteAdministratorAccessDenied;
                    myService.RemoteAdministratorAccessDenied = false;
                    myService.Update();

                    PublishingCache.FlushBlobCache(webApplication);
                }
                finally
                {
                    myService.RemoteAdministratorAccessDenied = initialRemoteAdministratorAccessDenied;
                    myService.Update();
                }
            }
        }
开发者ID:andresglx,项目名称:Dynamite,代码行数:38,代码来源:BlobCacheHelper.cs

示例3: 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

示例4: ForceRemoveConfigModifications

        // We make absolutely sure no mods with this owner exist
        public void ForceRemoveConfigModifications(SPWebApplication WebApp, string Owner)
        {
            List<SPWebConfigModification> removeMods = new List<SPWebConfigModification>();
            foreach (var mod in WebApp.WebConfigModifications)
            {
                if (mod.Owner == Owner)
                {
                    removeMods.Add(mod);
                }
            }

            foreach (var mod in removeMods)
            {
                string message = string.Format("Removing additional owner based mod: {0}", mod.Path);
                _log.Write(_id, SPTraceLogger.TraceSeverity.InformationEvent, "WebConfigModificationHandler", "Info", message);

                if (mod.Type != SPWebConfigModification.SPWebConfigModificationType.EnsureSection ||
                    (mod.Type == SPWebConfigModification.SPWebConfigModificationType.EnsureSection && !mod.Path.ToLower().Contains("system")))
                    WebApp.WebConfigModifications.Remove(mod);
                else
                {
                    string message2 = string.Format("Mod: {0} Type: {1} was not removed", mod.Path, mod.Type.ToString());
                    _log.Write(_id, SPTraceLogger.TraceSeverity.InformationEvent, "WebConfigModificationHandler", "Info", message2);
                }
            }

            _log.Write(_id, SPTraceLogger.TraceSeverity.InformationEvent, "WebConfigModificationHandler", "Info", "Mods deleted, updating");
            SPWebService.ContentService.WebApplications[WebApp.Id].Update();
            _log.Write(_id, SPTraceLogger.TraceSeverity.InformationEvent, "WebConfigModificationHandler", "Info", "Mods deleted, applying update");
            SPWebService.ContentService.WebApplications[WebApp.Id].WebService.ApplyWebConfigModifications();
        }
开发者ID:powareverb,项目名称:SPExpressionBuilder,代码行数:32,代码来源:WebConfigModificationHandler.cs

示例5: GetUrls

 internal static void GetUrls(List<string> urls, SPWebApplication webApp)
 {
     foreach (SPAlternateUrl url in webApp.AlternateUrls)
     {
         GetUrls(urls, url);
     }
 }
开发者ID:GSoft-SharePoint,项目名称:PowerShell-SPCmdlets,代码行数:7,代码来源:SetBackConnectionHostNames.cs

示例6: AddAndCleanWebConfigModification

        /// <summary>
        /// Method to add one or multiple WebConfig modifications
        /// NOTE: There should not have 2 modifications with the same Owner.
        /// </summary>
        /// <param name="webApp">The current Web Application</param>
        /// <param name="webConfigModificationCollection">The collection of WebConfig modifications to remove-and-add</param>
        /// <remarks>All SPWebConfigModification Owner should be UNIQUE !</remarks>
        public void AddAndCleanWebConfigModification(SPWebApplication webApp, Collection<SPWebConfigModification> webConfigModificationCollection)
        {
            // Verify emptyness
            if (webConfigModificationCollection == null || !webConfigModificationCollection.Any())
            {
                throw new ArgumentNullException("webConfigModificationCollection");
            }

            SPWebApplication webApplication = SPWebService.ContentService.WebApplications[webApp.Id];

            // Start by cleaning up any existing modification for all owners
            // By Good practice, owners should be unique, so we do this to remove duplicates entries if any.
            var owners = webConfigModificationCollection.Select(modif => modif.Owner).Distinct().ToList();
            this.RemoveExistingModificationsFromOwner(webApplication, owners);

            // Add WebConfig modifications
            foreach (var webConfigModification in webConfigModificationCollection)
            {
                webApplication.WebConfigModifications.Add(webConfigModification);
            }

            // Commit modification additions to the specified web application
            webApplication.Update();

            // Push modifications through the farm
            webApplication.WebService.ApplyWebConfigModifications();

            // Wait for timer job
            WaitForWebConfigPropagation(webApplication.Farm);
        }
开发者ID:NunoEdgarGub1,项目名称:Dynamite,代码行数:37,代码来源:WebConfigModificationHelper.cs

示例7: RemoveExistingModificationsFromOwner

        public void RemoveExistingModificationsFromOwner(SPWebApplication webApplication, IList<string> owners)
        {
            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 (owners.Contains(modification.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();
            }

            // Wait for timer job
            WaitForWebConfigPropagation(webApplication.Farm);
        }
开发者ID:NunoEdgarGub1,项目名称:Dynamite,代码行数:34,代码来源:WebConfigModificationHelper.cs

示例8: RemoveConfigModifications

        public virtual void RemoveConfigModifications(SPWebApplication WebApp, string Owner)
        {
            if (WebApp == null)
                throw new ArgumentException("WebApp is null, perhaps your feature is not scoped at WebApp level?", "WebApp");
            if (string.IsNullOrEmpty(Owner))
                throw new ArgumentException("Owner is null", "Owner");

            foreach (var mod in _modifications)
            {
                string message = string.Format("Removing Mod: {0}", mod.Path);
                _log.Write(_id, SPTraceLogger.TraceSeverity.InformationEvent, "WebConfigModificationHandler", "Info", message);

                WebApp.WebConfigModifications.Remove(mod);
            }

            //WebApp.Update();
            //WebApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();

            _log.Write(_id, SPTraceLogger.TraceSeverity.InformationEvent, "WebConfigModificationHandler", "Info", "Mods deleted, updating");
            SPWebService.ContentService.WebApplications[WebApp.Id].Update();
            _log.Write(_id, SPTraceLogger.TraceSeverity.InformationEvent, "WebConfigModificationHandler", "Info", "Mods deleted, applying update");
            SPWebService.ContentService.WebApplications[WebApp.Id].WebService.ApplyWebConfigModifications();

            ForceRemoveConfigModifications(WebApp, Owner);
        }
开发者ID:powareverb,项目名称:SPExpressionBuilder,代码行数:25,代码来源:WebConfigModificationHandler.cs

示例9: 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

示例10: DeleteJob

 private static void DeleteJob(SPWebApplication application, string jobName)
 {
     var job = application.JobDefinitions.SingleOrDefault(c => jobName == c.Name);
     if (job != null)
     {
         job.Delete();
     }
 }
开发者ID:ivankozyrev,项目名称:fls-internal-portal,代码行数:8,代码来源:Feature1.EventReceiver.cs

示例11: AddAndCleanWebConfigModification

        /// <summary>
        /// Method to add one or multiple WebConfig modifications
        /// NOTE: There should not have 2 modifications with the same Owner.
        /// </summary>
        /// <param name="web">The current Web Application</param>
        /// <param name="webConfigModificationCollection">The collection of WebConfig modifications to remove-and-add</param>
        /// <remarks>All SPWebConfigModification Owner should be UNIQUE !</remarks>
        public void AddAndCleanWebConfigModification(SPWebApplication webApp, Collection<SPWebConfigModification> webConfigModificationCollection)
        {
            // Verify emptyness
            if (webConfigModificationCollection == null || !webConfigModificationCollection.Any())
            {
                throw new ArgumentNullException("webConfigModificationCollection");
            }

            SPWebApplication webApplication = SPWebService.ContentService.WebApplications[webApp.Id];

            // Start by cleaning up any existing modification for all owners
            foreach (var owner in webConfigModificationCollection.Select(modif => modif.Owner).Distinct())
            {
                // Remove all modification by the same owner.
                // By Good practice, owner should be unique, so we do this to remove duplicates entries if any.
                this.RemoveExistingModificationsFromOwner(webApplication, owner);
            }

            if (webApplication.Farm.TimerService.Instances.Count > 1)
            {
                // HACK:
                //
                // When there are multiple front-end Web servers in the
                // SharePoint farm, we need to wait for the timer job that
                // performs the Web.config modifications to complete before
                // continuing. Otherwise, we may encounter the following error
                // (e.g. when applying Web.config changes from two different
                // features in rapid succession):
                //
                // "A web configuration modification operation is already
                // running."
                WaitForOnetimeJobToFinish(
                   webApplication.Farm,
                   "Microsoft SharePoint Foundation Web.Config Update",
                   120);
            }

            // Add WebConfig modifications
            foreach (var webConfigModification in webConfigModificationCollection)
            {
                webApplication.WebConfigModifications.Add(webConfigModification);
            }

            // Commit modification additions to the specified web application
            webApplication.Update();

            // Push modifications through the farm
            webApplication.WebService.ApplyWebConfigModifications();

            if (webApplication.Farm.TimerService.Instances.Count > 1)
            {
                WaitForOnetimeJobToFinish(
                   webApplication.Farm,
                   "Microsoft SharePoint Foundation Web.Config Update",
                   120);
            }
        }
开发者ID:GAlexandreBastien,项目名称:Dynamite-2010,代码行数:64,代码来源:WebConfigModificationHelper.cs

示例12: IisSettingNode

 public IisSettingNode(SPWebApplication app, KeyValuePair<SPUrlZone, SPIisSettings> iisSettings)
 {
     this.Tag = iisSettings.Value;
     this.Name = iisSettings.Key.ToString();
     this.Text = iisSettings.Key.ToString();
     this.ToolTipText = iisSettings.Key.ToString();
     this.BrowserUrl = app.GetResponseUri(iisSettings.Key).ToString();
     this.Setup();
 }
开发者ID:lucaslra,项目名称:SPM,代码行数:9,代码来源:IisSettingNode.cs

示例13: GetCurrentAlternateUrl

        protected SPAlternateUrl GetCurrentAlternateUrl(SPWebApplication webApp, AlternateUrlDefinition definition)
        {
            var alternateUrls = webApp.AlternateUrls;

            var url = definition.Url;
            var urlZone = (SPUrlZone)Enum.Parse(typeof(SPUrlZone), definition.UrlZone);

            return alternateUrls.GetResponseUrl(urlZone);
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:9,代码来源:AlternateUrlModelHandler.cs

示例14: FeatureCollectionNode

 public FeatureCollectionNode(SPWebApplication webApp)
     : this()
 {
     this.Text = SPMLocalization.GetString("SiteFeatures_Text");
     this.ToolTipText = SPMLocalization.GetString("SiteFeatures_ToolTip");
     this.Name = "SiteFeatures";
     this.Tag = webApp.Features;
     this.SPParent = webApp;
 }
开发者ID:lucaslra,项目名称:SPM,代码行数:9,代码来源:FeatureCollectionNode.cs

示例15: RemoveJobIfRegistered

 private void RemoveJobIfRegistered(SPWebApplication app)
 {
     foreach (SPJobDefinition job in app.JobDefinitions)
     {
         if (job.Title == JobName)
         {
             job.Delete();
         }
     }
 }
开发者ID:JeanNguon,项目名称:Projet,代码行数:10,代码来源:DeployClientAccessPolicy.EventReceiver.cs


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