fix file bugs
This commit is contained in:
parent
24be8e7791
commit
9f918c6509
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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<List<RoutingItem>>(File.ReadAllText(filePath));
|
||||
_routingItems = JsonSerializer.Deserialize<List<RoutingItem>>(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<List<RoutingProfile>>(File.ReadAllText(filePath));
|
||||
_routingProfiles = JsonSerializer.Deserialize<List<RoutingProfile>>(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<Conversation>(convFile);
|
||||
var content = File.ReadAllText(convFile);
|
||||
var record = JsonSerializer.Deserialize<Conversation>(content, _options);
|
||||
|
||||
var dialogFile = Path.Combine(convDir, "dialogs.txt");
|
||||
if (record != null && File.Exists(dialogFile))
|
||||
|
|
|
|||
|
|
@ -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<KeyValueModel>(),
|
||||
CreatedTime = DateTime.UtcNow,
|
||||
UpdatedTime = DateTime.UtcNow,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue