Exemplo n.º 1
0
        public ActionResult Catelog(int limitGiga = 0, int page = 1, int pageSize = 200)
        {
            var    scanResult = new List <ScanResult>();
            var    toBe       = new List <ScanResult>();
            string scanCache  = "scan";

            if (CacheTools.HasCache(scanCache))
            {
                scanResult = CacheTools.GetCache <List <ScanResult> >(scanCache);
            }
            else
            {
                scanResult = ScanDataBaseManager.GetMatchScanResult();
                CacheTools.CacheInsert(scanCache, scanResult, DateTime.Now.AddHours(3));
            }

            scanResult = scanResult.Where(x => !string.IsNullOrEmpty(x.Location)).ToList();

            if (limitGiga > 0)
            {
                double limit = (double)limitGiga * 1024 * 1024 * 1024;
                ApplicationLog.Debug("catelog -> limitGiga: " + limitGiga + " limit: " + limit);
                ApplicationLog.Debug("catelog -> beforeCount: " + scanResult.Count);

                foreach (var s in scanResult)
                {
                    if (new FileInfo(s.AvFilePath).Length >= limit)
                    {
                        toBe.Add(s);
                    }
                }

                ApplicationLog.Debug("catelog -> afterCount: " + toBe.Count);
            }
            else
            {
                toBe = scanResult;
            }

            var pageContent = toBe.OrderByDescending(x => x.ReleaseDate).Skip((page - 1) * pageSize).Take(pageSize).ToList();

            ViewData.Add("avs", pageContent);
            ViewData.Add("count", (int)Math.Ceiling((decimal)toBe.Count / pageSize));
            ViewData.Add("size", pageSize);
            ViewData.Add("current", page);
            ViewData.Add("total", toBe.Count);
            ViewData.Add("limit", limitGiga);

            return(View());
        }
Exemplo n.º 2
0
        public ActionResult Av(int avId)
        {
            var av    = JavDataBaseManager.GetAV(avId);
            var match = ScanDataBaseManager.GetMatchScanResult(avId);

            if (av == null)
            {
                av = new AV();
            }

            if (match == null)
            {
                match = new ScanResult();
            }

            ViewData.Add("av", av);
            ViewData.Add("match", match);

            return(View());
        }
Exemplo n.º 3
0
        private static void TestScanMatchResult()
        {
            var res = ScanDataBaseManager.GetMatchScanResult();

            var actressDic  = new Dictionary <string, List <ScanResult> >();
            var categoryDic = new Dictionary <string, List <ScanResult> >();
            var prefixDic   = res.GroupBy(x => x.Prefix).ToDictionary(x => x.Key, x => x.ToList());

            foreach (var r in res)
            {
                foreach (var category in r.CategoryList)
                {
                    if (categoryDic.ContainsKey(category))
                    {
                        categoryDic[category].Add(r);
                    }
                    else
                    {
                        categoryDic.Add(category, new List <ScanResult> {
                            r
                        });
                    }
                }

                foreach (var actress in r.ActressList)
                {
                    if (actressDic.ContainsKey(actress))
                    {
                        actressDic[actress].Add(r);
                    }
                    else
                    {
                        actressDic.Add(actress, new List <ScanResult> {
                            r
                        });
                    }
                }
            }
        }
Exemplo n.º 4
0
        public ActionResult GetAv(string search, bool onlyExist = false, string searchType = "all", int page = 1, int pageSize = 20)
        {
            var scanResult = new List <ScanResult>();

            scanResult = ScanDataBaseManager.GetMatchScanResult();

            if (onlyExist)
            {
                scanResult = scanResult.Where(x => !string.IsNullOrEmpty(x.Location)).ToList();
            }

            var toBePlay = new List <ScanResult>();
            List <ScanResult> namePlay     = new List <ScanResult>();
            List <ScanResult> actressPlay  = new List <ScanResult>();
            List <ScanResult> categoryPlay = new List <ScanResult>();
            List <ScanResult> prefixPlay   = new List <ScanResult>();
            List <ScanResult> direPlay     = new List <ScanResult>();

            if (searchType == "all" || searchType == "id")
            {
                foreach (var r in scanResult)
                {
                    if (r.AvId == search.ToUpper())
                    {
                        toBePlay.Add(r);
                    }
                }
            }

            if (searchType == "all" || searchType == "actress")
            {
                foreach (var r in scanResult)
                {
                    foreach (var ac in r.ActressList)
                    {
                        if (ac.Contains(search))
                        {
                            toBePlay.Add(r);
                        }
                    }
                }
            }

            if (searchType == "all" || searchType == "category")
            {
                foreach (var r in scanResult)
                {
                    foreach (var ca in r.CategoryList)
                    {
                        if (ca.Contains(search))
                        {
                            toBePlay.Add(r);
                        }
                    }
                }
            }

            if (searchType == "all" || searchType == "prefix")
            {
                foreach (var r in scanResult)
                {
                    if (r.Prefix.Contains(search.ToUpper()))
                    {
                        toBePlay.Add(r);
                    }
                }
            }

            if (searchType == "all" || searchType == "director")
            {
                foreach (var r in scanResult)
                {
                    if (r.Director.Contains(search))
                    {
                        toBePlay.Add(r);
                    }
                }
            }

            var pageContent = toBePlay.OrderByDescending(x => x.ReleaseDate).Skip((page - 1) * pageSize).Take(pageSize).ToList();

            ViewData.Add("avs", pageContent);
            ViewData.Add("search", search);
            ViewData.Add("count", (int)Math.Ceiling((decimal)toBePlay.Count / pageSize));
            ViewData.Add("size", pageSize);
            ViewData.Add("current", page);
            ViewData.Add("total", toBePlay.Count);

            return(View());
        }