Below is an instruction that describes a task. Write a response that appropriately completes the request.
using iRIS.Framework.Cqrs.Interfaces;
using iRIS.Framework.CrossCutting.Caching;
using iRIS.Framework.Workflow.Process.TaskSchedulerServiceInvoker;
using iRIS.InsuranceCore.Code.Implementations.TaskScheduler;
using iRIS.InsuranceCore.Code.Interfaces.Clients.ViewAppServiceClient.Constants;
using iRIS.InsuranceCore.Code.Interfaces.Clients.ViewAppServiceClient.Extensions;
using iRIS.InsuranceCore.Code.Interfaces.Clients.ViewAppServiceClient.Models.WebHookModels;
using iRIS.InsuranceCore.Code.Interfaces.TaskScheduler;
using iRIS.InsuranceCore.Code.Interfaces.TaskScheduler.Models;
using iRIS.InsuranceCore.Code.Interfaces.ViewAppService;
using iRIS.InsuranceCore.Code.Queries;
using Serilog;

namespace iRIS.InsuranceCore.Code.Implementations.ViewAppService
{
    public class ViewAppServiceRequestHandler : IViewAppServiceRequestHandler
    {
        private readonly ICqrsMediator _cqrsMediator;
        private readonly IScheduledTaskForBasketCreator _scheduledTaskForBasketCreator;
        private readonly ILogger _logger;
        private readonly ICache _cache;
        private readonly string _viewAppScheduledTaskCachePrefix = "ViewAppScheduledTask_";

        protected ICqrsMediator CqrsMediator => _cqrsMediator;

        protected IScheduledTaskForBasketCreator ScheduledTaskForBasketCreator => _scheduledTaskForBasketCreator;

        protected ILogger Logger => _logger;

        public ViewAppServiceRequestHandler(
            ICqrsMediator cqrsMediator,
            IScheduledTaskForBasketCreator scheduledTaskForBasketCreator,
            ILogger logger,
            ICache cache)
        {
            _cqrsMediator = cqrsMediator;
            _scheduledTaskForBasketCreator = scheduledTaskForBasketCreator;
            _logger = logger;
            _cache = cache;

            _logger.ForContext<ViewAppServiceRequestHandler>();
        }

        public virtual void HandleStatusChangedRequest(InspectionStatusChangedWebHookModel model)
        {
            ValidateWebHookModel(model);

            var inspectionStatusCode = GetActualInspectionStatusByPsoInspectionId(model.id);

            if (string.IsNullOrEmpty(inspectionStatusCode))
            {
                LogInspectionNotFoundWarn(model.id);

                throw new InspectionException("Данного осмотра не существует");
            }

            if (InspectionStatusConstants.CompleteStatuses.Contains(inspectionStatusCode))
            {
                LogSchedulerExcessTaskCreationWarn(model.id);
                return;
            }

            var basketNumber = GetBasketNumberByInspectionId(model.id);
            LogSchedulerTaskCreationInfo(basketNumber);

            var scheduledTask = _cache.GetString($"{_viewAppScheduledTaskCachePrefix}{basketNumber}");
            if (string.IsNullOrEmpty(scheduledTask))
            {
                var task = CreateTaskForBasketInScheduler(basketNumber);
                if (task != null)
                {
                    SetScheduledTaskInCache(basketNumber, task.Id);
                }
            }
            else
            {
                LogTaskIsAlreadyScheduledInfo(basketNumber, scheduledTask);
            }
        }

        public string GetDealProductByInspectionId(int inspectionId)
        {
            var deal = CqrsMediator.ResolveQuery<IQueryDeals>().GetDealByInspectionId(inspectionId);
            return deal?.Product?.ProductDictCode;
        }

        protected void ValidateWebHookModel(InspectionStatusChangedWebHookModel model)
        {
            if (model is null)
            {
                throw new InspectionException(nameof(model));
            }

            var user = model.InspectionStatusWebHookModel?.InspectionUser;

            if (user?.IsApiReninsUser() != true)
            {
                LogUnAuthenticatedAccessAttemptWarn();

                throw new InspectionException("Ошибка авторизации");
            }
        }

