Example #1
0
 static void Main(string[] args)
 {
     using (CommandLine command = new TailCommandLine(args))
     {
         CommandLineBootstrap.Start(command);
     }
 }
Example #2
0
 static void Main(string[] args)
 {
   using (CommandLine command = new TailCommandLine(args))
   {
     CommandLineBootstrap.Start(command);
   }
 }
Example #3
0
 static void Main(string[] args)
 {
     //args = new string[] { "-f", @"D:\WorkSpace\wj_isfp_rm\WJ.CLIENT.AGENT\bin\Debug\netcoreapp3.1\logs\INFO\2020-12-29.log" };
     args = new string[] { @"D:\数据\Logs\log.2020-12-21" };
     using (CommandLine command = new TailCommandLine(args))
     {
         CommandLineBootstrap.Start(command);
     }
 }
Example #4
0
    private void OnTailButtonClick(object sender, RoutedEventArgs e)
    {
      if (btnTail.Content.ToString() == TailCommand)
      {
        if (string.IsNullOrEmpty(tbFileName.Text))
        {
          MessageBox.Show(this, "Please specify a file for tailing.", this.Title,
            MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);
          return;
        }

        btnTail.Content = CancelCommand;
        tbFileName.IsEnabled = false;
        btnOpenFile.IsEnabled = false;
        tbFileData.Document.Blocks.Clear();

        try
        {
          string[] args = new string[] { 
            @"-F",
            tbFileName.Text
          };

          tail = new TailCommandLine(args);
          tail.CommandLineException += new EventHandler<CommandLineExceptionEventArgs>(OnCommandLineException);
          tail.CommandLineDataChanged += new EventHandler<CommandLineDataChangedEventArgs>(OnCommandLineDataChanged);

          ThreadPool.QueueUserWorkItem((WaitCallback)TailExecuter, tail);
        }
        catch (Exception ex)
        {
          MessageBox.Show(this, ex.Message, this.Title,
            MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
        }
      }
      else
      {
        btnTail.Content = TailCommand;
        tbFileName.IsEnabled = true;
        btnOpenFile.IsEnabled = true;

        try
        {
          if (tail != null)
          {
            tail.CommandLineException -= new EventHandler<CommandLineExceptionEventArgs>(OnCommandLineException);
            tail.CommandLineDataChanged -= new EventHandler<CommandLineDataChangedEventArgs>(OnCommandLineDataChanged);
            tail.Terminate();
            tail.Dispose();
            tail = null;
          }
        }
        catch (Exception ex)
        {
          MessageBox.Show(this, ex.Message, this.Title,
            MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
        }
      }
    }