private List <string> FindMatchedKeywordFromSource(List <string> operatorWords) { List <string> matchedString = new List <string>(); if (string.IsNullOrEmpty(FullText)) { return(matchedString); } if (operatorWords.Count > 0) { //if (!IsCaseSensitive) { matchedString = operatorWords.Where(x => (FullText.ToLower().Contains(x.ToLower()))).ToList(); } //else //{ // foreach (string op in operatorWords) // { // if (FullText.Contains(op)) // matchedString.Add(op); // } //} } return(matchedString); }
public void Fill(Database database, string connectionString) { if (database.Options.Ignore.FilterFullText) { using (SqlConnection conn = new SqlConnection(connectionString)) { using (SqlCommand command = new SqlCommand(GetSQL(), conn)) { conn.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { FullText item = new FullText(database); item.Id = (int)reader["fulltext_catalog_id"]; item.Name = reader["Name"].ToString(); item.Owner = reader["Owner"].ToString(); item.IsAccentSensity = (bool)reader["is_accent_sensitivity_on"]; item.IsDefault = (bool)reader["is_default"]; if (!reader.IsDBNull(reader.GetOrdinal("path"))) { item.Path = reader["path"].ToString().Substring(0, reader["path"].ToString().Length - item.Name.Length); } if (!reader.IsDBNull(reader.GetOrdinal("FileGroupName"))) { item.FileGroupName = reader["FileGroupName"].ToString(); } database.FullText.Add(item); } } } } } }
public void MyTaskTest() { FullText fullText = new FullText("Hello! Hello!"); string expectedValue = "ello! ello!"; Assert.AreEqual(expectedValue, fullText.buildedStrFullText); }
public override string ToString() { var parts = new List <string>(); if (Filter != null) { parts.Add($"Filter: {Filter}"); } if (FullText != null) { parts.Add($"FullText: '{FullText.Replace("'", "\'")}'"); } if (Skip > 0) { parts.Add($"Skip: {Skip}"); } if (Take < long.MaxValue) { parts.Add($"Take: {Take}"); } if (Sort.Count > 0) { parts.Add($"Sort: {string.Join(", ", Sort)}"); } return(string.Join("; ", parts)); }
public LoggedException(Exception exception) { Message = exception.Message; FullText = exception.ToString(); var cur = exception; while (cur != null) { if (cur.StackTrace != null) { FullText = FullText.Replace(cur.StackTrace, ""); } cur = cur.InnerException; } if (exception.InnerException != null) { InnerException = new LoggedException(exception.InnerException); } FullStackTrace = exception.StackTrace; if (FullStackTrace != null) { var stLines = FullStackTrace.Split(new[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries); var st = stLines.Where(l => l.Contains(ErrorNamespaceForStackTrace)) .ToList(); StackTrace = string.Join(Environment.NewLine, st); } }
// 매치되는 키워드를 하나만 찾아서 Highlight 시키는 함수 public void HighlightOnlyOneHit(string originalKeyword) { if (string.IsNullOrEmpty(FullText)) { return; } try { // default로는 대소문자 구분없이 highlight 시킴 string oriFullText = FullText; string tempFullText = IsCaseSensitive ? FullText : FullText.ToLower(); string tempKeyword = IsCaseSensitive ? originalKeyword : originalKeyword.ToLower(); if (tempFullText.Contains(tempKeyword)) { string pre = string.Empty; string post = string.Empty; //Logger.LogMessage(string.Format("{0} 파일 : {1} 문장 내에 포함되어 있음.", Path.GetFileName(fullPath), text)); string replaced = tempFullText.Replace('\n', ' '); // 임시로 줄넘김 문자를 띄어쓰기 문자로 대체시켜서 보여줌??? //replaced = Regex.Replace(replaced, @"[\s]", "", RegexOptions.None); int keyIndex = replaced.IndexOf(tempKeyword); if (keyIndex > 0) { if (IsEnableTailor && keyIndex > TailorLength) { pre = "..." + oriFullText.Substring(keyIndex - TailorLength, TailorLength); } else { pre = oriFullText.Substring(0, keyIndex); } } int postKeyIndex = keyIndex + tempKeyword.Length; if (IsEnableTailor && (postKeyIndex + TailorLength < replaced.Length)) { post = oriFullText.Substring(postKeyIndex, TailorLength) + "..."; } else { post = oriFullText.Substring(postKeyIndex); } string matchedText = oriFullText.Substring(keyIndex, tempKeyword.Length); SetColorOfString(pre, matchedText, post); // 화면에 보여지는 text는 original text로부터 추출 } else { SetColorOfString(FullText); // 화면에 보여지는 text는 original text로부터 추출 } } catch (Exception ex) { Logger.LogMessage(string.Format("Failed to highlight one keyword. ({0})", ex.Message), System.Diagnostics.TraceLevel.Error); } }
public File() { readFile(); FullText ft = new FullText(rText); Console.WriteLine(ft.buildedStrFullText); writeToFile(ft); Console.ReadKey(); }
protected string SafePeekString(int length) { var safeLength = Math.Min(length, FullText.Length - CurrentIndex); if (safeLength == 0) { return(string.Empty); } return(FullText.Substring(CurrentIndex, safeLength)); }
public override int GetHashCode() { unchecked { int hashCode = (DisplayText != null ? DisplayText.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (FullText != null ? FullText.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (EvalText != null ? EvalText.GetHashCode() : 0); return(hashCode); } }
public string GetString() { if (IsComplete()) { return(string.Empty); } int curr = m_curr; m_curr = FullText.Length; return(FullText.Substring(curr).Trim()); }
public void SplitInLines() { //Here the Text is first split up in lines where ever the programmer put a @, But if the text is stil longer then the MaxChar that fits in the width of the textbox // It is split down even further Lines = FullText.Split((char)'@').ToList(); AllLines = new List <string> { }; foreach (string _Line in Lines) { string Templine = ""; Templine = _Line; if (_Line.Count() > CharPerLine) { int _AmountOfLines = _Line.Count() / CharPerLine; int x = 0; int CurrentIndex = CharPerLine; while (_AmountOfLines > 0) { if (_Line.ElementAtOrDefault(CurrentIndex) == ' ') { StringBuilder sb = new StringBuilder(Templine); sb[CurrentIndex] = '@'; Templine = sb.ToString(); _AmountOfLines -= 1; CurrentIndex += CharPerLine; } else { x++; CurrentIndex -= 1; } } AllLines.AddRange(Templine.Split((char)'@').ToList()); } else { AllLines.Add(_Line); } } foreach (string y in AllLines) { Console.WriteLine(y); } FullText = FullText.Replace("@", System.Environment.NewLine); }
void setText() { if (FullText == null) { textBlock.Text = ""; return; } if (FullTextSize.Width + AutoPadding <= textBlock.ActualWidth) { textBlock.Padding = new Thickness(AutoPadding, 0, 0, 0); textBlock.Text = FullText; } else if (FullTextSize.Width + 5 <= textBlock.ActualWidth) { textBlock.Padding = new Thickness(textBlock.ActualWidth - (FullTextSize.Width + 5), 0, 0, 0); textBlock.Text = FullText; } else { textBlock.Padding = new Thickness(0, 0, 0, 0); //calculate average length of characters in the string double avgCharLength = FullTextSize.Width / FullText.Length; // length of added dots with a little extra buffer double dotsLength = avgCharLength * 3; // calculate how many characters need to be dropped to fit the string into the available space int nrDroppedChars = (int)Math.Ceiling(((FullTextSize.Width + dotsLength) - textBlock.ActualWidth) / avgCharLength); String text = ""; do { int newLength = FullText.Length - nrDroppedChars; if (newLength <= 0) { text = ""; break; } text = FullText.Substring(0, newLength) + "..."; nrDroppedChars++; } while (MeasureString(text).Width >= textBlock.ActualWidth - errorMargin); textBlock.Text = text; } }
public PostDto ToDto() { return(new PostDto { Id = Id, Title = Title.Trim(), LinkText = LinkText.Trim().ToLower(), PreviewText = PreviewText.Trim(), FullText = FullText.Trim(), PublishedAt = PublishedAt, Tags = Tags // IsPublished ignored }); }
public void writeToFile(FullText ft) { try { using (StreamWriter sw = new StreamWriter(opath, false, System.Text.Encoding.Default)) { sw.Write(ft.buildedStrFullText); } Console.WriteLine("Writing completed"); } catch (Exception e) { Console.WriteLine(e.Message); } }
private string FindParseText(string parameter) { string value = string.Empty; int indexStartParameter = FullText.IndexOf(parameter); if (indexStartParameter > 0) { indexStartParameter += parameter.Length + 1; int indexEndParameter = FullText.IndexOf(",", indexStartParameter); value = FullText.Substring(indexStartParameter, indexEndParameter - indexStartParameter); } return(value); }
public ActionResult Display(long id) { try { var ft = new FullText(); ft.Text = db.GetText(id); ft.RawText = db.Get(id); return(View(ft)); } catch (Exception ex) { Log.Error(ex.Message, ex); return(HttpNotFound()); } }
public ActionResult Edit(long id) { try { var ft = new FullText(); ft.Text = db.GetText(id); ft.RawText = db.Get(id); if (ft.Text.UserName != UserHelper.Instance.CurrentUserName) { return(HttpNotFound()); } return(View(ft)); } catch (Exception ex) { Log.Error(ex.Message, ex); return(HttpNotFound()); } }
public RoomRecord(string rawText) { FullText = rawText.Trim(); var parts = FullText.Split('-'); EncryptedName = string.Join('-', parts.Take(parts.Length - 1)); var suffix = parts.Last(); var suffixParts = suffix.Split('['); RawSectorId = suffixParts[0]; Checksum = suffixParts[1].TrimEnd(']'); SectorId = int.Parse(RawSectorId); var letters = EncryptedName.Replace("-", ""); var letterCounts = new Dictionary <char, int>(); foreach (var l in letters) { if (!letterCounts.ContainsKey(l)) { letterCounts[l] = 0; } letterCounts[l] = 1 + letterCounts[l]; } RealChecksum = new string( letterCounts .OrderByDescending(x => x.Value) .ThenBy(x => x.Key) .Select(x => x.Key) .ToArray() ) .Substring(0, 5); IsReal = RealChecksum == Checksum; RealName = IsReal ? Decrypt() : null; }
public DataTable ReadCSVFile(string filePath) { DataTable dtCsv = new DataTable(); string FullText; using (StreamReader sr = new StreamReader(filePath)) { FullText = sr.ReadToEnd().ToString(); //read full file text string[] rows = FullText.Split('\n'); //split full file text into rows { for (int i = 0; i < rows.Count() - 1; i++) { string[] rowValues = rows[i].Split(','); //split each row with comma to get individual value { if (i == 0) { for (int j = 0; j < rowValues.Count(); j++) { dtCsv.Columns.Add(rowValues[j]); //add headers } } else { DataRow dr = dtCsv.NewRow(); var length = rowValues.Count() > dtCsv.Columns.Count ? dtCsv.Columns.Count : rowValues.Count(); for (int k = 0; k < length; k++) { dr[k] = rowValues[k].ToString(); } dtCsv.Rows.Add(dr); //add other rows } } } } } return(dtCsv); }
string GetOneWord(params char[] sep) { if (IsComplete()) { return(null); } string flag = null; int start = m_curr; int end = m_curr; while (end < FullText.Length && !sep.Contains(FullText[end])) { end++; } if (start != end) { flag = FullText.Slice(start, end); } m_curr = end; return(flag); }
// [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); } }
public override string ToString() { return($"{{{Title} - {FullText.Substring(0, Math.Min(FullText.Length, 200))} }}"); }
public QueryInst doExecuteQuery(int sessionId, int appId, int docTypeId, int queryId, int maxRows, string[] fldValue, eTree condition, FullText FTCond) { return(epBridge.doExecuteQuery(sessionId, appId, docTypeId, queryId, maxRows, fldValue, condition, FTCond)); }
/// <summary> /// The MySqlCommand initialized for this query, including any and all parameters. /// </summary> public DBHelperCommandArgs ModelQueryCommand() { List <string> lstWhereTerms = new List <string>(); List <MySqlParameter> lstParams = new List <MySqlParameter>(); // Add each of the terms string[] rgTerms = FullText.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < rgTerms.Length; i++) { AddQueryTerm(rgTerms[i], String.Format(CultureInfo.InvariantCulture, "FullText{0}", i), "Concat(model, ' ', manufacturers.manufacturer, ' ', typename, ' ', family, ' ', modelname, ' ', categoryclass.CatClass)", lstWhereTerms, lstParams); } string szPreferred = "0"; if (PreferModelNameMatch) { string szModelMatch = String.Format(CultureInfo.InvariantCulture, "%{0}%", ConvertWildcards(FullText)); szPreferred = "IF(model LIKE ?modelMatch, 1, 0)"; lstParams.Add(new MySqlParameter("modelMatch", szModelMatch)); } AddQueryTerm(CatClass, "qCatClass", "catclass", lstWhereTerms, lstParams); AddQueryTerm(rNormalizeModel.Replace(Model, string.Empty), "qModel", "REPLACE(REPLACE(model, ' ', ''), '-', '')", lstWhereTerms, lstParams); if (ModelName.StartsWith(ICAOPrefix, StringComparison.CurrentCultureIgnoreCase)) { AddQueryTerm(ModelName.Substring(ICAOPrefix.Length), "qFamilyName", "family", lstWhereTerms, lstParams); } else { AddQueryTerm(ModelName, "qModelName", "modelname", lstWhereTerms, lstParams); } AddQueryTerm(ManufacturerName, "qMan", "manufacturer", lstWhereTerms, lstParams); AddQueryTerm(TypeName, "qType", "typename", lstWhereTerms, lstParams); if (ManufacturerID != Manufacturer.UnsavedID) { lstWhereTerms.Add(" (models.idManufacturer = ?manID) "); lstParams.Add(new MySqlParameter("manID", ManufacturerID)); } string szHavingPredicate = String.Join(" AND ", lstWhereTerms.ToArray()); const string szQTemplate = @"SELECT models.*, manufacturers.manufacturer, categoryclass.CatClass as 'Category/Class', {0} AS AircraftIDs, {1} AS preferred FROM models INNER JOIN manufacturers on manufacturers.idManufacturer = models.idmanufacturer INNER JOIN categoryclass on categoryclass.idCatClass = models.idcategoryclass {2} {3} {4} {5}"; const string szQSamplesTemplate = @"LEFT OUTER JOIN (SELECT ac.idmodel, group_concat(DISTINCT img.imageKey separator ',') AS AircraftIDs FROM Images img INNER JOIN aircraft ac ON CAST(img.imageKey AS Unsigned)=ac.idaircraft WHERE img.VirtPathID=1 GROUP BY ac.idmodel) Samples ON models.idmodel=Samples.idmodel"; string szQ = String.Format(CultureInfo.InvariantCulture, szQTemplate, IncludeSampleImages ? "Samples.AircraftIDs" : "NULL", szPreferred, IncludeSampleImages ? szQSamplesTemplate : string.Empty, szHavingPredicate.Length == 0 ? string.Empty : String.Format(CultureInfo.InvariantCulture, " WHERE {0} ", szHavingPredicate), SortOrderFromSortModeAndDirection(SortMode, SortDir), (Limit > 0 && Skip >= 0) ? String.Format(CultureInfo.InvariantCulture, " LIMIT {0},{1} ", Skip, Limit) : string.Empty); DBHelperCommandArgs args = new DBHelperCommandArgs(szQ, lstParams); return(args); }
// [Not used now] Highlight 3 matched keywords... public void HighlightHits(string originalKeyword) { if (string.IsNullOrEmpty(FullText)) { return; } // default로는 대소문자 구분없이 highlight 시킴 string oriFullText = FullText; string tempFullText = IsCaseSensitive ? FullText : FullText.ToLower(); string tempKeyword = IsCaseSensitive ? originalKeyword : originalKeyword.ToLower(); try { if (tempFullText.Contains(tempKeyword)) { string pre = string.Empty; string post = string.Empty; //Logger.LogMessage(string.Format("{0} 파일 : {1} 문장 내에 포함되어 있음.", Path.GetFileName(fullPath), text)); string replaced = tempFullText.Replace('\n', ' '); // 임시로 줄넘김 문자를 띄어쓰기 문자로 대체시켜서 보여줌 //replaced = Regex.Replace(replaced, @"[\s]", "", RegexOptions.None); for (int i = 0; i < MAX_HIT_COUNT; i++) { if (string.IsNullOrEmpty(replaced) || replaced.Contains(tempKeyword) == false) { break; } // 검색하는 키워드 앞뒤로 얼만큼 자를지 정해야 할 듯 int keyIndex = replaced.IndexOf(tempKeyword); if (keyIndex > 0) { if (IsEnableTailor && keyIndex > TailorLength) { pre = "..." + oriFullText.Substring(keyIndex - TailorLength, TailorLength); } else { pre = oriFullText.Substring(0, keyIndex); } } string matchedText = oriFullText.Substring(keyIndex, tempKeyword.Length); SetColorOfString(pre, matchedText, ""); // 화면에 보여지는 text는 original text로부터 추출 int postKeyIndex = keyIndex + tempKeyword.Length; if (IsEnableTailor && postKeyIndex < replaced.Length) { replaced = replaced.Substring(postKeyIndex); oriFullText = oriFullText.Substring(postKeyIndex); } else { replaced = oriFullText = string.Empty; } } // MAX_HIT_COUNT 까지 돌고 난 뒤 남는 문구에 대한 처리 if (IsEnableTailor && replaced.Length > TailorLength) { oriFullText = oriFullText.Substring(0, TailorLength) + "..."; } SetColorOfString("", "", oriFullText); // 화면에 보여지는 text는 original text로부터 추출 } else { SetColorOfString(FullText); // 화면에 보여지는 text는 original text로부터 추출 } } catch (Exception ex) { Logger.LogMessage(string.Format("Failed to highlight couple of keywords. ({0})", ex.Message), System.Diagnostics.TraceLevel.Error); } }