Ejemplo n.º 1
0
        /// <summary>
        /// Asynchronous implementation of the Invoke (End)
        /// </summary>
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
        {
            var    auditAsyncResult = result as AuditScopeAsyncResult;
            var    auditScopeState  = auditAsyncResult.AuditScopeState;
            object callResult;
            var    auditScope    = auditScopeState.AuditScope;
            var    auditWcfEvent = (auditScope.Event as AuditEventWcfAction).WcfEvent;

            try
            {
                callResult = _baseInvoker.InvokeEnd(instance, out outputs, auditAsyncResult.OriginalAsyncResult);
            }
            catch (Exception ex)
            {
                AuditBehavior.CurrentAuditScope = null;
                auditWcfEvent.Fault             = GetWcfFaultData(ex);
                auditWcfEvent.Success           = false;
                (auditScope.Event as AuditEventWcfAction).WcfEvent = auditWcfEvent;
                auditScope.Dispose();
                throw;
            }
            AuditBehavior.CurrentAuditScope = null;
            auditWcfEvent.OutputParameters  = GetEventElements(outputs);
            auditWcfEvent.Result            = new AuditWcfEventElement(callResult);
            (auditScope.Event as AuditEventWcfAction).WcfEvent = auditWcfEvent;
            auditScope.Dispose();
            return(callResult);
        }
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
        {
            object returnedValue = null;

            object[]  outputParams = {};
            Exception exception    = null;

            try
            {
                Task task = (result as Task);
                if (task.Status == TaskStatus.Faulted)
                {
                    //Preserve original stack trace.
                    exception = PreserveOriginalException(task.Exception);
                }
                CheckCompletesActorInstance(instance);
                returnedValue = m_OldInvoker.InvokeEnd(instance, out outputs, result);
                outputs       = outputParams;
                return(returnedValue);
            }
            catch
            {
                Debug.Assert(true, "Invoker End exception: " + exception.Message);
                throw exception;
            }
        }
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
        {
            var invokeResult = _OriginalInvoker.InvokeEnd(instance, out outputs, result);

            AfterInvoke();
            return(invokeResult);
        }
Ejemplo n.º 4
0
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult asyncResult)
        {
            // Finish invoking the operation using the inner operation
            // invoker.
            object result = innerOperationInvoker.InvokeEnd(instance, out outputs, asyncResult);

            return(result);
        }
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
        {
            var task = result as Task;

            if (task != null && task.IsFaulted && task.Exception != null)
            {
                this.Log(task.Exception);
            }

            return(_invoker.InvokeEnd(instance, out outputs, result));
        }
 public Object InvokeEnd(Object instance, out Object[] outputs, IAsyncResult result)
 {
     try
     {
         return(_originalInvoker.InvokeEnd(instance, out outputs, result));
     }
     finally
     {
         LogicalOperationScope.StopLogicalOperation();
     }
 }
 public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
 {
     try
     {
         return(_baseInvoker.InvokeEnd(instance, out outputs, result));
     }
     catch (Exception ex)
     {
         outputs = new object[0];
         return(CatchException(instance, ex));
     }
 }
 public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
 {
     try
     {
         var asyncResult = originalInvoker.InvokeEnd(instance, out outputs, result);
         return(TearDownService(instance, asyncResult));
     }
     catch (Exception ex)
     {
         throw TearDownService(instance, ex);
     }
 }
Ejemplo n.º 9
0
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
        {
            object returnedValue = null;

            object[]  outputParams = { };
            Exception exception    = null;

            returnedValue = m_OldInvoker.InvokeEnd(instance, out outputs, result);
            outputs       = outputParams;
            PostInvoke(instance, returnedValue, outputParams, exception);
            return(returnedValue);
        }
 void HandleCallback(IAsyncResult asyncResult)
 {
     try
     {
         innerOperationInvoker.InvokeEnd(instance, out outputs, asyncResult);
         Complete(false);
     }
     catch (Exception e)
     {
         Complete(false, e);
     }
 }
Ejemplo n.º 11
0
    public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
    {
        var task = result as Task;

        if (task != null && task.IsFaulted && task.Exception != null)
        {
            foreach (var error in task.Exception.InnerExceptions)
            {
                _log.Log(error);
            }
        }

        return(_invoker.InvokeEnd(instance, out outputs, result));
    }
