12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using Hotline.FlowEngine.Notifies;
- using Hotline.KnowledgeBase;
- using Hotline.Orders;
- using Hotline.Settings;
- using MediatR;
- using XF.Domain.Exceptions;
- namespace Hotline.Application.Handlers.FlowEngine;
- public class NextStepHandler : INotificationHandler<NextStepNotify>
- {
- private readonly IOrderRepository _orderRepository;
- private readonly IKnowledgeRepository _knowledgeRepository;
- public NextStepHandler(IOrderRepository orderRepository, IKnowledgeRepository knowledgeRepository)
- {
- _orderRepository = orderRepository;
- _knowledgeRepository = knowledgeRepository;
- }
- /// <summary>Handles a notification</summary>
- /// <param name="notification">The notification</param>
- /// <param name="cancellationToken">Cancellation token</param>
- public async Task Handle(NextStepNotify notification, CancellationToken cancellationToken)
- {
- var workflow = notification.Workflow;
- var data = notification.Dto;
- switch (workflow.ModuleCode)
- {
- case WorkflowModuleConsts.Order:
- var order = await _orderRepository.GetAsync(d => d.WorkflowId == workflow.Id, cancellationToken);
- if (order == null)
- throw new UserFriendlyException($"工单审批流程Id无效, workflowId: {workflow.Id}", "无效流程编号");
- order.Assign(notification.FlowAssignType, data.Handlers);
- //todo business logic
- break;
- //case WorkflowModuleConsts.KnowledgePublish:
- // var know = await _knowledgeRepository.GetAsync(d => d.WorkflowId == workflow.Id, cancellationToken);
- // //todo is null
- // know.Assign(notification.FlowAssignType, data.Handlers);
- // //todo business logic
- // break;
- }
- }
- }
|