22
schangxiang@126.com
2025-05-15 9a83dbb67b223e94a946e1bf7db59336e7fb2f28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System.ComponentModel;
using System.Runtime.Serialization;
using CMS.Plugin.FlowManagement.Abstractions.Enums;
using CMS.Plugin.FlowManagement.Abstractions.FlowBusiness.Activitys;
using CMS.Plugin.MesSuite.Abstractions.Models;
using CMS.Plugin.OrderManagement.Abstractions.Models;
using CMS.Plugin.ProcessManagement.Abstractions.Models;
using CMS.Plugin.TraceManagement.Abstractions.Models.Traces;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using SYC.Flow.Kernel;
 
namespace CMS.Plugin.PipeLineLems.Abstractions
{
    /// <summary>
    /// PipeLineLems 业务步骤
    /// </summary>
    [Design("PipeLineLems", "PipeLineLems 业务步骤", Sort = 99), Category("定制步骤")]
    [Serializable]
    public class PipeLineLemsActivity : BusinessActivity
    {
        /// <summary>
        /// 配置属性1
        /// </summary>
        [Design("配置属性1", "配置属性1", Sort = 1), Category("配置信息")]
        [DataMember]
        public string MyProperty1 { get; set; }
 
        /// <summary>
        /// 配置属性2
        /// </summary>
        [Design("配置属性2", "配置属性2", Sort = 2), Category("配置信息")]
        [DataMember]
        public int MyProperty2 { get; set; }
 
        /// <summary>
        /// 流程上下文标识集合
        /// </summary>
        public override List<FlowItemKey> FlowItemKeys => GetFlowItemKeys();
 
        /// <summary>
        /// 工艺流程处理
        /// </summary>
        public override async Task ProcessAsync(ProcessflowEventArgs args)
        {
            // 工艺模型
            var processModel = Flow.DataItems.ApplicationData as ProcessModel;
 
            // 工单模型
            var orderModel = Flow.DataItems[FlowItemCollection.OrderModel] as OrderModel;
 
            // 产品模型
            var productModel = Flow.DataItems[FlowItemCollection.ProductModel] as AssociationProductModel;
 
            // 追溯模型
            var traceModel = Flow.DataItems[FlowItemCollection.TraceModel] as TraceModel;
 
            Flow.Logger.LogInformation($"执行流程:实例={Flow.Instance.ProcID} -> {Flow.Name} -> {Name} PipeLineLemsActivity");
 
            // 业务处理
            // 由于ServiceProvider来源于Flow组件,此处需共享CMS.Plugin.PipeLineLems.Abstractions程序集,否则无法调用,修改CMS.Plugin.PipeLineLems项目中的CMSPluginModule.cs文件,取消注释GetSharedAssemblies()方法
            var pipelinelemsFlowService = Flow.ServiceProvider.GetService<IPipeLineLemsFlowService>();
            if (pipelinelemsFlowService != null)
            {
                await pipelinelemsFlowService.ProcessAsync(args);
            }
        }
 
        /// <summary>
        /// Gets the flow item keys.
        /// </summary>
        protected virtual List<FlowItemKey> GetFlowItemKeys()
        {
            var result = new List<FlowItemKey>();
            return result;
        }
    }
}