Ejemplo n.º 1
0
        //what to do once we recieve the message
        private void Recieve(string message, string from) //make the message the item code
        {
            //waits for the following message from the event channel once it gets it executes the following code
            if (from == "startEvent" && message == "order")
            {
                //Calls our buisness layer to check if the item entered is within the minimum and maximum range
                var DatabaseCall = new SCSM.Business.DatabaseCalls();
                var val          = DatabaseCall.CheckMinAndMaxRequired(itemOrder);

                //if too many alert the user
                if (val == "too many")
                {
                    MessageBox.Show("You need to order less (Maximum orders exceeded)");
                    //send a message to the mediator to indicate failure. The next processor will not start
                    Send("cancel");
                }
                else if (val == "too little")
                {
                    MessageBox.Show("You need to order more (Minimum orders not met)");
                    //send a message to the mediator to indicate failure. The next processor will not start

                    Send("cancel");
                }
                else
                {
                    /*Send a message to the mediator to indicate success. Mediator will then send a message via the event channel
                     * so the next process knows when to start*/
                    Send("order");
                }
            }
        }
Ejemplo n.º 2
0
        private void Recieve(string message, string from)
        {
            var databaseCall = new SCSM.Business.DatabaseCalls();

            //get the message from the mediator id the previous processes passed their success message it executes the appropriate logic
            if (from == "Process 2" && message == "add")
            {
                //if the amount spent so far exceeds the monthly budget sends a warning
                if (databaseCall.CalculateMoneySpent() > MONTHLY_BUDGET)
                {
                    MessageBox.Show("We are already overbudget please reconsider adding more stock and instead focus on selling the goods we have");

                    /*Send a message to the mediator to indicate success. Mediator will then send a message via the event channel
                     *                  so the next process knows when to start*/
                    Send("add");
                }
                Send("add");
            }
        }
Ejemplo n.º 3
0
        private void Recieve(string message, string from)
        {
            var databaseCall = new SCSM.Business.DatabaseCalls();

            //if process one is a sucess then the check if the item exists
            if (from == "Process 1" && message == "add")
            {
                if (databaseCall.CheckIfItemExists(stockItem.itemCode))
                {
                    //if the item does exist tell send a notification and send message to the mediator to tell it it has failed
                    MessageBox.Show("This item already exists you can not add an existing item");
                    Send("cancel");
                }
                else
                {
                    /*Send a message to the mediator to indicate success. Mediator will then send a message via the event channel
                     * so the next process knows when to start*/
                    Send("add");
                }
            }
        }
Ejemplo n.º 4
0
        private void Recieve(string message, string from)
        {
            var databaseCall = new SCSM.Business.DatabaseCalls();

            //if mediator tells us proccess 3 was a sucess we run the following code
            if (from == "Process 3" && message == "delete")
            {
                //delete the item
                databaseCall.DeleteStockItem(itemCode);

                /*Send a message to the mediator to indicate success. Mediator will then send a message via the event channel
                 *   so the next process knows when to start*/
                Send("delete");
            }

            //If it gets the success message from proccess 3 execute the following
            if (from == "Process 3" && message == "order")
            {
                //add it to the db
                databaseCall.OrderStocks(itemOrder);

                /*Send a message to the mediator to indicate success. Mediator will then send a message via the event channel
                 * so the next process knows when to start*/
                Send("order");
            }

            //If it gets the success message from proccess 3 execute the following
            if (from == "Process 3" && message == "add")
            {
                databaseCall.AddToStock(stockItem);

                /*Send a message to the mediator to indicate success. Mediator will then send a message via the event channel
                 *  so the next process knows when to start*/
                Send("add");
            }
        }