        protected string GetActualInspectionStatusByPsoInspectionId(int psoInspectionId)
        {
            var inspection = CqrsMediator.ResolveQuery<IQueryInspection>().GetActualInspectionByPsoInspectionId(psoInspectionId);
            return inspection?.InspectionStatusCode;
        }

        protected string GetBasketNumberByInspectionId(int inspectionId)
        {
            LogGettingBasketAttemptInfo(inspectionId);

            var basketNumber = CqrsMediator.ResolveQuery<IQueryBasket>().GetBasketNumberByInspectionId(inspectionId);

            if (string.IsNullOrWhiteSpace(basketNumber))
            {
                LogBasketNotFoundWarn(inspectionId);

                throw new InspectionException("Номер корзины не известен");
            }

            LogBasketIsFoundInfo(basketNumber, inspectionId);

            return basketNumber;
        }

        protected void LogUnAuthenticatedAccessAttemptWarn()
        {
            Logger.Warning("Вызов webhook неаутентифицированным пользователем");
        }

        protected void LogSchedulerTaskCreationInfo(string basketNumber)
        {
            Logger
                .ForContext("ProcessKey", basketNumber)
                .Information($"Постановка задачи шедулеру для корзины {basketNumber}");
        }

        protected void LogBasketIsFoundInfo(string basketNumber, int inspectionId)
        {
            Logger
                .ForContext("ProcessKey", basketNumber)
                .Information($"Получена корзина {basketNumber} по Id осмотра {inspectionId}");
        }

        protected void LogBasketNotFoundWarn(int inspectionId)
        {
            Logger.Warning($"Не найдена корзина по Id осмотра: {inspectionId}");
        }

        protected void LogGettingBasketAttemptInfo(int inspectionId)
        {
            Logger.Information($"Попытка получения корзины по Id осмотра: {inspectionId}");
        }

        protected void LogInspectionNotFoundWarn(int inspectionId)
        {
            Logger.Warning($"Не найден осмотр с Id: {inspectionId}");
        }

        protected void LogSchedulerExcessTaskCreationWarn(int inspectionId)
        {
            Logger.Warning($"Попытка постановки задачи шедулеру по завершенному осмотру с Id: {inspectionId}");
        }

        protected void LogTaskIsAlreadyScheduledInfo(string basketNumber, string taskId)
        {
            Logger
                .ForContext("ProcessKey", basketNumber)
                .Information($"Новая задача не может быть поставлена, так как предыдущая задача {taskId} еще выполняется.");
        }

        protected ScheduledTaskDto CreateTaskForBasketInScheduler(string basketNumber)
            => CreateTaskForBasketInScheduler(basketNumber, new WebHookProcessRestoreTaskCreator());

        protected virtual ScheduledTaskDto CreateTaskForBasketInScheduler(string basketNumber, ITaskForBasketCreator taskCreator)
        {
            var taskForBasket = taskCreator.CreateTaskForBasket(basketNumber);

            return ScheduledTaskForBasketCreator.CreateScheduledTask(taskForBasket);
        }

        protected virtual void SetScheduledTaskInCache(string basketNumber, int taskId)
        {
            _cache.Set($"{_viewAppScheduledTaskCachePrefix}{basketNumber}", taskId.ToString(), WebHookProcessRestoreTaskForBasketDto.TaskStratOffsetInMinutes);
        }

        protected virtual string GetProcessKey(int inspectionId)
        {
            return CqrsMediator.ResolveQuery<IQueryBasket>().GetBasketNumberByInspectionId(inspectionId);
        }
    }
}


