Пример #1
0
        public TRep RunServerOperationAndConvertToFaultException <TReq, TRep>(TReq request, Func <TReq, TRep> action) where TReq : DxStoreAccessRequest where TRep : DxStoreAccessReply
        {
            TRep trep = default(TRep);

            try
            {
                if (ExTraceGlobals.AccessEntryPointTracer.IsTraceEnabled(TraceType.DebugTrace))
                {
                    string arg = Utils.SerializeObjectToJsonString <TReq>(request, false, true) ?? "<serialization error>";
                    ExTraceGlobals.AccessEntryPointTracer.TraceDebug <string, string, string>((long)this.instance.IdentityHash, "{0}: Entering Request: {1} {2}", this.instance.Identity, typeof(TReq).Name, arg);
                }
                trep = action(request);
            }
            catch (Exception ex)
            {
                if (!this.instance.GroupConfig.Settings.IsUseHttpTransportForClientCommunication)
                {
                    DxStoreServerFault dxStoreServerFault = WcfUtils.ConvertExceptionToDxStoreFault(ex);
                    if (ExTraceGlobals.AccessEntryPointTracer.IsTraceEnabled(TraceType.ErrorTrace))
                    {
                        string text = Utils.SerializeObjectToJsonString <DxStoreServerFault>(dxStoreServerFault, false, true) ?? "<serialization error>";
                        ExTraceGlobals.AccessEntryPointTracer.TraceError((long)this.instance.IdentityHash, "{0}: Leaving (Failed) - Request: {1} - Fault: {2} - Exception: {3}", new object[]
                        {
                            this.instance.Identity,
                            typeof(TReq).Name,
                            text,
                            ex
                        });
                    }
                    throw new FaultException <DxStoreServerFault>(dxStoreServerFault);
                }
                ExTraceGlobals.AccessEntryPointTracer.TraceError <string, string, Exception>((long)this.instance.IdentityHash, "{0}: Leaving (Failed) - Request: {1} - Exception: {2}", this.instance.Identity, typeof(TReq).Name, ex);
                throw;
            }
            if (ExTraceGlobals.AccessEntryPointTracer.IsTraceEnabled(TraceType.DebugTrace))
            {
                string text2 = (trep != null) ? (Utils.SerializeObjectToJsonString <TRep>(trep, false, true) ?? "<serialization error>") : "<null>";
                ExTraceGlobals.AccessEntryPointTracer.TraceDebug((long)this.instance.IdentityHash, "{0}: Leaving (Success) - Request: {1} Reply: {2} {3}", new object[]
                {
                    this.instance.Identity,
                    typeof(TReq).Name,
                    typeof(TRep).Name,
                    text2
                });
            }
            return(trep);
        }