Browse Source

echance(workflow): model validation and localization

pull/439/head
cKey 4 years ago
parent
commit
f91ee6a370
  1. 5
      aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Application.Contracts/LINGYUN/Abp/WorkflowManagement/Activitys/Dto/ActivityReleaseInput.cs
  2. 3
      aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Application.Contracts/LINGYUN/Abp/WorkflowManagement/Activitys/Dto/GetPendingActivityInput.cs
  3. 2
      aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Application.Contracts/LINGYUN/Abp/WorkflowManagement/Events/Dto/EventPublishInput.cs
  4. 9
      aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Application.Contracts/LINGYUN/Abp/WorkflowManagement/Workflows/Dto/StepDto.cs
  5. 11
      aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Application.Contracts/LINGYUN/Abp/WorkflowManagement/Workflows/Dto/WorkflowDefinitionCreateDto.cs
  6. 12
      aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Application/LINGYUN/Abp/WorkflowManagement/Workflows/WorkflowAppService.cs
  7. 26
      aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Domain.Shared/LINGYUN/Abp/WorkflowManagement/Localization/Resources/en.json
  8. 26
      aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Domain.Shared/LINGYUN/Abp/WorkflowManagement/Localization/Resources/zh-Hans.json
  9. 2
      aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Domain.Shared/LINGYUN/Abp/WorkflowManagement/WorkflowManagementDomainSharedModule.cs
  10. 6
      aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Domain.Shared/LINGYUN/Abp/WorkflowManagement/WorkflowManagementErrorCodes.cs

5
aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Application.Contracts/LINGYUN/Abp/WorkflowManagement/Activitys/Dto/ActivityReleaseInput.cs

@ -1,7 +1,10 @@
namespace LINGYUN.Abp.WorkflowManagement.Activitys
using System.ComponentModel.DataAnnotations;
namespace LINGYUN.Abp.WorkflowManagement.Activitys
{
public class ActivityReleaseInput
{
[Required]
public string Token { get; set; }
}
}

3
aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Application.Contracts/LINGYUN/Abp/WorkflowManagement/Activitys/Dto/GetPendingActivityInput.cs

@ -1,11 +1,14 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace LINGYUN.Abp.WorkflowManagement.Activitys
{
public class GetPendingActivityInput
{
[Required]
public string ActivityName { get; set; }
[Required]
public string WorkflowId { get; set; }
public TimeSpan? Timeout { get; set; }

2
aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Application.Contracts/LINGYUN/Abp/WorkflowManagement/Events/Dto/EventPublishInput.cs

@ -6,9 +6,11 @@ namespace LINGYUN.Abp.WorkflowManagement.Events
public class EventPublishInput
{
[Required]
[StringLength(200)]
public string EventName { get; set; }
[Required]
[StringLength(200)]
public string EventKey { get; set; }
[Required]

9
aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Application.Contracts/LINGYUN/Abp/WorkflowManagement/Workflows/Dto/StepDto.cs

@ -1,13 +1,22 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Data;
using Volo.Abp.Validation;
namespace LINGYUN.Abp.WorkflowManagement.Workflows
{
public class StepDto
{
[Required]
[DynamicStringLength(typeof(WorkflowConsts), nameof(WorkflowConsts.MaxNameLength))]
public string Name { get; set; }
[Required]
[DynamicStringLength(typeof(WorkflowConsts), nameof(WorkflowConsts.MaxStepTypeLength))]
public string StepType { get; set; }
[DynamicStringLength(typeof(WorkflowConsts), nameof(WorkflowConsts.MaxCancelConditionLength))]
public string CancelCondition { get; set; }
public TimeSpan? RetryInterval { get; set; }
public bool Saga { get; set; }

11
aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Application.Contracts/LINGYUN/Abp/WorkflowManagement/Workflows/Dto/WorkflowDefinitionCreateDto.cs

@ -1,4 +1,6 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Validation;
namespace LINGYUN.Abp.WorkflowManagement.Workflows
{
@ -11,20 +13,29 @@ namespace LINGYUN.Abp.WorkflowManagement.Workflows
/// <summary>
/// 名称
/// </summary>
[Required]
[DynamicStringLength(typeof(WorkflowConsts), nameof(WorkflowConsts.MaxNameLength))]
public string Name { get; set; }
/// <summary>
/// 显示名称
/// </summary>
[Required]
[DynamicStringLength(typeof(WorkflowConsts), nameof(WorkflowConsts.MaxDisplayNameLength))]
public string DisplayName { get; set; }
/// <summary>
/// 描述
/// </summary>
[DynamicStringLength(typeof(WorkflowConsts), nameof(WorkflowConsts.MaxDescriptionLength))]
public string Description { get; set; }
/// <summary>
/// 版本号
/// </summary>
[Required]
[Range(1, 100)]
public int Version { get; set; }
[Required]
[MinLength(1)]
public List<StepDto> Steps { get; set; } = new List<StepDto>();
}
}

12
aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Application/LINGYUN/Abp/WorkflowManagement/Workflows/WorkflowAppService.cs

@ -35,7 +35,9 @@ namespace LINGYUN.Abp.WorkflowManagement.Workflows
var result = await _controller.ResumeWorkflow(id);
if (!result)
{
throw new BusinessException();
throw new BusinessException(
WorkflowManagementErrorCodes.SuspendError,
"The workflow cannot be resumed at this time. Please check the log");
}
}
@ -65,7 +67,9 @@ namespace LINGYUN.Abp.WorkflowManagement.Workflows
var result = await _controller.SuspendWorkflow(id);
if (!result)
{
throw new BusinessException();
throw new BusinessException(
WorkflowManagementErrorCodes.SuspendError,
"The workflow cannot be suspend at this time. Please check the log");
}
}
@ -74,7 +78,9 @@ namespace LINGYUN.Abp.WorkflowManagement.Workflows
var result = await _controller.TerminateWorkflow(id);
if (!result)
{
throw new BusinessException();
throw new BusinessException(
WorkflowManagementErrorCodes.TerminateError,
"The workflow cannot be terminated at this time. Please check the log");
}
}
}

