Merge pull request #410 from iceljc/features/refine-conversation-functionality
add repository enum
This commit is contained in:
commit
887619d5f4
|
|
@ -20,4 +20,7 @@ public class ElementButton
|
|||
|
||||
[JsonPropertyName("is_secondary")]
|
||||
public bool IsSecondary { get; set; }
|
||||
|
||||
[JsonPropertyName("post_action_disclaimer")]
|
||||
public string? PostActionDisclaimer { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
namespace BotSharp.Abstraction.Repositories.Enums;
|
||||
|
||||
public static class RepositoryEnum
|
||||
{
|
||||
public const string FileRepository = nameof(FileRepository);
|
||||
public const string MongoRepository = nameof(MongoRepository);
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
using BotSharp.Abstraction.Repositories.Enums;
|
||||
using System.IO;
|
||||
|
||||
namespace BotSharp.Core.Agents.Services;
|
||||
|
|
@ -6,12 +7,19 @@ public partial class AgentService
|
|||
{
|
||||
public async Task<string> RefreshAgents()
|
||||
{
|
||||
string refreshResult;
|
||||
var dbSettings = _services.GetRequiredService<BotSharpDatabaseSettings>();
|
||||
if (dbSettings.Default == RepositoryEnum.FileRepository)
|
||||
{
|
||||
refreshResult = $"Invalid database repository setting: {dbSettings.Default}";
|
||||
_logger.LogWarning(refreshResult);
|
||||
return refreshResult;
|
||||
}
|
||||
|
||||
var agentDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
|
||||
dbSettings.FileRepository,
|
||||
_agentSettings.DataDir);
|
||||
|
||||
string refreshResult;
|
||||
if (!Directory.Exists(agentDir))
|
||||
{
|
||||
refreshResult = $"Cannot find the directory: {agentDir}";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using BotSharp.Abstraction.Agents.Models;
|
||||
using BotSharp.Abstraction.Functions.Models;
|
||||
using BotSharp.Abstraction.Repositories;
|
||||
using BotSharp.Abstraction.Repositories.Enums;
|
||||
using BotSharp.Abstraction.Routing.Models;
|
||||
using System.IO;
|
||||
|
||||
|
|
@ -42,6 +43,16 @@ public partial class AgentService
|
|||
public async Task<string> UpdateAgentFromFile(string id)
|
||||
{
|
||||
string updateResult;
|
||||
var dbSettings = _services.GetRequiredService<BotSharpDatabaseSettings>();
|
||||
var agentSettings = _services.GetRequiredService<AgentSettings>();
|
||||
|
||||
if (dbSettings.Default == RepositoryEnum.FileRepository)
|
||||
{
|
||||
updateResult = $"Invalid database repository setting: {dbSettings.Default}";
|
||||
_logger.LogWarning(updateResult);
|
||||
return updateResult;
|
||||
}
|
||||
|
||||
var agent = _db.GetAgent(id);
|
||||
if (agent == null)
|
||||
{
|
||||
|
|
@ -50,8 +61,6 @@ public partial class AgentService
|
|||
return updateResult;
|
||||
}
|
||||
|
||||
var dbSettings = _services.GetRequiredService<BotSharpDatabaseSettings>();
|
||||
var agentSettings = _services.GetRequiredService<AgentSettings>();
|
||||
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
|
||||
dbSettings.FileRepository,
|
||||
agentSettings.DataDir);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using BotSharp.Abstraction.Repositories.Enums;
|
||||
using BotSharp.Abstraction.Settings;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
|
|
@ -32,7 +33,7 @@ public class RepositoryPlugin : IBotSharpPlugin
|
|||
|
||||
var myDatabaseSettings = new BotSharpDatabaseSettings();
|
||||
config.Bind("Database", myDatabaseSettings);
|
||||
if (myDatabaseSettings.Default == "FileRepository")
|
||||
if (myDatabaseSettings.Default == RepositoryEnum.FileRepository)
|
||||
{
|
||||
services.AddScoped<IBotSharpRepository, FileRepository>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using BotSharp.Abstraction.Plugins.Models;
|
||||
using BotSharp.Abstraction.Repositories.Enums;
|
||||
using BotSharp.Plugin.MongoStorage.Repository;
|
||||
|
||||
namespace BotSharp.Plugin.MongoStorage;
|
||||
|
|
@ -18,7 +19,7 @@ public class MongoStoragePlugin : IBotSharpPlugin
|
|||
var dbSettings = new BotSharpDatabaseSettings();
|
||||
config.Bind("Database", dbSettings);
|
||||
|
||||
if (dbSettings.Default == "MongoRepository")
|
||||
if (dbSettings.Default == RepositoryEnum.MongoRepository)
|
||||
{
|
||||
services.AddScoped((IServiceProvider x) =>
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue