/// <summary>Stores the email to Azure Table.</summary> /// <param name="email">The processed EmailSearch (or subclass) object to store.</param> public void StoreEmailToTableStorage(EmailSearch email) { if (string.IsNullOrEmpty(email.PartitionKey)) { //Set the partition key based on cascading priority rules if (!string.IsNullOrEmpty(email.EmailSenderTeam)) { email.PartitionKey = email.EmailSenderTeam; } else if (!string.IsNullOrEmpty(email.EmailSenderGroup)) { email.PartitionKey = email.EmailSenderGroup; } else if (!string.IsNullOrEmpty(email.EmailSender)) { email.PartitionKey = email.EmailSender; } } if (string.IsNullOrEmpty(email.RowKey)) { email.RowKey = email.EmailSentTime; } // Create the TableOperation that inserts the customer entity. TableOperation insertOperation = TableOperation.Insert(email); // Execute the insert operation. var result = emailTable.Execute(insertOperation); }
protected override void SetPageSessionContext() { _context = ShimsContext.Create(); base.SetPageSessionContext(); _testEntity = new EmailSearch { }; _privateTestObject = new PrivateObject(_testEntity); InitializeAllControls(_testEntity); InitializeSessionFakes(); }
/// <summary> /// Gets the activation link. /// </summary> /// <param name="email">The email.</param> /// <returns>System.String.</returns> public string GetActivationLink(string email) { EmailSearch.SendKeys(email); DetailsButton.Click(); var input = HTMLBody.Text; var result = input.Split(new[] { "href=\"" }, StringSplitOptions.None)[1] .Split('"')[0] .Trim(); return(result); }
/// <summary> /// Creates the telemetry for the email text parsing process. /// </summary> /// <param name="search">The search.</param> /// <param name="returnStrings">The return strings.</param> /// <returns></returns> protected IEnumerable <string> CreateReturnStringsTelemetry(EmailSearch search, List <string> returnStrings) { if (search != null && returnStrings != null) { var properties = new Dictionary <string, string>(); var metrics = new Dictionary <string, double> { { TelemetryKeyEmailLength, string.IsNullOrEmpty(search.EmailBodyText) ? (double)0 : (double)search.EmailBodyText.Length }, { TelemetryKeyTagsFound, (double)returnStrings.Count } }; telemetryClient.TrackEvent(TelemetryKeyEmailTagParsingOperation, null, metrics); } else { telemetryClient.TrackEvent(TelemetryKeyEmailTagParsingOperationNoneFound); } return(returnStrings); }
/// <summary>Processes the tags found in email body text and persists them to the data store.</summary> /// <param name="Search">The email 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="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> ProcessTagsFoundInEmailBodyText(EmailSearch Search, List <string> ReturnStrings, List <string> Tags, bool StoreResults = true, bool StoreUntaggedCommunication = false, bool OnlyReturnMatterTags = false) { ReturnStrings = new List <string>(); //Only do processing work if we have tags to process if (Tags.Count > 0) { //Process tags that are found StringBuilder stringBuilder; Search.MatterId = GenerateTagResults(ReturnStrings, Tags, out stringBuilder, OnlyReturnMatterTags, Search.TagStartToken).Replace(Search.TagStartToken, string.Empty); Search.EmailTagCluster = stringBuilder.ToString().Trim(); } //Store the results if appropriate StoreCommunication(StoreResults, StoreUntaggedCommunication, Tags, Search); return(ReturnStrings); }
public static string AddCommunication(EmailSearch Communication, GremlinClient GremlinClient) { Dictionary <string, string> properties = new Dictionary <string, string>(); properties.Add(CommunicationVertexPartitionKeyProperty, Communication.PartitionKey); properties.Add(CommunicationVertexRowKeyProperty, Communication.RowKey); properties.Add(CommunicationVertexSubjectProperty, Communication.EmailSubject); properties.Add(CommunicationVertexUTCTimeProperty, Communication.Timestamp.ToString()); properties.Add(CommunicationVertexYearProperty, Communication.Timestamp.Year.ToString()); properties.Add(CommunicationVertexMonthProperty, Communication.Timestamp.Month.ToString()); properties.Add(CommunicationVertexDayProperty, Communication.Timestamp.Day.ToString()); properties.Add(CommunicationVertexConversationIDProperty, Communication.EmailConversationId); properties.Add(CommunicationVertexReferenceKey, Communication.ReferenceKey); string communicationID = AddGraphVertex(GremlinClient, CommunicationVertexLabel, null, properties); return(communicationID); }
public void StoreEmailToGraphStorage(EmailSearch communication) { var communicationProcessor = CommunicationProcessingBusinessLogic.ProcessCommunicationToGraphDB(communication, graphDBHostName, graphDBPort, graphDBAccessKey, graphDBDatabaseName, graphDBCollectionName); }
private static void StoreCommunication(bool StoreResults, bool StoreUntaggedCommunication, List <string> Tags, EmailSearch Search) { //If we should be storing the results by request, and we have tags or a directive to store untagged communications if (StoreResults && ((Tags != null && Tags.Count > 0) || StoreUntaggedCommunication)) { Search.ServiceAPIVersion = Properties.Resources.ServiceVersion; StorageUtility.GetInstance().StoreEmailToTableStorage(Search); StorageUtility.GetInstance().StoreEmailToGraphStorage(Search); } }
public static bool ProcessCommunicationToGraphDB(EmailSearch Communication, string Hostname, int Port, string AuthKey, string Database, string Collection) { using (var gremlinClient = CreateGremlinClient(Hostname, Port, AuthKey, Database, Collection)) { //Add the communication sender var communicatorID = AddCommunicatorAndOrganization(Communication.EmailSender, gremlinClient); //Add the communication with properties var communicationID = AddCommunication(Communication, gremlinClient); //Add an edge from the communicator to the communcation var communicatorCommunicationEdgeQueryResult = AddGraphEdge(gremlinClient, communicatorID, communicationID, CommunicatorCommunicationEdgeLabel); //Add the communication secondary recipients with edges, note that we put this first to ensure primary relationship overwrite if applicable var secondaryRecipientIDs = ProcessCommunicationRecipients(gremlinClient, communicationID, Communication.EmailCcRecipients, CommunicationCommunicatorSecondaryRecipientEdgeProperty); //Add the communication primary recipients with edges var primaryRecipientIDs = ProcessCommunicationRecipients(gremlinClient, communicationID, Communication.EmailToRecipients, CommunicationCommunicatorPrimaryRecipientEdgeProperty); string matterID = string.Empty; if (!string.IsNullOrEmpty(Communication.MatterId)) { //Add the matter matterID = AddGraphVertex(gremlinClient, MatterVertexLabel, Communication.MatterId); //Add an edge from the communication to the matter var communicationMatterEdgeQueryResult = AddGraphEdge(gremlinClient, communicationID, matterID, CommunicationMatterEdgeLabel); } //Add the tags and edges List <string> tagIDs = null; if (Communication.EmailTagCluster != null && Communication.EmailTagCluster.Length > 0) { List <string> tags = CommunicationProcessingBusinessLogic.ParseConcatenatedString(Communication.EmailTagCluster, TagDelimiter); tagIDs = new List <string>(); foreach (var tag in tags) { tagIDs.Add(AddGraphVertex(gremlinClient, TagVertexLabel, tag)); // Rethinking this//if there is a matter associated with this communication ensure the tag and the matter are connected //if (!string.IsNullOrEmpty(matterID) && string.Equals(matterID, tag, StringComparison.OrdinalIgnoreCase) //{ //} } foreach (var tagID in tagIDs) { //Add an edge from the communication to the tags var communicationTagEdgeQueryResult = AddGraphEdge(gremlinClient, communicationID, tagID, CommunicationTagEdgeLabel); if (!string.IsNullOrEmpty(matterID)) { var queryResults = GetGraphEdge(gremlinClient, tagID, matterID, TagMatterEdgeLabel); //If we have no edge, add it if (queryResults.Count == 0) { //Add an edge from the tags to the matter var tagMatterEdgeQueryResults = AddGraphEdge(gremlinClient, tagID, matterID, TagMatterEdgeLabel); } } } } } return(true); }