完善ieventhandler的文档,完善quickhandler
abp_example/ExampleForm.Application.Contracts/ExampleForm.Application.Contracts.csproj
diff --git a/abp_example/ExampleForm.Application.Contracts/ExampleForm.Application.Contracts.csproj b/abp_example/ExampleForm.Application.Contracts/ExampleForm.Application.Contracts.csproj
index 809ae4e..cf18b2d 100644
--- a/abp_example/ExampleForm.Application.Contracts/ExampleForm.Application.Contracts.csproj
+++ b/abp_example/ExampleForm.Application.Contracts/ExampleForm.Application.Contracts.csproj
@@ -18,9 +18,15 @@
<PackageReference Include="Volo.Abp.Ddd.Application.Contracts" Version="8.3.4" />
</ItemGroup>
- <ItemGroup>
+ <ItemGroup Condition="'$(Configuration)' == 'Debug'">
<ProjectReference Include="..\..\framework\PasteApeart.Application.Contracts\PasteApeart.Application.Contracts.csproj" />
- <ProjectReference Include="..\ExampleForm.Domain\ExampleForm.Domain.csproj" />
</ItemGroup>
+ <ItemGroup Condition="'$(Configuration)' == 'Release'">
+ <PackageReference Include="PasteApeart.Application.Contracts" Version="26.10.08" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\ExampleForm.Domain\ExampleForm.Domain.csproj" />
+ </ItemGroup>
+
</Project>
abp_example/ExampleForm.Application/ExampleApeartDefaultService.cs
diff --git a/abp_example/ExampleForm.Application/ExampleApeartDefaultService.cs b/abp_example/ExampleForm.Application/ExampleApeartDefaultService.cs
index fb69feb..f76d5a2 100644
--- a/abp_example/ExampleForm.Application/ExampleApeartDefaultService.cs
+++ b/abp_example/ExampleForm.Application/ExampleApeartDefaultService.cs
@@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore;
using PasteApeart;
using PasteApeart.Application;
using PasteApeart.Application.Contracts;
+using PasteApeart.Handler;
namespace ExampleForm.Application
{
abp_example/ExampleForm.Application/ExampleForm.Application.csproj
diff --git a/abp_example/ExampleForm.Application/ExampleForm.Application.csproj b/abp_example/ExampleForm.Application/ExampleForm.Application.csproj
index 03615d5..9c89628 100644
--- a/abp_example/ExampleForm.Application/ExampleForm.Application.csproj
+++ b/abp_example/ExampleForm.Application/ExampleForm.Application.csproj
@@ -18,9 +18,15 @@
<PackageReference Include="Volo.Abp.Ddd.Application" Version="8.3.4" />
</ItemGroup>
- <ItemGroup>
+ <ItemGroup Condition="'$(Configuration)' == 'Debug'">
<ProjectReference Include="..\..\framework\PasteApeart.Application\PasteApeart.Application.csproj" />
- <ProjectReference Include="..\ExampleForm.Handler\ExampleForm.Handler.csproj" />
</ItemGroup>
+ <ItemGroup Condition="'$(Configuration)' == 'Release'">
+ <PackageReference Include="PasteApeart.Application" Version="26.10.08" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\ExampleForm.Handler\ExampleForm.Handler.csproj" />
+ </ItemGroup>
+
</Project>
abp_example/ExampleForm.Application/usermodels/RoleInfoAppService.cs
diff --git a/abp_example/ExampleForm.Application/usermodels/RoleInfoAppService.cs b/abp_example/ExampleForm.Application/usermodels/RoleInfoAppService.cs
index ae10df8..50010b2 100644
--- a/abp_example/ExampleForm.Application/usermodels/RoleInfoAppService.cs
+++ b/abp_example/ExampleForm.Application/usermodels/RoleInfoAppService.cs
@@ -7,7 +7,9 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using PasteApeart.Application.Contracts;
using PasteApeart.Handler;
+using PasteApeart.Handler.Level;
using PasteApeart.Helper;
+using PasteApeart.Helper.Extensions;
using System.Linq.Dynamic.Core;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;
abp_example/ExampleForm.Domain/ExampleForm.Domain.csproj
diff --git a/abp_example/ExampleForm.Domain/ExampleForm.Domain.csproj b/abp_example/ExampleForm.Domain/ExampleForm.Domain.csproj
index d168014..da4db76 100644
--- a/abp_example/ExampleForm.Domain/ExampleForm.Domain.csproj
+++ b/abp_example/ExampleForm.Domain/ExampleForm.Domain.csproj
@@ -18,9 +18,14 @@
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="8.3.4" />
</ItemGroup>
- <ItemGroup>
+ <ItemGroup Condition="'$(Configuration)' == 'Debug'">
<ProjectReference Include="..\..\framework\PasteApeart.Domain\PasteApeart.Domain.csproj" />
<ProjectReference Include="..\..\framework\PasteApeart.Helper\PasteApeart.Helper.csproj" />
</ItemGroup>
+ <ItemGroup Condition="'$(Configuration)' == 'Release'">
+ <PackageReference Include="PasteApeart.Domain" Version="26.10.08" />
+ <PackageReference Include="PasteApeart.Helper" Version="26.10.08" />
+ </ItemGroup>
+
</Project>
abp_example/ExampleForm.Handler/ExampleForm.Handler.csproj
diff --git a/abp_example/ExampleForm.Handler/ExampleForm.Handler.csproj b/abp_example/ExampleForm.Handler/ExampleForm.Handler.csproj
index 6ed5943..d9ad797 100644
--- a/abp_example/ExampleForm.Handler/ExampleForm.Handler.csproj
+++ b/abp_example/ExampleForm.Handler/ExampleForm.Handler.csproj
@@ -25,11 +25,17 @@
<PackageReference Include="StackExchange.Redis" Version="2.8.58" />
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="8.103.9.3" />
</ItemGroup>
-
- <ItemGroup>
+
+ <ItemGroup Condition="'$(Configuration)' == 'Debug'">
<ProjectReference Include="..\..\framework\PasteApeart.Handler\PasteApeart.Handler.csproj" />
- <ProjectReference Include="..\ExampleForm.Application.Contracts\ExampleForm.Application.Contracts.csproj" />
- <ProjectReference Include="..\ExampleForm.EntityFrameworkCore\ExampleForm.EntityFrameworkCore.csproj" />
</ItemGroup>
+ <ItemGroup Condition="'$(Configuration)' == 'Release'">
+ <PackageReference Include="PasteApeart.Handler" Version="26.10.08" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\ExampleForm.Application.Contracts\ExampleForm.Application.Contracts.csproj" />
+ <ProjectReference Include="..\ExampleForm.EntityFrameworkCore\ExampleForm.EntityFrameworkCore.csproj" />
+ </ItemGroup>
+
</Project>
abp_example/ExampleForm.Handler/ExampleFormHandlerModule.cs
diff --git a/abp_example/ExampleForm.Handler/ExampleFormHandlerModule.cs b/abp_example/ExampleForm.Handler/ExampleFormHandlerModule.cs
index cfb1c76..149316f 100644
--- a/abp_example/ExampleForm.Handler/ExampleFormHandlerModule.cs
+++ b/abp_example/ExampleForm.Handler/ExampleFormHandlerModule.cs
@@ -5,6 +5,7 @@ using Microsoft.Extensions.Logging;
using PasteApeart;
using PasteApeart.Handler;
using PasteApeart.Handler.common;
+using PasteApeart.Handler.Level;
using PasteApeart.Handler.rabbit;
using Volo.Abp.Modularity;
abp_example/ExampleForm.Handler/SerilogCustomHandler.cs
diff --git a/abp_example/ExampleForm.Handler/SerilogCustomHandler.cs b/abp_example/ExampleForm.Handler/SerilogCustomHandler.cs
index c823bb0..bf61dbd 100644
--- a/abp_example/ExampleForm.Handler/SerilogCustomHandler.cs
+++ b/abp_example/ExampleForm.Handler/SerilogCustomHandler.cs
@@ -1,5 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
using PasteApeart;
+using PasteApeart.Handler;
using Serilog.Core;
using Serilog.Events;
abp_example/ExampleForm.HttpApi.Host/ExampleForm.Application.xml
diff --git a/abp_example/ExampleForm.HttpApi.Host/ExampleForm.Application.xml b/abp_example/ExampleForm.HttpApi.Host/ExampleForm.Application.xml
index 8216b10..98522fc 100644
--- a/abp_example/ExampleForm.HttpApi.Host/ExampleForm.Application.xml
+++ b/abp_example/ExampleForm.HttpApi.Host/ExampleForm.Application.xml
@@ -87,10 +87,10 @@
</member>
<member name="T:ExampleForm.Application.ExampleFormDefaultService">
<summary>
-
+ 默认接口的辅助实现
</summary>
</member>
- <member name="M:ExampleForm.Application.ExampleFormDefaultService.#ctor(PasteApeart.Application.IPasteDefaultHelper,PasteApeart.IChannelHelper,ExampleForm.IExampleFormDbContext)">
+ <member name="M:ExampleForm.Application.ExampleFormDefaultService.#ctor(PasteApeart.Application.IPasteDefaultHelper,PasteApeart.Handler.IChannelHelper,ExampleForm.IExampleFormDbContext)">
<summary>
</summary>
abp_example/ExampleForm.HttpApi.Host/ExampleForm.HttpApi.Host.xml
diff --git a/abp_example/ExampleForm.HttpApi.Host/ExampleForm.HttpApi.Host.xml b/abp_example/ExampleForm.HttpApi.Host/ExampleForm.HttpApi.Host.xml
index 6ebe382..5584b54 100644
--- a/abp_example/ExampleForm.HttpApi.Host/ExampleForm.HttpApi.Host.xml
+++ b/abp_example/ExampleForm.HttpApi.Host/ExampleForm.HttpApi.Host.xml
@@ -319,7 +319,7 @@
系统初始化
</summary>
</member>
- <member name="M:ExampleForm.StartHostedService.#ctor(System.IServiceProvider,Microsoft.Extensions.Options.IOptions{PasteApeart.Application.Contracts.RabbitConfig},Microsoft.Extensions.Logging.ILogger{ExampleForm.StartHostedService},PasteApeart.IChannelHelper,PasteApeart.Handler.IEventActionHandler,Microsoft.Extensions.Options.IOptions{ExampleForm.AppConfig})">
+ <member name="M:ExampleForm.StartHostedService.#ctor(System.IServiceProvider,Microsoft.Extensions.Options.IOptions{PasteApeart.Application.Contracts.RabbitConfig},Microsoft.Extensions.Logging.ILogger{ExampleForm.StartHostedService},PasteApeart.Handler.IChannelHelper,PasteApeart.Handler.IEventActionHandler,Microsoft.Extensions.Options.IOptions{ExampleForm.AppConfig})">
<summary>
</summary>
example/ExampleApeart.Handler/ExampleApeart.Handler.csproj
diff --git a/example/ExampleApeart.Handler/ExampleApeart.Handler.csproj b/example/ExampleApeart.Handler/ExampleApeart.Handler.csproj
index b367d58..417553b 100644
--- a/example/ExampleApeart.Handler/ExampleApeart.Handler.csproj
+++ b/example/ExampleApeart.Handler/ExampleApeart.Handler.csproj
@@ -36,7 +36,7 @@
</ItemGroup>
<ItemGroup Condition="'$(Configuration)' == 'Release'">
- <PackageReference Include="PasteApeart.Handler" Version="26.9.16" />
+ <PackageReference Include="PasteApeart.Handler" Version="26.10.8" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ExampleApeart.Application.Contracts\ExampleApeart.Application.Contracts.csproj" />
example/ExampleApeart.HttpApi.Host/Controllers/QuickHandlerController.cs
diff --git a/example/ExampleApeart.HttpApi.Host/Controllers/QuickHandlerController.cs b/example/ExampleApeart.HttpApi.Host/Controllers/QuickHandlerController.cs
index 334ce44..9a2b51f 100644
--- a/example/ExampleApeart.HttpApi.Host/Controllers/QuickHandlerController.cs
+++ b/example/ExampleApeart.HttpApi.Host/Controllers/QuickHandlerController.cs
@@ -17,6 +17,7 @@ namespace ExampleApeart.HttpApi.Host.Controllers
[TypeFilter(typeof(RoleAttribute), Arguments = new object[] { "root", "root" })]
public class QuickHandlerController : IBaseController
{
+
private readonly IEventQuickActionHandler _queryHandler;
/// <summary>
@@ -28,6 +29,8 @@ namespace ExampleApeart.HttpApi.Host.Controllers
_queryHandler = eventActionHandler;
}
+ private static readonly string[] IgnoreProperty = new string[] { "mutexVal", "mutexKey" };
+
/// <summary>
/// 读取AddDto的数据模型
/// </summary>
@@ -39,9 +42,68 @@ namespace ExampleApeart.HttpApi.Host.Controllers
{
if (string.IsNullOrEmpty(model_name))
{
- throw new PasteArgsException(nameof(model_name));// PasteCodeException("");
+ throw new PasteArgsException(nameof(model_name));
+ }
+ var model = _queryHandler.ReadAddModel(model_name);
+ if (model.Attributes == null)
+ {
+ model.Attributes = new List<VoloModelAttribute>();
+ }
+ if (!model.Attributes.Any(x => x.Name == "okaction"))
+ {
+ model.Attributes.Add(new VoloModelAttribute { Name = "okaction", Args1 = "current", Args2 = "reload" });
+ }
+ if (model.Properties?.Any() == true)
+ {
+
+ //倒序
+ model.Properties.Reverse();
+
+ foreach (var item in model.Properties)
+ {
+
+ switch (item.Name)
+ {
+ case "eventName":
+ {
+ item.Title = "事件模型";
+ if (item.Attributes == null)
+ {
+ item.Attributes = new System.Collections.Generic.List<VoloModelAttribute>();
+ }
+ item.Attributes.Add(new VoloModelAttribute { Name = "hidden" });
+ }
+ break;
+ case "expireSecond":
+ {
+ item.Title = "延迟秒数";
+ item.Placeholder = "延迟X秒后执行这个事件,默认为立即执行";
+ }
+ break;
+ case "maxRetryTime":
+ {
+ item.Title = "最大重试";
+ item.Placeholder = "消息异常后,最大重试次数,会基于重试模型,自动延期";
+ }
+ break;
+ case "isSubscribe":
+ {
+ item.Title = "订阅模式";
+ item.Placeholder = "广播消息";
+ }
+ break;
+ case "retryModel":
+ {
+ item.Title = "重试模型";
+ item.Placeholder = "基于哪个重试模型,主要影响的是重试的间隔";
+ }
+ break;
+ }
+ }
+
+ model.Properties.RemoveAll(x => IgnoreProperty.Contains(x.Name) || !x.CanWrite);
}
- return _queryHandler.ReadAddModel(model_name);
+ return model;
}
@@ -72,6 +134,19 @@ namespace ExampleApeart.HttpApi.Host.Controllers
public async Task<PastePagedResult<QuickHandlerPropertyInfo>> Page([FromQuery] InputSearchBase input)
{
return await _queryHandler.PageAsync(input);
+ //var reads = await _queryHandler.PageAsync(input);
+
+ //if (reads == null)
+ //{
+ // return null;
+ //}
+ //var pageDto = new PastePagedResult<QuickHandlerModelDto>();
+ //if (reads.Items?.Any() == true)
+ //{
+ // pageDto.Items = reads.Items.Adapt<List<QuickHandlerModelDto>>();
+ //}
+ //pageDto.TotalCount = reads.TotalCount;
+ //return pageDto;
}
/// <summary>
@@ -81,16 +156,104 @@ namespace ExampleApeart.HttpApi.Host.Controllers
/// <returns></returns>
[HttpPost]
[Route("item")]
- public async Task<string> CreateItemAsync([FromServices] IEventActionHandler handler)
+ public async Task<dynamic> CreateItemAsync([FromServices]IEventActionHandler handler)
{
var bodyStr = String.Empty;
using var sb = new StreamReader(Request.Body);
bodyStr = await sb.ReadToEndAsync();
- await handler.ActionMessageAsync(bodyStr, typeof(UserInfoDto).Assembly.GetTypes());
- return "执行完成";
+ //await handler.ActionMessageAsync(bodyStr, typeof(UserInfoDto).Assembly.GetTypes());
+
+ //可以考虑基于PasteAuth校验权限... .. .
+ if (string.IsNullOrEmpty(bodyStr))
+ {
+ throw new PasteCodeException("传入的内容不能为空");
+ }
+
+ var result = await handler.ActionResultAsync(bodyStr, typeof(UserInfoDto).Assembly.GetTypes());
+ if (result != null)
+ {
+ return result;
+ }
+ //后续可以调用有返回值的版本!!!
+ return "执行完成 如果需要返回值请给Result赋值";
}
+
+ //private readonly IEventQuickActionHandler _queryHandler;
+
+ ///// <summary>
+ /////
+ ///// </summary>
+ ///// <param name="eventActionHandler"></param>
+ //public QuickHandlerController(IEventQuickActionHandler eventActionHandler)
+ //{
+ // _queryHandler = eventActionHandler;
+ //}
+
+ ///// <summary>
+ ///// 读取AddDto的数据模型
+ ///// </summary>
+ ///// <returns></returns>
+ //[HttpGet]
+ //[Route("readAddModel")]
+ //[TypeFilter(typeof(RoleAttribute), Arguments = new object[] { "data", "add" })]
+ //public VoloModelInfo ReadAddModel([FromQuery] string model_name)
+ //{
+ // if (string.IsNullOrEmpty(model_name))
+ // {
+ // throw new PasteArgsException(nameof(model_name));// PasteCodeException("");
+ // }
+ // return _queryHandler.ReadAddModel(model_name);
+ //}
+
+
+ ///// <summary>
+ ///// 读取ListDto的数据模型
+ ///// </summary>
+ ///// <returns></returns>
+ //[HttpGet]
+ //[Route("readListModel")]
+ //public VoloModelInfo ReadListModel()
+ //{
+ // var _model = BuilderHelper.AttributeReadModelProperty<QuickHandlerPropertyInfo>(new QuickHandlerPropertyInfo());
+ // var _query_model = BuilderHelper.AttributeReadModelProperty(new InputSearchBase());
+ // if (_query_model != null)
+ // {
+ // _model.QueryProperties = _query_model.Properties;
+ // }
+ // return _model;
+ //}
+
+ ///// <summary>
+ /////
+ ///// </summary>
+ ///// <param name="input"></param>
+ ///// <returns></returns>
+ //[HttpGet]
+ //[Route("page")]
+ //public async Task<PastePagedResult<QuickHandlerPropertyInfo>> Page([FromQuery] InputSearchBase input)
+ //{
+ // return await _queryHandler.PageAsync(input);
+ //}
+
+ ///// <summary>
+ ///// 执行一个
+ /////</summary>
+ ///// <param name="handler"></param>
+ ///// <returns></returns>
+ //[HttpPost]
+ //[Route("item")]
+ //public async Task<string> CreateItemAsync([FromServices] IEventActionHandler handler)
+ //{
+ // var bodyStr = String.Empty;
+ // using var sb = new StreamReader(Request.Body);
+ // bodyStr = await sb.ReadToEndAsync();
+ // await handler.ActionMessageAsync(bodyStr, typeof(UserInfoDto).Assembly.GetTypes());
+ // return "执行完成";
+
+ //}
+
}
}
framework/PasteApeart.Handler/common/IChannelHelper.cs
diff --git a/framework/PasteApeart.Handler/common/IChannelHelper.cs b/framework/PasteApeart.Handler/common/IChannelHelper.cs
index c6cab3d..9c88b69 100644
--- a/framework/PasteApeart.Handler/common/IChannelHelper.cs
+++ b/framework/PasteApeart.Handler/common/IChannelHelper.cs
@@ -14,7 +14,7 @@ namespace PasteApeart.Handler
Channel<IEventModel> ChannelEventModel { get; }
/// <summary>
- ///
+ /// 压入到队列 如果MutexKey有值而MutexVal没有,则会进行赋值 如果ExpireSecond大于0则压入延迟队列,否则是及时队列
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
@@ -25,7 +25,7 @@ namespace PasteApeart.Handler
/// <param name="input"></param>
/// <param name="isremove"></param>
/// <returns></returns>
- [Obsolete]
+ [Obsolete("use WriteAutoQueueAsync set IsSubscribe=true")]
Task WriteBroadcastMessageAsync(IEventModel input, bool isremove);
/// <summary>
///
@@ -33,7 +33,7 @@ namespace PasteApeart.Handler
/// <typeparam name="T"></typeparam>
/// <param name="input"></param>
/// <returns></returns>
- [Obsolete]
+ [Obsolete("use WriteAutoQueueAsync set MutexKey !=stringEmpty and MutexVal is null")]
Task WriteMutexMQAsync<T>(T input) where T : IEventModel;
/// <summary>
///
@@ -42,7 +42,7 @@ namespace PasteApeart.Handler
/// <param name="input"></param>
/// <param name="id"></param>
/// <returns></returns>
- [Obsolete]
+ [Obsolete("use WriteAutoQueueAsync set MutexKey !=stringEmpty and MutexVal is null")]
Task WriteMutexMQAsync<T>(T input, object id) where T : IEventModel;
}
}
\ No newline at end of file