示例#1
0
        public static IEnumerable <TList> GetLists <TList>(this SPWeb web, SPBaseType baseType, string templateName)
            where TList : SPList
        {
            SPListTemplate template = GetListTemplate(web, templateName);

            return(web.GetLists <TList>(template.BaseType, template));
        }
示例#2
0
        public static SPList TryGetListByUrl(SPWeb web, string listUrlName, SPBaseType baseType)
        {
            string WebRelativeUrl  = web.ServerRelativeUrl;
            string ListRelativeUrl = String.Empty;
            SPList list            = null;

            if (baseType == SPBaseType.GenericList)
            {
                ListRelativeUrl = ("/Lists/" + listUrlName);
            }
            else
            {
                ListRelativeUrl = ("/" + listUrlName);
            }
            string ListWebRelativeUrl = SPUrlUtility.CombineUrl(WebRelativeUrl, ListRelativeUrl);

            try
            {
                list = web.GetList(ListWebRelativeUrl);
            }
            catch
            {
            }
            return(list);
        }
示例#3
0
 public static IEnumerable <TList> GetLists <TList>(this SPWeb web, SPBaseType baseType, SPListTemplate template)
     where TList : SPList
 {
     if (template == null)
     {
         throw new ArgumentNullException("template");
     }
     return(web.GetLists <TList>(template.BaseType, template.Type));
 }
示例#4
0
        /// <summary>
        /// Used by EditorParts to fill in a dropdown control with all site lists
        /// excluded all of baseType
        /// </summary>
        /// <param name="dropDownList">Control to fill</param>
        /// <param name="baseType">Type of the base.</param>
        public static void FillListsExclude(ListControl dropDownList, SPBaseType baseType)
        {
            SPWeb web = SPContext.Current.Web;

            foreach (SPList list in web.Lists)
            {
                if (!list.Hidden && list.BaseType != baseType)
                {
                    dropDownList.Items.Add(new ListItem(list.Title, list.ID.ToString()));
                }
            }
        }
示例#5
0
        public static DataTable GetData(this SPWeb web, SPQuery query, SPBaseType listType, bool recursive = false)
        {
            DataTable dt = web.GetSiteData(new SPSiteDataQuery()
            {
                Webs              = recursive ? "<Webs Scope='Recursive' />" : "<Webs Scope='SiteCollection' />",
                Lists             = string.Format("<Lists BaseType=\"{0}\" />", (int)listType),
                Query             = query.Query,
                ViewFields        = query.ViewFields,
                RowLimit          = query.RowLimit,
                QueryThrottleMode = query.QueryThrottleMode
            });

            return(dt);
        }