using iRIS.Framework.Common;
using iRIS.Framework.Cqrs.Interfaces;
using iRIS.Framework.CrossCutting.Caching;
using iRIS.Framework.Data.Services.Client;
using iRIS.Framework.Entity.Dictionary.EntitySettings;
using iRIS.Framework.ExtensionMethods;
using iRIS.Framework.Workflow.Process.TaskSchedulerServiceInvoker;
using iRIS.InsuranceCore.Code.Constants;
using iRIS.InsuranceCore.Code.CustomProcesses.BasketPreparationProcess.Enums;
using iRIS.InsuranceCore.Code.Implementations.TaskScheduler;
using iRIS.InsuranceCore.Code.Implementations.ViewAppService;
using iRIS.InsuranceCore.Code.Interfaces.Clients.ViewAppServiceClient;
using iRIS.InsuranceCore.Code.Interfaces.Clients.ViewAppServiceClient.Constants;
using iRIS.InsuranceCore.Code.Interfaces.Clients.ViewAppServiceClient.Models.ResponseModels;
using iRIS.InsuranceCore.Code.Interfaces.Clients.ViewAppServiceClient.Models.WebHookModels;
using iRIS.InsuranceCore.Code.Interfaces.TaskScheduler;
using iRIS.InsuranceCore.Code.Interfaces.ViewAppService;
using iRIS.InsuranceCore.Code.Queries;
using iRIS.InsuranceCore.Entities;
using iRIS.KaskoLink2.Implementations.Code.Constants;
using Serilog;
using System;
using System.Linq;

namespace iRIS.KaskoLink2.Code.Implementations.ViewAppService
{
    public class ViewAppKaskoServiceRequestHandler : ViewAppServiceRequestHandler, IViewAppServiceRequestHandler
    {
        private readonly string _viewAppScheduledTaskCachePrefix = "ViewAppScheduledTask_";

        private readonly IViewAppServiceClient _viewAppItBrokerClient;
        private readonly IDataServiceInvoker _dataServiceInvoker;
        private readonly IEntitySettingsManager _entitySettingManager;
        private readonly ICache _cache;

        public ViewAppKaskoServiceRequestHandler(
            ICqrsMediator cqrsMediator,
            IScheduledTaskForBasketCreator scheduledTaskForBasketCreator, 
            ILogger logger,
            IViewAppServiceClient viewAppItBrokerClient,
            IDataServiceInvoker dataServiceInvoker,
            ICache cache,
            IEntitySettingsManager entitySettingsManager)
            : base(cqrsMediator, scheduledTaskForBasketCreator, logger, cache) 
        {
            _viewAppItBrokerClient = viewAppItBrokerClient;
            _dataServiceInvoker = dataServiceInvoker;
            _entitySettingManager = entitySettingsManager;
            _cache = cache;

            Logger.ForContext<ViewAppKaskoServiceRequestHandler>();
        }

        public override void HandleStatusChangedRequest(InspectionStatusChangedWebHookModel model)
        {
            Logger.ForContext("InputViewAppModel", model.ToJson()).Information("Входная модель ViewApp");
            ValidateWebHookModel(model);

            var inspectionStatusCode = GetActualInspectionStatusByPsoInspectionId(model.id);

            if (!string.IsNullOrEmpty(inspectionStatusCode))
            {
                base.HandleStatusChangedRequest(model);
                return;
            }

            HandleSendToOss(model.id);
        }

        private void HandleSendToOss(int psoInspectionId) 
        {
            var psoInspection = _viewAppItBrokerClient.GetInspectionById(psoInspectionId);

            ValidatePsoInspection(psoInspectionId, psoInspection);

            if (!InspectionStatusConstants.CompleteStatuses.Contains(psoInspection.InspectionStatus.Alias))
            {
                LogSendToOssSchedulerExcessTaskCreationWarn(psoInspectionId);
                return;
            }

            var policyNumber = GetPsoInspectionPolicyNumber(psoInspection);
            var (basketNumber, dealEntityId) = GetBasketNumberByPolicyNumber(policyNumber);

            LogBasketIsFoundInfo(basketNumber, psoInspectionId);

            PublishInspection(dealEntityId, psoInspection);

            _ = CreateTaskForBasketInScheduler(basketNumber, new WebHookProcessRestoreAndSendToOssTaskCreator());
        }

