temp save
This commit is contained in:
parent
0addd38ce4
commit
7c34dbc0a7
|
|
@ -1,4 +1,5 @@
|
|||
using BotSharp.Abstraction.Tasks.Models;
|
||||
using BotSharp.Abstraction.Users.Enums;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
|
|
@ -25,6 +26,20 @@ public partial class AgentService
|
|||
|
||||
var user = _db.GetUserById(_user.Id);
|
||||
_db.BulkInsertAgents(new List<Agent> { agentRecord });
|
||||
if (!UserConstant.AdminRoles.Contains(user.Role))
|
||||
{
|
||||
_db.BulkInsertUserAgents(new List<UserAgent>
|
||||
{
|
||||
new UserAgent
|
||||
{
|
||||
UserId = user.Id,
|
||||
AgentId = agent.Id,
|
||||
Actions = new List<string> { UserAction.Edit },
|
||||
CreatedTime = DateTime.UtcNow,
|
||||
UpdatedTime = DateTime.UtcNow
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Utilities.ClearCache();
|
||||
return await Task.FromResult(agentRecord);
|
||||
|
|
|
|||
|
|
@ -429,15 +429,16 @@ public partial class MongoRepository
|
|||
{
|
||||
if (userAgents.IsNullOrEmpty()) return;
|
||||
|
||||
var userAgentDocs = userAgents.Select(x => new UserAgentDocument
|
||||
{
|
||||
Id = !string.IsNullOrEmpty(x.Id) ? x.Id : Guid.NewGuid().ToString(),
|
||||
UserId = !string.IsNullOrEmpty(x.UserId) ? x.UserId : string.Empty,
|
||||
AgentId = x.AgentId,
|
||||
Actions = x.Actions,
|
||||
CreatedTime = x.CreatedTime,
|
||||
UpdatedTime = x.UpdatedTime
|
||||
}).ToList();
|
||||
var userAgentDocs = userAgents.Where(x => !string.IsNullOrEmpty(x.UserId))
|
||||
.Select(x => new UserAgentDocument
|
||||
{
|
||||
Id = !string.IsNullOrEmpty(x.Id) ? x.Id : Guid.NewGuid().ToString(),
|
||||
UserId = x.UserId,
|
||||
AgentId = x.AgentId,
|
||||
Actions = x.Actions,
|
||||
CreatedTime = x.CreatedTime,
|
||||
UpdatedTime = x.UpdatedTime
|
||||
}).ToList();
|
||||
|
||||
_dc.UserAgents.InsertMany(userAgentDocs);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue