Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //序列化
            Order order = new Order
            {
                Items    = new List <OrderItem>(),
                Customer = new CustomerInfo()
                {
                    Email = "*****@*****.**", Name = "test", Phone = "12345678901"
                }
            };

            order.Items.Add(new OrderItem()
            {
                Number  = 10,
                Product = new ProductModel()
                {
                    Name = "p1", Price = 500
                }
            });
            order.Items.Add(new OrderItem()
            {
                Number  = 9,
                Product = new ProductModel()
                {
                    Name = "p2", Price = 100
                }
            });
            OrderExamineApproveManager approveFlows = OrderExamineApproveManager.CreateFlows();

            using (Stream stream1 = File.Open("orderChecks.xml", FileMode.Create))
            {
                BinaryFormatter format = new BinaryFormatter();
                format.Serialize(stream1, approveFlows);
            }

            //反序列化
            using (Stream stream2 = File.Open("orderChecks.xml", FileMode.Open))
            {
                BinaryFormatter format      = new BinaryFormatter();
                var             approveFlws = format.Deserialize(stream2) as OrderExamineApproveManager;
                approveFlows.RunFlows(order);
            }
        }
Ejemplo n.º 2
0
        public static OrderExamineApproveManager CreateFlows()
        {
            OrderExamineApproveManager result = new OrderExamineApproveManager();
            //绑定信息员审批流程
            Infomationer infoMationer = new Infomationer();

            result.Flows += infoMationer.CheckPrices;
            result.Flows += infoMationer.CheckNumbers;

            //绑定业务经理审批流程
            BusinessManager businessManager = new BusinessManager();

            result.Flows += businessManager.CallPhoneConfirm;
            result.Flows += businessManager.SendEmailNotice;

            //绑定总经理审批流程
            GeneralManager generalManager = new GeneralManager();

            result.Flows += generalManager.FinalConfirm;
            result.Flows += generalManager.SignAndRecord;

            return(result);
        }