Exemplo n.º 1
0
        static void FileChanged(object sender, Tail.TailEventArgs e)
        {
            if (e == null)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(e.Line))
            {
                return;
            }

            var wc = new WebClient();

            string line = e.Line.Trim();

            var oldCol = Console.ForegroundColor;

            try
            {
                Console.WriteLine(e.Line);
                wc.UploadString(url, new SlackObj(e.Line).ToString());
            }
            catch (WebException ex)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write("WebException: ");
                try
                {
                    var resp = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
                    Console.WriteLine(resp);
                }
                catch (Exception)
                {
                    Console.WriteLine("Failed to get exception body");
                }
                Console.ForegroundColor = oldCol;
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write("Exception: ");
                if (Environment.GetCommandLineArgs().Any(a => a == "--debug"))
                {
                    Console.WriteLine(ex);
                }
                else
                {
                    Console.WriteLine(ex.GetBaseException().Message);
                }
                Console.ForegroundColor = oldCol;
            }
        }
 private async void Tail_Changed(object sender, Tail.TailEventArgs e)
 {
     await Task.Run(() =>
     {
         bool scrollToBottom = false;
         if (scrollViewer.VerticalOffset == scrollViewer.ScrollableHeight)
         {
             scrollToBottom = true;
         }
         syncCtx.Post(new SendOrPostCallback(o =>
         {
             textBlock.Text += (string)o;
             if (scrollToBottom)
             {
                 scrollViewer.ScrollToBottom();
             }
         }),
                      e.Line);
     });
 }
Exemplo n.º 3
0
 private void Tail_Changed(object sender, Tail.TailEventArgs e)
 {
     LogText     += e.Line;
     ScrollOffset = new Vector(0, LogText.Length);
 }
Exemplo n.º 4
0
 private void Tail_Changed(object sender, Tail.TailEventArgs e)
 {
     Progress?.Invoke(this, e.Line);
 }