コード例 #1
0
        /// <summary>
        /// 文章分类列表数据
        /// </summary>
        /// <param name="id">文章分类列表的主键值</param>
        /// <returns>文章分类列表数据模型</returns>
        public static string NameList(string idList)
        {
            List <string> contentList = new List <string>();

            if (!string.IsNullOrEmpty(idList))
            {
                idList = idList.Substring(1, idList.Length - 2);
            }
            idList = idList.Replace("||", "#");

            if (idList.Length > 0)
            {
                foreach (string temp in idList.Split('#'))
                {
                    List <string> nameList = new List <string>();
                    foreach (string id in temp.Split('|'))
                    {
                        nameList.Add(ArticleClassBLL.Read(Convert.ToInt32(id)).Name);
                    }
                    if (nameList.Count > 0)
                    {
                        contentList.Add(string.Join(" > ", nameList));
                    }
                }
            }
            return(string.Join(",", contentList));
        }
コード例 #2
0
        /// <summary>
        /// 面包屑导航改进版,根据分类自动显示对应链接
        /// </summary>
        /// <param name="idList"></param>
        /// <returns></returns>
        public static string ArticleClassNavigationList(string idList)
        {
            string content = string.Empty;

            if (idList != string.Empty)
            {
                idList = idList.Substring(1, idList.Length - 2);
            }
            idList = idList.Replace("||", "#");
            if (idList.Length > 0)
            {
                foreach (string temp in idList.Split('#'))
                {
                    string tempArticleClassName = string.Empty;
                    int    linkCount            = 1;
                    foreach (string id in temp.Split('|'))
                    {
                        if (tempArticleClassName == string.Empty)
                        {
                            if (linkCount < temp.Split('|').Length)
                            {
                                tempArticleClassName = "<a href=\"" + GetClassUrl(Read(Convert.ToInt32(id))) + "\" >" + Read(Convert.ToInt32(id)).Name + "</a>";
                            }
                            else
                            {
                                tempArticleClassName = ArticleClassBLL.Read(Convert.ToInt32(id)).Name;
                            }
                        }
                        else
                        {
                            if (linkCount < temp.Split('|').Length)
                            {
                                tempArticleClassName += " > <a href=\"" + GetClassUrl(Read(Convert.ToInt32(id))) + "\" >" + ArticleClassBLL.Read(Convert.ToInt32(id)).Name + "</a>";
                            }
                            else
                            {
                                tempArticleClassName += " > " + ArticleClassBLL.Read(Convert.ToInt32(id)).Name + "";
                            }
                        }
                        linkCount++;
                    }
                    if (tempArticleClassName != string.Empty)
                    {
                        if (content == string.Empty)
                        {
                            content = tempArticleClassName;
                        }
                        else
                        {
                            content += "," + tempArticleClassName;
                        }
                    }
                }
            }
            return(content);
        }
コード例 #3
0
        /// <summary>
        /// 根据帮助分类类型获取URL
        /// </summary>
        /// <param name="articleClass"></param>
        /// <returns></returns>
        public static string GetHelpClassUrl(ArticleClassInfo articleClass)
        {
            string           url      = "";
            ArticleClassInfo tmpCLass = new ArticleClassInfo();

            if (ArticleClassBLL.ReadChilds(articleClass.Id).Count > 0 && Read(articleClass.Id).ShowType != 5)
            {
                tmpCLass = ArticleClassBLL.ReadChilds(articleClass.Id)[0]; //如果是父级分类则取第一个子分类的URL
            }
            else
            {
                tmpCLass = articleClass;//如果不是父级分类则取当前分类的URL
            }
            switch (tmpCLass.ShowType)
            {
            case 5:    //链接URL
                url = string.IsNullOrEmpty(tmpCLass.Description) ? "/" : tmpCLass.Description;
                break;

            case 4:    //父级分类
            {
                List <ArticleClassInfo> childlist = ReadChilds(articleClass.Id);
                if (childlist.Count > 0)
                {
                    url = GetHelpClassUrl(childlist[0]);
                }
                else
                {
                    url = "/";
                }
            }
            break;

            case 2:    //文章列表
                url = "/Help-C" + tmpCLass.Id + ".html";
                break;

            case 1:    //单文章
            default:
            {
                ArticleSearchInfo articleSearch = new ArticleSearchInfo();
                articleSearch.ClassId = "|" + tmpCLass.Id + "|";
                List <ArticleInfo> articleList = ArticleBLL.SearchList(articleSearch);
                if (articleList.Count > 0)
                {
                    url = "/HelpDetail-I" + articleList[0].Id + ".html";
                }
                else
                {
                    url = "/Help-C" + tmpCLass.Id + ".html";
                }
            }
            break;
            }
            return(url);
        }