Beispiel #1
0
        public void ProcessOrdinalTagsFoundInEmailBodyTextTest()
        {
            var testRequest03 = JsonConvert.DeserializeObject <TagsSearchByTagStartTokenOrdinal>(File.ReadAllText(TestUtilities.GetTestRequestFilePath("TestRequest03.json")));
            var tags          = EmailParser.FindTags(testRequest03.EmailBodyText, testRequest03.TagStartToken, testRequest03.RemoveDuplicates, testRequest03.ExcludePriorEmailsFromSearch);
            var ordinalTags   = EmailParser.FindTagsOnContiguousNewLines(testRequest03.EmailBodyText, testRequest03.TagStartToken);
            var result        = TagProcessingBusinessLogic.ProcessOrdinalTagsFoundInEmailBodyText(testRequest03, null, tags, ordinalTags, 3, false);

            if (result.Count < 1)
            {
                Assert.Fail();
            }
        }
        /// <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 void FindTagsOnContiguousNewLinesTest()
        {
            var testEmail01        = JsonConvert.DeserializeObject <TestEmail>(File.ReadAllText(GetTestEmailFilePath("TestEmail01.json")));
            var testEmail01Results = EmailParser.FindTagsOnContiguousNewLines(testEmail01.Content, testEmail01.TagToken);

            if (testEmail01Results.Count != testEmail01.TagCountCurrentEmailOrdinal)
            {
                Assert.Fail();
            }

            var testEmail02        = JsonConvert.DeserializeObject <TestEmail>(File.ReadAllText(GetTestEmailFilePath("TestEmail02.json")));
            var testEmail02Results = EmailParser.FindTagsOnContiguousNewLines(testEmail02.Content, testEmail02.TagToken);

            if (testEmail02Results.Count != testEmail02.TagCountCurrentEmailOrdinal)
            {
                Assert.Fail();
            }

            var testEmail03        = JsonConvert.DeserializeObject <TestEmail>(File.ReadAllText(GetTestEmailFilePath("TestEmail03.json")));
            var testEmail03Results = EmailParser.FindTagsOnContiguousNewLines(testEmail03.Content, testEmail03.TagToken);

            if (testEmail03Results.Count != testEmail03.TagCountCurrentEmailOrdinal)
            {
                Assert.Fail();
            }

            var testEmail04        = JsonConvert.DeserializeObject <TestEmail>(File.ReadAllText(GetTestEmailFilePath("TestEmail04.json")));
            var testEmail04Results = EmailParser.FindTagsOnContiguousNewLines(testEmail04.Content, testEmail04.TagToken);

            if (testEmail04Results.Count != testEmail04.TagCountCurrentEmailOrdinal)
            {
                Assert.Fail();
            }

            var testEmail05        = JsonConvert.DeserializeObject <TestEmail>(File.ReadAllText(GetTestEmailFilePath("TestEmail05.json")));
            var testEmail05Results = EmailParser.FindTagsOnContiguousNewLines(testEmail05.Content, testEmail05.TagToken);

            if (testEmail05Results.Count != testEmail05.TagCountCurrentEmailOrdinal)
            {
                Assert.Fail();
            }
        }