Exemple #1
0
        /// <summary>
        /// 获取Pool预览图
        /// </summary>
        /// <param name="previewInfoList">预览信息列表</param>
        /// <returns></returns>
        public static List <PoolPreviewInfo> GetPreviewImage(List <PoolPreviewInfo> 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(PoolPreviewInfo.AddPreview(previewInfoList, result.ToDictionary(k => k.Key, v => v.Value)));
        }
Exemple #2
0
        /// <summary>
        /// 获取Pool偏好
        /// </summary>
        /// <param name="mode">模式</param>
        /// <param name="preferArray">前端所选偏好</param>
        /// <returns></returns>
        internal static List <PoolPreviewInfo> GetPoolPrefer(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(PoolPreviewInfo.Convert(dt));
        }
Exemple #3
0
        /// <summary>
        /// 获取单个图站Pool预览信息
        /// </summary>
        /// <param name="inputName">用户输入的名称</param>
        /// <param name="site">图站</param>
        /// <param name="column">按此列排序</param>
        /// <param name="ratingArray">分级</param>
        /// <returns></returns>
        private static List <PoolPreviewInfo> GetOneSitePoolPreview(string inputName, Site site, PoolOrderBy column, Rating[] ratingArray)
        {
            DataTable dt = DAL.Pool.SelectPoolPreviewList(inputName, site, column, ratingArray);

            return(PoolPreviewInfo.Convert(dt, site));
        }