示例#6
0
 public static SPList GetList(string webUrl, string listUrl, SPBaseType type = SPBaseType.DocumentLibrary)
 {
     SPList list = null;
     Helper.RunElevated(webUrl, Guid.Empty, delegate(SPSite elevatedSite, SPWeb elevatedWeb)
     {
         SPListCollection docLibrCollection = elevatedWeb.GetListsOfType(type);
         IEnumerable<SPList> lists = docLibrCollection.OfType<SPList>();
         foreach (var l in lists)
         {
             string absoluteListUrl = elevatedSite.MakeFullUrl(l.RootFolder.ServerRelativeUrl);
         }
         list = lists.Where(l =>
             string.Equals(elevatedSite.MakeFullUrl(l.RootFolder.ServerRelativeUrl), listUrl, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
     });
     return list;
 }
示例#7
0
 public static IEnumerable <TList> GetListsByInternalName <TList>(this SPListCollection lists, string internalName, SPBaseType baseType, SPListTemplateType templateType)
     where TList : SPList
 {
     return(lists.GetListsByInternalName <TList>(internalName, baseType).Where(l => l.BaseTemplate == templateType));
 }
示例#8
0
 public static IEnumerable <TList> GetListsByInternalName <TList>(this SPListCollection lists, string internalName, SPBaseType baseType)
     where TList : SPList
 {
     return(lists.Web.GetLists <TList>(baseType).Where(l => l.RootFolder.Name == internalName));
 }
示例#9
0
 public static IEnumerable <TList> GetLists <TList>(this SPWeb web, SPBaseType baseType)
     where TList : SPList
 {
     return(web.GetListsOfType(baseType).OfType <TList>());
 }
示例#10
0
 public static IEnumerable <TList> GetLists <TList>(this SPWeb web, SPBaseType baseType, SPListTemplateType templateType)
     where TList : SPList
 {
     return(web.GetLists <TList>(baseType).Where(lst => lst.BaseTemplate == templateType));
 }
示例#11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ListTemplate" /> class.
 /// </summary>
 /// <param name="title">title.</param>
 /// <param name="description">description.</param>
 /// <param name="type">type.</param>
 /// <param name="baseType">baseType.</param>
 /// <param name="name">name.</param>
 /// <param name="isCustomTemplate">isCustomTemplate.</param>
 public ListTemplate(string title = default(string), string description = default(string), SPListTemplateType type = default(SPListTemplateType), SPBaseType baseType = default(SPBaseType), string name = default(string), bool isCustomTemplate = default(bool))
 {
     this.Title            = title;
     this.Description      = description;
     this.Type             = type;
     this.BaseType         = baseType;
     this.Name             = name;
     this.IsCustomTemplate = isCustomTemplate;
 }
示例#12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="docITems"></param>
        /// <param name="lstType"></param>
        /// <param name="lstID">控件不重复命名</param>
        /// <param name="isNew"></param>
        private void FillResults(DataTable docITems, SPBaseType lstType, bool isNew, ref Table tbContent)
        { //填充内容
            //tbContent.Rows.Clear();
            TableRow   tRow;
            TableCell  tCell;
            LinkButton lnkBtn;

            try
            {
                string   title  = "";
                string[] lnkUrl = new string[] { };
                for (int i = 0; i < docITems.Rows.Count; i++)
                {
                    tRow  = new TableRow();
                    tCell = new TableCell();
                    if (lstType == SPBaseType.DocumentLibrary && ViewState["hasRight"].ToString() == "1" && webObj.Action == "Edit")
                    {
                        title = docITems.Rows[i]["Title"].ToString();
                        if (title == "")
                        {
                            title = docITems.Rows[i]["FileRef"].ToString();
                            title = title.Substring(title.LastIndexOf("/") + 1);
                        }
                        tCell.Controls.Add(new LiteralControl("<a href='" + docITems.Rows[i]["FileRef"] + "'>" + title + "</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"));
                    }
                    else if (lstType == SPBaseType.GenericList)
                    {
                        lnkUrl = docITems.Rows[i]["Result"].ToString().Split(',');
                        tCell.Controls.Add(new LiteralControl("<a href='" + lnkUrl[0] + "'>" + docITems.Rows[i]["Title"] + "</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"));
                        //"http://xqx2012/blog/blog1/DocLib/%E5%91%BD%E5%90%8D%E6%96%87%E6%A1%A3%E8%A7%84%E5%88%99201807301426633.docx, 命名文档"
                    }

                    tRow.Cells.Add(tCell);//加审核项


                    if (ViewState["hasRight"].ToString() == "1" && webObj.Action == "Edit")
                    {
                        tCell       = new TableCell();
                        tCell.Width = 50;
                        lnkBtn      = new LinkButton();

                        if (isNew)
                        {
                            lnkBtn.CommandName     = "add";
                            lnkBtn.ID              = "btn" + tbContent.Rows.Count.ToString();
                            lnkBtn.CommandArgument = title + ";" + docITems.Rows[i]["FileRef"].ToString();//添加文档库的链接
                            lnkBtn.Text            = "选择";
                            lnkBtn.OnClientClick   = "if(!confirm('确定要选择“" + title + "”作为结果吗?'))return false;";
                        }
                        else
                        {
                            lnkBtn.CommandName     = "edit";
                            lnkBtn.ID              = "btn" + tbContent.Rows.Count.ToString() + "_" + docITems.Rows[i]["ID"]; //不同列表的ID会出现重复的情况
                            lnkBtn.CommandArgument = docITems.Rows[i]["Title"] + ";" + lnkUrl[0];                            //添加文档库的链接
                            lnkBtn.Text            = "删除";
                            lnkBtn.OnClientClick   = "if(!confirm('确定要从结果中删除“" + docITems.Rows[i]["Title"] + "” 吗?'))return false;";
                        }
                        lnkBtn.Click += lnkBtn_Click;
                        tCell.Controls.Add(lnkBtn);
                        tRow.Cells.Add(tCell);//
                    }
                    tbContent.Rows.Add(tRow);
                }
            }
            catch (Exception ex)
            {
                lblMsg.Text = "docITems.Count" + ex.ToString();
            }
        }