示例#1
0
文件: DB_RecLog.cs 项目: xceza7/EDCB
        public List <RecLogItem> search_Like(SqlCommand cmd0, string searchWord0, RecLogItem.RecodeStatuses recodeStatuse0, searchColumns searchColumn0 = searchColumns.title,
                                             int count0 = 50, EpgContentInfo epgContentInfo0 = null)
        {
            List <string> searchWordList1 = getSearchWordList(searchWord0);
            StringBuilder sb1             = new StringBuilder();

            foreach (var item1 in searchWordList1)
            {
                string        likeWord1    = " LIKE " + createTextValue("%" + item1 + "%");
                List <string> searchWords1 = new List <string>();
                if (searchColumn0.HasFlag(searchColumns.title))
                {
                    searchWords1.Add(DB_EpgEventInfo.TABLE_NAME_ABBR + "." + DB_EpgEventInfo.COLUMN_ShortInfo_event_name + likeWord1);
                }
                if (searchColumn0.HasFlag(searchColumns.content))
                {
                    searchWords1.Add(DB_EpgEventInfo.TABLE_NAME_ABBR + "." + DB_EpgEventInfo.COLUMN_ShortInfo_text_char + likeWord1);
                    searchWords1.Add(DB_EpgEventInfo.TABLE_NAME_ABBR + "." + DB_EpgEventInfo.COLUMN_ExtInfo_text_char + likeWord1);
                }
                if (searchColumn0.HasFlag(searchColumns.comment))
                {
                    searchWords1.Add(TABLE_NAME_ABBR + "." + COLUMN_comment + likeWord1);
                }
                if (searchColumn0.HasFlag(searchColumns.recFilePath))
                {
                    searchWords1.Add(TABLE_NAME_ABBR + "." + COLUMN_RecFilePath + likeWord1);
                }
                StringBuilder sb2 = new StringBuilder();
                foreach (var item2 in searchWords1)
                {
                    if (0 < sb2.Length)
                    {
                        sb2.Append(" OR ");
                    }
                    sb2.Append(item2);
                }
                //
                if (0 < sb1.Length)
                {
                    sb1.Append(" AND ");
                }
                sb1.Append(sb2.ToString());
            }
            return(seach(sb1.ToString(), recodeStatuse0, count0, cmd0, epgContentInfo0));
        }
示例#2
0
文件: DB_RecLog.cs 项目: xceza7/EDCB
        public static string getSearchWordQuery_Fulltext(searchColumns searchColumn0, List <string> searchWordList0, bool isFreetext0)
        {
            if (searchWordList0.Count == 0)
            {
                return(null);
            }
            //
            string freetextOrContains1 = "CONTAINS";

            if (isFreetext0)
            {
                freetextOrContains1 = "FREETEXT";
            }
            // フルテキスト・サーチでエラーになる文字を削除(空白文字に置換え)
            char[]        removeChars1 = new char[] { '!', '(', ')', ',' };
            StringBuilder sb1          = new StringBuilder();

            foreach (var item in searchWordList0)
            {
                string word1 = item;
                foreach (var c1 in removeChars1)
                {
                    word1 = word1.Replace(c1, ' ');
                }
                if (0 < sb1.Length)
                {
                    sb1.Append(" AND ");
                }
                sb1.Append('"' + word1 + '"');
            }
            string        searchWord2 = createTextValue(sb1.ToString());
            StringBuilder query1      = new StringBuilder();

            {
                List <string> columList1 = new List <string>();
                if (searchColumn0.HasFlag(searchColumns.title))
                {
                    columList1.Add(DB_EpgEventInfo.TABLE_NAME_ABBR + "." + DB_EpgEventInfo.COLUMN_ShortInfo_event_name);
                }
                if (searchColumn0.HasFlag(searchColumns.content))
                {
                    columList1.Add(DB_EpgEventInfo.TABLE_NAME_ABBR + "." + DB_EpgEventInfo.COLUMN_ShortInfo_text_char);
                    columList1.Add(DB_EpgEventInfo.TABLE_NAME_ABBR + "." + DB_EpgEventInfo.COLUMN_ExtInfo_text_char);
                }
                if (0 < columList1.Count)
                {
                    StringBuilder sb_Colum1 = new StringBuilder();
                    foreach (var item in columList1)
                    {
                        if (0 < sb_Colum1.Length)
                        {
                            sb_Colum1.Append(", ");
                        }
                        sb_Colum1.Append(item);
                    }
                    query1.Append(freetextOrContains1 + "((" + sb_Colum1.ToString() + "), " + searchWord2 + ")");
                }
            }
            {
                List <string> columList_RecLog1 = new List <string>();
                if (searchColumn0.HasFlag(searchColumns.comment))
                {
                    columList_RecLog1.Add(TABLE_NAME_ABBR + "." + COLUMN_comment);
                }
                if (searchColumn0.HasFlag(searchColumns.recFilePath))
                {
                    columList_RecLog1.Add(TABLE_NAME_ABBR + "." + COLUMN_RecFilePath);
                }
                if (0 < columList_RecLog1.Count)
                {
                    StringBuilder sb_Colum_RecLog1 = new StringBuilder();
                    foreach (var item in columList_RecLog1)
                    {
                        if (0 < sb_Colum_RecLog1.Length)
                        {
                            sb_Colum_RecLog1.Append(", ");
                        }
                        sb_Colum_RecLog1.Append(item);
                    }
                    if (0 < query1.Length)
                    {
                        query1.Append(" OR ");
                    }
                    query1.Append(freetextOrContains1 + "((" + sb_Colum_RecLog1.ToString() + "), " + searchWord2 + ")");
                }
            }

            return(query1.ToString());
        }
