//private static Dictionary<int, Tuple<string, string>> dict = new Dictionary<int, Tuple<string, string>>(); /// <summary> /// /// </summary> /// <param name="client"></param> /// <param name="systemID"></param> /// <param name="systemName"></param> /// <param name="environment">环境</param> /// <param name="TraceExtensionAct">TraceExtensionAct</param> public static void RegistTracing(this RpcHttpClient client, string systemID = null, string systemName = null, string environment = null, Action <HttpResponseMessage, RpcContext, TraceLogs> TraceExtensionAct = null) { RpcHttpClient.OnResponseDelegate onResponse = (response, rpcContext) => { TraceLogs trace = new TraceLogs(); trace.IsSuccess = true; trace.IsException = false; trace.SystemID = systemID ?? EnvironmentConfig.SystemID; trace.SystemName = systemName ?? EnvironmentConfig.SystemName; trace.Environment = environment ?? EnvironmentConfig.Environment; TraceExtensionAct?.Invoke(response, rpcContext, trace); FillClientSR(trace, response.RequestMessage, response, rpcContext); Record(trace); }; RpcHttpClient.OnErrorDelegate onError = (ex, request, rpcContext) => { TraceLogs trace = new TraceLogs(); trace.IsSuccess = false; trace.IsException = true; trace.SystemID = systemID ?? EnvironmentConfig.SystemID; trace.SystemName = systemName ?? EnvironmentConfig.SystemName; trace.Environment = environment ?? EnvironmentConfig.Environment; FillClientSR(trace, request, null, rpcContext); trace.Extensions.Add("Exception", Util.GetFullExceptionMessage(ex)); Record(trace); }; client.RequestContentDataHandler -= Client_RequestContentDataHandler; client.OnRequest -= Client_OnRequest; client.OnResponse -= onResponse; client.OnError -= onError; client.RequestContentDataHandler += Client_RequestContentDataHandler; client.OnRequest += Client_OnRequest; client.OnResponse += onResponse; client.OnError += onError; //dict[client.GetHashCode()] = new Tuple<string, string>(systemID, systemName); }
public NeoJsonRpcService(RpcHttpClient rpcHttpClient) { _rpcHttpClient = rpcHttpClient; }