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


C# SPFolder.Update方法代码示例

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


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

示例1: DeployWelcomePage

        private void DeployWelcomePage(object modelHost, DefinitionBase model, SPFolder folder, WelcomePageDefinition welcomePgaeModel)
        {
            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = folder,
                ObjectType = typeof(SPFolder),
                ObjectDefinition = welcomePgaeModel,
                ModelHost = modelHost
            });

            TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Changing welcome page to: [{0}]", welcomePgaeModel.Url);
            
            // https://github.com/SubPointSolutions/spmeta2/issues/431
            folder.WelcomePage = UrlUtility.RemoveStartingSlash(welcomePgaeModel.Url);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = folder,
                ObjectType = typeof(SPFolder),
                ObjectDefinition = welcomePgaeModel,
                ModelHost = modelHost
            });

            folder.Update();
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:31,代码来源:WelcomePageModelHandler.cs

示例2: update_folder_time

 protected void update_folder_time(SPFolder current_folder)
 {
     if (current_folder == null || !current_folder.Url.Contains("/")) return;
     current_folder.SetProperty("Name", current_folder.Name);
     current_folder.Update();
     update_folder_time(current_folder.ParentFolder);
 }
开发者ID:ricardocarneiro,项目名称:SharePoint-1,代码行数:7,代码来源:Item+Changed+Event.cs

示例3: DeployContentTypeOrder

        private void DeployContentTypeOrder(object modelHost, SPList list, SPFolder folder, UniqueContentTypeOrderDefinition contentTypeOrderDefinition)
        {
            var oldContentTypeOrder = folder.ContentTypeOrder;
            var newContentTypeOrder = new List<SPContentType>();

            var listContentTypes = list.ContentTypes.OfType<SPContentType>().ToList();

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = folder,
                ObjectType = typeof(SPFolder),
                ObjectDefinition = contentTypeOrderDefinition,
                ModelHost = modelHost
            });

            // re-order
            foreach (var srcContentTypeDef in contentTypeOrderDefinition.ContentTypes)
            {
                SPContentType listContentType = null;

                if (!string.IsNullOrEmpty(srcContentTypeDef.ContentTypeName))
                {
                    listContentType = listContentTypes.FirstOrDefault(c => c.Name.ToUpper() == srcContentTypeDef.ContentTypeName.ToUpper());

                    if (listContentType != null)
                    {
                        TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall,
                            string.Format("Found content type by name:[{0}]", srcContentTypeDef.ContentTypeName));
                    }
                }

                if (listContentType == null && !string.IsNullOrEmpty(srcContentTypeDef.ContentTypeId))
                {
                    listContentType = listContentTypes.FirstOrDefault(c => c.Id.ToString().ToUpper().StartsWith(srcContentTypeDef.ContentTypeId.ToUpper()));

                    if (listContentType != null)
                    {
                        TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall,
                            string.Format("Found content type by matching ID start:[{0}]", srcContentTypeDef.ContentTypeId));
                    }
                }

                if (listContentType != null && !newContentTypeOrder.Contains(listContentType))
                {
                    TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall,
                        string.Format("Adding content type to new ordering"));
                    newContentTypeOrder.Add(listContentType);
                }
            }

            // filling up gapes
            foreach (var oldCt in oldContentTypeOrder)
            {
                if (newContentTypeOrder.Count(c =>
                    c.Name == oldCt.Name ||
                    c.Id.ToString().ToUpper().StartsWith(oldCt.Id.ToString().ToUpper())) == 0)
                    newContentTypeOrder.Add(oldCt);
            }

            if (newContentTypeOrder.Count() > 0)
                folder.UniqueContentTypeOrder = newContentTypeOrder;

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = folder,
                ObjectType = typeof(SPFolder),
                ObjectDefinition = contentTypeOrderDefinition,
                ModelHost = modelHost
            });

            folder.Update();
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:78,代码来源:UniqueContentTypeOrderModelHandler.cs

