public static void TransactGraphQueries(Dictionary <string, string> GremlinQueries, String Hostname, int Port, String AuthKey, String Database, String Collection, bool VerboseReporting = false)
        {
            var gremlinClient = CommunicationProcessingBusinessLogic.CreateGremlinClient(Hostname, Port, AuthKey, Database, Collection);

            foreach (var query in GremlinQueries)
            {
                Console.WriteLine(String.Format("Running this query: {0}: {1}", query.Key, query.Value));
                TransactGraphQuery(gremlinClient, query.Value, VerboseReporting);
            }
        }
Пример #2
0
        public static MatterGraphModel GetMatters(IGraphConfiguration GraphConfiguration)
        {
            using (var tagHiveClient = CommunicationProcessingBusinessLogic.CreateGremlinClient(GraphConfiguration))
            {
                string query   = GraphQueryBusinessLogic.GetMattersGraphQuery();
                var    results = CommunicationProcessingBusinessLogic.SubmitRequest(tagHiveClient, query).Result;

                var jsonString = JsonConvert.SerializeObject(results);
                return(JsonConvert.DeserializeObject <MatterGraphModel>(jsonString));
            }
        }
Пример #3
0
        public static DocumentGraphModelList GetDocumentsForTag(IGraphConfiguration GraphConfiguration, string Tag)
        {
            using (var tagHiveClient = CommunicationProcessingBusinessLogic.CreateGremlinClient(GraphConfiguration))
            {
                string query   = GraphQueryBusinessLogic.GetDocumentsForTagGraphQuery(Tag);
                var    results = CommunicationProcessingBusinessLogic.SubmitRequest(tagHiveClient, query).Result;

                var jsonString = JsonConvert.SerializeObject(results);
                return(JsonConvert.DeserializeObject <DocumentGraphModelList>(jsonString));
            }
        }
Пример #4
0
        public static List <string> GetTopicSenders(string Topic, IGraphConfiguration GraphConfiguration)
        {
            List <string> tagSenders = new List <string>();

            using (var tagHiveClient = CommunicationProcessingBusinessLogic.CreateGremlinClient(GraphConfiguration))
            {
                string query   = GraphQueryBusinessLogic.GetTopicSendersGraphQuery(Topic);
                var    results = CommunicationProcessingBusinessLogic.SubmitRequest(tagHiveClient, query).Result;
                if (results.Count > 0)
                {
                    foreach (var item in results)
                    {
                        //TagSender tagSender = JsonConvert.DeserializeObject<TagSender>(JsonConvert.SerializeObject(item));
                        tagSenders.Add(item);
                    }
                }
            }

            return(tagSenders);
        }
Пример #5
0
        public static List <TagRecipient> GetTopicRecipients(string Topic, IGraphConfiguration GraphConfiguration)
        {
            List <TagRecipient> tagRecipients = new List <TagRecipient>();

            using (var tagHiveClient = CommunicationProcessingBusinessLogic.CreateGremlinClient(GraphConfiguration))
            {
                //TODO Update this query to find most common recipients of the topic
                string query   = string.Format("g.V(\"{0}\").outE(\"recipient\")", Topic);
                var    results = CommunicationProcessingBusinessLogic.SubmitRequest(tagHiveClient, query).Result;
                if (results.Count > 0)
                {
                    foreach (var item in results)
                    {
                        TagRecipient tagRecipient = JsonConvert.DeserializeObject <TagRecipient>(JsonConvert.SerializeObject(item));
                        tagRecipients.Add(tagRecipient);
                    }
                }
            }

            return(tagRecipients);
        }
Пример #6
0
        public static Dictionary <string, int> GetTopicSendersWithSentValues(string Topic, IGraphConfiguration GraphConfiguration)
        {
            Dictionary <string, int> tagSenders = new Dictionary <string, int>();

            using (var tagHiveClient = CommunicationProcessingBusinessLogic.CreateGremlinClient(GraphConfiguration))
            {
                string query   = GraphQueryBusinessLogic.GetTopicSendersGraphQueryWithSentValues(Topic);
                var    results = CommunicationProcessingBusinessLogic.SubmitRequest(tagHiveClient, query).Result;
                if (results.Count > 0)
                {
                    foreach (var resultsetItem in results)
                    {
                        foreach (var item in resultsetItem)
                        {
                            tagSenders.Add(((KeyValuePair <string, object>)item).Key, int.Parse(((KeyValuePair <string, object>)item).Value.ToString()));
                        }
                    }
                }
            }

            return(tagSenders);
        }
        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);
        }