1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using System.Text.Encodings.Web;
- using System.Text.Json;
- using System.Text.Unicode;
- using Hotline.CallCenter.Tels;
- using Hotline.FlowEngine.Notifications;
- using Hotline.FlowEngine.WfModules;
- using Hotline.KnowledgeBase;
- using Hotline.Orders;
- using MediatR;
- using Microsoft.Extensions.Logging;
- namespace Hotline.Application.Handlers.FlowEngine
- {
- public class StartWorkflowHandler : INotificationHandler<StartWorkflowNotify>
- {
- private readonly IOrderDomainService _orderDomainService;
- private readonly IKnowledgeDomainService _knowledgeDomainService;
- private readonly ITelDomainService _telDomainService;
- private readonly ILogger<StartWorkflowHandler> _logger;
- public StartWorkflowHandler(
- IOrderDomainService orderDomainService,
- IKnowledgeDomainService knowledgeDomainService,
- ITelDomainService telDomainService,
- ILogger<StartWorkflowHandler> logger)
- {
- _orderDomainService = orderDomainService;
- _knowledgeDomainService = knowledgeDomainService;
- _telDomainService = telDomainService;
- _logger = logger;
- }
- /// <summary>Handles a notification</summary>
- /// <param name="notification">The notification</param>
- /// <param name="cancellationToken">Cancellation token</param>
- public async Task Handle(StartWorkflowNotify notification, CancellationToken cancellationToken)
- {
- //基础拉丁字母和中日韩统一表意文字的基础Unicode 块(U+4E00-U+9FCC)。 基本涵盖了除使用西里尔字母以外所有西方国家的文字和亚洲中日韩越的文字
- _logger.LogInformation(
- $"收到{nameof(StartWorkflowNotify)}, notification: {JsonSerializer.Serialize(notification, new JsonSerializerOptions { Encoder = JavaScriptEncoder.Create(UnicodeRanges.BasicLatin, UnicodeRanges.CjkUnifiedIdeographs) })}");
- var workflow = notification.Workflow;
- var data = notification.Dto;
- switch (workflow.ModuleCode)
- {
- case WorkflowModuleConsts.OrderManage:
- await _orderDomainService.ManageFlowStartAsync(notification.FlowAssignMode,
- notification.IsCountersignStart, workflow.ExternalId, workflow.Id,
- workflow.ActualHandleStepTime, workflow.ActualHandleStepName, workflow.ExpiredTime, cancellationToken);
- break;
- case WorkflowModuleConsts.KnowledgeAdd:
- case WorkflowModuleConsts.KnowledgeUpdate:
- case WorkflowModuleConsts.KnowledgeDelete:
- await _knowledgeDomainService.UpdateWorkFlowId(notification.FlowAssignMode, workflow.ExternalId, workflow.Id, cancellationToken);
- break;
- case WorkflowModuleConsts.TelRestApply:
- await _telDomainService.TelRestFlowStartAsync(notification.FlowAssignMode, workflow.ExternalId, workflow.Id, cancellationToken);
- break;
- }
- }
- }
- }
|