| | | 1 | | using OzonOrdersWeb.TransactionServices; |
| | | 2 | | using Services.TransactionUtilsServices; |
| | | 3 | | |
| | | 4 | | namespace OzonOrdersWeb.WebServices.Transactions.Grid.Commit.Steps; |
| | | 5 | | |
| | | 6 | | /// <summary>Запись <c>Transaction</c> и привязка заказов через делегат определения (<c>TransactionManager.Create*</c>). |
| | | 7 | | public sealed class CreateTransactionStep : ITransactionCommitStep |
| | | 8 | | { |
| | | 9 | | private readonly TransactionManager _manager; |
| | | 10 | | |
| | 0 | 11 | | public CreateTransactionStep(TransactionManager manager) |
| | | 12 | | { |
| | 0 | 13 | | _manager = manager; |
| | 0 | 14 | | } |
| | | 15 | | |
| | 0 | 16 | | public string Key => TransactionCommitStepKeys.CreateTransaction; |
| | | 17 | | |
| | | 18 | | public async Task ExecuteAsync(TransactionCommitContext ctx) |
| | | 19 | | { |
| | 0 | 20 | | if (ctx.OrdersToTransaction.Count == 0) |
| | | 21 | | { |
| | 0 | 22 | | return; |
| | | 23 | | } |
| | | 24 | | |
| | 0 | 25 | | await ctx.StageAsync("document", "Записываем документ в Studio2"); |
| | 0 | 26 | | ctx.HistoryWindowStart = DateTime.Now; |
| | 0 | 27 | | var comment = TransactionCommentAiSchedulingHelper.ResolveCommentForDatabase( |
| | 0 | 28 | | ctx.CommentFlow.UserCommentOnly, ctx.CommentFlow.ScheduleAiComment, ctx.TechnicalComment); |
| | | 29 | | |
| | 0 | 30 | | var (changeCount, dateTime, transactionId) = await ctx.Definition.CreateTransaction( |
| | 0 | 31 | | _manager, ctx.OrdersToTransaction, ctx.User.Name, ctx.CreatedAt, comment); |
| | | 32 | | |
| | 0 | 33 | | ctx.ChangedCount = changeCount; |
| | 0 | 34 | | ctx.TransactionDateTime = dateTime; |
| | 0 | 35 | | ctx.TransactionId = transactionId; |
| | 0 | 36 | | } |
| | | 37 | | } |