コード例 #1
0
        private void _DoApplySearchResult(MovieFilter filter)
        {
            that.DebugAndLog("frmMovieStat -> DoApplySearchResult()");
            List <MovieProfile> movieList = MovieDB.GetMovieList(filter);

            that.DebugAndLog("Total movie got from MovieDB = " + movieList.Count.ToString());

            string descMovie = "Filter: "
                               + ((filter.NeedCheckCode()) ? ("Code, ") : (""))
                               + ((filter.NeedCheckTitle()) ? ("Title, ") : (""))
                               + ((filter.NeedCheckStory()) ? ("Story, ") : (""))
                               + ((filter.NeedCheckType()) ? ("Type, ") : (""))
                               + ((filter.NeedCheckRating()) ? ("Rating, ") : (""))
                               + ((filter.NeedCheckCountry()) ? ("Country, ") : (""))
                               + ((filter.NeedCheckFileConnect()) ? ("FileConnect, ") : (""))
                               + ((filter.NeedCheckActress()) ? ("Actress, ") : (""))
                               + ((filter.NeedCheckTag()) ? ("Tag, ") : (""))
                               + ((filter.NeedCheckCountPlay()) ? ("CountPlay, ") : (""))
                               + ((filter.NeedCheckFilePath()) ? ("FilePath, ") : (""))
            ;

            __RefreshSearchResult(movieList, descMovie);
        }
コード例 #2
0
ファイル: MovieDB.cs プロジェクト: ptksoft/xDB-Metro
        public static List <MovieProfile> GetMovieList(MovieFilter filter)
        {
            List <MovieProfile> curList = new List <MovieProfile>();

            lock (MovieDB.hMovie.SyncRoot)
            {
                foreach (DictionaryEntry kv in hMovie)
                {
                    curList.Add((MovieProfile)kv.Value);
                }
            }

            if (filter.NeedCheckCode())
            {
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckCode");
                if (filter.IsEmptyCode)
                {
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (!curList[i].Code.Length.Equals(0))
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
                else
                {
                    string keyword = filter.Code.Trim().ToUpper();
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (!curList[i].Code.Contains(keyword))
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
            }
            if (filter.NeedCheckTitle())
            {
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckTitle");
                if (filter.IsEmptyTitle)
                {
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (!curList[i].Title.Length.Equals(0))
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
                else
                {
                    string keyword = filter.Title.Trim();
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (!curList[i].Title.Contains(keyword))
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
            }
            if (filter.NeedCheckStory())
            {
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckStory");
                if (filter.IsEmptyStory)
                {
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (!curList[i].Story.Length.Equals(0))
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
                else
                {
                    string keyword = filter.Story.Trim();
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (!curList[i].Story.Contains(keyword))
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
            }
            if (filter.NeedCheckType())
            {   // Include one of filter.Type
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckType");
                for (int i = curList.Count - 1; i >= 0; i--)
                {
                    if (!filter.Type.Contains(curList[i].Type))
                    {
                        curList.RemoveAt(i);
                    }
                }
            }
            if (filter.NeedCheckRating())
            {   // Include one of filter.Rating
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckRating");
                for (int i = curList.Count - 1; i >= 0; i--)
                {
                    if (!filter.Rating.Contains(curList[i].Rating))
                    {
                        curList.RemoveAt(i);
                    }
                }
            }
            if (filter.NeedCheckCountry())
            {
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckCountry");
                for (int i = curList.Count - 1; i >= 0; i--)
                {
                    if (!filter.Country.Contains(curList[i].Country))
                    {
                        curList.RemoveAt(i);
                    }
                }
            }
            if (filter.NeedCheckActress())
            {   // Find any actress match filter
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckActress");
                if (filter.IsNoActress)
                {
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (curList[i].Actress.Length > 0)
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
                else
                {
                    string[] keywords = filter.Actress.ToArray();
                    for (int i = 0; i < keywords.Length; i++)
                    {
                        keywords[i] = keywords[i].ToUpper();
                    }
                    bool isFound;
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        isFound = false;
                        for (int k = 0; k < keywords.Length; k++)
                        {
                            if (curList[i].FoundActress(keywords[k]))
                            {
                                isFound = true;
                                break;
                            }
                        }
                        if (isFound)
                        {
                            continue;
                        }
                        curList.RemoveAt(i);    // Not Found of any keyword
                    }
                }
            }
            if (filter.NeedCheckTag())
            {
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckTag");
                if (filter.IsNoTag)
                {
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (curList[i].Tag.Length > 0)
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
                else
                {
                    string[] keywords = filter.Tag.ToArray();
                    for (int i = 0; i < keywords.Length; i++)
                    {
                        keywords[i] = keywords[i].ToLower();
                    }
                    bool isFound;
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        isFound = false;
                        for (int k = 0; k < keywords.Length; k++)
                        {
                            if (curList[i].Tag.Contains(keywords[k]))
                            {
                                isFound = true;
                                break;
                            }
                        }
                        if (isFound)
                        {
                            continue;
                        }
                        curList.RemoveAt(i);    // Not Found of any keyword
                    }
                }
            }
            if (filter.NeedCheckFileConnect())
            {
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckFileConnect");
                string[] keywords = filter.FileConnect.ToArray();
                for (int i = 0; i < keywords.Length; i++)
                {
                    keywords[i] = keywords[i].ToUpper();
                }
                bool isFound;
                for (int i = curList.Count - 1; i >= 0; i--)
                {
                    isFound = false;
                    for (int k = 0; k < keywords.Length; k++)
                    {
                        if (curList[i].FileConnect.Equals(keywords[k]))
                        {
                            isFound = true;
                            break;
                        }
                    }
                    if (isFound)
                    {
                        continue;
                    }
                    curList.RemoveAt(i);    // Not found of any keyword
                }
            }
            if (filter.NeedCheckNoFilePath())
            {   // Have no FilePath
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckNoFilePath");
                for (int i = curList.Count - 1; i >= 0; i--)
                {
                    if (curList[i].FilePath.Length > 0)
                    {
                        curList.RemoveAt(i);
                    }
                }
            }
            if (filter.NeedCheckCountPlay())
            {   // Count play in range of Min & Max
                that.DebugAndLog("MovieDB.GetMovieList:: filter->CheckCountPlay");
                if (filter.MinCountPlay.Length > 0)
                {
                    long minPlay = long.Parse(filter.MinCountPlay);
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (curList[i].CountPlay < minPlay)
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
                if (filter.MaxCountPlay.Length > 0)
                {
                    long maxPlay = long.Parse(filter.MaxCountPlay);
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (curList[i].CountPlay > maxPlay)
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
            }
            if (filter.NeedCheckFilePath())
            {   // Check Have FilePath in Last Path
                that.DebugAndLog("MovieDB.GetMovieList:: filter->CheckFilePath");
                string keyword = filter.FilePath.ToLower();
                for (int i = curList.Count - 1; i >= 0; i--)
                {
                    if (!curList[i].FilePath.ToLower().Contains(keyword))
                    {
                        curList.RemoveAt(i);
                    }
                }
            }


            return(curList);
        }