示例4: DeployContentTypeOrder

        private void DeployContentTypeOrder(object modelHost, SPList list, SPFolder folder, UniqueContentTypeOrderDefinition contentTypeOrderDefinition)
        {
            var oldContentTypeOrder = folder.ContentTypeOrder;
            var newContentTypeOrder = new List<SPContentType>();

            var listContentTypes = list.ContentTypes.OfType<SPContentType>().ToList();

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = folder,
                ObjectType = typeof(SPFolder),
                ObjectDefinition = contentTypeOrderDefinition,
                ModelHost = modelHost
            });

            // re-order
            foreach (var srcContentTypeDef in contentTypeOrderDefinition.ContentTypes)
            {
                SPContentType listContentType = null;

                if (!string.IsNullOrEmpty(srcContentTypeDef.ContentTypeName))
                    listContentType = listContentTypes.FirstOrDefault(c => c.Name == srcContentTypeDef.ContentTypeName);

                if (listContentType == null && !string.IsNullOrEmpty(srcContentTypeDef.ContentTypeId))
                    listContentType = listContentTypes.FirstOrDefault(c => c.Id.ToString().ToUpper().StartsWith(srcContentTypeDef.ContentTypeId.ToUpper()));

                if (listContentType != null && !newContentTypeOrder.Contains(listContentType))
                    newContentTypeOrder.Add(listContentType);
            }

            // filling up gapes
            foreach (var oldCt in oldContentTypeOrder)
            {
                if (newContentTypeOrder.Count(c =>
                    c.Name == oldCt.Name ||
                    c.Id.ToString().ToUpper().StartsWith(oldCt.Id.ToString().ToUpper())) == 0)
                    newContentTypeOrder.Add(oldCt);
            }

            if (newContentTypeOrder.Count() > 0)
                folder.UniqueContentTypeOrder = newContentTypeOrder;

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = folder,
                ObjectType = typeof(SPFolder),
                ObjectDefinition = contentTypeOrderDefinition,
                ModelHost = modelHost
            });

            folder.Update();
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:58,代码来源:UniqueContentTypeOrderModelHandler.cs

示例5: DeployHideContentTypeLinks

        private void DeployHideContentTypeLinks(object modelHost, SPList list, SPFolder folder, HideContentTypeLinksDefinition contentTypeOrderDefinition)
        {
            var oldContentTypeOrder = folder.ContentTypeOrder;
            var newContentTypeOrder = oldContentTypeOrder;

            var listContentTypes = list.ContentTypes.OfType<SPContentType>().ToList();

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = folder,
                ObjectType = typeof(SPFolder),
                ObjectDefinition = contentTypeOrderDefinition,
                ModelHost = modelHost
            });

            // re-order
            foreach (var srcContentTypeDef in contentTypeOrderDefinition.ContentTypes)
            {
                SPContentType listContentType = null;

                if (!string.IsNullOrEmpty(srcContentTypeDef.ContentTypeName))
                    listContentType = listContentTypes.FirstOrDefault(c => c.Name == srcContentTypeDef.ContentTypeName);

                if (listContentType == null && !string.IsNullOrEmpty(srcContentTypeDef.ContentTypeId))
                    listContentType = listContentTypes.FirstOrDefault(c => c.Id.ToString().ToUpper().StartsWith(srcContentTypeDef.ContentTypeId.ToUpper()));

                if (listContentType != null)
                {
                    var existingCt = newContentTypeOrder.FirstOrDefault(ct => ct.Name == listContentType.Name || ct.Id == listContentType.Id);

                    if (existingCt != null && newContentTypeOrder.Contains(existingCt))
                        newContentTypeOrder.Remove(existingCt);
                }
            }

            if (newContentTypeOrder.Count() > 0)
                folder.UniqueContentTypeOrder = newContentTypeOrder;

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = folder,
                ObjectType = typeof(SPFolder),
                ObjectDefinition = contentTypeOrderDefinition,
                ModelHost = modelHost
            });

            folder.Update();
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:54,代码来源:HideContentTypeLinksModelHandler.cs

