Example #1
0
        public void Merge(Result result)
        {
            // This will copy the results from the 'BatchResult' back to the original structure.  The 'ResultBatch' returned
            // from the execution of the batch only has the return codes and the exceptions.  This will correlate and copy
            // those values back into the original batch so the caller will have the impression that the entire structure made
            // the round trip to the server and back.  The 'ResultBatch' was designed to minimize the amount of traffic and
            // deserializing that had to be done during the trip to the server and back.
            foreach (Result.Transaction resultTransaction in result.Transactions)
            {
                // Correlate the current result transaction with the original transaction.
                Batch.Transaction batchTransaction = this.Transactions[resultTransaction.Index];

                // Copy each of the transaction level exceptions back into the original structure.
                foreach (Exception exception in resultTransaction.Exceptions)
                {
                    batchTransaction.Exceptions.Add(exception);
                }

                foreach (Result.Method resultMethod in resultTransaction.Methods)
                {
                    // Correlate the original method with the resulting method.
                    Batch.Method batchMethod = batchTransaction.Methods[resultMethod.Index];

                    // Copy each of the output parameters back into the original method.
                    batchMethod.Results = resultMethod.Results;

                    // Copy each of the exceptions back into the original method.
                    foreach (Exception exception in resultMethod.Exceptions)
                    {
                        batchMethod.Exceptions.Add(exception);
                    }
                }
            }
        }
Example #2
0
            public Transaction(Batch.Transaction batchTransaction)
            {
                // Initialize the object
                this.Index      = batchTransaction.Index;
                this.Exceptions = batchTransaction.Exceptions.ToArray();

                // Copy the framework of the method out of the original structure and place it in the results.  Note that unless
                // there was an exception or some return values, the method doesn't need to be passed back to the caller.
                List <Method> methodList = new List <Method>();

                foreach (Batch.Method batchMethod in batchTransaction.Methods)
                {
                    Result.Method resultMethod = new Result.Method(batchMethod);
                    if (resultMethod.Exceptions.Length != 0 || resultMethod.Results != null)
                    {
                        methodList.Add(resultMethod);
                    }
                }
                this.Methods = methodList.ToArray();
            }