Код: Выделить всё
public async Task UpdateSchemeInvestor([FromBody] AddUpdateSchemeInvestorDto model)
{
using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
{
try
{
int schemeInvestorId = model.Id.GetValueOrDefault();
await _adminService.UpdateSchemeInvestorAsync(model, CurrentUser);
var emails = new List()
{
model.Email1,
model.Email2,
model.Email3,
model.Email4,
model.Email5
};
emails.RemoveAll(string.IsNullOrWhiteSpace);
emails = emails.Distinct().ToList();
var existingEmails = await _adminService.GetSchemeInvestorEmailsAsync(schemeInvestorId);
var newEmails = emails.Except(existingEmails).ToList();
var removedEmails = existingEmails.Except(emails).ToList();
await ValidateSchemeInvestorEmailUsageInFundHouseAsync(model.FundHouseId, newEmails); // this is using dapper
if (newEmails.Any())
{
await _adminService.AddSchemeInvestorUsersAsync(schemeInvestorId, newEmails, CurrentUser);
}
if (removedEmails.Any())
{
await _adminService.DeleteSchemeInvestorUsersAsync(schemeInvestorId, removedEmails);
}
scope.Complete();
return BuildSuccessResponse("");
}
catch (ApplicationException ex)
{
scope.Dispose();
return BuildFailureResponse(ex.Message);
}
catch
{
scope.Dispose();
throw;
}
}
}
Код: Выделить всё
ValidateSchemeInvestorEmailUsageInFundHouseAsyncЭто реализация метода
Код: Выделить всё
public async Task GetEmailAlreadyInUseInOtherFundHouseAsync(int fundHouseId, IEnumerable emails)
{
using (var connection = BuildConnection())
{
connection.Open();
string query = @"
select
u.Email
from schemeinvestorusers siu
join aspnetusers u on siu.InvestorUserId=u.Id
join schemeinvestors si on siu.SchemeInvestorId=si.Id
join schemes s on si.SchemeId=s.Id
join funds f on s.FundId=f.Id
where u.Email in @emails and f.FundHouseId@fundHouseId";
var users = await connection.QueryAsync(query, param: new { fundHouseId, emails });
return users.Select(x => x.Email).Distinct();
}
Код: Выделить всё
IdentityResult result = await _userManager.CreateAsync(newUser, UserAuthentication.GlobalPassword);
Тайм-аут команды истек до завершения операции.
Выполнение запроса было прервано
И это полная трассировка исключения
Microsoft.EntityFrameworkCore.DbUpdateException: произошла ошибка
при сохранении изменений сущности. Подробности смотрите во внутреннем исключении.
---> MySqlConnector.MySqlException (0x80004005): время ожидания команды истекло до завершения операции. --->
MySqlConnector.MySqlException (0x80004005): выполнение запроса
прервано в
MySqlConnector.Core.ServerSession.ReceiveReplyAsyncAwaited(ValueTask)
Код: Выделить всё
1 task) in /_/src/MySqlConnector/Core/ServerSession.cs:line 962 at MySqlConnector.Core.ResultSet.ReadResultSetHeaderAsync(IOBehavior ioBehavior) in /_/src/MySqlConnector/Core/ResultSet.cs:line 43 at MySqlConnector.MySqlDataReader.ActivateResultSet(CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlDataReader.cs:line 124 at MySqlConnector.MySqlDataReader.CreateAsync(CommandListPosition commandListPosition, ICommandPayloadCreator payloadCreator, IDictionary, активность активности, IOBehavior ioBehavior, CancellationToken
cancellationToken) в /_/src/MySqlConnector/MySqlDataReader.cs:line
468 atMySqlConnector.Core.CommandExecutor.ExecuteReaderAsync(IReadOnlyList
Код: Выделить всё
1 commands, ICommandPayloadCreator payloadCreator, CommandBehavior behavior, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/CommandExecutor.cs:line 56 at MySqlConnector.MySqlCommand.ExecuteReaderAsync(CommandBehavior behavior, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlCommand.cs:line 344 at MySqlConnector.MySqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlCommand.cs:line 337 at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken) --- End of inner exception stack trace --- at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerablecommandBatches, соединение IRelationalConnection, CancellationToken
cancellationToken) в
Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable
Код: Выделить всё
1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerablecommandBatches, соединение IRelationalConnection, CancellationToken
cancellationToken) в
Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList
Код: Выделить всё
1 entriesToSave, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, FuncКод: Выделить всё
4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStoreпользователь, CancellationToken cancelToken) в
Microsoft.AspNetCore.Identity.UserManager
Код: Выделить всё
1.CreateAsync(TUser user) at Microsoft.AspNetCore.Identity.UserManagerстроковый пароль) в
KpfsInvestor.Business.Services.Implementations.AdminService.AddSchemeInvestorUsersAsync(Int32
schemeInvestorId, IEnumerable
Код: Выделить всё
1 emails, CurrentUserDto user) in D:\Projects\Main\kpfs-exp-investor\Server\KpfsInvestor.Business\Services\Implementations\AdminService.cs:line 278 at KpfsInvestor.Web.Controllers.AdminController.UpdateSchemeInvestor(AddUpdateSchemeInvestorDto model) at lambda_method1681(Closure, Object) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker invoker, ValueTaskMicrosoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker
invoker, Task LastTask, State next, Область области действия, Состояние объекта, Boolean
isCompleted) в
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed
context) в
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State&
next, Область и область, Object& состояние, Boolean& isCompleted) в
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker
invoker, Task LastTask, State next, Область области, Состояние объекта, Boolean
isCompleted) в
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|26_0(ResourceInvoker
invoker, Task lastTask, State next, Область области действия, Состояние объекта, Boolean
isCompleted)< /p>
Подробнее здесь: https://stackoverflow.com/questions/790 ... ctionscope
Мобильная версия