protected void startTestButton_Click(object sender, EventArgs e) { TraceManager.WebRoleComponent.TraceIn(); try { TestRunStartEvent startEvent = new TestRunStartEvent() { TestRunID = Guid.Parse(this.testRunIDTextBox.Text), MessageCount = Convert.ToInt32(this.messageCountTextBox.Text), MessageSize = Convert.ToInt32(this.messageSizeDropDown.Text), EnableAsyncPublish = this.publishAsyncCheckbox.Checked, EnableAsyncDispatch = this.enableAsyncDispatchCheckbox.Checked, RequireTopicCleanup = this.requireTopicCleanupCheckbox.Checked, PurgeTraceLogTable = this.purgeTraceLogTableCheckbox.Checked }; var targetInstance = RoleEnvironment.Roles.Where(r => { return(r.Value != RoleEnvironment.CurrentRoleInstance.Role); }). SelectMany(i => i.Value.Instances).OrderBy(inst => { return(CommonFuncs.GetRoleInstanceIndex(inst.Id)); }).Take(1). FirstOrDefault(); TraceManager.WebRoleComponent.TraceInfo("Sending an unicast IRC event to role instance ID {0}", targetInstance.Id); var ircEvent = new InterRoleCommunicationEvent(startEvent, roleInstanceID: targetInstance.Id); Global.InterRoleCommunicator.Publish(ircEvent); this.panelInfo.Visible = true; } catch (Exception ex) { this.labelExceptionDetails.Text = ExceptionTextFormatter.Format(ex); this.panelException.Visible = true; } }
/// <summary> /// Verifies whether or not a connection string for the specified database identifier exists. /// </summary> /// <param name="databaseName">A database identifier.</param> /// <returns>A flag indicating that the connection string has been registered in the configuration.</returns> public bool Exists(string databaseName) { Guard.ArgumentNotNullOrEmptyString(databaseName, "databaseName"); try { ConnectionStringSettings connStrSettings = null; if (this.databaseSettings != null) { connStrSettings = this.databaseSettings.GetConnectionStringSettings(databaseName); } else if (this.connectionStringsConfig != null) { connStrSettings = this.connectionStringsConfig.ConnectionStrings[databaseName]; } return(connStrSettings != null && !String.IsNullOrEmpty(connStrSettings.ConnectionString)); } catch (ConfigurationErrorsException ex) { Trace.WriteLine(ExceptionTextFormatter.Format(ex)); return(false); } }
public void TraceError(Exception ex, bool includeStackTrace, Guid callToken) { if (IsEnabled) { ExceptionTextFormatter exceptionFormatter = new ExceptionTextFormatter(this.providerName); TraceEvent(TraceEventType.Error, WellKnownTraceCategory.TraceError, InstrumentationUtility.SystemEventId.Error, InstrumentationUtility.Resources.FormatStringTraceError, exceptionFormatter.FormatException(ex, includeStackTrace), callToken); } }
/// <summary> /// Loads configuration property for component. /// </summary> /// <param name="propertyBag">The configuration property bag.</param> /// <param name="errorLog">Error status (not in use).</param> void IPersistPropertyBag.Load(IPropertyBag propertyBag, int errorLog) { // The outer try/catch block is intended to catch an exception related of incorrect tracing configuration or missing tracing component assembly. try { var callToken = PipelineTraceManager.TraceIn(); try { IDictionary <string, object> props = GetConfigurableProperties(); if (props != null && props.Count > 0) { using (DisposableObjectWrapper dispObjects = new DisposableObjectWrapper(propertyBag, props)) { ICollection <string> propertyNameList = new List <string>(props.Keys); foreach (string propName in propertyNameList) { // Read the component property value from property bag provided. object value = PropertyHelper.ReadPropertyBag(propertyBag, propName); // Only change the value if it was returned from the property bag to prevent detaults from being wiped out. if (value != null) { props[propName] = value; } } // Update the instance properties which are marked with a Browsable attribute. ApplyConfigurableProperties(props); // Invoke the user implementation of the Load method in case there are any custom properties require loading. Load(propertyBag, errorLog); } } PipelineTraceManager.TraceOut(callToken); } catch (Exception e) { // Put component name as a source in this exception so that the error message could reflect this. e.Source = this.Name; // Trace the exception details. PipelineTraceManager.TraceError(e, EnableDetailedExceptions, callToken); // Re-throw the exception so that it can be handled by the caller. throw; } } catch (Exception ex) { Trace.WriteLine(ExceptionTextFormatter.Format(ex)); } }
public static int LogException(Exception exception, string source, string parameters) { return(WriteToLog(new LogItem() { Date = DateTime.Now, Source = source, Parameters = parameters, Type = LogItemType.Error, Text = ExceptionTextFormatter.FormatToString(exception), })); }
private void TraceEventOnFailOver(Exception ex, TraceEventType eventType, string eventCategory, int eventId, string format, params object[] args) { if (this.debugTraceProvider.Switch.ShouldTrace(eventType)) { if (args != null && args.Length > 0) { this.debugTraceProvider.TraceEvent(eventType, eventId, format, args); } else { this.debugTraceProvider.TraceEvent(eventType, eventId, format); } } if (ex != null) { this.debugTraceProvider.TraceEvent(TraceEventType.Error, InstrumentationUtility.SystemEventId.Error, ExceptionTextFormatter.Format(ex)); } }
/// <summary> /// Writes the exception details to the trace. /// </summary> /// <param name="ex">An exception to be formatted and written to the trace.</param> private void HandleException(Exception ex) { this.backupTraceListener.TraceEvent(this.traceEventCache, !String.IsNullOrEmpty(ex.Source) ? ex.Source : Name, TraceEventType.Error, InstrumentationUtility.SystemEventId.Error, ExceptionTextFormatter.Format(ex)); }
public void TraceError(Exception ex, bool includeStackTrace) { ExceptionTextFormatter exceptionFormatter = new ExceptionTextFormatter(); TraceEvent(TraceEventType.Error, WellKnownTraceCategory.TraceError, InstrumentationUtility.SystemEventId.Error, InstrumentationUtility.Resources.FormatStringTraceErrorNoToken, exceptionFormatter.FormatException(ex, includeStackTrace)); }