public static EventBuilder CreateFromLogEvent(this ExceptionlessClient client, LogEventInfo ev) {
            var contextData = new ContextData(ev.GetContextData());

            if (ev.Exception != null)
                contextData.SetException(ev.Exception);

            var builder = client.CreateEvent(contextData);
            if (ev.Exception == null) {
                builder.SetSource(ev.LoggerName);
                builder.SetProperty(Event.KnownDataKeys.Level, ev.Level.Name);
            }

            builder.Target.Date = ev.TimeStamp;

            if (!String.IsNullOrWhiteSpace(ev.FormattedMessage))
                builder.SetMessage(ev.FormattedMessage);

            if (ev.Exception != null)
                builder.SetSource(ev.LoggerName);

            var tagList = ev.GetTags();
            if (tagList.Count > 0)
                builder.AddTags(tagList.ToArray());

            foreach (var p in ev.Properties.Where(kvp => !_ignoredEventProperties.Contains(kvp.Key.ToString(), StringComparer.OrdinalIgnoreCase)))
                builder.SetProperty(p.Key.ToString(), p.Value);

            return builder;
        }
        public static EventBuilder CreateFromLogEvent(this ExceptionlessClient client, LogEventInfo ev) {
            if (client == null)
                throw new ArgumentNullException(nameof(client));

            var contextData = new ContextData(ev.GetContextData());

            if (ev.Exception != null)
                contextData.SetException(ev.Exception);

            var builder = client.CreateEvent(contextData);
            builder.Target.Date = ev.TimeStamp;
            builder.SetSource(ev.LoggerName);

            var properties = ev.Properties
                .Where(kvp => !_ignoredEventProperties.Contains(kvp.Key.ToString(), StringComparer.OrdinalIgnoreCase))
                .ToDictionary(kvp => kvp.Key.ToString(), kvp => kvp.Value, StringComparer.OrdinalIgnoreCase);

            object value;
            if (properties.TryGetValue("@value", out value)) {
                try {
                    builder.SetValue(Convert.ToDecimal(value));
                    properties.Remove("@value");
                } catch (Exception) {}
            }

            object stackingKey;
            if (properties.TryGetValue(Event.KnownDataKeys.ManualStackingInfo, out stackingKey)) {
                try {
                    builder.SetManualStackingKey(stackingKey.ToString());
                    properties.Remove(Event.KnownDataKeys.ManualStackingInfo);
                } catch (Exception) { }
            }
            
            if (ev.Exception == null)
                builder.SetProperty(Event.KnownDataKeys.Level, ev.Level.Name);
            
            if (!String.IsNullOrWhiteSpace(ev.FormattedMessage))
                builder.SetMessage(ev.FormattedMessage);
            
            var tagList = ev.GetTags();
            if (tagList.Count > 0)
                builder.AddTags(tagList.ToArray());

            foreach (var p in properties)
                builder.SetProperty(p.Key, p.Value);

            return builder;
        }
 /// <summary>
 /// Submits a resource not found event.
 /// </summary>
 /// <param name="client">The client instance.</param>
 /// <param name="resource">The name of the resource that was not found.</param>
 public static void SubmitNotFound(this ExceptionlessClient client, string resource) {
     client.CreateEvent().SetType(Event.KnownTypes.NotFound).SetSource(resource).Submit();
 }
 /// <summary>
 /// Creates a feature usage event.
 /// </summary>
 /// <param name="client">The client instance.</param>
 /// <param name="feature">The name of the feature that was used.</param>
 public static EventBuilder CreateFeatureUsage(this ExceptionlessClient client, string feature) {
     return client.CreateEvent().SetType(Event.KnownTypes.FeatureUsage).SetSource(feature);
 }
 /// <summary>
 /// Submits a feature usage event.
 /// </summary>
 /// <param name="client">The client instance.</param>
 /// <param name="feature">The name of the feature that was used.</param>
 public static void SubmitFeatureUsage(this ExceptionlessClient client, string feature) {
     client.CreateEvent().SetType(Event.KnownTypes.FeatureUsage).SetSource(feature).Submit();
 }
 /// <summary>
 /// Creates a log message event.
 /// </summary>
 /// <param name="client">The client instance.</param>
 /// <param name="source">The log source.</param>
 /// <param name="message">The log message.</param>
 public static EventBuilder CreateLog(this ExceptionlessClient client, string source, string message) {
     return client.CreateEvent().SetType(Event.KnownTypes.Log).SetSource(source).SetMessage(message);
 }
 /// <summary>
 /// Submits a log message event.
 /// </summary>
 /// <param name="client">The client instance.</param>
 /// <param name="source">The log source.</param>
 /// <param name="message">The log message.</param>
 public static void SubmitLog(this ExceptionlessClient client, string source, string message) {
     client.CreateEvent().SetType(Event.KnownTypes.Log).SetSource(source).SetMessage(message).Submit();
 }
 /// <summary>
 /// Creates a session end event.
 /// </summary>
 /// <param name="client">The client instance.</param>
 /// <param name="sessionId">The session id.</param>
 public static EventBuilder CreateSessionEnd(this ExceptionlessClient client, string sessionId) {
     return client.CreateEvent().SetType(Event.KnownTypes.SessionEnd).SetSessionId(sessionId);
 }
 /// <summary>
 /// Submits a session end event.
 /// </summary>
 /// <param name="client">The client instance.</param>
 /// <param name="sessionId">The session id.</param>
 public static void SubmitSessionEnd(this ExceptionlessClient client, string sessionId) {
     client.CreateEvent().SetType(Event.KnownTypes.SessionEnd).SetSessionId(sessionId).Submit();
 }