示例6: EnsureUniqueContentTypeOrder

        private static void EnsureUniqueContentTypeOrder(SPFolder folder, FolderInfo folderInfo)
        {
            if (folderInfo.UniqueContentTypeOrder != null && folderInfo.UniqueContentTypeOrder.Count > 0)
            {
                SPContentTypeCollection listContentTypes = folder.ParentWeb.Lists[folder.ParentListId].ContentTypes;
                IList<SPContentType> uniqueOrder = new List<SPContentType>();

                foreach (ContentTypeInfo needToEnsureThisCTInfo in folderInfo.UniqueContentTypeOrder)
                {
                    var foundRealCT = listContentTypes[needToEnsureThisCTInfo.ContentTypeId];

                    if (foundRealCT == null)
                    {
                        // Failed to find CT with direct ID lookup: now let's assume that we were given site collection CT IDs as
                        // input and that we need to inspect the list CTs' parents to find a match.
                        foreach (var listCT in listContentTypes.Cast<SPContentType>())
                        {
                            if (listCT.Id.Parent == needToEnsureThisCTInfo.ContentTypeId)
                            {
                                foundRealCT = listCT;
                                break;
                            }
                        }
                    }

                    uniqueOrder.Add(foundRealCT);
                }

                folder.UniqueContentTypeOrder = uniqueOrder;
                folder.Update();
            }
        }
开发者ID:andresglx,项目名称:Dynamite,代码行数:32,代码来源:FolderHelper.cs

示例7: AddFolderPages

        private void AddFolderPages(SPList library, SPFolder folder, IFolderInfo folderInfo)
        {
            if (folderInfo.Pages != null)
            {
                var publishingSite = new PublishingSite(library.ParentWeb.Site);
                var publishingWeb = PublishingWeb.GetPublishingWeb(library.ParentWeb);
                var publishingPages = publishingWeb.GetPublishingPages();

                foreach (var page in folderInfo.Pages)
                {
                    PageLayout pageLayout;

                    // If a page layout was specified and its from the correct web.
                    if (page.PageLayout != null && page.PageLayout.ListItem.ParentList.ParentWeb.ID == publishingSite.RootWeb.ID)
                    {
                        // Associate the page layout specified in the page.
                        pageLayout = page.PageLayout;
                    }
                    else
                    {
                        // Get the first page layout with the specified content type id.
                        var pageContentType = publishingSite.ContentTypes[page.ContentTypeId];
                        var pageLayouts = publishingSite.GetPageLayouts(pageContentType, true);
                        pageLayout = pageLayouts[0]; // default to first associated page layout
                    }

                    var pageServerRelativeUrl = folder.ServerRelativeUrl + "/" + page.Name + ".aspx";
                    var existingPage = publishingWeb.GetPublishingPage(pageServerRelativeUrl);

                    if (existingPage == null)
                    {
                        // Only create the page if it doesn't exist yet
                        var publishingPage = publishingPages.Add(pageServerRelativeUrl, pageLayout);

                        this.EnsurePageCheckOut(publishingPage);

                        var item = publishingPage.ListItem;

                        ApplyPageValues(item, page);

                        publishingPage.Update();

                        // Add webparts to the page
                        this.EnsureWebpartsOnPage(publishingPage);

                        if (page.IsWelcomePage)
                        {
                            folder.WelcomePage = item.Name;
                            folder.Update();
                            EnsureFolderPublish(folder);

                            if (folder.UniqueId == library.RootFolder.UniqueId)
                            {
                                // We are setting the Pages library's root folder's welcome page, so let's assume this means we also need to set it as the website's welcome page as well
                                var webRootFolder = library.ParentWeb.RootFolder;
                                webRootFolder.WelcomePage = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", publishingPages.PubWeb.PagesListName, publishingPage.Name);
                                webRootFolder.Update();

                                EnsureFolderPublish(folder);
                            }
                        }

                        EnsurePageCheckInAndPublish(publishingPage);
                    }
                    else
                    {
                        this.logger.Info("Folder maker is skipping the creation of page '{0}' because it already exists.", existingPage.Url);

                        if (this.defaultPageWebPartIndex.GetDefaultWebPartsForPageUrl(existingPage.Url) != null)
                        {
                            // If there are some registered on the index, add the
                            // webparts to the page (make sure to checkout/checkin).
                            this.logger.Info("Ensuring the existance of the webparts on page '{0}'.", existingPage.Url);

                            this.EnsurePageCheckOut(existingPage);
                            this.EnsureWebpartsOnPage(existingPage);
                            EnsurePageCheckInAndPublish(existingPage);
                        }
                    }
                }
            }
        }
开发者ID:GAlexandreBastien,项目名称:Dynamite-2010,代码行数:82,代码来源:FolderMaker.cs


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