Browse Source

Merge pull request #567 from colinin/5.2.0

fix: 使用Newtownsoft.Json来序列化作业参数
pull/580/head
yx lin 4 years ago
committed by GitHub
parent
commit
3bfaed0a90
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/SendEmailJob.cs
  2. 7
      aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/SendSmsJob.cs
  3. 8
      aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/ServiceInvocationJob.cs
  4. 8
      aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundJobAdapter.cs
  5. 7
      aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundJobManager.cs
  6. 3
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhookSendRecordAppService.cs

12
aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/SendEmailJob.cs

@ -1,10 +1,9 @@
using System.Threading.Tasks; using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Emailing; using Volo.Abp.Emailing;
using Volo.Abp.TextTemplating; using Volo.Abp.TextTemplating;
using Volo.Abp.Json;
using System.Collections.Generic;
using System;
using Newtonsoft.Json;
namespace LINGYUN.Abp.BackgroundTasks.Jobs; namespace LINGYUN.Abp.BackgroundTasks.Jobs;
@ -55,10 +54,9 @@ public class SendEmailJob : IJobRunnable
context.TryGetString(PropertyCulture, out var culture); context.TryGetString(PropertyCulture, out var culture);
if (context.TryGetString(PropertyContext, out var globalCtx)) if (context.TryGetString(PropertyContext, out var globalCtx))
{ {
var jsonSerializer = context.GetRequiredService<IJsonSerializer>();
try try
{ {
globalContext = jsonSerializer.Deserialize<Dictionary<string, object>>(globalCtx); globalContext = JsonConvert.DeserializeObject<Dictionary<string, object>>(globalCtx);
} }
catch { } catch { }
} }

7
aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/SendSmsJob.cs

@ -1,6 +1,6 @@
using System.Collections.Generic; using Newtonsoft.Json;
using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Json;
using Volo.Abp.Sms; using Volo.Abp.Sms;
namespace LINGYUN.Abp.BackgroundTasks.Jobs; namespace LINGYUN.Abp.BackgroundTasks.Jobs;
@ -23,8 +23,7 @@ public class SendSmsJob : IJobRunnable
try try
{ {
var jsonSerializer = context.GetRequiredService<IJsonSerializer>(); properties = JsonConvert.DeserializeObject<Dictionary<string, object>>(data);
properties = jsonSerializer.Deserialize<Dictionary<string, object>>(data);
} }
catch { } catch { }

8
aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/ServiceInvocationJob.cs

@ -1,5 +1,6 @@
using LINGYUN.Abp.Dapr.Client.DynamicProxying; using LINGYUN.Abp.Dapr.Client.DynamicProxying;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
@ -12,7 +13,6 @@ using Volo.Abp.Http.Client.ClientProxying;
using Volo.Abp.Http.Client.DynamicProxying; using Volo.Abp.Http.Client.DynamicProxying;
using Volo.Abp.Http.Client.Proxying; using Volo.Abp.Http.Client.Proxying;
using Volo.Abp.Http.Modeling; using Volo.Abp.Http.Modeling;
using Volo.Abp.Json;
using Volo.Abp.Localization; using Volo.Abp.Localization;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
@ -102,8 +102,7 @@ public class ServiceInvocationJob : IJobRunnable
var invokeParameters = new Dictionary<string, object>(); var invokeParameters = new Dictionary<string, object>();
if (context.TryGetString(PropertyData, out var data)) if (context.TryGetString(PropertyData, out var data))
{ {
var jsonSerializer = context.GetRequiredService<IJsonSerializer>(); invokeParameters = JsonConvert.DeserializeObject<Dictionary<string, object>>(data);
invokeParameters = jsonSerializer.Deserialize<Dictionary<string, object>>(data);
} }
// 构造服务代理上下文 // 构造服务代理上下文
@ -196,8 +195,7 @@ public class ServiceInvocationJob : IJobRunnable
var invokeParameters = new Dictionary<string, object>(); var invokeParameters = new Dictionary<string, object>();
if (context.TryGetString(PropertyData, out var data)) if (context.TryGetString(PropertyData, out var data))
{ {
var jsonSerializer = context.GetRequiredService<IJsonSerializer>(); invokeParameters = JsonConvert.DeserializeObject<Dictionary<string, object>>(data);
invokeParameters = jsonSerializer.Deserialize<Dictionary<string, object>>(data);
} }
// 构造服务代理上下文 // 构造服务代理上下文

8
aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundJobAdapter.cs

