本文整理汇总了C#中SPWeb.ApplyTheme方法的典型用法代码示例。如果您正苦于以下问题:C# SPWeb.ApplyTheme方法的具体用法?C# SPWeb.ApplyTheme怎么用?C# SPWeb.ApplyTheme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPWeb
的用法示例。
在下文中一共展示了SPWeb.ApplyTheme方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUpDocumentWorkspace
private void SetUpDocumentWorkspace(SPItemEventProperties eventProperties, SPSite rootWeb, SPWeb documentWorkspace)
{
//Make sure it inherits the theme from the rootWeb
string currentTheme = rootWeb.RootWeb.Theme;
documentWorkspace.ApplyTheme(currentTheme);
string docSetName = "Agenda Workspace DS-6";
string defaultDocumentsLibraryName = null;
string libraryNameInDocumentWorkspace = null;
string boardSiteURL = null;
string boardMeetingListName = null;
string lookAheadListName = null;
string lookAheadListNameInEmis = null;
SPContentType newDocumentSetContentType = null;
//SPFolder defaultDocuments =rootWeb.RootWeb.Folders["Default Documents"];
SPWebApplication webApplication = eventProperties.Web.Site.WebApplication;
if (webApplication.Properties != null && webApplication.Properties.Count > 0)
{
if (webApplication.Properties.ContainsKey("DefaultDocumentsLibrary"))
{
defaultDocumentsLibraryName = webApplication.Properties["DefaultDocumentsLibrary"].ToString();
libraryNameInDocumentWorkspace = webApplication.Properties["LibraryNameInDocumentWorkspace"].ToString();
boardSiteURL = webApplication.Properties["BoardSiteURL"].ToString();
boardMeetingListName = webApplication.Properties["BoardMeetingListName"].ToString();
lookAheadListName = webApplication.Properties["LookAheadListName"].ToString();
lookAheadListNameInEmis = webApplication.Properties["LookAheadListNameInEmis"].ToString();
}
}
DocumentSetTemplate newDocumentSetTemplate = null;
SPField fld = rootWeb.RootWeb.Fields[new Guid()];
if (eventProperties.ListItem["AgendaType"].ToString() == "Procurement Resolution")
{
docSetName = DocSetNames.ProcurementResolution;
if (rootWeb.RootWeb.ContentTypes[docSetName] == null)
{
// create the new document set content Type
newDocumentSetContentType = rootWeb.RootWeb.ContentTypes.Add(new SPContentType(rootWeb.RootWeb.ContentTypes["Document Set"], rootWeb.RootWeb.ContentTypes, docSetName));
// get a document set template for the new document set
newDocumentSetTemplate = DocumentSetTemplate.GetDocumentSetTemplate(newDocumentSetContentType);
//add allowable content types
newDocumentSetTemplate.AllowedContentTypes.Add(rootWeb.RootWeb.ContentTypes["AgendaDocument"].Id);
newDocumentSetTemplate.AllowedContentTypes.Add(rootWeb.RootWeb.ContentTypes["Procurement Resolution"].Id);
newDocumentSetTemplate.AllowedContentTypes.Remove(rootWeb.RootWeb.ContentTypes["Document"].Id);
newDocumentSetTemplate.Update(true);
// SPQuery queryForDefaultDocs = new SPQuery()
// {
// Query = string.Format(@"<Where>
// <Eq>
// <FieldRef Name='Agenda Type'/>
// <Value Type='Choice'>{0}</Value>
// </Eq>
// </Where>", eventProperties.ListItem["AgendaType"].ToString())
// };
// SPDocumentLibrary defaultDocsLibrary = (SPDocumentLibrary)eventProperties.Web.Lists[defaultDocumentsLibraryName];
// //SPListItemCollection lic = defaultDocsLibrary.GetItems(queryForDefaultDocs);
// SPListItemCollection lic = defaultDocsLibrary.Items;
// foreach (SPListItem defaultDocItem in lic)
// {
// if (defaultDocItem["Agenda Type"].ToString() == eventProperties.ListItem["AgendaType"].ToString())
// {
// SPFile file = defaultDocItem.File;
// byte[] defaultDocumentBytes = file.OpenBinary();
// //Add the default document
// SPListItem itemForFile = file.Item;
// DefaultDocument defaultDocument = newDocumentSetTemplate.DefaultDocuments.Add(file.Name,
// rootWeb.RootWeb.ContentTypes[itemForFile.ContentType.Name].Id,
// defaultDocumentBytes);
// }
// }
//add a shareable property
//TODO: Worry about Shareable fields later on.
//newDocumentSetTemplate.SharedFields.Add(rootWeb.RootWeb.Fields["AgendaID"]);//The agenda of the board
//newDocumentSetTemplate.SharedFields.Add(rootWeb.RootWeb.Fields["Sponsor"]);
//newDocumentSetTemplate.SharedFields.Add(rootWeb.RootWeb.Fields[new Guid("20CD7D82-64D8-4D37-A977-BF81894A1BFF")]); //Voting Requirements.
//newDocumentSetTemplate.SharedFields.Add(rootWeb.RootWeb.Fields[new Guid("5C3D49E7-CDF4-4745-AD29-DDC99D6508D4")]); //Contract Bid Date.
//make sure to add the document set name to the default documents.
newDocumentSetTemplate.DefaultDocuments.AddSetName = false;
newDocumentSetTemplate.Update(true);
newDocumentSetContentType.Update();
rootWeb.RootWeb.Update();
}
}
else if (eventProperties.ListItem["AgendaType"].ToString() == "Non-Procurement Resolution")
{
docSetName = DocSetNames.NonProcurementResolution;
//.........这里部分代码省略.........
示例2: ApplyThemeToWeb
/// <summary>
/// Applies the theme to web.
/// </summary>
/// <param name="theme">The theme.</param>
/// <param name="web">The web.</param>
/// <param name="recurse">if set to <c>true</c> [recurse].</param>
internal static void ApplyThemeToWeb(string theme, SPWeb web, bool recurse)
{
web.ApplyTheme(theme);
if (recurse)
{
foreach (SPWeb subWeb in web.Webs)
{
try
{
ApplyThemeToWeb(theme, subWeb, recurse);
}
finally
{
subWeb.Dispose();
}
}
}
}
示例3: SetUpDocumentWorkspace
private void SetUpDocumentWorkspace(SPItemEventProperties eventProperties, SPSite rootWeb, SPWeb documentWorkspace)
{
//First change the permissions for the documentWorkspace
documentWorkspace.AllowUnsafeUpdates = true;
documentWorkspace.BreakRoleInheritance(false);
string agendaType = eventProperties.ListItem["AgendaType"].ToString();
string agmOffice = eventProperties.ListItem["AGM Office"].ToString();
try
{
SPFieldUserValueCollection authUsers = PaperLessBoardHelper.GetKeyPeopleForAgenda(agendaType, agmOffice, eventProperties);
foreach (SPFieldUserValue userValue in authUsers)
{
SPRoleAssignment role;
role = new SPRoleAssignment(eventProperties.Web.EnsureUser(userValue.LookupValue));
role.RoleDefinitionBindings.Add(documentWorkspace.RoleDefinitions.GetByType(SPRoleType.Contributor));
documentWorkspace.RoleAssignments.Add(role);
documentWorkspace.Update();
}
//In addition the following groups get certain permissions
//TODO: These permissions should ideally come from configuration
SPGroup agendaCoordinators = eventProperties.Web.Groups["Agenda Coordinators"];
SPRoleDefinition roleDefForAgendaCoordinators = eventProperties.Web.RoleDefinitions["Read"];
SPRoleAssignment roleForAgendaCoordinators = new SPRoleAssignment(agendaCoordinators);
roleForAgendaCoordinators.RoleDefinitionBindings.Add(roleDefForAgendaCoordinators);
documentWorkspace.RoleAssignments.Add(roleForAgendaCoordinators);
documentWorkspace.Update();
SPGroup emisPortalMembers = eventProperties.Web.Groups["EMIS Portal Members"];
SPRoleDefinition roleDefForEmisPortalMembers = eventProperties.Web.RoleDefinitions["Restricted Contribute"];
SPRoleAssignment roleForEmisPortalMembers = new SPRoleAssignment(emisPortalMembers);
roleForEmisPortalMembers.RoleDefinitionBindings.Add(roleDefForEmisPortalMembers);
documentWorkspace.RoleAssignments.Add(roleForEmisPortalMembers);
documentWorkspace.Update();
SPGroup boardOfficeMembers = eventProperties.Web.Groups["Board Office Members"];
SPRoleDefinition roleDefForBoardOfficeMemebers = eventProperties.Web.RoleDefinitions["Full Control"];
SPRoleAssignment roleForBoardOfficeMembers = new SPRoleAssignment(boardOfficeMembers);
roleForBoardOfficeMembers.RoleDefinitionBindings.Add(roleDefForBoardOfficeMemebers);
documentWorkspace.RoleAssignments.Add(roleForBoardOfficeMembers);
documentWorkspace.Update();
SPGroup cpmManagers = eventProperties.Web.Groups["CPM Managers"];
SPRoleDefinition roleDefForCPMManagers = eventProperties.Web.RoleDefinitions["Restricted Contribute"];
SPRoleAssignment roleForCPMManagers = new SPRoleAssignment(cpmManagers);
roleForCPMManagers.RoleDefinitionBindings.Add(roleDefForCPMManagers);
documentWorkspace.RoleAssignments.Add(roleForCPMManagers);
documentWorkspace.Update();
}
catch (Exception exc)
{
Microsoft.Office.Server.Diagnostics.PortalLog.LogString("Exception – {0} – {1} – {2}", "Board Agenda Receiver Error while adding Key People and setting Permissions in workspace", exc.Message, exc.StackTrace);
}
//Make sure it inherits the theme from the rootWeb
string currentTheme = rootWeb.RootWeb.Theme;
documentWorkspace.ApplyTheme(currentTheme);
string docSetName = "Agenda Workspace DS-6";
string defaultDocumentsLibraryName = null;
string libraryNameInDocumentWorkspace = null;
string boardSiteURL = null;
string boardMeetingListName = null;
string lookAheadListName = null;
string masterKeyPeopleListName = null;
SPContentType newDocumentSetContentType = null;
//SPFolder defaultDocuments =rootWeb.RootWeb.Folders["Default Documents"];
SPWebApplication webApplication = eventProperties.Web.Site.WebApplication;
if (webApplication.Properties != null && webApplication.Properties.Count > 0)
{
if (webApplication.Properties.ContainsKey("DefaultDocumentsLibrary"))
{
defaultDocumentsLibraryName = webApplication.Properties["DefaultDocumentsLibrary"].ToString();
libraryNameInDocumentWorkspace = webApplication.Properties["LibraryNameInDocumentWorkspace"].ToString();
boardSiteURL = webApplication.Properties["BoardSiteURL"].ToString();
boardMeetingListName = webApplication.Properties["BoardMeetingListName"].ToString();
lookAheadListName = webApplication.Properties["LookAheadListName"].ToString();
lookAheadListName = webApplication.Properties["LookAheadListName"].ToString();
masterKeyPeopleListName = webApplication.Properties["MasterKeyPeopleListName"].ToString();
}
}
DocumentSetTemplate newDocumentSetTemplate = null;
if (eventProperties.ListItem["AgendaType"].ToString() == "Procurement Resolution")
{
docSetName = DocSetNames.ProcurementResolution;
if (rootWeb.RootWeb.ContentTypes[docSetName] == null)
{
// create the new document set content Type
newDocumentSetContentType = rootWeb.RootWeb.ContentTypes.Add(new SPContentType(rootWeb.RootWeb.ContentTypes["Document Set"], rootWeb.RootWeb.ContentTypes, docSetName));
//.........这里部分代码省略.........