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


C# SPSite.GetCatalog方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:chutinhha,项目名称:news-announcement,代码行数:12,代码来源:SiteFeatureReceiver.cs

示例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);
            }
        }
开发者ID:ivankozyrev,项目名称:fls-internal-portal,代码行数:22,代码来源:CreateSitesCollection.EventReceiver.cs

示例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;
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:21,代码来源:SharePointUtilities.cs

示例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;
        }
开发者ID:andresglx,项目名称:Dynamite,代码行数:25,代码来源:MasterPageHelper.cs


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