Esempio n. 1
0
        public static string tree2json2(SiteGroupCms.Entity.Catalogtree tree, bool isfirst)
        {
            string respons = String.Empty;

            if (tree != null)
            {
                respons += "{\"catalogid\":" + tree.Id + ",\"id\":" + tree.Id + ",\"text\":" + SiteGroupCms.Utils.fastJSON.JSON.WriteString(tree.Name);   //站点不输出url即不输出连接

                if (tree.HasChild)
                {
                    respons += ",\"children\":[";
                    for (int i = 0; i < tree.SubChild.Count; i++)
                    {
                        respons += tree2json2(tree.SubChild[i], false);
                        if (i != tree.SubChild.Count - 1)
                        {
                            respons += ",";
                        }
                    }
                    respons += "]";
                }
                else
                {
                    respons += "";
                }
                respons += "}";
            }
            return(respons);
        }
Esempio n. 2
0
        public static string tree2json(SiteGroupCms.Entity.Catalogtree tree, bool isfirst)
        {
            string respons = String.Empty;

            if (tree != null)
            {
                if (isfirst)
                {
                    respons += "{text:'" + tree.Name + "',id:'site" + tree.Id + "'";//站点不输出url即不输出连接
                }
                else
                {
                    respons += "{text:'" + tree.Name + "',isexpand:'false',id:'" + tree.Id + "',url:'articlelist.aspx?type=catalog&catalogid=" + tree.Id + "'";
                }
                if (tree.HasChild)
                {
                    respons += ",children:[";
                    for (int i = 0; i < tree.SubChild.Count; i++)
                    {
                        respons += tree2json(tree.SubChild[i], false);
                        if (i != tree.SubChild.Count - 1)
                        {
                            respons += ",";
                        }
                    }
                    respons += "]";
                }
                else
                {
                    respons += "";
                }
                respons += "}";
            }
            return(respons);
        }
Esempio n. 3
0
        private SiteGroupCms.Entity.Catalogtree getTree(string _siteid, string _classid, bool _includechild)
        {
            SiteGroupCms.Entity.Catalogtree _tree = new SiteGroupCms.Entity.Catalogtree();
            SiteGroupCms.Entity.Site        _site = new SiteGroupCms.Dal.SiteDal().GetEntity(Str2Int(_siteid));
            if (_site == null)
            {
                return(null);
            }
            if (_classid == "0")//表示从根节点开始
            {
                _tree.Id   = _site.ID.ToString();
                _tree.Name = _site.Title;
            }
            else
            {
                SiteGroupCms.Entity.Catalog _catalog = new SiteGroupCms.Dal.CatalogDal().GetEntity(_classid);
                SiteGroupCms.Entity.Admin   _admin   = (SiteGroupCms.Entity.Admin)HttpContext.Current.Session["admin"];
                if (_admin.Catalogid.Trim() == "" || ((_admin.Catalogid.IndexOf(_catalog.ID + ",") >= 0) && (_catalog.Father == 0)) || _catalog.Father != 0) //超级管理或者包含该栏目则显示
                {
                    _tree.Id   = _catalog.ID.ToString();
                    _tree.Name = _catalog.Title;
                }
            }

            _tree.HasChild = HasChild(_classid);
            List <SiteGroupCms.Entity.Catalogtree> subtree = new List <SiteGroupCms.Entity.Catalogtree>();

            if (_includechild)
            {
                using (DbOperHandler _doh = new Common().Doh())
                {
                    _doh.Reset();
                    _doh.SqlCmd = "SELECT id FROM [yy_cataloginfo] WHERE [siteid]=" + _siteid + " AND [fatherid]=" + _classid + " order by sort desc";
                    DataTable dtClass = _doh.GetDataTable();
                    for (int i = 0; i < dtClass.Rows.Count; i++)
                    {
                        string _subclassid = dtClass.Rows[i]["Id"].ToString();
                        SiteGroupCms.Entity.Admin _admin = (SiteGroupCms.Entity.Admin)HttpContext.Current.Session["admin"];
                        if (_admin.Catalogid == "" || _admin.Catalogid.IndexOf(_subclassid + ",") >= 0 || _classid != "0")//超级管理或者包含该栏目则显示
                        {
                            subtree.Add(getTree(_siteid, _subclassid, _includechild));
                        }
                    }
                    dtClass.Clear();
                    dtClass.Dispose();
                }
            }
            _tree.SubChild = subtree;
            return(_tree);
        }
Esempio n. 4
0
        /// <summary>
        /// 取出栏目中需要生成的文件的总数目
        /// 包括文字也 栏目页 子集栏目页 和首页
        /// </summary>
        /// <returns></returns>
        public int getcatalogneespublishnum(string catalogid) //catalogid=0 表示从根站点开始
        {
            int total = 1;                                    //当前栏目页

            SiteGroupCms.Entity.Site        _site       = (SiteGroupCms.Entity.Site)HttpContext.Current.Session["site"];
            SiteGroupCms.Entity.Catalogtree catalogtree = getTree(_site.ID.ToString(), catalogid, true);
            //先计算所有需要发布的文档
            total += getpublishcontnum(catalogid);
            //在计算自己栏目
            for (int i = 0; i < catalogtree.SubChild.Count; i++)
            {
                total += getcatalogneespublishnum(catalogtree.SubChild[i].Id);
            }
            return(total);
        }