示例#3
0
文件: DB_RecLog.cs 项目: xceza7/EDCB
        /// <summary>
        /// フルテキストのFREETEXTで得た結果をRegexで絞り込む
        /// </summary>
        /// <param name="searchWord0"></param>
        /// <param name="recodeStatuse0"></param>
        /// <param name="searchColumn0"></param>
        /// <param name="count0"></param>
        /// <returns></returns>
        public List <RecLogItem> search_Fulltext_Freetext_Regex(string searchWord0, RecLogItem.RecodeStatuses recodeStatuse0,
                                                                searchColumns searchColumn0 = searchColumns.title, int count0 = 50, EpgContentInfo epgContentInfo0 = null)
        {
            List <RecLogItem> recLogItemList1 = new List <RecLogItem>();

            List <string> searchWordList1 = new List <string>()
            {
                searchWord0
            };
            string searchWordQuery_Fulltext1 = getSearchWordQuery_Fulltext(searchColumn0, searchWordList1, true);

            List <RecLogItem> recLogItemList2 = new List <RecLogItem>();

            try
            {
                using (SqlConnection sqlConn1 = new SqlConnection(sqlConnStr))
                {
                    sqlConn1.Open();
                    using (SqlCommand cmd1 = sqlConn1.CreateCommand())
                    {
                        recLogItemList2 = seach(searchWordQuery_Fulltext1, recodeStatuse0, count0, cmd1, epgContentInfo0);
                    }
                }
            }
            catch (Exception ex0)
            {
                System.Diagnostics.Trace.WriteLine(ex0);
            }

            List <string> searchWordList2  = getSearchWordList(searchWord0);
            List <Regex>  searchRegexList2 = new List <Regex>();

            foreach (var item in searchWordList2)
            {
                searchRegexList2.Add(new Regex(item));
            }
            foreach (var recLogItem1 in recLogItemList2)
            {
                List <string> textList1 = new List <string>();
                if (searchColumn0.HasFlag(searchColumns.title))
                {
                    textList1.Add(recLogItem1.tvProgramTitle);
                }
                if (searchColumn0.HasFlag(searchColumns.content))
                {
                    textList1.Add(recLogItem1.tvProgramSummary);
                }
                if (searchColumn0.HasFlag(searchColumns.comment))
                {
                    textList1.Add(recLogItem1.comment);
                }
                if (searchColumn0.HasFlag(searchColumns.recFilePath))
                {
                    textList1.Add(recLogItem1.recFilePath);
                }
                foreach (var text1 in textList1)
                {
                    int matchCnt1 = 0;
                    foreach (var rgx1 in searchRegexList2)
                    {
                        if (rgx1.IsMatch(text1))
                        {
                            matchCnt1++;
                        }
                    }
                    if (matchCnt1 == searchRegexList2.Count)
                    {
                        recLogItemList1.Add(recLogItem1);
                        break;
                    }
                }
            }

            return(recLogItemList1);
        }