Exemple #1
0
        private static void UpdateCache()
        {
            if (!CacheTools.HasCache("cache-prefix"))
            {
                var allPrefix = ScanDataBaseManager.GetPrefix().Select(x => x.Prefix).ToList();
                allPrefix = allPrefix.OrderByDescending(x => x.Length).ToList();

                CacheTools.CacheInsert("cache-prefix", allPrefix, DateTime.Now.AddDays(1));
            }
        }
Exemple #2
0
        public static List <AV> GetClosetMatch(string inputName)
        {
            List <AV>     ret = new List <AV>();
            List <string> allPossibleMatch = new List <string>();

            inputName = inputName.ToUpper();

            if (!CacheTools.HasCache("cache-prefix"))
            {
                UpdateCache();
            }

            var allPrefix = CacheTools.GetCache <List <string> >("cache-prefix");

            foreach (var prefix in allPrefix)
            {
                if (inputName.Contains(prefix))
                {
                    var pattern    = prefix + "{1}-?\\d{1,5}";
                    var possibleId = Regex.Match(inputName, pattern).Value;

                    if (possibleId.Contains("-"))
                    {
                        allPossibleMatch.Add(possibleId);
                    }
                    else
                    {
                        bool          isFirst = true;
                        StringBuilder sb      = new StringBuilder();

                        foreach (var c in possibleId)
                        {
                            if (c >= '0' && c <= '9')
                            {
                                if (isFirst)
                                {
                                    sb.Append("-");
                                    isFirst = false;
                                }
                            }
                            sb.Append(c);
                        }

                        allPossibleMatch.Add(sb.ToString());
                    }
                }
            }

            ret = JavDataBaseManager.GetAllAV(allPossibleMatch);
            ret = ret.OrderByDescending(x => x.AvLength).ToList();

            return(ret);
        }
Exemple #3
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());
        }
Exemple #4
0
        public ActionResult GetAv(string search, bool onlyExist = false, string searchType = "all", int page = 1, int pageSize = 20)
        {
            var    scanResult = 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));
            }

            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());
        }