Ejemplo n.º 1
0
        public static AV GetCloseLibAVModel(AV javBusRecord, Dictionary <string, string> mapping)
        {
            StringBuilder actSb = new StringBuilder();
            StringBuilder dirSb = new StringBuilder();
            StringBuilder comSb = new StringBuilder();
            StringBuilder pubSb = new StringBuilder();
            StringBuilder catSb = new StringBuilder();

            var actArray = javBusRecord.Actress.Split(',');
            var dirArray = javBusRecord.Director.Split(',');
            var comArray = javBusRecord.Company.Split(',');
            var pubArray = javBusRecord.Publisher.Split(',');
            var catArray = javBusRecord.Category.Split(',');

            foreach (var act in actArray)
            {
                if (!string.IsNullOrEmpty(act))
                {
                    if (act.Contains("("))
                    {
                        var  temp    = act.Replace("(", "、").Replace(")", "");
                        var  tempArr = temp.Split('、');
                        bool find    = false;

                        foreach (var split in tempArr)
                        {
                            if (JavDataBaseManager.HasActressByName(split))
                            {
                                actSb.Append(split + ",");
                                find = true;
                                break;
                            }
                        }

                        if (!find)
                        {
                            actSb.Append("[" + temp + "]");
                        }
                    }
                    else
                    {
                        if (JavDataBaseManager.HasActressByName(act))
                        {
                            actSb.Append(act + ",");
                        }
                        else
                        {
                            actSb.Append("[" + act + "]");
                        }
                    }
                }
            }

            foreach (var dir in dirArray)
            {
                if (!string.IsNullOrEmpty(dir))
                {
                    if (JavDataBaseManager.HasDirectorByName(dir))
                    {
                        dirSb.Append(dir + ",");
                    }
                    else
                    {
                        dirSb.Append("[" + dir + "],");
                    }
                }
            }

            foreach (var com in comArray)
            {
                if (!string.IsNullOrEmpty(com))
                {
                    if (JavDataBaseManager.HasCompanyByName(com))
                    {
                        comSb.Append(com + ",");
                    }
                    else
                    {
                        comSb.Append("[" + com + "],");
                    }
                }
            }

            foreach (var pub in pubArray)
            {
                if (!string.IsNullOrEmpty(pub))
                {
                    if (!string.IsNullOrEmpty(pub))
                    {
                        if (JavDataBaseManager.HasCompanyByName(pub))
                        {
                            pubSb.Append(pub + ",");
                        }
                        else
                        {
                            pubSb.Append("[" + pub + "],");
                        }
                    }
                }
            }

            foreach (var cat in catArray)
            {
                if (!string.IsNullOrEmpty(cat))
                {
                    var jianti = FileUtility.GetJianTiStr(cat);

                    if (mapping.ContainsKey(jianti))
                    {
                        var mapStr = mapping[jianti];

                        if (JavDataBaseManager.HasCategoryByName(mapStr))
                        {
                            catSb.Append(mapStr + ",");
                        }
                    }
                    else
                    {
                        catSb.Append("[" + jianti + "],");
                    }
                }
            }

            javBusRecord.Actress   = actSb.ToString();
            javBusRecord.Director  = dirSb.ToString();
            javBusRecord.Company   = comSb.ToString();
            javBusRecord.Publisher = pubSb.ToString();
            javBusRecord.Category  = catSb.ToString();

            return(javBusRecord);
        }