diff --git a/src/Infrastructure/BotSharp.Abstraction/Conversations/Models/Conversation.cs b/src/Infrastructure/BotSharp.Abstraction/Conversations/Models/Conversation.cs index f8f85871..87895f01 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Conversations/Models/Conversation.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Conversations/Models/Conversation.cs @@ -1,3 +1,5 @@ +using System.Text.Json.Serialization; + namespace BotSharp.Abstraction.Conversations.Models; public class Conversation @@ -6,7 +8,9 @@ public class Conversation public string AgentId { get; set; } = string.Empty; public string UserId { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; + [JsonIgnore] public string Dialog { get; set; } = string.Empty; + [JsonIgnore] public ConversationState States { get; set; } public DateTime UpdatedTime { get; set; } = DateTime.UtcNow; diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs index f0edecf6..f7899710 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs @@ -48,10 +48,7 @@ public class ConversationStateService : IConversationStateService, IDisposable public ConversationState Load(string conversationId) { - if (_states != null) - { - return _states; - } + _conversationId = conversationId; _savedStates = _db.GetConversationStates(_conversationId); diff --git a/src/Infrastructure/BotSharp.Core/Repository/FileRepository.cs b/src/Infrastructure/BotSharp.Core/Repository/FileRepository.cs index 32e40cc2..b52f7f52 100644 --- a/src/Infrastructure/BotSharp.Core/Repository/FileRepository.cs +++ b/src/Infrastructure/BotSharp.Core/Repository/FileRepository.cs @@ -138,7 +138,7 @@ public class FileRepository : IBotSharpRepository var filePath = Path.Combine(_dbSettings.FileRepository, _agentSettings.DataDir, "route.json"); if (File.Exists(filePath)) { - _routingItems = JsonSerializer.Deserialize>(File.ReadAllText(filePath)); + _routingItems = JsonSerializer.Deserialize>(File.ReadAllText(filePath), _options); } return _routingItems.AsQueryable(); @@ -159,7 +159,7 @@ public class FileRepository : IBotSharpRepository var filePath = Path.Combine(_dbSettings.FileRepository, _agentSettings.DataDir, "routing-profile.json"); if (File.Exists(filePath)) { - _routingProfiles = JsonSerializer.Deserialize>(File.ReadAllText(filePath)); + _routingProfiles = JsonSerializer.Deserialize>(File.ReadAllText(filePath).ToLower(), _options); } return _routingProfiles.AsQueryable(); @@ -511,7 +511,8 @@ public class FileRepository : IBotSharpRepository if (!string.IsNullOrEmpty(convDir)) { var convFile = Path.Combine(convDir, "conversation.json"); - var record = JsonSerializer.Deserialize(convFile); + var content = File.ReadAllText(convFile); + var record = JsonSerializer.Deserialize(content, _options); var dialogFile = Path.Combine(convDir, "dialogs.txt"); if (record != null && File.Exists(dialogFile)) diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.cs index 6402f94c..8343690f 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.cs @@ -476,6 +476,7 @@ public class MongoRepository : IBotSharpRepository AgentId = Guid.Parse(conversation.AgentId), UserId = Guid.Parse(conversation.UserId), Title = conversation.Title, + States = conversation.States?.ToKeyValueList() ?? new List(), CreatedTime = DateTime.UtcNow, UpdatedTime = DateTime.UtcNow, };