• .net之工作流工程展示及代码分享(二)工作流引擎


    在介绍完表单类的时候,接下来介绍工作流引擎,主要由四个类组成,分别是流程、流程步骤、流程实例、流程步骤实例类。

    流程类:

     1     [Serializable]
     2     public class Flow
     3     {
     4         [XmlAttribute]
     5         public Guid FlowId { get; set; }
     6         [XmlAttribute]
     7         public string FlowName { get; set; }
     8         public List<FlowStep> FlowSteps { get; set; }
     9         [XmlAttribute]
    10         public string FlowCategory { get; set; }
    11         [XmlAttribute]
    12         public bool Enabled { get; set; }
    13         [XmlAttribute]
    14         public DateTime CreateDate { get; set; }
    15         public Person Creator { get; set; }
    16         
    17         public DateTime? CanRequestDateStart { get; set; }
    18         
    19         public DateTime? CanRequestDateEnd { get; set; }
    20 
    21         public string CreaterName
    22         {
    23             get
    24             {
    25                 if(Creator!=null)
    26                 return Creator.PersonName;
    27                 return string.Empty;
    28             }
    29         }
    30         [XmlAttribute]
    31         public Guid FormId { get; set; }
    32         [XmlAttribute]
    33         public string FormName { get; set; }
    34         public WorkflowConstant.AccessMode AccessMode { get; set; }
    35         [XmlAttribute]
    36         public short PeriodTime { get; set; }
    37         [XmlAttribute]
    38         public string RequestRights { get; set; }
    39         [XmlAttribute]
    40         public string RequestGroup { get; set; }
    41         public string AccessModeDesc
    42         {
    43             get
    44             {
    45                 switch (RequestRights)
    46                 {
    47                     case "-不限-":
    48                         return "所有人";
    49                     default:
    50                         return RequestRights+": ";
    51                 }
    52             }
    53         }
    54 
    55         [XmlAttribute]
    56         public string RoleGroups {
    57             get
    58             {
    59                 if (!string.IsNullOrEmpty(RequestGroup))
    60                 {
    61                     return string.Join("", RequestGroup.Split(',').Select(g => g.Split('|')[0]));
    62                 }
    63                 else
    64                 {
    65                     return string.Empty;
    66                 }
    67             } 
    68         }
    69     }
    View Code

    流程步骤类:

     1     [Serializable]
     2     public class FlowStep
     3     {
     4         [XmlAttribute]
     5         public Guid StepId { get; set; }
     6         [XmlAttribute]
     7         public Guid PreviousStepId { get; set; }
     8         [XmlAttribute]
     9         public Guid NextStepId { get; set; }
    10         [XmlAttribute]
    11         public int SequenceId { get; set; }
    12         [XmlAttribute]
    13         public string StepName { get; set; }
    14         [XmlAttribute]
    15         public string RightGroupTitle { get; set; }
    16         public List<Guid> CanWriteFormContolIds { get; set; }
    17         [XmlAttribute]
    18         public bool CanReturnToPreviousStep { get; set; }
    19         [XmlAttribute]
    20         public bool CanReturnToFirstStep { get; set; }
    21         [XmlAttribute]
    22         public bool AllowSelectAuditor { get; set; }
    23         public WorkflowConstant.CounterSignatureMode CounterSignatureMode { get; set; }
    24         [XmlAttribute]
    25         public bool IsStartStep { get; set; }
    26         [XmlAttribute]
    27         public bool IsLastStep { get; set; }
    28         [XmlAttribute]
    29         public bool CanUploadFile { get; set; }
    30         [XmlAttribute]
    31         public bool MustUploadFile { get; set; }
    32         [XmlAttribute]
    33         public int UploadFileCount { get; set; }
    34     }
    View Code

    流程实例类:

     1    [Serializable]
     2     public class FlowInstance
     3     {
     4         [XmlAttribute]
     5         public Guid FlowInstantId { get; set; }
     6         public Flow Flow { get; set; }
     7         
     8         public List<FlowInstanceStep> FlowStepInstances { get; set; } 
     9         public Person Creator { get; set; }
    10         [XmlAttribute]
    11         public DateTime CreateDate { get; set; }
    12         [XmlAttribute]
    13         public DateTime LastDealDate { get; set; }
    14         [XmlAttribute]
    15         public WorkflowConstant.SignatureStatus FlowStatus { get; set; }
    16 
    17         public string FlowStatusName
    18         {
    19             get
    20             {
    21                 switch (FlowStatus)
    22                 {
    23                     case WorkflowConstant.SignatureStatus.Start:
    24                         return "进行中";
    25                         break;
    26                     case WorkflowConstant.SignatureStatus.Undeal:
    27                         return "未处理";
    28                         break;
    29                     case WorkflowConstant.SignatureStatus.PartialPassed:
    30                         return "部分通过";
    31                         break;
    32                     case WorkflowConstant.SignatureStatus.Passed:
    33                         return "通过";
    34                         break;
    35                     case WorkflowConstant.SignatureStatus.OutDated:
    36                         return "过期";
    37                         break;
    38                     case WorkflowConstant.SignatureStatus.Canceled:
    39                         return "取消";
    40                         break;
    41                     case WorkflowConstant.SignatureStatus.RejectToPreviousStep:
    42                         return "退回上一步";
    43                         break;
    44                     case WorkflowConstant.SignatureStatus.RejectToFirstStep:
    45                         return "退回第一步";
    46                         break;
    47                     case WorkflowConstant.SignatureStatus.Stopped:
    48                         return "停止";
    49                         break;
    50                     case WorkflowConstant.SignatureStatus.Finish:
    51                         return "结束";
    52                         break;
    53                     default:
    54                         return string.Empty;
    55                 }
    56             }
    57         }
    58 
    59         public DateTime? EndDate
    60         {
    61             get
    62             {
    63                 if (Flow != null)
    64                 {
    65                     return CreateDate.AddDays(Flow.PeriodTime);
    66                 }
    67                 else return null;
    68             }
    69         }
    70 
    71         public string CurrentStepDisplayName { get; set; }
    72     }
    View Code

    流程步骤实例类:

     1     [Serializable]
     2     public class FlowInstanceStep
     3     {
     4         [XmlAttribute]
     5         public Guid StepInstanceId { get; set; }
     6         public List<WorkflowPersonSignature> PersonSignatures { get; set; }
     7 
     8         public SerializableDictionary<Guid, string> WriteValues { get; set; }
     9        
    10         public FlowStep FlowStep { get; set; }
    11         [XmlAttribute]
    12         public DateTime CreateDate { get; set; }
    13         [XmlAttribute]
    14         public DateTime ProcessDate { get; set; }
    15         [XmlAttribute]
    16         public WorkflowConstant.SignatureStatus StepStatus { get; set; }
    17         public List<AttachFile> FileList { get; set; } 
    18     }
    View Code

    这几个类使用了“贫血模型” 

    设定好流程和步骤,以后每次建立的流程实例都是从流程获取到的。

    本系列导航:

    1. .net之工作流工程展示及代码分享(预告)
    2. .net之工作流工程展示及代码分享(一)工作流表单
    3. .net之工作流工程展示及代码分享(二)工作流引擎
    4. .net之工作流工程展示及代码分享(三)数据存储引擎
    5. .net之工作流工程展示及代码分享(四)主控制类
    6. .net之工作流工程展示及代码分享(五)前端交互
  • 相关阅读:
    C# .Net基础知识点解答
    依赖注入框架Autofac的简单使用
    Linq表达式、Lambda表达式你更喜欢哪个?
    C#抽象类、接口、虚函数和抽象函数
    MVC面试问题与答案
    并发 并行 同步 异步 多线程的区别
    .Net中的控制翻转和依赖注入
    解析ASP.NET WebForm和Mvc开发的区别
    测试与代码质量
    netty 同步调用
  • 原文地址:https://www.cnblogs.com/thanks/p/4305884.html
Copyright © 2020-2023  润新知