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


C# Web.GetListByUrl方法代码示例

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


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

示例1: GetList

 internal List GetList(Web web)
 {
     List list = null;
     if (List != null)
     {
         list = List;
     }
     else if (Id != Guid.Empty)
     {
         list = web.Lists.GetById(Id);
     }
     else if (!string.IsNullOrEmpty(Title))
     {
         list = web.GetListByTitle(Title);
         if (list == null)
         {
             list = web.GetListByUrl(Title);
         }
     }
     if (list != null)
     {
         web.Context.Load(list, l => l.Id, l => l.BaseTemplate, l => l.OnQuickLaunch, l => l.DefaultViewUrl, l => l.Title, l => l.Hidden, l => l.ContentTypesEnabled, l => l.RootFolder.ServerRelativeUrl);
         web.Context.ExecuteQueryRetry();
     }
     return list;
 }
开发者ID:russgove,项目名称:PnP-PowerShell,代码行数:26,代码来源:ListPipeBind.cs

示例2: GetList

        private List GetList(Web web)
        {
            var listUrlProperty = GetProperty("ListUrl");

            if (!string.IsNullOrEmpty(listUrlProperty?.Value))
            {
                return web.GetListByUrl(listUrlProperty.Value);
            }

            var listIdProperty = GetProperty("ListId");
            Guid listId;
            if (TryParseGuidProperty(listIdProperty, out listId))
            {
                return web.Lists.GetById(listId);
            }

            var listNameProperty = GetProperty("ListName");
            if (TryParseGuidProperty(listNameProperty, out listId))
            {
                return web.Lists.GetById(listId);
            }

            var listDisplayName = GetProperty("ListDisplayName");
            if (!string.IsNullOrEmpty(listDisplayName?.Value))
            {
                return web.GetListByTitle(listDisplayName.Value);
            }

            return null;
        }
开发者ID:stijnbrouwers,项目名称:PnP-Sites-Core,代码行数:30,代码来源:XsltWebPartPostProcessor.cs

示例3: ProvisionObjects


//.........这里部分代码省略.........


                var exists = true;
                Microsoft.SharePoint.Client.File file = null;
                try
                {
                    file = web.GetFileByServerRelativeUrl(url);
                    web.Context.Load(file);
                    web.Context.ExecuteQuery();
                }
                catch (ServerException ex)
                {
                    if (ex.ServerErrorTypeName == "System.IO.FileNotFoundException")
                    {
                        exists = false;
                    }
                }

                if (exists)
                {
                    if (page.Overwrite)
                    {
                        file.DeleteObject();
                        web.Context.ExecuteQueryRetry();
                        web.AddPublishingPage(page.PageName, page.PageLayoutName, page.Title, page.Content, page.Properties, page.Publish);
                    }

                    //if (file.CheckOutType == CheckOutType.None)
                    //{
                    //    file.CheckOut();
                    //}
                }
                else
                {
                    web.AddPublishingPage(page.PageName, page.PageLayoutName, page.Title, page.Content, page.Properties, page.Publish);

                    
                }

                if (page.WelcomePage)
                {
                    if (!web.IsPropertyAvailable("RootFolder"))
                    {
                        web.Context.Load(web.RootFolder);
                        web.Context.ExecuteQueryRetry();
                    }

                    var rootFolderRelativeUrl = url.Substring(web.RootFolder.ServerRelativeUrl.Length);
                    web.SetHomePage(rootFolderRelativeUrl);
                }

                // Check out the file if needed
                
                
                

                if (page.WebParts != null & page.WebParts.Any())
                {
                    if (!exists)
                    {
                        file = web.GetFileByServerRelativeUrl(url);
                        web.Context.Load(file);
                        web.Context.ExecuteQuery();
                    }
                    file.CheckOut();    
                                    

                    var existingWebParts = web.GetWebParts(url);

                    foreach (var webpart in page.WebParts)
                    {
                        if (existingWebParts.FirstOrDefault(w => w.WebPart.Title == webpart.Title) == null)
                        {
                            WebPartEntity wpEntity = new WebPartEntity();
                            wpEntity.WebPartTitle = webpart.Title;
                            wpEntity.WebPartIndex = (int)webpart.Order;
                            wpEntity.WebPartZone = webpart.Zone;

                            if (!string.IsNullOrWhiteSpace(webpart.ListUrl))
                            {
                                var list = web.GetListByUrl(webpart.ListUrl);

                                var contents = String.Format(webpart.Contents, list.Id, list.Title);
                                wpEntity.WebPartXml = contents.Trim(new[] { '\n', ' ' });
                            }
                            else
                            {
                                wpEntity.WebPartXml = webpart.Contents.ToParsedString().Trim(new[] { '\n', ' ' });
                            }

                            //wpEntity.WebPartXml = webpart.Contents.ToParsedString().Trim(new[] {'\n', ' '});
                            web.AddWebPartToWebPartPage(url, wpEntity);
                        }
                    }

                    file.CheckIn("", CheckinType.MajorCheckIn);
                    file.Publish("");
                }
            }
        }
开发者ID:psrank,项目名称:PnP,代码行数:101,代码来源:ObjectPublishingPages.cs

示例4: DeleteListByUrl

        public static void DeleteListByUrl(Web web, string webRelativeUrl)
        {
            try
            {
                Logger.LogInfoMessage(String.Format("Deleting List {0} from {1} ...", webRelativeUrl, web.Url), false);

                List targetList = web.GetListByUrl(webRelativeUrl);

                if (targetList != null && targetList.ServerObjectIsNull == false)
                {
                    targetList.DeleteObject();
                    web.Context.ExecuteQuery();

                    Logger.LogSuccessMessage(String.Format("Deleted List {0} from {1}", webRelativeUrl, web.Url), false);
                }
                else
                {
                    Logger.LogErrorMessage(String.Format("DeleteListByUrl() failed for {0}: Error=List {1} was not found", web.Url, webRelativeUrl), false);
                }
            }
            catch (ServerException ex)
            {
                if (ex.ServerErrorTypeName.Equals("System.IO.FileNotFoundException", StringComparison.InvariantCultureIgnoreCase) == false)
                {
                    Logger.LogErrorMessage(String.Format("DeleteListByUrl() failed for {0}: Error={1}", web.Url, ex.Message), false);
                }
            }
            catch (Exception ex)
            {
                Logger.LogErrorMessage(String.Format("DeleteListByUrl() failed for {0}: Error={1}", web.Url, ex.Message), false);
            }
        }
开发者ID:OfficeDev,项目名称:PnP-Transformation,代码行数:32,代码来源:Helper.cs


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