Beispiel #1
0
        private void ExecuteTransaction(IServerCallHandler handler)
        {
            try
            {
                var tx     = CurrentTransactionContext.Transaction;
                var retVal = handler.Execute(tx.Params.ToByteArray());
                if (retVal != null)
                {
                    CurrentTransactionContext.Trace.ReturnValue         = ByteString.CopyFrom(retVal);
                    CurrentTransactionContext.Trace.ReadableReturnValue = handler.ReturnBytesToString(retVal);
                }

                CurrentTransactionContext.Trace.ExecutionStatus = ExecutionStatus.Executed;
            }
            catch (TargetInvocationException ex)
            {
                CurrentTransactionContext.Trace.Error          += ex;
                CurrentTransactionContext.Trace.ExecutionStatus = ExecutionStatus.ContractError;
            }
            catch (AssertionException ex)
            {
                CurrentTransactionContext.Trace.ExecutionStatus = ExecutionStatus.ContractError;
                CurrentTransactionContext.Trace.Error          += "\n" + ex;
            }
            catch (Exception ex)
            {
                // TODO: Simplify exception
                CurrentTransactionContext.Trace.ExecutionStatus = ExecutionStatus.ContractError;
                CurrentTransactionContext.Trace.Error          += "\n" + ex;
            }
        }
        public void Execute_Test()
        {
            var input = new StringInput
            {
                StringValue = "test"
            };
            var inputArray = input.ToByteArray();
            var result     = _callHandler.Execute(inputArray);

            result.ShouldNotBeNull();

            var objectInfo = _callHandler.ReturnBytesToObject(result);
            var outValue   = (StringOutput)objectInfo;

            outValue.StringValue.ShouldBe("test");
        }
        private void ExecuteTransaction(IServerCallHandler handler)
        {
            try
            {
                var tx     = CurrentTransactionContext.Transaction;
                var retVal = handler.Execute(tx.Params.ToByteArray());
                if (retVal != null)
                {
                    CurrentTransactionContext.Trace.ReturnValue = ByteString.CopyFrom(retVal);
                }

                CurrentTransactionContext.Trace.ExecutionStatus = ExecutionStatus.Executed;
            }
            catch (Exception ex)
            {
                CurrentTransactionContext.Trace.ExecutionStatus = ExecutionStatus.ContractError;
                CurrentTransactionContext.Trace.Error          += ex + "\n";
            }
        }