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); }
private void TrackExceptions(Exception exception) { int num = 0; string name = exception.GetType().Name; this.ExceptionCountMap.TryGetValue(name, out num); num = (this.ExceptionCountMap[name] = num + 1); FaultException <DxStoreServerFault> faultException = exception as FaultException <DxStoreServerFault>; if (faultException != null) { DxStoreServerFault detail = faultException.Detail; if (detail != null) { switch (detail.FaultCode) { case DxStoreFaultCode.Stale: this.CountStale++; return; case DxStoreFaultCode.InstanceNotReady: this.CountNotReady++; return; case DxStoreFaultCode.ServerTimeout: this.CountFailedServerTimeout++; break; case DxStoreFaultCode.ConstraintNotSatisfied: this.CountFailedConstraints++; return; default: return; } } } }