public ConcurrentDictionary <string, ConversationList> LoadConversations()
        {
            var analyzationVersion = ConfigurationService.AnalyzationVersion;

            var conversationLists = new ConcurrentDictionary <string, ConversationList>();

            foreach (var directory in Directory.GetDirectories(_databaseDirectory))
            {
                conversationLists[Path.GetFileName(directory)] = LoadConversationList(directory);
            }

            foreach (var conversationList in conversationLists)
            {
                foreach (var conversation in conversationList.Value.conversations)
                {
                    if (conversation.Value.analyzationVersion != analyzationVersion)
                    {
                        var analyzedConversation = analyzationService.AnalyzeConversation(conversation.Value);
                        conversationLists[conversationList.Key].conversations[conversation.Key] = analyzedConversation;
                        var json = JsonConvert.SerializeObject(analyzedConversation);
                        File.WriteAllText(_databaseDirectory + "\\" + conversationList.Value.type + "\\" + analyzedConversation.name + ".json", json, Encoding.Unicode);
                    }
                }
            }

            return(conversationLists);
        }
        public bool UpdateDatabases(ChatRequest chat)
        {
            var          conversation = conversationService.GetConversation(chat);
            AnalyzedChat inResponseTo = null;

            if (conversation.responses.Count() > 1)
            {
                inResponseTo = conversation.responses[conversation.responses.Count() - 2];
            }
            var analyzedConversation = analyzationService.AnalyzeConversation(conversation);
            var conversationUdpdated = covnersationUpdateService.UpdateConversation(analyzedConversation, chat.type);

            userService.UpdateUsers(analyzedConversation.responses.Last(), inResponseTo);

            return(conversationUdpdated);
        }
Esempio n. 3
0
        public ChatResponse ProcessChat(ChatRequest chat)
        {
            var conversation         = conversationService.GetConversation(chat);
            var analyzedConversation = analyzationService.AnalyzeConversation(conversation);
            var conversationUdpdated = covnersationUpdateService.UpdateConversation(analyzedConversation, chat.type);

            AnalyzedChat inResponseTo = null;

            if (analyzedConversation.responses.Count() > 1)
            {
                inResponseTo = analyzedConversation.responses[analyzedConversation.responses.Count() - 2];
            }
            userService.UpdateUsers(analyzedConversation.responses.Last(), inResponseTo);

            return(GetChatResponse(conversation, chat.exclusiveTypes, chat.requiredProperyMatches, chat.excludedTypes, chat.subjectGoals));
        }