コード例 #1
0
        public DataModel CreateExceptionNotice(Exception ex, string message = null, string level = "error", IDictionary<string, string> requestSession = null, PersonModel person = null)
        {
            var body = BodyModelBuilder.CreateExceptionBody(ex);
            var model = Create(level, body, requestSession, person);

            //merge exception data dictionaries to list of keyValues pairs
            var keyValuePairs = body.TraceChain.Where(tm => tm.Exception.Data != null).SelectMany(tm => tm.Exception.Data);

            foreach (var keyValue in keyValuePairs)
            {
                //the keys in keyValuePairs aren't necessarily unique, so don't add but overwrite
                model.Custom[keyValue.Key.ToString()] = keyValue.Value;
            }

            model.Title = message;

            return model;
        }
コード例 #2
0
 /// <summary>
 /// Sends a text notice using the "warning" level
 /// </summary>
 /// <param name="message"></param>
 /// <param name="customData"></param>
 /// <param name="modelAction"></param>
 /// <param name="userParam"></param>
 public Task SendWarningMessage(string message, IDictionary<string, object> customData = null, Action<DataModel> modelAction = null, object userParam = null, IDictionary<string, string> requestSession = null, PersonModel person = null)
 {
     return SendMessage(message, "warning", customData, modelAction, userParam, requestSession, person);
 }
コード例 #3
0
 /// <summary>
 /// Sents an exception using the "warning" level
 /// </summary>
 /// <param name="ex"></param>
 /// <param name="title"></param>
 /// <param name="modelAction"></param>
 /// <param name="userParam"></param>
 public Task SendWarningException(Exception ex, string title = null, Action<DataModel> modelAction = null, object userParam = null, IDictionary<string, string> requestSession = null, PersonModel person = null)
 {
     return SendException(ex, title, "warning", modelAction, userParam, requestSession, person);
 }
コード例 #4
0
 /// <summary>
 /// Sents a text notice using the given level of severity
 /// </summary>
 /// <param name="message"></param>
 /// <param name="level"></param>
 /// <param name="customData"></param>
 /// <param name="modelAction"></param>
 /// <param name="userParam"></param>
 public Task SendMessage(string message, string level, IDictionary<string, object> customData = null, Action<DataModel> modelAction = null, object userParam = null, IDictionary<string, string> requestSession = null, PersonModel person = null)
 {
     var notice = NoticeBuilder.CreateMessageNotice(message, level, customData, requestSession, person);
     if (modelAction != null)
     {
         modelAction(notice);
     }
     return Send(notice, userParam);
 }
コード例 #5
0
 /// <summary>
 /// Sends the given <see cref="Exception"/> to Rollbar including
 /// the stack trace. 
 /// </summary>
 /// <param name="ex"></param>
 /// <param name="title"></param>
 /// <param name="level">Default is "error". "critical" and "warning" may also make sense to use.</param>
 /// <param name="modelAction"></param>
 /// <param name="userParam"></param>
 public Task SendException(Exception ex, string title = null, string level = "error", Action<DataModel> modelAction = null, object userParam = null, IDictionary<string, string> requestSession = null, PersonModel person = null)
 {
     var notice = NoticeBuilder.CreateExceptionNotice(ex, title, level, requestSession, person);
     if (modelAction != null)
     {
         modelAction(notice);
     }
     return Send(notice, userParam);
 }
コード例 #6
0
        /// <summary>
        /// Create the best stub of a request that we can using the message level and body
        /// </summary>
        /// <param name="level"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        protected DataModel Create(string level, BodyModel body, IDictionary<string, string> requestSession, PersonModel person)
        {
            var model = new DataModel(level, body);

            model.CodeVersion = Configuration.CodeVersion;
            model.Environment = Configuration.Environment;
            model.Platform = Configuration.Platform;
            model.Language = Configuration.Language;
            model.Framework = Configuration.Framework;

            model.Timestamp = (ulong)Now();

            model.Notifier = NotifierModelBuilder.CreateFromAssemblyInfo();

            var currentHttpRequest = GetCurrentHttpRequest();

            if (currentHttpRequest == null)
            {
                model.Request = new RequestModel();
                model.Server = new ServerModel();
                model.Person = new PersonModel();
            }
            else
            {
                model.Request = RequestModelBuilder.CreateFromHttpRequest(currentHttpRequest, HttpContext.Current.Session, Configuration.ScrubParams);
                model.Server = ServerModelBuilder.CreateFromHttpRequest(currentHttpRequest);
                model.Person = PersonModelBuilder.CreateFromHttpRequest(currentHttpRequest);
            }

            if (requestSession != null)
            {
                foreach(var key in requestSession.Keys)
                {
                    model.Request.Session[key] = requestSession[key];
                }
            }

            if (person != null)
            {
                model.Person.Email = person.Email ?? model.Person.Email;
                model.Person.Id = person.Id ?? model.Person.Id;
                model.Person.Username = person.Username ?? model.Person.Username;
            }

            model.Server.GitSha = Configuration.GitSha;

            return model;
        }
コード例 #7
0
 public DataModel CreateMessageNotice(string message, string level = "info", IDictionary<string, object> customData = null, IDictionary<string, string> requestSession = null, PersonModel person = null)
 {
     return Create(level, BodyModelBuilder.CreateMessageBody(message, customData), requestSession, person);
 }