/// <summary>Processes the ordinal tags found in email body text.</summary> /// <param name="Search">The search object that contains the search parameters and content.</param> /// <param name="ReturnStrings">The array of strings that represents tags that are found.</param> /// <param name="Tags">The tags that were found.</param> /// <param name="OrdinalTags">The ordinal tags that were found.</param> /// <param name="OrdinalTagSequenceCount">The threshold ordinal tag sequence count necessary to trigger ordinal processing.</param> /// <param name="StoreResults">if set to <c>true</c> send results to storage.</param> /// <param name="StoreUntaggedCommunication">if set to <c>true</c> store communications that contain no tags too.</param> /// <returns></returns> public static List <string> ProcessOrdinalTagsFoundInEmailBodyText(TagsSearchByTagStartTokenOrdinal Search, List <string> ReturnStrings, List <string> Tags, List <string> OrdinalTags = null, int OrdinalTagSequenceCount = 0, bool StoreResults = true, bool StoreUntaggedCommunication = false) { //Only process if we have tags if (Tags != null && Tags.Count > 0) { //Drop in to pick up the default return list building logic ReturnStrings = ProcessTagsFoundInEmailBodyText(Search, ReturnStrings, Tags, false); //Process ordinal tags that are found if we have tags, and we have a minimum tag sequence if (OrdinalTags != null && OrdinalTags.Count >= OrdinalTagSequenceCount) { StringBuilder stringBuilder; GenerateOrdinalTagResults(OrdinalTags.GetRange(0, OrdinalTagSequenceCount), out stringBuilder); Search.EmailTagClusterOrdinal = stringBuilder.ToString().Trim(); } else { Search.EmailTagClusterOrdinal = ""; } } //Store the results if appropriate StoreCommunication(StoreResults, StoreUntaggedCommunication, Tags, Search); return(ReturnStrings); }
public static int GetOrdinalTagSetSize(TagsSearchByTagStartTokenOrdinal Search, int DefaultTagSetSize = -1) { //Override the default if we have one if (Search.TagSetSize != null && Search.TagSetSize.Length > 0) { return(int.Parse(Search.TagSetSize)); } else { return(DefaultTagSetSize); } }
/// <summary>Process tags in a search, looking for ordinal tags.</summary> /// <param name="Search">The plain text (html elements stripped) version of the email to be parsed and other configuration paramaters.</param> /// <param name="ReturnOnlyMattersTags">Should the results be filtered to only include matter tags.</param> public static List <string> ProcessOrdinalTags(TagsSearchByTagStartTokenOrdinal Search, bool ReturnOnlyMattersTags = false) { List <string> returnStrings = null; if (Search != null && Search.TagStartToken != null && Search.TagStartToken.Length > 0 && Search.EmailBodyText != null && Search.EmailBodyText.Length > 0) { //Find all of the tags in the email var tags = EmailParser.FindTags(Search.EmailBodyText, Search.TagStartToken, Search.RemoveDuplicates, Search.ExcludePriorEmailsFromSearch); int tagSetSize = TagProcessingBusinessLogic.GetOrdinalTagSetSize(Search); List <string> ordinalTags = null; //Search for ordinal tags if there is a declared minimum set size greater than 0. Note that a search below size of 2 is pointless so we may want to revisit ths if (tagSetSize > 0) { //Find ordinal (sequenced) tags in the email ordinalTags = EmailParser.FindTagsOnContiguousNewLines(Search.EmailBodyText, Search.TagStartToken, Search.RemoveDuplicates, Search.ExcludePriorEmailsFromSearch); } foreach (var item in tags) { if (MatterIdentificationBL.ValidateMatterID(Search.TagStartToken, item)) { Search.MatterId = item.Substring(Search.TagStartToken.Length); break; } } //Process all of the tags into the persistence object and send to storage, event if we do not find tags in the content var strings = TagProcessingBusinessLogic.ProcessOrdinalTagsFoundInEmailBodyText(Search, returnStrings, tags, ordinalTags, tagSetSize, true, true); //If we are only supposed to return matter related tags filter accordingly if (ReturnOnlyMattersTags) { returnStrings = new List <string>(); //Iterate over the found tags searching for valid matter numbers foreach (var item in strings) { if (MatterIdentificationBL.ValidateMatterID(Search.TagStartToken, item)) { returnStrings.Add(item); } } } //otherwise return all found tags else { returnStrings = strings; } } return(returnStrings); }
public IEnumerable <string> Post([FromBody] TagsSearchByTagStartTokenOrdinal Search) { return(CreateReturnStringsTelemetry(Search, TagProcessingBusinessLogic.ProcessOrdinalTags(Search, false))); }