From 6d9cf5ddbb7a6b6499f75159582fbf3b879adfec Mon Sep 17 00:00:00 2001 From: Oceania2018 Date: Wed, 6 Jun 2018 11:20:02 -0500 Subject: [PATCH] fix user expression parts order --- BotSharp.Core/Agents/AgentDriver.cs | 2 +- BotSharp.Core/Intents/IntentDriver.cs | 7 ++++++- BotSharp.Core/Intents/IntentResponseParameter.cs | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/BotSharp.Core/Agents/AgentDriver.cs b/BotSharp.Core/Agents/AgentDriver.cs index fa24e1c5..b8444af9 100644 --- a/BotSharp.Core/Agents/AgentDriver.cs +++ b/BotSharp.Core/Agents/AgentDriver.cs @@ -83,7 +83,7 @@ namespace BotSharp.Core.Agents var intents = dc.Table() .Include(x => x.Contexts) .Include(x => x.UserSays).ThenInclude(say => say.Data) - .Where(x => x.UserSays.Count > 0) + .Where(x => x.AgentId == agent.Id && x.UserSays.Count > 0) .ToList(); intents.ForEach(intent => diff --git a/BotSharp.Core/Intents/IntentDriver.cs b/BotSharp.Core/Intents/IntentDriver.cs index 68e3c12b..28b510cf 100644 --- a/BotSharp.Core/Intents/IntentDriver.cs +++ b/BotSharp.Core/Intents/IntentDriver.cs @@ -13,13 +13,18 @@ namespace BotSharp.Core.Intents { public static Intent GetIntent(this IBotEngine bot, Database dc, string intentId) { - return dc.Table() + var intent = dc.Table() .Include(x => x.Contexts) .Include(x => x.Responses).ThenInclude(x => x.Contexts) .Include(x => x.Responses).ThenInclude(x => x.Parameters) .Include(x => x.Responses).ThenInclude(x => x.Messages) .Include(x => x.UserSays).ThenInclude(x => x.Data) .FirstOrDefault(x => x.Id == intentId); + + // order parts by time + intent.UserSays.ForEach(x => x.Data = x.Data.OrderBy(d => d.UpdatedTime).ToList()); + + return intent; } public static String CreateIntent(this Agent agent, Database dc, Intent intent) diff --git a/BotSharp.Core/Intents/IntentResponseParameter.cs b/BotSharp.Core/Intents/IntentResponseParameter.cs index 07165476..9b0c3a9b 100644 --- a/BotSharp.Core/Intents/IntentResponseParameter.cs +++ b/BotSharp.Core/Intents/IntentResponseParameter.cs @@ -19,6 +19,9 @@ namespace BotSharp.Core.Intents [MaxLength(32)] public string DataType { get; set; } + [MaxLength(128)] + public string DefaultValue { get; set; } + [MaxLength(64)] public string Name { get; set; }