public void SendSimpleErrorNotification() { PersistentEvent ev = null; var client = new ExceptionlessClient("123456789"); try { throw new Exception("Happy days are here again..."); } catch (Exception ex) { var builder = ex.ToExceptionless(client: client); EventEnrichmentManager.Enrich(new EventEnrichmentContext(client, builder.EnrichmentContextData), builder.Target); ev = Mapper.Map <PersistentEvent>(builder.Target); } ev.Id = "1"; ev.OrganizationId = "1"; ev.ProjectId = "1"; ev.StackId = "1"; var mailer = IoC.GetInstance <Mailer>(); mailer.SendNotice(Settings.Current.TestEmailAddress, new EventNotification { Event = ev, IsNew = true, IsCritical = true, IsRegression = false, TotalOccurrences = 1, ProjectName = "Testing" }); }
/// <summary> /// Submits the event to be sent to the server. /// </summary> /// <param name="ev">The event data.</param> /// <param name="enrichmentContextData"> /// Any contextual data objects to be used by Exceptionless enrichments to gather default /// information for inclusion in the report information. /// </param> public void SubmitEvent(Event ev, ContextData enrichmentContextData = null) { if (ev == null) { throw new ArgumentNullException("ev"); } if (!Configuration.Enabled) { _log.Value.Info(typeof(ExceptionlessClient), "Configuration is disabled. The error will not be submitted."); return; } if (!Configuration.IsLocked) { Configuration.LockConfig(); if (!Configuration.Validate().IsValid) { _log.Value.FormattedError(typeof(ExceptionlessClient), "Disabling client due to invalid configuration: {0}", String.Join(", ", Configuration.Validate().Messages)); return; } } var context = new EventEnrichmentContext(this, enrichmentContextData); EventEnrichmentManager.Enrich(context, ev); if (_duplicateChecker.Value != null && _duplicateChecker.Value.IsDuplicate(ev)) { return; } // ensure all required data if (String.IsNullOrEmpty(ev.Type)) { ev.Type = Event.KnownTypes.Log; } if (ev.Date == DateTimeOffset.MinValue) { ev.Date = DateTimeOffset.Now; } if (!OnSubmittingEvent(ev, enrichmentContextData)) { _log.Value.FormattedInfo(typeof(ExceptionlessClient), "Event submission cancelled by event handler: id={0} type={1}", ev.ReferenceId, ev.Type); return; } _log.Value.FormattedTrace(typeof(ExceptionlessClient), "Submitting event: type={0}{1}", ev.Type, !String.IsNullOrEmpty(ev.ReferenceId) ? " refid=" + ev.ReferenceId : String.Empty); _queue.Value.Enqueue(ev); if (String.IsNullOrEmpty(ev.ReferenceId)) { return; } _log.Value.FormattedTrace(typeof(ExceptionlessClient), "Setting last reference id '{0}'", ev.ReferenceId); _lastReferenceIdManager.Value.SetLast(ev.ReferenceId); }
/// <summary> /// Submits the event to be sent to the server. /// </summary> /// <param name="ev">The event data.</param> /// <param name="enrichmentContextData"> /// Any contextual data objects to be used by Exceptionless enrichments to gather default /// information for inclusion in the report information. /// </param> public void SubmitEvent(Event ev, IDictionary <string, object> enrichmentContextData = null) { if (!Configuration.Enabled) { _log.Value.Info(typeof(ExceptionlessClient), "Configuration is disabled. The error will not be submitted."); return; } if (ev == null) { throw new ArgumentNullException("ev"); } var context = new EventEnrichmentContext(this, enrichmentContextData); EventEnrichmentManager.Enrich(context, ev); if (_duplicateChecker.Value.IsDuplicate(ev)) { return; } // ensure all required data if (String.IsNullOrEmpty(ev.Type)) { ev.Type = Event.KnownTypes.Log; } if (ev.Date == DateTimeOffset.MinValue) { ev.Date = DateTimeOffset.Now; } if (!OnSubmittingEvent(ev)) { _log.Value.FormattedInfo(typeof(ExceptionlessClient), "Event submission cancelled by event handler: id={0} type={1}", ev.ReferenceId, ev.Type); return; } _log.Value.FormattedInfo(typeof(ExceptionlessClient), "Submitting event: type={0}{1}", ev.Type, !String.IsNullOrEmpty(ev.ReferenceId) ? " refid=" + ev.ReferenceId : String.Empty); _queue.Value.Enqueue(ev); if (!String.IsNullOrEmpty(ev.ReferenceId)) { _log.Value.FormattedInfo(typeof(ExceptionlessClient), "Setting last reference id '{0}'", ev.ReferenceId); _lastReferenceIdManager.Value.SetLast(ev.ReferenceId); } //LocalConfiguration.SubmitCount++; }
public ExceptionlessConfiguration(IDependencyResolver resolver) { ServerUrl = DEFAULT_SERVER_URL; UserAgent = DEFAULT_USER_AGENT; Enabled = true; EnableSSL = true; DefaultTags = new TagSet(); DefaultData = new DataDictionary(); Settings = new SettingsDictionary(); if (resolver == null) { throw new ArgumentNullException("resolver"); } _resolver = resolver; EventEnrichmentManager.AddDefaultEnrichments(this); }