Esempio n. 10
0
 /// <summary>
 /// Creates a resource not found event.
 /// </summary>
 /// <param name="client">The client instance.</param>
 /// <param name="resource">The name of the resource that was not found.</param>
 public static EventBuilder CreateNotFound(this ExceptionlessClient client, string resource) {
     return client.CreateEvent().SetType(Event.KnownTypes.NotFound).SetSource(resource);
 }
        /// <summary>
        /// Create event for page.
        /// </summary>
        /// <param name="facebook">
        /// The facebook.
        /// </param>
        /// <param name="pageId">
        /// The page id.
        /// </param>
        /// <param name="event">
        /// The event.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <returns>
        /// Page ID of the newly created event.
        /// </returns>
        /// <remarks>
        /// The access token must be of user not of page.
        /// </remarks>
        public static string CreateEventForPage(this Facebook facebook, string pageId, Event @event, IDictionary<string, string> parameters)
        {
            IDictionary<string, string> pars = parameters != null
                                                   ? new Dictionary<string, string>(parameters)
                                                   : new Dictionary<string, string>();

            pars.Add("page_id", pageId);

            return facebook.CreateEvent(@event, pars);
        }
        /// <summary>
        /// Creates a session start event.
        /// </summary>
        /// <param name="client">The client instance.</param>
        public static EventBuilder CreateSessionStart(this ExceptionlessClient client) {
            if (client == null)
                throw new ArgumentNullException(nameof(client));

            return client.CreateEvent().SetType(Event.KnownTypes.Session);
        }
        /// <summary>
        /// Creates a resource not found event.
        /// </summary>
        /// <param name="client">The client instance.</param>
        /// <param name="resource">The name of the resource that was not found.</param>
        public static EventBuilder CreateNotFound(this ExceptionlessClient client, string resource) {
            if (client == null)
                throw new ArgumentNullException(nameof(client));

            return client.CreateEvent().SetType(Event.KnownTypes.NotFound).SetSource(resource);
        }
        /// <summary>
        /// Creates a feature usage event.
        /// </summary>
        /// <param name="client">The client instance.</param>
        /// <param name="feature">The name of the feature that was used.</param>
        public static EventBuilder CreateFeatureUsage(this ExceptionlessClient client, string feature) {
            if (client == null)
                throw new ArgumentNullException(nameof(client));

            return client.CreateEvent().SetType(Event.KnownTypes.FeatureUsage).SetSource(feature);
        }
        /// <summary>
        /// Creates a log message event.
        /// </summary>
        /// <param name="client">The client instance.</param>
        /// <param name="message">The log message.</param>
        public static EventBuilder CreateLog(this ExceptionlessClient client, string message) {
            if (client == null)
                throw new ArgumentNullException(nameof(client));

            return client.CreateEvent().SetType(Event.KnownTypes.Log).SetMessage(message);
        }
 /// <summary>
 /// Creates a session heartbeat event.
 /// </summary>
 /// <param name="client">The client instance.</param>
 public static EventBuilder CreateSessionHeartbeat(this ExceptionlessClient client) {
     return client.CreateEvent().SetType(Event.KnownTypes.SessionHeartbeat);
 }