        private void PublishInspection(int dealEntityId, GetPsoInspectionResponseModel getInspectionResultModel) 
        {
            var inspection = new Inspection()
            {
                PsoInspectionId = getInspectionResultModel.Id,
                InspectionStatusCode = getInspectionResultModel.InspectionStatus.Alias,
                StatusChangeDescription = getInspectionResultModel.InspectionStatus.Message,
                DealEntityId = dealEntityId,
                AdditionalFieldsIsSentToPso = false
            };

            _dataServiceInvoker.Publish(inspection, AggregateNames.InspectionDetailed);
        }

        private (string basketNumber, int dealEntityId) GetBasketNumberByPolicyNumber(string policyNumber)
        {
            var basket = CqrsMediator
                .ResolveQuery<IQueryBasket>()
                .GetBasketsByPolicySeriesAndNumber(string.Empty, policyNumber, new[] { nameof(Basket.Deals) })
                ?.FirstOrDefault();

            if (basket == null)
            {
                LogBasketNotFoundBypolicyNumberWarn(policyNumber);
                throw new InspectionException("Процедура не найдена ");
            }

            var deal = basket.Deals.FirstOrDefault(d => d.DealStatusCode == EntityStatusType.PolicyIssued.ToString() && d.PolicyNumber.Equals(policyNumber));

            return (basketNumber: basket.Number, dealEntityId: deal.EntityId);
        }

        private void ValidatePsoInspection(int psoInspectionId, GetPsoInspectionResponseModel psoInspection) 
        {
            if (psoInspection?.Success != true || string.IsNullOrWhiteSpace(GetPsoInspectionPolicyNumber(psoInspection)))
            {
                LogInspectionNotReceivedFromPartnerWarn(psoInspectionId);
                throw new InspectionException("Ошибка получения осмотра");
            }
        }

        protected override ScheduledTaskDto CreateTaskForBasketInScheduler(string basketNumber, ITaskForBasketCreator taskCreator)
        {
            var taskForBasket = taskCreator.CreateTaskForBasket(basketNumber);

            if (_entitySettingManager.TryGetSettingValue<int>(EntitySettingCodes.KaskoTaskStartOffsetInMinutes, out var taskStartOffsetInMinutes))
            {
                taskForBasket.StartDateTime = DT.UtcNow.Add(TimeSpan.FromMinutes(taskStartOffsetInMinutes));
            }

            return ScheduledTaskForBasketCreator.CreateScheduledTask(taskForBasket);
        }

        protected override void SetScheduledTaskInCache(string basketNumber, int taskId)
        {
            if (_entitySettingManager.TryGetSettingValue<int>(EntitySettingCodes.KaskoTaskStartOffsetInMinutes, out var taskStartOffsetInMinutes))
            {
                _cache.Set($"{_viewAppScheduledTaskCachePrefix}{basketNumber}", taskId.ToString(), taskStartOffsetInMinutes);
            }
            else
            {
                base.SetScheduledTaskInCache(basketNumber, taskId);
            }
        }

        private string GetPsoInspectionPolicyNumber(GetPsoInspectionResponseModel psoInspection)
            => psoInspection?.FormData?.FirstOrDefault(d => d.FieldId.In("number_policy", "policy_number"))?.Value?.Value ?? string.Empty;

        private void LogInspectionNotReceivedFromPartnerWarn(int psoInspectionId)
            => Logger.Warning($"Ошибка получения осмотра {psoInspectionId} от сервиса партнёра ItBroker");

        private void LogSendToOssSchedulerExcessTaskCreationWarn(int inspectionId)
            => Logger.Warning($"Попытка постановки задачи отправки в ОСС шедулеру по не завершенному осмотру с Id: {inspectionId}");

        private void LogBasketNotFoundBypolicyNumberWarn(string policyNumber)
            => Logger.Warning($"Не найдена процедура по номеру договора {policyNumber}");

        protected override string GetProcessKey(int inspectionId)
        {
            return CqrsMediator.ResolveQuery<IQueryBasket>().GetRelatedProcessKeyByInspectionId(inspectionId);
        }
    }
}

Как мне в моем переопределенном методе HandleStatusChangedRequest получать GetProcessKey