26
aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Domain.Shared/LINGYUN/Abp/WorkflowManagement/Localization/Resources/en.json

@ -7,6 +7,30 @@
"Permission:WorkflowDef": "Definition",
"Permission:Create": "Create",
"Permission:Delete": "Delete",
"Permission:ManageSettings": "Manage Settings"
"Permission:ManageSettings": "Manage Settings",
"Workflow:10100": "Unable to restart workflow temporarily, please check log.",
"Workflow:10101": "Unable to suspend workflow, please check log.",
"Workflow:10102": "Unable to terminate workflow temporarily, please check log.",
"DisplayName:IsEnabled": "Is Enabled",
"DisplayName:Name": "Name",
"DisplayName:DisplayName": "DisplayName",
"DisplayName:Description": "Description",
"DisplayName:Version": "Version",
"DisplayName:Steps": "Steps",
"DisplayName:StepType": "Step Type",
"DisplayName:CancelCondition": "Cancel Condition",
"DisplayName:RetryInterval": "Retry Interval",
"DisplayName:NextStep": "Next Step",
"DisplayName:CompensateWith": "Compensates",
"DisplayName:Inputs": "Inputs",
"DisplayName:Outputs": "Outputs",
"DisplayName:SelectNextStep": "Select Next Step",
"DisplayName:EventName": "Event Name",
"DisplayName:EventKey": "Event Key",
"DisplayName:EventData": "Event Data",
"DisplayName:Token": "Token",
"DisplayName:Result": "Result",
"DisplayName:ActivityName": "Activity Name",
"DisplayName:WorkflowId": "Workflow Id"
}
}

26
aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Domain.Shared/LINGYUN/Abp/WorkflowManagement/Localization/Resources/zh-Hans.json

@ -7,6 +7,30 @@
"Permission:WorkflowDef": "流程定义",
"Permission:Create": "创建",
"Permission:Delete": "删除",
"Permission:ManageSettings": "管理设置"
"Permission:ManageSettings": "管理设置",
"Workflow:10100": "暂时无法重启工作流,请检查日志.",
"Workflow:10101": "暂时无法暂停工作流,请检查日志.",
"Workflow:10102": "暂时无法终止工作流,请检查日志.",
"DisplayName:IsEnabled": "是否启用",
"DisplayName:Name": "名称",
"DisplayName:DisplayName": "显示名称",
"DisplayName:Description": "描述",
"DisplayName:Version": "版本",
"DisplayName:Steps": "节点列表",
"DisplayName:StepType": "步骤类型",
"DisplayName:CancelCondition": "终止条件",
"DisplayName:RetryInterval": "重试间隔",
"DisplayName:NextStep": "下一个节点",
"DisplayName:CompensateWith": "补偿节点",
"DisplayName:Inputs": "数据输入",
"DisplayName:Outputs": "数据输出",
"DisplayName:SelectNextStep": "选择下一步",
"DisplayName:EventName": "事件名称",
"DisplayName:EventKey": "事件标识",
"DisplayName:EventData": "事件数据",
"DisplayName:Token": "令牌",
"DisplayName:Result": "返回数据",
"DisplayName:ActivityName": "活动名称",
"DisplayName:WorkflowId": "工作流标识"
}
}

2
aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Domain.Shared/LINGYUN/Abp/WorkflowManagement/WorkflowManagementDomainSharedModule.cs

@ -21,7 +21,7 @@ namespace LINGYUN.Abp.WorkflowManagement
{
options.Resources
.Add<WorkflowManagementResource>()
.AddVirtualJson("/Abp/WorkflowManagement/Localization/Resources");
.AddVirtualJson("/LINGYUN/Abp/WorkflowManagement/Localization/Resources");
});
Configure<AbpExceptionLocalizationOptions>(options =>

6
aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowManagement.Domain.Shared/LINGYUN/Abp/WorkflowManagement/WorkflowManagementErrorCodes.cs

@ -2,6 +2,10 @@
{
public static class WorkflowManagementErrorCodes
{
public const string Namespace = "WorkflowManagement";
public const string Namespace = "Workflow";
public const string ResumeError = Namespace + ":10100";
public const string SuspendError = Namespace + ":10101";
public const string TerminateError = Namespace + ":10102";
}
}

Loading…
Cancel
Save