private WebPartEntity CreateYammerWebPart(string feedType, YammerUser user, string yammerGroupName, string title) { YammerGroup group; string groupId; // 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. group = YammerUtility.CreateYammerGroup(yammerGroupName, false, ConfigurationManager.AppSettings["YammerAccessToken"]); // Get Yammer web part return(YammerUtility.GetYammerGroupDiscussionPart(user.network_name, group.id, false, false)); } else { if (!string.IsNullOrEmpty(YammerExistingGroups.SelectedValue)) { group = YammerUtility.GetYammerGroupByName(YammerExistingGroups.SelectedValue, ConfigurationManager.AppSettings["YammerAccessToken"]); groupId = group.id.ToString(); } else { groupId = ""; } // Get OpenGrap object for using that as the discussion feed return(YammerUtility.GetYammerOpenGraphDiscussionPart(user.network_name, Request["SPHostUrl"] + "/" + txtUrl.Text, false, false, "SharePoint Site Feed - " + title, "", groupId)); } }
/// <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.CreateSite(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); }