NextStepHandler.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using Hotline.FlowEngine.Notifies;
  2. using Hotline.KnowledgeBase;
  3. using Hotline.Orders;
  4. using Hotline.Settings;
  5. using MediatR;
  6. using XF.Domain.Exceptions;
  7. namespace Hotline.Application.Handlers.FlowEngine;
  8. public class NextStepHandler : INotificationHandler<NextStepNotify>
  9. {
  10. private readonly IOrderRepository _orderRepository;
  11. private readonly IKnowledgeRepository _knowledgeRepository;
  12. public NextStepHandler(IOrderRepository orderRepository, IKnowledgeRepository knowledgeRepository)
  13. {
  14. _orderRepository = orderRepository;
  15. _knowledgeRepository = knowledgeRepository;
  16. }
  17. /// <summary>Handles a notification</summary>
  18. /// <param name="notification">The notification</param>
  19. /// <param name="cancellationToken">Cancellation token</param>
  20. public async Task Handle(NextStepNotify notification, CancellationToken cancellationToken)
  21. {
  22. var workflow = notification.Workflow;
  23. var data = notification.Dto;
  24. switch (workflow.ModuleCode)
  25. {
  26. case WorkflowModuleConsts.Order:
  27. var order = await _orderRepository.GetAsync(d => d.WorkflowId == workflow.Id, cancellationToken);
  28. if (order == null)
  29. throw new UserFriendlyException($"工单审批流程Id无效, workflowId: {workflow.Id}", "无效流程编号");
  30. order.Assign(notification.FlowAssignType, data.Handlers);
  31. //todo business logic
  32. break;
  33. //case WorkflowModuleConsts.KnowledgePublish:
  34. // var know = await _knowledgeRepository.GetAsync(d => d.WorkflowId == workflow.Id, cancellationToken);
  35. // //todo is null
  36. // know.Assign(notification.FlowAssignType, data.Handlers);
  37. // //todo business logic
  38. // break;
  39. }
  40. }
  41. }