Ejemplo n.º 1
0
        private void PopulateNodes1(TreeNodeCollection nodes, int parent)
        {
            ZhuJi.Portal.IDAL.IChannel          channel = ZhuJi.AOP.Operator.WrapInterface(typeof(ZhuJi.Portal.NHibernateDAL.Channel)) as ZhuJi.Portal.IDAL.IChannel;
            IList <ZhuJi.Portal.Domain.Channel> list    = channel.GetObjects();

            ZhuJi.Portal.Domain.ChannelCollection channels = new ZhuJi.Portal.Domain.ChannelCollection();
            DataTable dt = channels.CreateDateTable(list);

            DataRow[] drs = dt.Select(string.Format("[Parent] = {0}", parent));
            if (drs.Length == 0)
            {
                return;
            }
            else
            {
                foreach (DataRow dr in drs)
                {
                    TreeNode tn = new TreeNode();
                    tn.Text  = dr["Title"].ToString();
                    tn.Value = dr["Id"].ToString();
                    if (dt.Select(string.Format("[Parent] = {0}", tn.Value)).Length > 0)
                    {
                        tn.PopulateOnDemand = true;
                    }
                    tn.NavigateUrl = string.Format("ContentItem.aspx?ChannelId={0}", dr["Id"]);
                    nodes.Add(tn);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 从持久性存储区加载站点地图信息,并在内存中构建它。
        /// </summary>
        /// <returns>站点地图导航结构的根 SiteMapNode</returns>
        public override SiteMapNode BuildSiteMap()
        {
            lock (_lock)
            {
                // 单例模式的实现
                if (_node != null)
                {
                    return(_node);
                }

                try
                {
                    ZhuJi.Portal.IDAL.IChannel channel = ZhuJi.AOP.Operator.WrapInterface(typeof(ZhuJi.Portal.NHibernateDAL.Channel)) as ZhuJi.Portal.IDAL.IChannel;

                    IList <ZhuJi.Portal.Domain.Channel> list = channel.GetObjects("from Channel");

                    if (list.Count > 0)
                    {
                        // 把第一条记录作为根节点添加
                        _node = new SiteMapNode(this, "0", "/", "首页", "首页");
                        _nodes.Add(0, _node);
                        AddNode(_node, null);

                        // 构造节点树
                        for (int i = 0; i < list.Count; i++)
                        {
                            // 在站点地图中增加一个节点
                            SiteMapNode node = CreateSiteMapNode(list[i]);
                            AddNode(node, GetParentNode(list[i]));
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw (ex);
                }

                // 返回SiteMapNode
                return(_node);
            }
        }
Ejemplo n.º 3
0
        private void PopulateNodes(TreeNodeCollection nodes, int parent)
        {
            try
            {
                ZhuJi.Portal.IDAL.IChannel          channel = ZhuJi.AOP.Operator.WrapInterface(typeof(ZhuJi.Portal.NHibernateDAL.Channel)) as ZhuJi.Portal.IDAL.IChannel;
                IList <ZhuJi.Portal.Domain.Channel> list    = channel.GetObjects();

                ZhuJi.Portal.Domain.ChannelCollection channels = new ZhuJi.Portal.Domain.ChannelCollection();
                DataTable dt = channels.CreateDateTable(list);

                DataRow[] drs = dt.Select(string.Format("[Parent] = {0}", parent));
                if (drs.Length == 0)
                {
                    return;
                }
                else
                {
                    foreach (DataRow dr in drs)
                    {
                        TreeNode tn = new TreeNode();
                        tn.Text  = string.Format("{0}({1})", dr["Title"].ToString(), dr["Id"].ToString());
                        tn.Value = dr["Id"].ToString();
                        if (dt.Select(string.Format("[Parent] = {0}", tn.Value)).Length > 0)
                        {
                            tn.PopulateOnDemand = true;
                        }
                        tn.SelectAction = TreeNodeSelectAction.Expand;
                        nodes.Add(tn);
                    }
                }
            }
            catch (Exception ex)
            {
                ShowMessage(ex);
            }
        }