public List <DigitalContentEntity> GetDigitalContentList(string category, string type, string searchName, string sort, string order, int offset, int pageSize, out int totalCount) { totalCount = 0; List <DigitalContentEntity> list = new List <DigitalContentEntity>(); string rootPath = DigitalContentRootPath; if (Directory.Exists(rootPath)) { string[] digitalContentList = Directory.GetFiles(Path.Combine(rootPath, category)); foreach (string fileName in digitalContentList) { DigitalContentEntity digitalContentEntity = new DigitalContentEntity() { Category = category, Type = GetFileType(Path.GetExtension(fileName)), Name = Path.GetFileNameWithoutExtension(fileName), Path = "http://" + WebHost + "/CEA_EDU/DigitalContent/GetByPath?path=" + Server.UrlEncode(fileName.Replace(Path.Combine(rootPath), "")) }; list.Add(digitalContentEntity); } if (!string.IsNullOrWhiteSpace(searchName)) { list = list.Where(r => r.Name.Contains(searchName)).ToList(); } totalCount = list.Count; if (sort == "Type") { list = list.OrderBy(r => r.Type).Skip(offset).Take(pageSize).ToList(); if (order == "desc") { list = list.OrderByDescending(r => r.Type).Skip(offset).Take(pageSize).ToList(); } } else { list = list.OrderBy(r => r.Name).Skip(offset).Take(pageSize).ToList(); if (order == "desc") { list = list.OrderByDescending(r => r.Name).Skip(offset).Take(pageSize).ToList(); } } } return(list); }
public List <DigitalContentEntity> GetDigitalContentList(string category, string type) { List <DigitalContentEntity> list = new List <DigitalContentEntity>(); string rootPath = DigitalContentRootPath; if (Directory.Exists(rootPath)) { string[] digitalContentList = Directory.GetFiles(Path.Combine(rootPath, category)); foreach (string fileName in digitalContentList) { DigitalContentEntity digitalContentEntity = new DigitalContentEntity() { Category = category, Type = GetFileType(Path.GetExtension(fileName)), Name = Path.GetFileNameWithoutExtension(fileName), Path = "http://" + WebHost + "/CEA_EDU/DigitalContent/GetByPath?path=" + Server.UrlEncode(fileName.Replace(Path.Combine(rootPath), "")) }; if (type == digitalContentEntity.Type.ToString()) { list.Add(digitalContentEntity); if (type == "2") { //视频缩略图路径 string smallImagePath = Path.Combine(ArticlePictureRootPath, "公司和校园视频缩略图\\" + (category == "公司介绍" ? "company_" : "school_") + Path.GetFileNameWithoutExtension(fileName) + ".jpg"); //获取视频缩略图 smallImagePath = VideoThumbnailUtility.CatchImg(fileName, smallImagePath, 560, 500); if (string.IsNullOrWhiteSpace(smallImagePath)) { digitalContentEntity.SmallImage = "../FlatLab/img/company.jpg";//无法生成时显示的图片 } else { //设置缩略图 digitalContentEntity.SmallImage = "http://" + WebHost + "/CEA_EDU/DigitalContent/GetArticlePictureByPath?path=" + Server.UrlEncode(smallImagePath.Replace(Path.Combine(ArticlePictureRootPath), "")); } } } } } return(list); }