public DataCollection GetDataSource()
        {
            DataCollection dt = new DataCollection();

            if (GetSourceEvent != null)
            {
                GetSourceEvent(ref dt, WebPart.BlockKey);
            }
            else
            {
                string sql = WebPart.RepeatDataDataSql;
                sql = sql.Replace("[UserId]", UserId);

                /*ISession sess = ActiveRecordMediator.GetSessionFactoryHolder().CreateSession(typeof(ActiveRecordBase));
                 *
                 * // Now you can use sess.DbConnection
                 * //sess.Connection.CreateCommand();
                 * SqlDataAdapter sda = new SqlDataAdapter(sql, sess.Connection.ConnectionString);
                 * DataSet ds = new DataSet();
                 * sda.Fill(ds);
                 * ActiveRecordMediator.GetSessionFactoryHolder().ReleaseSession(sess);
                 * dt = CommonDataHelper.DataTableToDataCollection(ds.Tables[0]);
                 * sda.Dispose();
                 * ds.Dispose();*/
                dt = CommonDataHelper.DataTableToDataCollection(DataHelper.QueryDataTable(sql));
            }
            return(dt);
        }
        //获取所有版块
        public static string GetAllBlockNames(string userId, string blockType, string templateId, string isManage, string DBName)
        {
            string temp     = @"<div align='left' class='panelcon'>
					<img src='{2}' align='absmiddle' class='panelicon'>{1} <img src='/Modules/WebPart/add2.gif' align='absmiddle' class='paneladdimg' onclick=addBlock('{0}','{1}');>
				</div>
				"                ;
            string tempDept = @"<div align='left' class='panelcon'>
					<img src='{2}' align='absmiddle' class='panelicon'><font color='blue'>{1}</font> <img src='/Modules/WebPart/add2.gif' align='absmiddle' class='paneladdimg' onclick=addBlock('{0}','{1}');>
				</div>
				"                ;
            string html     = "";

            /*string sql = "select Id,BlockTitle,BlockImage,BlockType from DoorBlock where IsHidden='F' and BlockType='"+blockType+"'";
             * if ( blockType == "Dept" )
             *  sql = "select Id,BlockTitle,BlockImage,BlockType from DoorBlock where IsHidden='F' and (BlockType='Portal' OR (BlockType='"+blockType+"' and TemplateId = '"+templateId+"'))";
             */
            /*string sql = "SELECT Id,BlockTitle,BlockImage,BlockType FROM DoorBlock DB WHERE IsHidden='F' AND BlockType='Portal' OR "+
             *  "EXISTS( SELECT * FROM " + DBName + "..NewsType PIC WHERE DB.BlockKey = PIC.Id AND ( PIC.AllowQueryId IS NULL OR PIC.AllowQueryId = '' OR PIC.AllowQueryId LIKE '%" + userId + "%' OR " +
             *  "EXISTS( SELECT * FROM OgUserProperty WHERE PATINDEX ( '%,'+Property+',%' , ','+REPLACE(PIC.AllowQueryId,'_',',')+',' ) > 0 AND LEN(Property)>0 AND UserId = '"+userId+"') ) ) ORDER BY BlockType DESC,BlockTitle";*/
            string sql = "SELECT Id,BlockTitle,BlockImage,BlockType FROM WebPart where isHidden=0";

            if (blockType != null && blockType.Trim() != "")
            {
                sql = "SELECT Id,BlockTitle,BlockImage,BlockType FROM WebPart where isHidden=0 and BlockType='" + blockType + "'";
            }
            if (HttpContext.Current.Request["DeptId"] != null && HttpContext.Current.Request["DeptId"].Trim() != "")
            {
                sql  = "SELECT Id,BlockTitle,BlockImage,BlockType FROM WebPart where isHidden=0 ";
                sql += " and (DeptId  like '%" + HttpContext.Current.Request["DeptId"] + "%' or isnull(DeptId,'')='')";
            }

            /* ISession sess = ActiveRecordMediator.GetSessionFactoryHolder().CreateSession(typeof(ActiveRecordBase));
             * SqlDataAdapter sda = new SqlDataAdapter(sql, sess.Connection.ConnectionString);
             * DataTable ds = new DataTable();
             * sda.Fill(ds);
             * ActiveRecordMediator.GetSessionFactoryHolder().ReleaseSession(sess);*/
            DataTable      ds   = DataHelper.QueryDataTable(sql);
            DataCollection list = CommonDataHelper.DataTableToDataCollection(ds);

            ds.Dispose();
            //sda.Dispose();
            foreach (DataElement item in list.GetElements(""))
            {
                if (item.GetAttr("BlockType") == "Dept")
                {
                    html += string.Format(tempDept, item.GetAttr("Id"), item.GetAttr("BlockTitle"), item.GetAttr("BlockImage"));
                }
                else
                {
                    html += string.Format(temp, item.GetAttr("Id"), item.GetAttr("BlockTitle"), item.GetAttr("BlockImage"));
                }
            }
            return(html);
        }