//Communications, communicators, organizations, organizationCommunicators, tags, senderTag, tagPrimaryRecipient, tagSecondaryRecipient, tagRelationships private static void BuildInteractionDictionaries(List <EmailSearch> Communications, Dictionary <string, string> Communicators, Dictionary <string, string> Organizations, Dictionary <string, string> OrganizationCommunicators, Dictionary <string, string> Tags, Dictionary <string, int> SenderTag, Dictionary <string, int> TagPrimaryRecipient, Dictionary <string, int> TagSecondaryRecipient, Dictionary <string, int> TagRelationships) { // Iterate through all the communications foreach (var communication in Communications) { //Only process entries that have tags if (communication.EmailTagCluster != null && communication.EmailTagCluster.Length > 0) { var communicationModel = new CommunicationGraphModel(communication); //Add new communicators AddStringToDictionary(Communicators, communicationModel.CommunicationSender); AddStringListToDictionary(Communicators, communicationModel.ToRecipients); AddStringListToDictionary(Communicators, communicationModel.CcRecipients); //Add orgs and create org-communicator mappings CreateCommunicatorOrganizationRelationship(Organizations, OrganizationCommunicators, communicationModel.CommunicationSender, KeyBinder); if (communicationModel.ToRecipients != null) { foreach (var item in communicationModel.ToRecipients) { CreateCommunicatorOrganizationRelationship(Organizations, OrganizationCommunicators, item, KeyBinder); } } if (communicationModel.CcRecipients != null) { foreach (var item in communicationModel.CcRecipients) { CreateCommunicatorOrganizationRelationship(Organizations, OrganizationCommunicators, item, KeyBinder); } } //Add new tags and tag relationships CreateTagRelationships(Tags, SenderTag, TagPrimaryRecipient, TagSecondaryRecipient, TagRelationships, communicationModel, KeyBinder); } } }
private static void AddTagSender(Dictionary <string, int> SenderTag, CommunicationGraphModel communicationModel, string tag) { string key = communicationModel.CommunicationSender + KeyBinder + tag; IncrementKeyedIntegerInDictionary(SenderTag, key); }
private static void CreateTagRelationships(Dictionary <string, string> Tags, Dictionary <string, int> SenderTag, Dictionary <string, int> TagPrimaryRecipient, Dictionary <string, int> TagSecondaryRecipient, Dictionary <string, int> TagRelationships, CommunicationGraphModel CommunicationModel, string KeyBinder) { //Add new tags AddStringListToDictionary(Tags, CommunicationModel.Tags); //Process the tag sender and recipient relationships foreach (var tag in CommunicationModel.Tags) { if (tag.Length > 0) { AddTagSender(SenderTag, CommunicationModel, tag); AddTagRecipients(TagPrimaryRecipient, tag, CommunicationModel.ToRecipients); AddTagRecipients(TagSecondaryRecipient, tag, CommunicationModel.CcRecipients); } } // Only process relationships if there are multiple tags if (CommunicationModel.Tags.Count > 1) { // Iterate over the list of tags associated with the communication for (int i = 0; i < CommunicationModel.Tags.Count - 1; i++) { // Move forward in the list by one for (int j = i + 1; j < CommunicationModel.Tags.Count; j++) { var key = CommunicationModel.Tags.ElementAt(i) + KeyBinder + CommunicationModel.Tags.ElementAt(j); IncrementKeyedIntegerInDictionary(TagRelationships, key); } } } }