add log in agent refresh
This commit is contained in:
parent
5380ecba7d
commit
2af4102b65
|
|
@ -51,10 +51,12 @@ public partial class AgentService
|
||||||
var isAgentDeleted = _db.DeleteAgent(agent.Id);
|
var isAgentDeleted = _db.DeleteAgent(agent.Id);
|
||||||
if (isAgentDeleted)
|
if (isAgentDeleted)
|
||||||
{
|
{
|
||||||
|
await Task.Delay(100);
|
||||||
_db.BulkInsertAgents(new List<Agent> { agent });
|
_db.BulkInsertAgents(new List<Agent> { agent });
|
||||||
_db.BulkInsertUserAgents(new List<UserAgent> { userAgent });
|
_db.BulkInsertUserAgents(new List<UserAgent> { userAgent });
|
||||||
_db.BulkInsertAgentTasks(tasks);
|
_db.BulkInsertAgentTasks(tasks);
|
||||||
refreshedAgents.Add(agent.Name);
|
refreshedAgents.Add(agent.Name);
|
||||||
|
_logger.LogInformation($"Agent {agent.Name} has been migrated.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -66,7 +68,7 @@ public partial class AgentService
|
||||||
if (!refreshedAgents.IsNullOrEmpty())
|
if (!refreshedAgents.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
Utilities.ClearCache();
|
Utilities.ClearCache();
|
||||||
refreshResult = $"Agents are migrated! {string.Join("\r\n", refreshedAgents)}";
|
refreshResult = $"Agents are migrated!\r\n{string.Join("\r\n", refreshedAgents)}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -41,10 +41,13 @@ public partial class AgentService
|
||||||
|
|
||||||
public async Task<string> UpdateAgentFromFile(string id)
|
public async Task<string> UpdateAgentFromFile(string id)
|
||||||
{
|
{
|
||||||
|
string updateResult;
|
||||||
var agent = _db.GetAgent(id);
|
var agent = _db.GetAgent(id);
|
||||||
if (agent == null)
|
if (agent == null)
|
||||||
{
|
{
|
||||||
return $"Cannot find agent ${id}";
|
updateResult = $"Cannot find agent ${id}";
|
||||||
|
_logger.LogError(updateResult);
|
||||||
|
return updateResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
var dbSettings = _services.GetRequiredService<BotSharpDatabaseSettings>();
|
var dbSettings = _services.GetRequiredService<BotSharpDatabaseSettings>();
|
||||||
|
|
@ -57,7 +60,9 @@ public partial class AgentService
|
||||||
var foundAgent = FetchAgentFileById(agent.Id, filePath);
|
var foundAgent = FetchAgentFileById(agent.Id, filePath);
|
||||||
if (foundAgent == null)
|
if (foundAgent == null)
|
||||||
{
|
{
|
||||||
return $"Cannot find agent {agent.Name} in file directory: {filePath}";
|
updateResult = $"Cannot find agent {agent.Name} in file directory: {filePath}";
|
||||||
|
_logger.LogError(updateResult);
|
||||||
|
return updateResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -79,11 +84,16 @@ public partial class AgentService
|
||||||
|
|
||||||
_db.UpdateAgent(clonedAgent, AgentField.All);
|
_db.UpdateAgent(clonedAgent, AgentField.All);
|
||||||
Utilities.ClearCache();
|
Utilities.ClearCache();
|
||||||
return $"Agent {agent.Name} has been migrated!";
|
|
||||||
|
updateResult = $"Agent {agent.Name} has been migrated!";
|
||||||
|
_logger.LogInformation(updateResult);
|
||||||
|
return updateResult;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
return $"Failed to migrate agent {agent.Name} in file directory {filePath}.\r\nError: {ex.Message}";
|
updateResult = $"Failed to migrate agent {agent.Name} in file directory {filePath}.\r\nError: {ex.Message}";
|
||||||
|
_logger.LogError(updateResult);
|
||||||
|
return updateResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue