public void OnProxyFailed(DateTime timestamp, ProxyError error) { var metrics = PerRequestMetrics.Current; metrics.ProxyStopOffset = metrics.CalcOffset(timestamp); metrics.Error = error; }
private HttpContext GetFailedRequestContext(ProxyError error) { var errorFeature = new ProxyErrorFeature(error, null); var context = new DefaultHttpContext(); context.Features.Set <IProxyErrorFeature>(errorFeature); return(context); }
/// <summary> /// 检查服务器是否返回了错误 /// </summary> /// <param name="responseStr"></param> private static void CheckResponse(string responseStr) { ProxyError proxyError = JsonConvert.DeserializeObject <ProxyError>(responseStr); if (proxyError.proxy_code != 0) { throw new HiWiFiApiAccessDeniedException($"[HiWiFiAPI]Proxy Error, code: {proxyError.proxy_code}, msg: {proxyError.proxy_msg}"); } }
public void ProxyFailed(ProxyError error) { Interlocked.Increment(ref _failedRequests); if (IsEnabled(EventLevel.Informational, EventKeywords.All)) { Debug.Assert(sizeof(ProxyError) == sizeof(int), "Backing type of ProxyError MUST NOT be changed"); WriteEvent(eventId: 3, (int)error); } }
/// <summary> /// Initialize cryptographer from <see cref="TokenSettings"/> /// <remarks> /// Setting the <see cref="DefaultCryptographer"/> to the Direct Project's <see cref="SMIMECryptographer"/> /// </remarks> /// </summary> /// <param name="pluginDef"></param> public void Init(PluginDefinition pluginDef) { try { var settings = pluginDef.DeserializeSettings <TokenResolverSettings>(); Init(settings); } catch (Exception ex) { ProxyError.NotifyEvent(this, ex); // Do not remove. Exceptions here can cause the Direct Project to not bind to SMTP. } }
public static async Task InsertErrorAsync(ProxyError error) { // Create a command object identifying the stored procedure using (var cmd = new SqlCommand("sp_InsertErrorLog")) { // // Set the command object so it knows to execute a stored procedure cmd.CommandType = CommandType.StoredProcedure; // // Add parameters to command, which will be passed to the stored procedure if (error.Snapshot.Value != null) { cmd.Parameters.AddWithValue("@ScreenCapture", error.Snapshot.Value.ToBytes()); } cmd.Parameters.AddWithValue("@ServerDateTime", error.ServerDateTime); cmd.Parameters.AddWithValue("@Host", error.Host); cmd.Parameters.AddWithValue("@User", error.User); cmd.Parameters.AddWithValue("@IsHandled", error.IsHandled); cmd.Parameters.AddWithValue("@Type", error.ErrorType); cmd.Parameters.AddWithValue("@AppName", error.AppName); cmd.Parameters.AddWithValue("@CurrentCulture", error.CurrentCulture); cmd.Parameters.AddWithValue("@CLRVersion", error.ClrVersion); cmd.Parameters.AddWithValue("@Message", error.Message); cmd.Parameters.AddWithValue("@Source", error.Source ?? ""); cmd.Parameters.AddWithValue("@StackTrace", error.StackTrace); cmd.Parameters.AddWithValue("@ModuleName", error.ModuleName); cmd.Parameters.AddWithValue("@MemberType", error.MemberType); cmd.Parameters.AddWithValue("@Method", error.Method); cmd.Parameters.AddWithValue("@Processes", error.Processes); cmd.Parameters.AddWithValue("@ErrorDateTime", error.ErrorDateTime); cmd.Parameters.AddWithValue("@OS", error.OS); cmd.Parameters.AddWithValue("@IPv4Address", error.IPv4Address); cmd.Parameters.AddWithValue("@MACAddress", error.MacAddress); cmd.Parameters.AddWithValue("@HResult", error.HResult); cmd.Parameters.AddWithValue("@Line", error.LineColumn.Line); cmd.Parameters.AddWithValue("@Column", error.LineColumn.Column); cmd.Parameters.AddWithValue("@Duplicate", error.Duplicate); cmd.Parameters.AddWithValue("@Data", error.Data); // // execute the command await ConnectionManager.GetDefaultConnection().ExecuteNonQueryAsync(cmd); } }
public void Init(TokenResolverSettings resolverSettings) { try { IPropertyManager client = resolverSettings.ClientSettings.CreatePropertyManagerClient(); Property[] properties = client.GetProperties(new [] { "TokenSettings" }); string tokenSettingsXml = properties.SingleOrDefault().Value; var tokenSettings = tokenSettingsXml.FromXml <TokenSettings>(); m_innerSoftwareCryptographer = new SMIMECryptographer( tokenSettings.DefaultEncryption, tokenSettings.DefaultDigest); tokenSettings.Error += ProxyError; m_innerHsmCryptographer = tokenSettings.Create(); } catch (Exception ex) { ProxyError.NotifyEvent(this, ex); // Do not remove. Exceptions here can cause the Direct Project to not bind to SMTP. } }
private static async Task <Tuple <ProxyError, bool> > TransmitOneError(ProxyError error) { if (ErrorHandlingOption.EnableNetworkSending) // Server Connector to online or offline ? { try { await SqlServerManager.InsertErrorAsync(error); } catch (AggregateException exp) { // If an unhandled exception occurs during dataflow processing, all // exceptions are propagated through an AggregateException object. ErrorHandlingOption.EnableNetworkSending = false; exp.Handle(e => { ErrorHandlingOption.AtSentState = false; return(true); }); } } // Mark the head of the pipeline as complete. The continuation tasks // propagate completion through the pipeline as each part of the // pipeline finishes. else { ErrorListenerTransformBlock.Complete(); ErrorHandlingOption.AtSentState = false; } if (ErrorListenerTransformBlock.InputCount == 0) { ErrorHandlingOption.AtSentState = false; } // // Post to Acknowledge Action Block: return(new Tuple <ProxyError, bool>(error, ErrorHandlingOption.EnableNetworkSending)); }
private static string GetMessage(ProxyError error) { return(error switch { ProxyError.None => throw new NotSupportedException("A more specific error must be used"), ProxyError.Request => "An error was encountered before receiving a response.", ProxyError.RequestTimedOut => "The request timed out before receiving a response.", ProxyError.RequestCanceled => "The request was canceled before receiving a response.", ProxyError.RequestBodyCanceled => "Copying the request body was canceled.", ProxyError.RequestBodyClient => "The client reported an error when copying the request body.", ProxyError.RequestBodyDestination => "The destination reported an error when copying the request body.", ProxyError.ResponseBodyCanceled => "Copying the response body was canceled.", ProxyError.ResponseBodyClient => "The client reported an error when copying the response body.", ProxyError.ResponseBodyDestination => "The destination reported an error when copying the response body.", ProxyError.UpgradeRequestCanceled => "Copying the upgraded request body was canceled.", ProxyError.UpgradeRequestClient => "The client reported an error when copying the upgraded request body.", ProxyError.UpgradeRequestDestination => "The destination reported an error when copying the upgraded request body.", ProxyError.UpgradeResponseCanceled => "Copying the upgraded response body was canceled.", ProxyError.UpgradeResponseClient => "The client reported an error when copying the upgraded response body.", ProxyError.UpgradeResponseDestination => "The destination reported an error when copying the upgraded response body.", ProxyError.NoAvailableDestinations => throw new NotImplementedException(), // Not used in this class _ => throw new NotImplementedException(error.ToString()), });
public void AddRow(ProxyError row) { DataGridViewHelper <IError, ProxyError> .AddRow(this, row); }
private void ReportProxyError(HttpContext context, ProxyError error, Exception ex) { context.Features.Set <IProxyErrorFeature>(new ProxyErrorFeature(error, ex)); Log.ErrorProxying(_logger, error, ex); ProxyTelemetry.Log.ProxyFailed(error); }
public static void ErrorProxying(ILogger logger, ProxyError error, Exception ex) { _proxyError(logger, error, GetMessage(error), ex); }
internal ProxyErrorFeature(ProxyError error, Exception ex) { Error = error; Exception = ex; }
public void OnProxyFailed(DateTime timestamp, ProxyError error) { }
public void OnProxyFailed(DateTime timestamp, ProxyError error) => AddStage(nameof(OnProxyFailed), timestamp);
public void UpdateRow(ProxyError rowObj) { DataGridViewHelper <IError, ProxyError> .UpdateRow(this, rowObj); }
public void RemoveRow(ProxyError rowObj) { DataGridViewHelper <IError, ProxyError> .RemoveRow(this, rowObj); }