• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SPWebApplication类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: RemoveTimerJobs

 private void RemoveTimerJobs(SPWebApplication webApp)
 {
     foreach (SPJobDefinition job in webApp.JobDefinitions)
     {
         if (job.Name == GlymaExportWorkItemTimerJob.JobName)
         {
             job.Delete();
         }
     }
 }
开发者ID:chris-tomich,项目名称:Glyma,代码行数:10,代码来源:GlymaExportTimerJobInstaller.EventReceiver.cs


示例17: WebApplicationNode

        public WebApplicationNode(SPWebService service, SPWebApplication app)
        {
            this.SPParent = service;
            this.Tag = app;
            this.DefaultExpand = true;

            this.Setup();

            this.Nodes.Add(new ExplorerNodeBase("Dummy"));
        }
开发者ID:lucaslra,项目名称:SPM,代码行数:10,代码来源:WebApplicationNode.cs


示例18: SafeGetWebAppTitle

 public static string SafeGetWebAppTitle(SPWebApplication webApp)
 {
     try
     {
         return webApp.Name;
     }
     catch
     {
         return null;
     }
 }
开发者ID:SharePointPog,项目名称:FeatureAdmin,代码行数:11,代码来源:LocationInfo.cs


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


示例20: SafeGetWebAppUrl

 public static string SafeGetWebAppUrl(SPWebApplication webApp)
 {
     try
     {
         return GetWebAppUrl(webApp);
     }
     catch
     {
         return null;
     }
 }
开发者ID:SharePointPog,项目名称:FeatureAdmin,代码行数:11,代码来源:LocationInfo.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SP_DEVICE_INTERFACE_DATA类代码示例发布时间:2022-05-24
下一篇:
C# SPWeb类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap