2025-02-23 14:55:35 +00:00
|
|
|
using BotSharp.Abstraction.Agents.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace BotSharp.Plugin.MongoStorage.Models;
|
|
|
|
|
|
|
|
|
|
[BsonIgnoreExtraElements(Inherited = true)]
|
2025-02-24 01:04:44 +00:00
|
|
|
public class AgentCPMongoElement
|
2025-02-23 14:55:35 +00:00
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
public string ServerId { get; set; }
|
|
|
|
|
|
|
|
|
|
public bool Disabled { get; set; }
|
2025-02-24 01:04:44 +00:00
|
|
|
public List<AcpFunctionMongoElement> Functions { get; set; } = [];
|
|
|
|
|
public List<AcpTemplateMongoElement> Templates { get; set; } = [];
|
2025-02-23 14:55:35 +00:00
|
|
|
|
2025-02-24 01:04:44 +00:00
|
|
|
public static AgentCPMongoElement ToMongoElement(AgentCP utility)
|
2025-02-23 14:55:35 +00:00
|
|
|
{
|
2025-02-24 01:04:44 +00:00
|
|
|
return new AgentCPMongoElement
|
2025-02-23 14:55:35 +00:00
|
|
|
{
|
|
|
|
|
Name = utility.Name,
|
|
|
|
|
Disabled = utility.Disabled,
|
2025-02-24 01:04:44 +00:00
|
|
|
Functions = utility.Functions?.Select(x => new AcpFunctionMongoElement(x.Name))?.ToList() ?? [],
|
|
|
|
|
Templates = utility.Templates?.Select(x => new AcpTemplateMongoElement(x.Name))?.ToList() ?? []
|
2025-02-23 14:55:35 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-24 01:04:44 +00:00
|
|
|
public static AgentCP ToDomainElement(AgentCPMongoElement utility)
|
2025-02-23 14:55:35 +00:00
|
|
|
{
|
2025-02-24 01:04:44 +00:00
|
|
|
return new AgentCP
|
2025-02-23 14:55:35 +00:00
|
|
|
{
|
|
|
|
|
Name = utility.Name,
|
|
|
|
|
Disabled = utility.Disabled,
|
2025-02-24 01:04:44 +00:00
|
|
|
Functions = utility.Functions?.Select(x => new ACPFunction(x.Name))?.ToList() ?? [],
|
|
|
|
|
Templates = utility.Templates?.Select(x => new ACPTemplate(x.Name))?.ToList() ?? []
|
2025-02-23 14:55:35 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-24 01:04:44 +00:00
|
|
|
public class AcpFunctionMongoElement
|
2025-02-23 14:55:35 +00:00
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
2025-02-24 01:04:44 +00:00
|
|
|
public AcpFunctionMongoElement()
|
2025-02-23 14:55:35 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-24 01:04:44 +00:00
|
|
|
public AcpFunctionMongoElement(string name)
|
2025-02-23 14:55:35 +00:00
|
|
|
{
|
|
|
|
|
Name = name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-24 01:04:44 +00:00
|
|
|
public class AcpTemplateMongoElement
|
2025-02-23 14:55:35 +00:00
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
2025-02-24 01:04:44 +00:00
|
|
|
public AcpTemplateMongoElement()
|
2025-02-23 14:55:35 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-24 01:04:44 +00:00
|
|
|
public AcpTemplateMongoElement(string name)
|
2025-02-23 14:55:35 +00:00
|
|
|
{
|
|
|
|
|
Name = name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|