钝化程序模式SOA架构BPM
来源:互联网 发布:淘宝店铺申请企业店铺 编辑:程序博客网 时间:2024/04/29 14:00
钝化程序模式SOA架构BPM
在SOA架构中,通常都会存在着N多个服务接口,每个服务接口的消费者有着明确的角色定义,通过将一系列的服务接口串联起来就可以组成一个完整的业务流程,这也被称为业务流程管理(Business Process Manager)。那么扮演关业务流程管理的这段逻辑角色要能够支持多地区调用,某个业务内的流程管理器所要面对的是这个业务内的所有要参与其中的角色,每个角色调用不同的服务方法,但彼此又是相互影响的。
BPM每个阶段产生的数据都将作为下一个阶段需要输入的数据,将多个完本独立的SOA接口组成一个可以用来产生实际业务价值的业务功能块,这也是实施SOA(面向服务的体系结构-Service-Oriented Architecture)架构的价值之一。
钝化模式绝对是BPM框架的核心模式之一,下面我们就提供一个订单审批流程管理器
订单审批流程共需3个角色参与:
1.信息员检查订单
2.业务经理确认
3.总经理最终确认签字
第一次启动输出:
第二次启动输出:
第三次启动输出:
第四次启动输出:
附上代码:
类:Program
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- using System.Runtime.Serialization.Formatters.Binary;
- namespace ConsoleApplication52
- {
- public class Program
- {
- static void Main(string[] args)
- {
- string path = AppDomain.CurrentDomain.BaseDirectory + "approve001.xml";
- ApproveManager approveManager = null;
- if (File.Exists(path))
- {
- using (Stream stream = File.Open(path, FileMode.Open))
- {
- BinaryFormatter binaryFormatter = new BinaryFormatter();
- approveManager = (ApproveManager)binaryFormatter.Deserialize(stream);
- }
- }
- else
- {
- approveManager = new ApproveManager(new OrderInfo { });
- }
- approveManager.RunFlow();
- using (Stream stream = File.Open(path, FileMode.OpenOrCreate))
- {
- BinaryFormatter binaryFormatter = new BinaryFormatter();
- binaryFormatter.Serialize(stream, approveManager);
- }
- Console.ReadKey();
- }
- }
- }
类:Informationer
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication52
- {
- [Serializable]
- public class Informationer
- {
- public void CheckPrice(OrderInfo orderInfo, ref ApproveHander approveHander)
- {
- if (orderInfo.approveStatus == ApproveStatus.客服检查)
- {
- Console.WriteLine("CheckPrice");
- approveHander -= this.CheckPrice;
- }
- }
- public void CheckNum(OrderInfo orderInfo, ref ApproveHander approveHander)
- {
- if (orderInfo.approveStatus == ApproveStatus.客服检查)
- {
- Console.WriteLine("CheckNum");
- approveHander -= this.CheckNum;
- }
- }
- }
- }
类:BusinessManager
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication52
- {
- [Serializable]
- public class BusinessManager
- {
- public void CallPhone(OrderInfo order, ref ApproveHander approveManager)
- {
- if (order.approveStatus == ApproveStatus.业务员确认)
- {
- Console.WriteLine("CallPhone");
- approveManager -= this.CallPhone;
- }
- }
- public void SendMail(OrderInfo order, ref ApproveHander approveManager)
- {
- if (order.approveStatus == ApproveStatus.业务员确认)
- {
- Console.WriteLine("SendMail");
- approveManager -= this.SendMail;
- }
- }
- }
- }
类:GeneralManager
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication52
- {
- [Serializable]
- public class GeneralManager
- {
- public void FinalConfirm(OrderInfo order, ref ApproveHander approveHander)
- {
- if (order.approveStatus == ApproveStatus.主管签字)
- {
- approveHander -= this.FinalConfirm;
- Console.WriteLine("FinalConfirm");
- }
- }
- public void SignRecord(OrderInfo order, ref ApproveHander approveHander)
- {
- if (order.approveStatus == ApproveStatus.主管签字)
- {
- approveHander -= this.SignRecord;
- Console.WriteLine("SignRecord");
- }
- }
- }
- }
类:ApproveManager
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication52
- {
- public delegate void ApproveHander(OrderInfo orderInfo, ref ApproveHander approveHander);
- [Serializable]
- public class ApproveManager
- {
- public ApproveHander approveHander;
- private OrderInfo order;
- public ApproveManager(OrderInfo order)
- {
- Informationer informationer = new Informationer();
- approveHander += informationer.CheckNum;
- approveHander += informationer.CheckPrice;
- BusinessManager businessManager = new BusinessManager();
- approveHander += businessManager.CallPhone;
- approveHander += businessManager.SendMail;
- GeneralManager generalManager = new GeneralManager();
- approveHander += generalManager.FinalConfirm;
- approveHander += generalManager.SignRecord;
- this.order = order;
- }
- public void RunFlow()
- {
- if (order.approveStatus == ApproveStatus.提交 )
- {
- order.approveStatus = ApproveStatus.客服检查;
- }
- else if (order.approveStatus == ApproveStatus.客服检查)
- {
- order.approveStatus = ApproveStatus.业务员确认;
- }
- else
- {
- order.approveStatus = ApproveStatus.主管签字;
- }
- if (approveHander != null)
- {
- this.approveHander(this.order, ref approveHander);
- }
- else
- {
- Console.WriteLine("流程已处理完成");
- }
- }
- }
- }
类:OrderInfo
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication52
- {
- [Serializable]
- public class OrderInfo
- {
- public ApproveStatus approveStatus { get; set; }
- }
- public enum ApproveStatus
- {
- 提交,
- 客服检查,
- 业务员确认,
- 主管签字
- }
- }
0 0
- 钝化程序模式SOA架构BPM
- .NET框架设计(高级框架架构模式)—钝化程序、逻辑冻结、冻结程序的延续、瞬间转移
- SOA架构常见模式
- SOA架构模式
- 酒店管理IT架构案例:引进中间件/SOA/BPM
- IBM SOA[ESB,BPM,Portal]基础架构图解
- SOA 新业务语言 新系统架构——SOA与BPM
- BPM结盟SOA
- SOA 的应用 -- BPM
- SOA 的应用 -- BPM
- SOA 的应用 -- BPM
- SOA 的应用 -- BPM
- SOA 的应用 -- BPM
- SOA 的应用 -- BPM
- SOA 的应用 -- BPM
- SOA 的应用 -- BPM
- SOA 的应用 -- BPM
- SOA 的应用 -- BPM
- 蓝桥杯 运送马匹
- 升级php7+安装laravel过程中遇到的问题汇总
- Python函数(上)
- 网站开发流程以及HTML5简介(九)
- [emacs]helm-mode
- 钝化程序模式SOA架构BPM
- SetTimeout 的伪多线程
- Eclipse 开发android 添加support解决方案
- 求职宝典 第11章
- Starting from 0 learning Python(The First Day)
- Redis数据结构和对象(二)
- 绘制旋转七彩动画_VC源码_易语言源码
- 73. Set Matrix Zeroes
- C 语言 指针的详解