2023-09-07 22:04:34 +00:00
|
|
|
using BotSharp.Abstraction.Agents.Models;
|
2023-08-26 04:41:01 +00:00
|
|
|
using BotSharp.Abstraction.Repositories;
|
2023-09-07 22:04:34 +00:00
|
|
|
using BotSharp.Abstraction.Users.Models;
|
2023-08-10 04:53:22 +00:00
|
|
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
|
|
|
|
2023-06-11 23:46:02 +00:00
|
|
|
namespace BotSharp.Core.Repository;
|
|
|
|
|
|
2023-08-10 04:53:22 +00:00
|
|
|
public class BotSharpDbContext : Database, IBotSharpRepository
|
2023-06-11 23:46:02 +00:00
|
|
|
{
|
2023-09-07 22:04:34 +00:00
|
|
|
public IQueryable<User> Users => throw new NotImplementedException();
|
2023-08-10 04:53:22 +00:00
|
|
|
|
2023-09-07 22:04:34 +00:00
|
|
|
public IQueryable<Agent> Agents => throw new NotImplementedException();
|
2023-09-02 05:10:46 +00:00
|
|
|
|
2023-09-07 22:04:34 +00:00
|
|
|
public IQueryable<UserAgent> UserAgents => throw new NotImplementedException();
|
|
|
|
|
|
|
|
|
|
public IQueryable<Conversation> Conversations => throw new NotImplementedException();
|
|
|
|
|
|
2023-09-02 05:10:46 +00:00
|
|
|
|
2023-08-10 04:53:22 +00:00
|
|
|
public int Transaction<TTableInterface>(Action action)
|
|
|
|
|
{
|
|
|
|
|
DatabaseFacade database = base.GetMaster(typeof(TTableInterface)).Database;
|
|
|
|
|
int num = 0;
|
|
|
|
|
if (database.CurrentTransaction == null)
|
|
|
|
|
{
|
|
|
|
|
using (Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction dbContextTransaction = database.BeginTransaction())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
action();
|
|
|
|
|
num = base.SaveChanges();
|
|
|
|
|
dbContextTransaction.Commit();
|
|
|
|
|
return num;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
dbContextTransaction.Rollback();
|
|
|
|
|
if (ex.Message.Contains("See the inner exception for details"))
|
|
|
|
|
{
|
|
|
|
|
throw ex.InnerException;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
action();
|
|
|
|
|
return base.SaveChanges();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex2)
|
|
|
|
|
{
|
|
|
|
|
if (database.CurrentTransaction != null)
|
|
|
|
|
{
|
|
|
|
|
database.CurrentTransaction.Rollback();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ex2.Message.Contains("See the inner exception for details"))
|
|
|
|
|
{
|
|
|
|
|
throw ex2.InnerException;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw ex2;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-03 04:11:53 +00:00
|
|
|
|
2023-09-07 22:04:34 +00:00
|
|
|
|
2023-09-15 22:08:59 +00:00
|
|
|
#region Agent
|
|
|
|
|
public Agent GetAgent(string agentId)
|
2023-09-03 04:11:53 +00:00
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-19 22:27:51 +00:00
|
|
|
public List<Agent> GetAgents(string? name = null, bool? disabled = null, bool? allowRouting = null,
|
|
|
|
|
bool? isPublic = null, List<string>? agentIds = null)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Agent> GetAgentsByUser(string userId)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-15 22:08:59 +00:00
|
|
|
public void UpdateAgent(Agent agent, AgentField field)
|
2023-09-03 04:11:53 +00:00
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-15 22:08:59 +00:00
|
|
|
public string GetAgentTemplate(string agentId, string templateName)
|
2023-09-03 04:11:53 +00:00
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-15 22:08:59 +00:00
|
|
|
public List<string> GetAgentResponses(string agentId, string prefix, string intent)
|
2023-09-03 04:11:53 +00:00
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
2023-10-17 20:29:40 +00:00
|
|
|
|
|
|
|
|
public void BulkInsertAgents(List<Agent> agents)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void BulkInsertUserAgents(List<UserAgent> userAgents)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool DeleteAgents()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
2023-09-15 22:08:59 +00:00
|
|
|
#endregion
|
2023-09-03 04:54:22 +00:00
|
|
|
|
2023-09-15 22:08:59 +00:00
|
|
|
|
|
|
|
|
#region Conversation
|
|
|
|
|
public void CreateNewConversation(Conversation conversation)
|
2023-09-03 04:54:22 +00:00
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
2023-09-03 19:32:12 +00:00
|
|
|
|
2023-09-15 22:08:59 +00:00
|
|
|
public Conversation GetConversation(string conversationId)
|
2023-09-03 19:32:12 +00:00
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
2023-09-03 22:43:50 +00:00
|
|
|
|
2023-09-15 22:08:59 +00:00
|
|
|
public List<Conversation> GetConversations(string userId)
|
2023-09-07 22:04:34 +00:00
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-10 16:01:03 +00:00
|
|
|
public List<Conversation> GetLastConversations()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-15 22:08:59 +00:00
|
|
|
public string GetConversationDialog(string conversationId)
|
2023-09-07 22:04:34 +00:00
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-15 22:08:59 +00:00
|
|
|
public List<StateKeyValue> GetConversationStates(string conversationId)
|
2023-09-03 22:43:50 +00:00
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-15 22:08:59 +00:00
|
|
|
public void UpdateConversationDialog(string conversationId, string dialogs)
|
2023-09-03 22:43:50 +00:00
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-15 22:08:59 +00:00
|
|
|
public void UpdateConversationStates(string conversationId, List<StateKeyValue> states)
|
2023-09-07 22:04:34 +00:00
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
2023-10-23 20:33:24 +00:00
|
|
|
|
2023-11-15 18:35:24 +00:00
|
|
|
public void UpdateConversationStatus(string conversationId, string status)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-23 20:33:24 +00:00
|
|
|
public void AddExectionLogs(string conversationId, List<string> logs)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<string> GetExectionLogs(string conversationId)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
2023-09-15 22:08:59 +00:00
|
|
|
#endregion
|
2023-09-07 22:04:34 +00:00
|
|
|
|
2023-09-15 22:08:59 +00:00
|
|
|
|
|
|
|
|
#region User
|
2023-10-17 20:29:40 +00:00
|
|
|
public User? GetUserByEmail(string email)
|
2023-09-03 22:43:50 +00:00
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-14 01:25:25 +00:00
|
|
|
public User? GetUserById(string id)
|
2023-10-19 22:27:51 +00:00
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-15 22:08:59 +00:00
|
|
|
public void CreateUser(User user)
|
2023-09-03 22:43:50 +00:00
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
2023-09-15 22:08:59 +00:00
|
|
|
#endregion
|
2023-06-11 23:46:02 +00:00
|
|
|
}
|