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


C# Web.CreateWeb方法代码示例

本文整理汇总了C#中Web.CreateWeb方法的典型用法代码示例。如果您正苦于以下问题:C# Web.CreateWeb方法的具体用法?C# Web.CreateWeb怎么用?C# Web.CreateWeb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Web的用法示例。


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

示例1: CreateSubSite

        /// <summary>
        /// Actual sub site creation and modification logic. Calls Core component methods to make things work
        /// </summary>
        /// <param name="hostWeb"></param>
        /// <param name="url"></param>
        /// <param name="template"></param>
        /// <param name="title"></param>
        /// <param name="description"></param>
        /// <param name="feedType"></param>
        /// <param name="yammerGroupName"></param>
        /// <returns></returns>
        public void CreateSubSite(Web hostWeb, string url, string template,
                                    string title, string description, string feedType, string yammerGroupName)
        {
            // Create new sub site
            Web newWeb = hostWeb.CreateWeb(title, url, description, template, 1033);

            // Set theme for the site
            newWeb.SetThemeToSubWeb(hostWeb, "Orange");

            //Remove the out of the box "NewsFeed" web part
            newWeb.DeleteWebPart("SitePages", "Site feed", "home.aspx");

            // Let's first get the details on the Yammer network using the access token
            WebPartEntity wpYammer;
            YammerUser user = YammerUtility.GetYammerUser(ConfigurationManager.AppSettings["YammerAccessToken"]);

            // Notice that in general we do not recommend of matching Yammer group for each site to avoid "group pollution" in Yammer
            if (feedType == "Group")
            {
                // Get Yammer Group - Creates if does not exist. Let's create these as public by default.
                YammerGroup group =
                    YammerUtility.CreateYammerGroup(yammerGroupName, false, ConfigurationManager.AppSettings["YammerAccessToken"]);
                // Get Yammer web part
                wpYammer = YammerUtility.GetYammerGroupDiscussionPart(user.network_name, group.id, false, false);
            }
            else
            {
                // Get OpenGrap object for using that as the discussion feed
                wpYammer = YammerUtility.GetYammerOpenGraphDiscussionPart(user.network_name, Request["SPHostUrl"] + "/" + txtUrl.Text,
                                                                            false, false, "SharePoint Site Feed - " + title);
            }
            // Add Yammer web part to the page
            newWeb.AddWebPartToWikiPage("SitePages", wpYammer, "home.aspx", 2, 1, false);
        }
开发者ID:ADefWebserver,项目名称:PnP,代码行数:45,代码来源:Default.aspx.cs

示例2: CreateSubSite

        /// <summary>
        /// Actual sub site creation and modification logic. Calls Core component methods to make things work
        /// </summary>
        /// <param name="hostWeb"></param>
        /// <param name="url"></param>
        /// <param name="template"></param>
        /// <param name="title"></param>
        /// <param name="description"></param>
        /// <param name="feedType"></param>
        /// <param name="yammerGroupName"></param>
        /// <returns></returns>
        public void CreateSubSite(Web hostWeb, string url, string template,
                                    string title, string description, string feedType, string yammerGroupName)
        {
            // Create new sub site
            Web newWeb = hostWeb.CreateWeb(title, url, description, template, 1033);

            //Remove the out of the box "NewsFeed" web part
            newWeb.DeleteWebPart("SitePages", "Site feed", "home.aspx");

            // Let's first get the details on the Yammer network using the access token
            WebPartEntity wpYammer;
            YammerUser user = YammerUtility.GetYammerUser(ConfigurationManager.AppSettings["YammerAccessToken"]);

            // Created Yammer web part with needed configuration
            wpYammer = CreateYammerWebPart(feedType, user, yammerGroupName, title);

            // Add Yammer web part to the page
            newWeb.AddWebPartToWikiPage("SitePages", wpYammer, "home.aspx", 2, 1, false);

            // Add theme to the site and apply that
            ApplyThemeToSite(hostWeb, newWeb);
        }
开发者ID:AaronSaikovski,项目名称:PnP,代码行数:33,代码来源:Default.aspx.cs


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