Ejemplo n.º 12
0
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult asyncResult)
        {
            // Finish invoking the operation using the inner operation
            // invoker.
            object result = innerOperationInvoker.InvokeEnd(instance, out outputs, asyncResult);

            // Save the instance using the storage manager saved in the
            // current InstanceContext.
            InstanceContextExtension extension =
                OperationContext.Current.InstanceContext.Extensions.Find <InstanceContextExtension>();

            extension.StorageManager.SaveInstance(extension.ContextId, instance);
            return(result);
        }
        public Task <object> InvokeOperationAsync(object instance, object[] inputs, object state)
        {
            Message inputMessage  = null;
            Message outputMessage = null;

            try
            {
                if (inputs != null && inputs.Length == 1)
                {
                    inputMessage = inputs[0] as Message;
                }

                if (inputMessage != null)
                {
                    // We need to copy the message in order to read it.
                    // This means the original message will have the 'Read' state, which means it can no longer be read.
                    var bufferedMessage = inputMessage.CreateBufferedCopy(Int32.MaxValue);

                    inputs[0] = bufferedMessage.CreateMessage();
                    var messageToWorkOn = bufferedMessage.CreateMessage();

                    Stream messageStream = messageToWorkOn.GetBody <Stream>();
                    if (messageStream != null)
                    {
                        outputMessage = GetOutputMessageForInputMessageStream(messageStream);
                    }
                }
            }
            catch (Exception ex)
            {
                // Swallow all the exceptions
                outputMessage = null;
            }

            if (outputMessage == null)
            {
                var capturedOperationContext = OperationContext.Current;
                return(Task <object> .Factory.StartNew(() =>
                {
                    OperationContext.Current = capturedOperationContext;
                    var begin = _innerInvoker.InvokeBegin(instance, inputs, null, state);
                    object[] o;

                    return _innerInvoker.InvokeEnd(instance, out o, begin);
                }));
            }

            return(Task.FromResult((object)outputMessage));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 异步调用结束后操作
        /// </summary>
        /// <param name="instance"></param>
        /// <param name="outputs"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
        {
            object[] outputParams = { };

            try
            {
                return(orgninInvoker.InvokeEnd(instance, out outputParams, result));
            }
            finally
            {
                //写日志
                logger.WriteLog();
                outputs = outputParams;
            }
        }
Ejemplo n.º 15
0
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
        {
            object returnedValue = null;

            object[] outputParams = { };

            try
            {
                returnedValue = invoker.InvokeEnd(instance, out outputs, result);
                outputs       = outputParams;
                return(returnedValue);
            }
            catch (PropValiException pv)
            {
                TransResponse response = this.CreateResponse(out outputParams);

                if (response != null)
                {
                    response.Status  = TransStatus.ValidateError;
                    response.Message = pv.Message;
                    returnedValue    = response;
                }
                else
                {
                    returnedValue = null;
                }
            }
            catch (Exception ex)
            {
                TransResponse response = this.CreateResponse(out outputParams);

                if (response != null)
                {
                    response.Status  = TransStatus.Error;
                    response.Message = ex.Message;
                    returnedValue    = response;
                }
                else
                {
                    returnedValue = null;
                }
            }

            outputs = outputParams;
            return(returnedValue);
        }
Ejemplo n.º 16
0
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
        {
            object    returnedValue = null;
            Exception exception     = null;

            try
            {
                returnedValue = invoker.InvokeEnd(instance, out outputs, result);
            }
            catch (Exception ex)
            {
                exception = ex;
                throw;
            }

            PostInvoke(result.AsyncState as object[], returnedValue, outputs, exception);

            return(returnedValue);
        }
Ejemplo n.º 17
0
            /// <summary>
            /// 功能:异步结束方法。
            /// </summary>
            /// <returns>
            /// 返回值。
            /// </returns>
            /// <param name="instance">调用的对象。</param><param name="outputs">方法的输出。</param><param name="result"><see cref="T:System.IAsyncResult"/> 对象。</param>
            public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
            {
                outputs = null;
                object returnValue = null;

                try
                {
                    returnValue = m_oldInvoker.InvokeEnd(instance, out outputs, result);
                }
                catch (DataMessageException dmex)
                {
                    returnValue = GetDataErrorResponse(dmex);
                }
                catch (Exception ex)
                {
                    returnValue = GetErrorResponse(instance, ex);
                }

                return(returnValue);
            }
Ejemplo n.º 18
0
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
        {
            object returnedValue = null;

            object[]  outputParams = {};
            Exception exception    = null;

            try
            {
                Task task = (result as Task);
                if (task.Status == TaskStatus.Faulted)
                {
                    //Preserve original stack trace.
                    exception = PreserveOriginalException(task.Exception);
                }
                //TEST ONLY...
                if (CompletesActorInstance(instance))
                {
                    AsyncContextScope scope = CallContext.LogicalGetData("Context") as AsyncContextScope;
                    if (scope != null)
                    {
                        scope.Close();
                    }
                }

                CheckCompletesActorInstance(instance);
                returnedValue = m_OldInvoker.InvokeEnd(instance, out outputs, result);
                outputs       = outputParams;

                return(returnedValue);
            }
            catch
            {
                Debug.Assert(true, "Invoker End exception: " + exception.Message);
                throw CheckForActorNotFoundException(instance, exception);
            }
            finally
            {
                OnPostInvoke(instance, exception);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 异步调用结束后操作
        /// </summary>
        /// <param name="instance"></param>
        /// <param name="outputs"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
        {
            object[] outputParams = { };

            try
            {
                return(orgninInvoker.InvokeEnd(instance, out outputParams, result));
            }
            catch (Exception ex)
            {
                //写日志 因为考虑到NLog框架及各项目自身情况,不在本框架里实现写日志(这样程序的灵活性和扩展性高),框架只实现该实现的,其他由具体项目实现
                logger.WriteLog(ex);

                //return null;
                throw;
            }
            finally
            {
                outputs = outputParams;
            }
        }
Ejemplo n.º 20
0
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
        {
            object returnedValue = null;

            object[]  outputParams = { };
            Exception exception    = null;

            try
            {
                returnedValue = m_InnerInvoker.InvokeEnd(instance, out outputs, result);
                outputs       = outputParams;
                return(returnedValue);
            }
            catch (Exception operationException)
            {
                exception = operationException;
                throw;
            }
            finally
            {
                PostInvoke(instance, returnedValue, outputParams, exception);
            }
        }
Ejemplo n.º 21
0
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult asyncResult)
        {
            CachingAsyncResult result = asyncResult as CachingAsyncResult;
            CachingUserState   state  = result.CachingUserState;

            if (state.CacheItem == null)
            {
                object data = _invoker.InvokeEnd(instance, out outputs, result.OriginalAsyncResult);
                state.CacheItem = new CachedOperationResult {
                    Data = data, Outputs = outputs
                };

                CacheServiceHelper.Current.Add(state.CacheKey, state.CacheItem, TimeSpan.FromSeconds(_cacheDuration));

                return(data);
            }
            else
            {
                InvokerDelegate invoker = ((AsyncResult)result.OriginalAsyncResult).AsyncDelegate as InvokerDelegate;
                invoker.EndInvoke(out outputs, result.OriginalAsyncResult);

                return(state.CacheItem.Data);
            }
        }
Ejemplo n.º 22
0
 public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
 {
     // Not supported - an exception will be thrown
     return(_innerInvoker.InvokeEnd(instance, out outputs, result));
 }
 public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
 {
     // Use the default invoker. Don't time async methods
     return(_previousInvoker.InvokeEnd(instance, out outputs, result));
 }
 public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
 {
     return(_baseInvoker.InvokeEnd(instance, out outputs, result));
 }
 public virtual object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
 {
     return(OldInvoker.InvokeEnd(instance, out outputs, result));
 }
Ejemplo n.º 26
0
    public object InvokeEnd(object instance, out object[] outputs, IAsyncResult asyncResult)
    {
        object result = _innerOperationInvoker.InvokeEnd(instance, out outputs, asyncResult);

        return(result);
    }
 public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
 {
     return(dispatchOperationInvoker.InvokeEnd(instance, out outputs, result));
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Method which fires at the time of Request invoke action ends
 /// </summary>
 /// <param name="instance">operation context instance</param>
 /// <param name="outputs">output parameter array</param>
 /// <param name="result">result obtained</param>
 /// <returns>returns object</returns>
 public Object InvokeEnd(Object instance, out Object[] outputs, IAsyncResult result)
 {
     return(InnerOperationInvoker.InvokeEnd(instance, out outputs, result));
 }
 public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
 {
     LogComplete();
     return(_invoker.InvokeEnd(instance, out outputs, result));
 }