From 1bf4dd16a0c3d6e6389526c2a11bbeac8a8d4cac Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Mon, 28 Aug 2023 14:36:02 -0500 Subject: [PATCH] resolve conflicts --- .../BotSharp.Core/Routing/Router.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Infrastructure/BotSharp.Core/Routing/Router.cs b/src/Infrastructure/BotSharp.Core/Routing/Router.cs index 594ee734..996e83bc 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/Router.cs +++ b/src/Infrastructure/BotSharp.Core/Routing/Router.cs @@ -1,7 +1,7 @@ using BotSharp.Abstraction.Agents.Models; +using BotSharp.Abstraction.Repositories; using BotSharp.Abstraction.Routing.Models; using System.IO; -using static Tensorflow.ApiDef.Types; namespace BotSharp.Core.Routing; @@ -33,7 +33,19 @@ public class Router : IAgentRouting var agentSettings = _services.GetRequiredService(); var dbSettings = _services.GetRequiredService(); var filePath = Path.Combine(dbSettings.FileRepository, agentSettings.DataDir, agentSettings.RouterId, "route.json"); - return JsonSerializer.Deserialize(File.ReadAllText(filePath)); + + var db = _services.GetRequiredService(); + var agent = db.Agent.FirstOrDefault(x => x.Id == agentSettings.RouterId); + var routes = agent?.Routes ?? new List(); + var routingRecords = new RoutingRecord[routes.Count]; + + for (int i = 0; i < routes.Count; i++) + { + if (string.IsNullOrEmpty(routes[i])) continue; + routingRecords[i] = JsonSerializer.Deserialize(routes[i]); + } + + return routingRecords; } public RoutingRecord GetRecordByName(string name)