/// <summary> /// 获取单个图站Post预览信息 /// </summary> /// <param name="customSQL">自定义SQL</param> /// <param name="inputTags">未经处理的标签</param> /// <param name="column">按此列排序</param> /// <param name="site">图站</param> /// <param name="ratingArray">分级</param> /// <returns></returns> private static List <PostPreviewInfo> GetOneSitePostPreview(string customSQL, string inputTags, Site site, PostOrderBy column, Rating[] ratingArray) { string treatedTags = Tag.TreatInputTags(inputTags); DataTable dt = DAL.Post.SelectPostPreviewList(customSQL, treatedTags, site, column, ratingArray); return(PostPreviewInfo.Convert(dt)); }
/// <summary> /// 获取单个图站PoolPosts信息 /// </summary> /// <param name="pool_id"></param> /// <param name="orderMode"></param> /// <param name="preferArray"></param> /// <param name="site"></param> /// <returns></returns> public static List <PostPreviewInfo> GetOneSitePoolPostsPreview(int pool_id, Site site) { DataTable dt = DAL.Pool.SelectPoolPostsPreviewList(pool_id, site); IEnumerable <PostPreviewInfo> temp = PostPreviewInfo.Convert(dt); //排序 temp = temp.OrderBy(c => c.order_column); return(temp.ToList()); }
/// <summary> /// 获取Post预览图 /// </summary> /// <param name="previewInfoList">预览信息列表</param> /// <returns></returns> public static List <PostPreviewInfo> GetPreviewImage(List <PostPreviewInfo> previewInfoList) { //按md5首位分类 var md5LookUp = previewInfoList.Select(a => a.file_md5).ToLookup(b => b.Substring(0, 1)); //多线程查询结果集 IEnumerable <KeyValuePair <string, byte[]> > result = new Dictionary <string, byte[]>(); //根据查询图站数量创建线程 Task <Dictionary <string, byte[]> >[] tasks = new Task <Dictionary <string, byte[]> > [md5LookUp.Count]; int x = 0; foreach (var md5Group in md5LookUp) { tasks[x] = new Task <Dictionary <string, byte[]> >(p => { return(GetPreviewImageByGroup((IGrouping <string, string>)p)); }, md5Group); x++; } //开启多线程查询 foreach (var t in tasks) { t.Start(); } Task.WaitAll(tasks); //合并多线程结果集 foreach (var t in tasks) { result = result.Concat(t.Result); } return(PostPreviewInfo.AddPreview(previewInfoList, result.ToDictionary(k => k.Key, v => v.Value))); }
/// <summary> /// 获取Post偏好 /// </summary> /// <param name="mode">模式</param> /// <param name="preferArray">前端所选偏好</param> /// <returns></returns> internal static List <PostPreviewInfo> GetPostPrefer(Prefer[] preferArray) { List <Prefer> selected = new List <Prefer>(); if (preferArray == null || preferArray.Length == 0 || preferArray.Length == 3) { return(null); } if (preferArray.Contains(Prefer.Normal)) { if (preferArray.Contains(Prefer.Bad) == false) { selected.Add(Prefer.Bad); } if (preferArray.Contains(Prefer.Good) == false) { selected.Add(Prefer.Good); } } else { if (preferArray.Contains(Prefer.Bad)) { selected.Add(Prefer.Bad); } if (preferArray.Contains(Prefer.Good)) { selected.Add(Prefer.Good); } } DataTable dt = DAL.Preference.SelectPreferMD5(Mode.Posts, selected.ToArray()); return(PostPreviewInfo.Convert(dt)); }