コード例 #1
0
        //In button click part of the initial event
        private void orderStockButton_Click(object sender, EventArgs e)
        {
            var itemCode = stockDataGrid.SelectedCells[0].Value.ToString();

            var itemOrder = new OrderItem();

            itemOrder.itemCode         = itemCode;
            itemOrder.itemQuantity     = Convert.ToInt32(orderStockQuanityTextBox.Value);
            itemOrder.stockArrivalDate = orderStocksSADTextBox.Value;

            orderStocksLabel.Text = itemCode;

            var mediator = new Mediator();

            //inititalise the intial event
            var startEvent = new OrderStockEvent(mediator, "startEvent");

            //initialise all the mediator steps
            var process1 = new CheckMinAndMaxProcessor(mediator, "Process 1", itemOrder);
            var process2 = new CheckRevenueGenerateProcessor(mediator, "Process 2", itemCode);
            var process3 = new Processors.CalculateCostProcessor(mediator, "Process 3", itemOrder);
            var process4 = new StockItemProcessor(mediator, "Process 4", itemOrder);
            var process5 = new NotificationProcessor(mediator, "Process 5", itemCode);

            //start the initial event passing a message which should tell processor one to start via the mediator send method
            startEvent.Send("order");

            //refresh the table
            ClearTable();
            LoadTable();
        }
コード例 #2
0
        //the following button is pressed starts the initial event
        private void deleteStockButton_Click(object sender, EventArgs e)
        {
            //item code is the current selected cell on the table
            var itemCode = stockDataGrid.SelectedCells[0].Value.ToString();

            //create an instance of the mediator
            var mediator = new Mediator();

            //inititalise the intial event
            var startEvent = new DeleteStockEvent(mediator, "startEvent");
            //inititialise the processors sending the mediator the message and the object in the constructor
            var process1 = new CheckRevenueGenerateProcessor(mediator, "Process 1", itemCode);
            var process2 = new CancelCurrentOrdersProcessor(mediator, "Process 2", itemCode);
            var process3 = new ConfirmationProcessor(mediator, "Process 3", itemCode);
            var process4 = new StockItemProcessor(mediator, "Process 4", itemCode);
            var process5 = new NotificationProcessor(mediator, "Process 5", itemCode);

            //start the initial event passing a message which should tell processor one to start via the mediator send method
            startEvent.Send("delete");

            //Refresh the table
            ClearTable();
            LoadTable();
        }