本文整理汇总了C#中SPSite.GetCatalog方法的典型用法代码示例。如果您正苦于以下问题:C# SPSite.GetCatalog方法的具体用法?C# SPSite.GetCatalog怎么用?C# SPSite.GetCatalog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPSite
的用法示例。
在下文中一共展示了SPSite.GetCatalog方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetMasterPage
private void SetMasterPage(SPSite siteCollection, string masterPageName)
{
SPList masterPage = siteCollection.GetCatalog(SPListTemplateType.MasterPageCatalog);
string masterUrl = SPUrlUtility.CombineUrl(masterPage.RootFolder.ServerRelativeUrl, masterPageName);
foreach (SPWeb site in siteCollection.AllWebs)
{
site.MasterUrl = masterUrl;
site.CustomMasterUrl = masterUrl;
site.Update();
}
}
示例2: LoadTemplateFromPackage
private void LoadTemplateFromPackage(SPSite site, string packageFileName, string packageDirectory)
{
SPDocumentLibrary solutions = (SPDocumentLibrary)site.GetCatalog(SPListTemplateType.SolutionCatalog);
/*SPFile solutionFile = solutions.RootFolder.Files.Add(
packageFileName,
fileSystemHelper.ReadFile(
fileSystemHelper.CombinePath(packageDirectory, packageFileName)));*/
SPFile solutionFile = solutions.RootFolder.Files.Add(
packageFileName, ReadFile(CombinePath(packageDirectory, packageFileName)));
SPUserSolution solution = site.Solutions.Add(solutionFile.Item.ID);
Guid solutionId = solution.SolutionId;
SPFeatureDefinitionCollection siteFeatures = site.FeatureDefinitions;
var features = from SPFeatureDefinition f
in siteFeatures
where f.SolutionId.Equals(solutionId) && f.Scope == SPFeatureScope.Site
select f;
foreach (SPFeatureDefinition feature in features)
{
site.Features.Add(feature.Id, false, SPFeatureDefinitionScope.Site);
}
}
示例3: AddSandboxedSolution
public static SPUserSolution AddSandboxedSolution(SPSite site, byte[] fileData, string solutionName)
{
site.RequireNotNull("site");
fileData.RequireNotNull("fileData");
solutionName.RequireNotNullOrEmpty("solutionName");
SPDocumentLibrary solutionGallery = site.GetCatalog(SPListTemplateType.SolutionCatalog) as SPDocumentLibrary;
if (null != solutionGallery)
{
solutionGallery.ParentWeb.AllowUnsafeUpdates = true;
string solutionPath = Path.Combine(solutionGallery.RootFolder.ServerRelativeUrl, solutionName);
if (!site.RootWeb.GetFile(solutionPath).Exists)
{
SPFile solutionFile = solutionGallery.RootFolder.Files.Add(solutionName, fileData);
SPUserSolution solution = site.Solutions.Add(solutionFile.Item.ID);
return solution;
}
}
return null;
}
示例4: GetSiteRelativeMasterPageUrl
/// <summary>
/// Method to get the MasterPage SPFile from a fileName and the SPSite
/// RootFolder.Files is a SPFileCollection and the indexer [] throws an ArgumentException if the fileName is not found.
/// We can't use web.GetFile() for a catalog file.
/// Log the error and return null.
/// </summary>
/// <param name="site">The current Site Collection where the MasterPage Gallery lives</param>
/// <param name="fileName">The filename of the MasterPage we are looking for. With the extension. Ex: seattle.master</param>
/// <returns>A SPFile if found, null if not found.</returns>
private SPFile GetSiteRelativeMasterPageUrl(SPSite site, string fileName)
{
SPFile masterPageFile = null;
var masterPageCatalog = site.GetCatalog(SPListTemplateType.MasterPageCatalog);
try
{
masterPageFile = masterPageCatalog.RootFolder.Files[fileName];
}
catch (ArgumentException e)
{
this.logger.Warn("The file with filename '{0}' was not found in the master page gallery. StackTrace: {1}", fileName, e.StackTrace);
}
return masterPageFile;
}