/// <summary>
        /// 根据分类获取附件
        /// </summary>
        /// <param name="typeId">分类id</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public List <AppendixByLike_Result> GetFileListByTypeId(string typeId, string like, string sequence, int pagesize, int pagecurrent, JSZX_ResourceEntities db)
        {
            List <AppendixByLike_Result> appList = new List <AppendixByLike_Result>();
            string typeStr = GetTypeCondition(db, typeId);

            DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd"));

            var query = from t in db.AppendixByLike(like, dt) where typeStr.Contains(t.TYPE_ID) select t;

            #region 排序
            if (sequence == "1")
            {
                query = query.OrderByDescending(t => t.REVIEW_NUM).OrderByDescending(t => t.num);
            }
            else if (sequence == "2")
            {
                query = query.OrderByDescending(t => t.PRAISE_PRE).OrderByDescending(t => t.num);
            }
            else if (sequence == "3")
            {
                query = query.OrderByDescending(t => t.PAGE_VIEW_NUM).OrderByDescending(t => t.num);
            }
            else if (sequence == "4")
            {
                query = query.OrderByDescending(t => t.DOWNLOAD_NUM).OrderByDescending(t => t.num);
            }
            else
            {
                query = query.OrderByDescending(t => t.UPLOAD_TIME).OrderByDescending(t => t.num);
            }
            #endregion
            appList = query.Select(t => t).Skip((pagecurrent - 1) * pagesize).Take(pagesize).ToList();
            return(appList);
        }
        /// <summary>
        /// 根据分类获取附件总件数
        /// </summary>
        /// <param name="typeId">分类id</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public int GetFileSizeByTypeId(string typeId, string like, JSZX_ResourceEntities db)
        {
            DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd"));

            string typeStr = GetTypeCondition(db, typeId);
            var    query   = from t in db.AppendixByLike(like, dt) where typeStr.Contains(t.TYPE_ID) select t;

            return(query.Count());
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="typeFlg"></param>
        /// <param name="userId"></param>
        /// <param name="orderBy"></param>
        /// <param name="pagesize"></param>
        /// <param name="pagecurrent"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public List <AppendixByLike_Result> GetAppendList(string typeFlg, string like, string userId, string orderBy, int pagesize, int pagecurrent, JSZX_ResourceEntities db)
        {
            List <AppendixByLike_Result> list = new List <AppendixByLike_Result>();

            DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd"));

            var query = from t in db.AppendixByLike(like, dt) select t;

            // 资源类型
            if (!string.IsNullOrEmpty(typeFlg))
            {
                query = query.Where(t => typeFlg.Contains(t.TYPE_FLG));
            }
            //登录用户的文库
            if (!string.IsNullOrEmpty(userId))
            {
                query = query.Where(t => t.UserID.Contains(userId));
            }
            #region 排序
            if (orderBy == "1")
            {
                //评价次数
                query = query.OrderByDescending(t => t.REVIEW_NUM).OrderByDescending(t => t.num).Select(t => t).Skip((pagecurrent - 1) * pagesize).Take(pagesize);
            }
            else if (orderBy == "2")
            {
                //最受好评
                query = query.OrderByDescending(t => t.GRADE).OrderByDescending(t => t.num).Select(t => t).Skip((pagecurrent - 1) * pagesize).Take(pagesize);
            }
            else if (orderBy == "3")
            {
                //最多浏览
                query = query.OrderByDescending(t => t.PAGE_VIEW_NUM).OrderByDescending(t => t.num).Select(t => t).Skip((pagecurrent - 1) * pagesize).Take(pagesize);
            }
            else if (orderBy == "4")
            {
                //最多下载
                query = query.OrderByDescending(t => t.DOWNLOAD_NUM).OrderByDescending(t => t.num).Select(t => t).Skip((pagecurrent - 1) * pagesize).Take(pagesize);
            }
            else if (orderBy == "5")
            {
                //最新上传
                query = query.OrderByDescending(t => t.UPLOAD_TIME).OrderByDescending(t => t.num).Select(t => t).Skip((pagecurrent - 1) * pagesize).Take(pagesize);
            }
            else
            {
                query = query.OrderByDescending(t => t.num).Select(t => t).Skip((pagecurrent - 1) * pagesize).Take(pagesize);
            }
            #endregion
            list = query.ToList();
            return(list);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="typeFlg"></param>
        /// <param name="userId"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public int GetAppendListCount(string typeFlg, string like, string userId, JSZX_ResourceEntities db)
        {
            DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd"));

            var query = from t in db.AppendixByLike(like, dt) select t;

            // 资源类型(0:文档 1:视频, 2:图片)
            if (!string.IsNullOrEmpty(typeFlg))
            {
                query = query.Where(t => typeFlg.Contains(t.TYPE_FLG));
            }
            //登录用户的文库
            if (!string.IsNullOrEmpty(userId))
            {
                query = query.Where(t => t.UserID.Contains(userId));
            }
            return(query.Count());
        }
        /// <summary>
        /// 根据关键字检索
        /// </summary>
        /// <param name="keyword">关键字</param>
        /// <param name="pagesize">总页数</param>
        /// <param name="pagecurrent">跳转页</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public List <AppendixByLike_Result> GetAppendixListByKeyword(string keyword, string fileType, string orderBy, int pagesize, int pagecurrent, JSZX_ResourceEntities db)
        {
            List <AppendixByLike_Result> list = new List <AppendixByLike_Result>();
            DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd"));

            var query = from t in db.AppendixByLike(keyword, dt) select t;

            if (!string.IsNullOrEmpty(fileType))
            {
                if (fileType == "video")
                {
                    query = query.Where(t => t.TYPE_FLG == "1");
                }
                else
                {
                    query = query.Where(t => t.TYPE_FLG == "0" && t.FILE_NAME.Contains(fileType));
                }
            }
            #region 排序
            if (orderBy == "1")
            {
                query = query.OrderByDescending(t => t.REVIEW_NUM).OrderByDescending(t => t.num);
            }
            else if (orderBy == "2")
            {
                query = query.OrderByDescending(t => t.GRADE).OrderByDescending(t => t.num);
            }
            else if (orderBy == "3")
            {
                query = query.OrderByDescending(t => t.PAGE_VIEW_NUM).OrderByDescending(t => t.num);
            }
            else if (orderBy == "4")
            {
                query = query.OrderByDescending(t => t.DOWNLOAD_NUM).OrderByDescending(t => t.num);
            }
            else
            {
                query = query.OrderByDescending(t => t.UPLOAD_TIME).OrderByDescending(t => t.num);
            }
            #endregion
            list = query.Select(t => t).Skip((pagecurrent - 1) * pagesize).Take(pagesize).ToList();
            return(list);
        }
        /// <summary>
        /// 根据关键字检索出的总数
        /// </summary>
        /// <param name="keyword">关键字</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public int GetAppendixSizeByKeyword(string keyword, string fileType, JSZX_ResourceEntities db)
        {
            DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd"));

            var query = from t in db.AppendixByLike(keyword, dt) select t;

            if (!string.IsNullOrEmpty(fileType))
            {
                if (fileType == "video")
                {
                    query = query.Where(t => t.TYPE_FLG == "1");
                }
                else
                {
                    query = query.Where(t => t.TYPE_FLG == "0" && t.FILE_NAME.Contains(fileType));
                }
            }
            return(query.Count());
        }
        /// <summary>
        /// 拼接sql
        /// </summary>
        /// <param name="keyword">关键字</param>
        /// <param name="db"></param>
        /// <returns></returns>
        private IEnumerable <AppendixByLike_Result> getSql(string keyword, string filetype, JSZX_ResourceEntities db)
        {
            DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd"));

            var query = from t in db.AppendixByLike(keyword, dt) select t;

            if (!string.IsNullOrEmpty(filetype))
            {
                if (filetype == "video")
                {
                    query = query.Where(t => t.TYPE_FLG == "1");
                }
                else
                {
                    query = query.Where(t => t.TYPE_FLG == "0" && t.FILE_NAME.Contains(filetype));
                }
            }
            return(query);
        }