Beispiel #1
0
        //method that will be called when an unprocessed order is added to the orderprocessing
        public void unProcessedOrderAddedToBuffer(int destinationSupplierID)
        {
            //the order that was added is intended for this supplier
            if (destinationSupplierID == this.supplierID)
            {
                //get the encrypted order from the order processor
                string encryptedOrderToProcess = OrderProcessing.getUnProcessedOrder(this.supplierID);

                //decrypt the string and assign it to an Order Object
                Order newOrderToProcess = Decoder.Decrypt(encryptedOrderToProcess);

                //validate the order
                Boolean orderIsValid = validateOrder(newOrderToProcess);

                //if the order is valid
                if (orderIsValid)
                {
                    //set order as a valid order
                    newOrderToProcess.ValidOrder = true;
                }

                //create new thread and send to order processed as processed order
                //this occurs regardless of whether or not the order was validated

                //this thread is just creating a new thread to run the method after the =>
                Thread threadToProcessOrder = new Thread(() => OrderProcessing.addProcessedOrder(this.supplierID, Encoder.Encrypt(newOrderToProcess)));

                //start thread
                threadToProcessOrder.Start();
            }
        }