@ -2,10 +2,9 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using System.Collections.Generic; using Newtonsoft.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.BackgroundJobs; using Volo.Abp.BackgroundJobs;
using Volo.Abp.Json;
namespace LINGYUN.Abp.BackgroundTasks; namespace LINGYUN.Abp.BackgroundTasks;
@ -35,8 +34,9 @@ public class BackgroundJobAdapter<TArgs> : IJobRunnable
object args = null; object args = null;
if (context.TryGetString(nameof(TArgs), out var argsJson)) if (context.TryGetString(nameof(TArgs), out var argsJson))
{ {
var jsonSerializer = context.GetRequiredService<IJsonSerializer>(); //var jsonSerializer = context.GetRequiredService<IJsonSerializer>();
args = jsonSerializer.Deserialize<TArgs>(argsJson); //args = jsonSerializer.Deserialize<TArgs>(argsJson);
args = JsonConvert.DeserializeObject<TArgs>(argsJson);
} }
var jobType = Options.GetJob(typeof(TArgs)).JobType; var jobType = Options.GetJob(typeof(TArgs)).JobType;

7
aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundJobManager.cs

@ -1,11 +1,11 @@
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.BackgroundJobs; using Volo.Abp.BackgroundJobs;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids; using Volo.Abp.Guids;
using Volo.Abp.Json;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
using Volo.Abp.Timing; using Volo.Abp.Timing;
@ -19,7 +19,6 @@ public class BackgroundJobManager : IBackgroundJobManager, ITransientDependency
protected IJobPublisher JobPublisher { get; } protected IJobPublisher JobPublisher { get; }
protected ICurrentTenant CurrentTenant { get; } protected ICurrentTenant CurrentTenant { get; }
protected IGuidGenerator GuidGenerator { get; } protected IGuidGenerator GuidGenerator { get; }
protected IJsonSerializer JsonSerializer { get; }
protected AbpBackgroundTasksOptions TasksOptions { get; } protected AbpBackgroundTasksOptions TasksOptions { get; }
protected AbpBackgroundJobOptions Options { get; } protected AbpBackgroundJobOptions Options { get; }
public BackgroundJobManager( public BackgroundJobManager(
@ -28,7 +27,6 @@ public class BackgroundJobManager : IBackgroundJobManager, ITransientDependency
IJobPublisher jobPublisher, IJobPublisher jobPublisher,
ICurrentTenant currentTenant, ICurrentTenant currentTenant,
IGuidGenerator guidGenerator, IGuidGenerator guidGenerator,
IJsonSerializer jsonSerializer,
IOptions<AbpBackgroundJobOptions> options, IOptions<AbpBackgroundJobOptions> options,
IOptions<AbpBackgroundTasksOptions> taskOptions) IOptions<AbpBackgroundTasksOptions> taskOptions)
{ {
@ -37,7 +35,6 @@ public class BackgroundJobManager : IBackgroundJobManager, ITransientDependency
JobPublisher = jobPublisher; JobPublisher = jobPublisher;
CurrentTenant = currentTenant; CurrentTenant = currentTenant;
GuidGenerator = guidGenerator; GuidGenerator = guidGenerator;
JsonSerializer = jsonSerializer;
Options = options.Value; Options = options.Value;
TasksOptions = taskOptions.Value; TasksOptions = taskOptions.Value;
} }
@ -56,7 +53,7 @@ public class BackgroundJobManager : IBackgroundJobManager, ITransientDependency
var jobId = GuidGenerator.Create(); var jobId = GuidGenerator.Create();
var jobArgs = new Dictionary<string, object> var jobArgs = new Dictionary<string, object>
{ {
{ nameof(TArgs), JsonSerializer.Serialize(args) }, { nameof(TArgs), JsonConvert.SerializeObject(args) },
{ "ArgsType", jobConfiguration.ArgsType.AssemblyQualifiedName }, { "ArgsType", jobConfiguration.ArgsType.AssemblyQualifiedName },
{ "JobType", jobConfiguration.JobType.AssemblyQualifiedName }, { "JobType", jobConfiguration.JobType.AssemblyQualifiedName },
{ "JobName", jobConfiguration.JobName }, { "JobName", jobConfiguration.JobName },

3
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhookSendRecordAppService.cs

@ -68,6 +68,8 @@ public class WebhookSendRecordAppService : WebhooksManagementAppServiceBase, IWe
var sendEvent = await EventRepository.GetAsync(sendRecord.WebhookEventId); var sendEvent = await EventRepository.GetAsync(sendRecord.WebhookEventId);
var subscription = await SubscriptionRepository.GetAsync(sendRecord.WebhookSubscriptionId); var subscription = await SubscriptionRepository.GetAsync(sendRecord.WebhookSubscriptionId);
using (CurrentTenant.Change(sendRecord.TenantId))
{
await BackgroundJobManager.EnqueueAsync(new WebhookSenderArgs await BackgroundJobManager.EnqueueAsync(new WebhookSenderArgs
{ {
TenantId = CurrentTenant.Id, TenantId = CurrentTenant.Id,
@ -82,3 +84,4 @@ public class WebhookSendRecordAppService : WebhooksManagementAppServiceBase, IWe
}); });
} }
} }
}

Loading…
Cancel
Save