public override void OnException(ExceptionContext filterContext)
        {
            var message = new Message();
            message.AttachExceptionContext(filterContext);
            message.Send();

            base.OnException(filterContext);
        }
예제 #2
0
 public void PostToSlack()
 {
     try
     {
         string test = null;
         // We are doing this to get a stacktrace.
         // No beauty but you get it right?
         var len = test.Length;
     }
     catch (Exception e)
     {
         var message = new Message("I think something is wrong.", "#exceptions");
         message.AttachException(new NotSupportedException("I FAILED YOU MASTER",e));
         message.Send();
     }
 }
예제 #3
0
        public void Handle(IncomingMessage message)
        {
            var verb = message.Text.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries)[0];

            var msg = new Message(null, message.ChannelName);

            switch (verb.ToLower())
            {
                case "start":
                    _timers.AddOrUpdate(message.UserId, (uid) =>
                    {
                        var newWatch = new Stopwatch();
                        newWatch.Start();
                        msg.Text = string.Format("Started new timer for @{0}.", message.UserName);
                        return newWatch;
                    }, (uid, watch) =>
                    {
                        watch.Stop();
                        var newWatch = new Stopwatch();
                        newWatch.Start();
                        msg.Text = string.Format("Stopped at {0} and started new timer for @{1}.",watch.Elapsed.ToString("g"),message.UserName);
                        return newWatch;
                    });
                    break;
                case "stop":
                    Stopwatch currentWatch = null;
                    if (_timers.TryGetValue(message.UserId, out currentWatch))
                    {
                        currentWatch.Stop();
                        msg.Text = string.Format("Timer stopped at {0} for @{1}.", currentWatch.Elapsed.ToString("g"), message.UserName);
                    }
                    break;
                default:
                    msg = null;
                    break;
            }

            if(msg != null)
                msg.Send();
        }