参考文档中的代码:https://docs.orchardcore.net/en/dev/docs/reference/modules/Workflows/
注意:可转发此博客,但必须表示原作者。
1.创建一个模块。
2.在模块中创建几个文件夹同上面图中的文件夹一样。
3.在Activities文件夹中创建CreateEvaluationTask.cs:
using Microsoft.AspNetCore.Mvc.Localization;
using Microsoft.Extensions.Localization;
using Onon.Workflow.Notify;
using OrchardCore.ContentFields.Fields;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Records;
using OrchardCore.DisplayManagement.Notify;
using OrchardCore.Lists.Models;
using OrchardCore.Media.Fields;
using OrchardCore.Workflows.Abstractions.Models;
using OrchardCore.Workflows.Activities;
using OrchardCore.Workflows.Models;
using OrchardCore.Workflows.Services;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using YesSql;
namespace Onon.Workflow.Activities
{
public class CreateEvaluationTask : TaskActivity
{
private readonly INotifier _notifier;
private readonly IStringLocalizer S;
private readonly IHtmlLocalizer H;
private readonly IWorkflowExpressionEvaluator _expressionEvaluator;
private readonly HtmlEncoder _htmlEncoder;
private readonly IContentManager _contentManager;
private readonly ISession _session;
public CreateEvaluationTask(INotifier notifier, IStringLocalizer<CreateEvaluationTask> s, IHtmlLocalizer<CreateEvaluationTask> h, IWorkflowExpressionEvaluator expressionEvaluator, HtmlEncoder htmlEncoder, IContentManager contentManager, ISession session)
{
_notifier = notifier;
S = s;
H = h;
_expressionEvaluator = expressionEvaluator;
_htmlEncoder = htmlEncoder;
_contentManager = contentManager;
_session = session;
}
// The technical name of the activity. Activities on a workflow definition reference this name.
public override string Name => nameof(CreateEvaluationTask);
// The displayed name of the activity, so it can use localization.
public override LocalizedString DisplayText => S["创建评价内容"];
// The category to which this activity belongs. The activity picker groups activities by this category.
public override LocalizedString Category => S["UI"];
// A description of this activity's purpose.
//public overrid