public void Insert(KeywordMatchInfo matchInfo) { var sqlString = "INSERT INTO wx_KeywordMatch (PublishmentSystemID, Keyword, KeywordID, IsDisabled, KeywordType, MatchType) VALUES (@PublishmentSystemID, @Keyword, @KeywordID, @IsDisabled, @KeywordType, @MatchType)"; var parms = new IDataParameter[] { GetParameter(ParmPublishmentSystemId, EDataType.Integer, matchInfo.PublishmentSystemId), GetParameter(ParmKeyword, EDataType.NVarChar, 255, matchInfo.Keyword), GetParameter(ParmKeywordId, EDataType.Integer, matchInfo.KeywordId), GetParameter(ParmIsDisabled, EDataType.VarChar, 18, matchInfo.IsDisabled.ToString()), GetParameter(ParmKeywordType, EDataType.VarChar, 50, EKeywordTypeUtils.GetValue(matchInfo.KeywordType)), GetParameter(ParmMatchType, EDataType.VarChar, 50, EMatchTypeUtils.GetValue(matchInfo.MatchType)) }; ExecuteNonQuery(sqlString, parms); }
public void Insert(KeywordMatchInfo matchInfo) { var sqlString = "INSERT INTO wx_KeywordMatch (PublishmentSystemID, Keyword, KeywordID, IsDisabled, KeywordType, MatchType) VALUES (@PublishmentSystemID, @Keyword, @KeywordID, @IsDisabled, @KeywordType, @MatchType)"; var parms = new IDataParameter[] { GetParameter(PARM_PUBLISHMENT_SYSTEM_ID, EDataType.Integer, matchInfo.PublishmentSystemID), GetParameter(PARM_KEYWORD, EDataType.NVarChar, 255, matchInfo.Keyword), GetParameter(PARM_KEYWORD_ID, EDataType.Integer, matchInfo.KeywordID), GetParameter(PARM_IS_DISABLED, EDataType.VarChar, 18, matchInfo.IsDisabled.ToString()), GetParameter(PARM_KEYWORD_TYPE, EDataType.VarChar, 50, EKeywordTypeUtils.GetValue(matchInfo.KeywordType)), GetParameter(PARM_MATCH_TYPE, EDataType.VarChar, 50, EMatchTypeUtils.GetValue(matchInfo.MatchType)) }; ExecuteNonQuery(sqlString, parms); }
public List <KeywordMatchInfo> GetKeywordMatchInfoList(int publishmentSystemId, int keyWordId) { var keywordMatchInfoList = new List <KeywordMatchInfo>(); string sqlWhere = $"WHERE {KeywordMatchAttribute.PublishmentSystemId} = {publishmentSystemId} AND {KeywordMatchAttribute.KeywordId} = {keyWordId}"; var sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TableName, 0, SqlUtils.Asterisk, sqlWhere, null); using (var rdr = ExecuteReader(sqlSelect)) { while (rdr.Read()) { var keywordMatchInfo = new KeywordMatchInfo(rdr.GetInt32(0), rdr.GetInt32(1), rdr.GetValue(2).ToString(), rdr.GetInt32(3), TranslateUtils.ToBool(rdr.GetValue(6).ToString()), EKeywordTypeUtils.GetEnumType(rdr.GetValue(4).ToString()), EMatchTypeUtils.GetEnumType(rdr.GetValue(5).ToString())); keywordMatchInfoList.Add(keywordMatchInfo); } rdr.Close(); } return(keywordMatchInfoList); }
// [IN] match되는 걸 확인한 word만 저장된 keyword List public void HighlightHits(ObservableCollection <string> originalKeywordList) { if (string.IsNullOrEmpty(FullText)) { return; } // default로는 대소문자 구분없이 highlight 시킴 string oriFullText = FullText; //string tempFullText = IsCaseSensitive ? FullText : FullText.ToLower(); string tempFullText = FullText.ToLower(); //string replaced = tempFullText.Replace('\n', ' '); // 임시로 줄넘김 문자를 띄어쓰기 문자로 대체시켜서 보여줌 tempFullText = tempFullText.Replace('\n', ' '); if (string.IsNullOrEmpty(tempFullText)) { return; } try { List <string> matchedKeywordList = FindMatchedKeywordFromSource(originalKeywordList.ToList()); List <KeywordMatchInfo> keyInfoList = new List <KeywordMatchInfo>(); foreach (string matchedKeyword in matchedKeywordList) { //string tempKeyword = IsCaseSensitive ? matchedKeyword : matchedKeyword.ToLower(); string tempKeyword = matchedKeyword.ToLower(); int keyIndex = tempFullText.IndexOf(tempKeyword); string matchedString = oriFullText.Substring(keyIndex, tempKeyword.Length); // match되는 string을 도려내서 저장 KeywordMatchInfo info = new KeywordMatchInfo(matchedString, keyIndex, matchedString.Length); keyInfoList.Add(info); } if (keyInfoList.Count > 0) { keyInfoList.Sort((x, y) => x.MatchedIndex.CompareTo(y.MatchedIndex)); int startIndex = 0; string sum = string.Empty; foreach (KeywordMatchInfo info in keyInfoList) { string pre = string.Empty; string keyword = string.Empty; string post = string.Empty; if (IsEnableTailor && startIndex == 0 && info.MatchedIndex > 0) { SetColorOfString("...", "", ""); startIndex = info.MatchedIndex; } if (IsEnableTailor && sum.Length > FullLength) { break; } if (startIndex > info.MatchedIndex) { continue; } pre = oriFullText.Substring(startIndex, info.MatchedIndex - startIndex); if (pre.Length + sum.Length > FullLength) { // 키워드 사이의 string 길이가 길 경우 잘라서 붙여줌. pre = pre.Substring(0, (FullLength - sum.Length)); SetColorOfString(pre); } else { keyword = info.Keyword; SetColorOfString(pre, keyword); } sum = sum + pre + keyword; startIndex = info.MatchedIndex + info.Keyword.Length; } // 아직 뒤에 남은 문구가 있을 때 if (startIndex < oriFullText.Length) { if (IsEnableTailor) { if (sum.Length < FullLength) { string post = oriFullText.Substring(startIndex); // 남은 문구를 잘라서 붙이기 위한 작업 int bufferLeng = FullLength - sum.Length; if (post.Length > bufferLeng) { post = post.Substring(0, bufferLeng); } SetColorOfString("", "", post); } else { // FullLength가 넘으면 ...만 붙임 SetColorOfString("", "", "..."); } } else { string post = oriFullText.Substring(startIndex); SetColorOfString("", "", post); } } } else { SetColorOfString(FullText); } } catch (Exception ex) { Logger.LogMessage(string.Format("Failed to highlight multiple keywords. ({0})", ex.Message), System.Diagnostics.TraceLevel.Error); } }