From b3980da48fc1a95f151fe58782e84725390baf94 Mon Sep 17 00:00:00 2001 From: huangxianguo Date: Wed, 11 Sep 2024 12:00:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BF=9B=E7=A8=8B=E9=97=B4?= =?UTF-8?q?=E9=80=9A=E8=AE=AF=E6=B6=88=E6=81=AF=E5=BA=8F=E5=88=97=E5=8F=B7?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataExporter/SystemParamsService.cs | 1 + .../Process/Client/ProcessHelper.cs | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/MasstransferExporter/DataExporter/SystemParamsService.cs b/MasstransferExporter/DataExporter/SystemParamsService.cs index 2cce4fd..3e988d9 100644 --- a/MasstransferExporter/DataExporter/SystemParamsService.cs +++ b/MasstransferExporter/DataExporter/SystemParamsService.cs @@ -134,6 +134,7 @@ public class SystemParamsService }; await MessageQueueHelper.Publish(Topics.ReportConfigData, systemParams); + await MessageQueueHelper.Publish(Topics.ReportConfigData, systemParams); } catch (Exception e) { diff --git a/MasstransferInfrastructure/Process/Client/ProcessHelper.cs b/MasstransferInfrastructure/Process/Client/ProcessHelper.cs index 2999f40..d09b218 100644 --- a/MasstransferInfrastructure/Process/Client/ProcessHelper.cs +++ b/MasstransferInfrastructure/Process/Client/ProcessHelper.cs @@ -64,7 +64,6 @@ public class ProcessHelper if (dictionary == null) return; var topic = dictionary["Topic"] as string; - var data = dictionary["Data"]; if (!Subscribers.TryGetValue(topic, out var subscribers)) return; @@ -75,9 +74,21 @@ public class ProcessHelper var methodInfo = subscriber.Method; var parameters = methodInfo.GetParameters(); if (parameters.Length != 2) continue; - var type = parameters[1].ParameterType; + + var dataType = parameters[1].ParameterType; + + var type = typeof(Message<>).MakeGenericType(dataType); + + var payload = JsonUtil.FromJson(type, message); + + if (payload == null) continue; + + var property = type.GetProperty("Data"); + + var data = property?.GetValue(payload); + // 通知订阅者 - subscriber.DynamicInvoke(topic, JsonUtil.FromJson(type, message)); + subscriber.DynamicInvoke(topic, data); } catch (Exception exception) {