예제 #1
0
        public void DecideColumnizerByName_WhenReaderIsNotReady_ReturnCorrectColumnizer(
            string fileName, Type columnizerType)
        {
            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName);

            // TODO: When DI container is ready, we can mock this set up.
            PluginRegistry.GetInstance().RegisteredColumnizers.Add(new JsonCompactColumnizer());
            var result = ColumnizerPicker.DecideColumnizerByName(fileName,
                                                                 PluginRegistry.GetInstance().RegisteredColumnizers);

            Assert.AreEqual(result.GetType(), columnizerType);
        }
예제 #2
0
        private void FillColumnizerList()
        {
            columnizerDataGridView.Rows.Clear();

            DataGridViewComboBoxColumn
                comboColumn = (DataGridViewComboBoxColumn)columnizerDataGridView.Columns[1];

            comboColumn.Items.Clear();

            DataGridViewTextBoxColumn textColumn = (DataGridViewTextBoxColumn)columnizerDataGridView.Columns[0];

            IList <ILogLineColumnizer> columnizers = PluginRegistry.GetInstance().RegisteredColumnizers;

            foreach (ILogLineColumnizer columnizer in columnizers)
            {
                int index = comboColumn.Items.Add(columnizer.GetName());
            }
            //comboColumn.DisplayMember = "Name";
            //comboColumn.ValueMember = "Columnizer";

            foreach (ColumnizerMaskEntry maskEntry in Preferences.columnizerMaskList)
            {
                DataGridViewRow row = new DataGridViewRow();
                row.Cells.Add(new DataGridViewTextBoxCell());
                DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell();

                foreach (ILogLineColumnizer logColumnizer in columnizers)
                {
                    int index = cell.Items.Add(logColumnizer.GetName());
                }

                row.Cells.Add(cell);
                row.Cells[0].Value = maskEntry.mask;
                ILogLineColumnizer columnizer = ColumnizerPicker.DecideColumnizerByName(maskEntry.columnizerName,
                                                                                        PluginRegistry.GetInstance().RegisteredColumnizers);

                row.Cells[1].Value = columnizer.GetName();
                columnizerDataGridView.Rows.Add(row);
            }

            int count = columnizerDataGridView.RowCount;

            if (count > 0 && !columnizerDataGridView.Rows[count - 1].IsNewRow)
            {
                DataGridViewComboBoxCell comboCell = (DataGridViewComboBoxCell)columnizerDataGridView.Rows[count - 1].Cells[1];
                comboCell.Value = comboCell.Items[0];
            }
        }
예제 #3
0
        private void StartTool(string cmd, string args, bool sysoutPipe, string columnizerName, string workingDir)
        {
            if (string.IsNullOrEmpty(cmd))
            {
                return;
            }

            Process          process   = new Process();
            ProcessStartInfo startInfo = new ProcessStartInfo(cmd, args);

            if (!Util.IsNull(workingDir))
            {
                startInfo.WorkingDirectory = workingDir;
            }

            process.StartInfo           = startInfo;
            process.EnableRaisingEvents = true;

            if (sysoutPipe)
            {
                ILogLineColumnizer columnizer = ColumnizerPicker.DecideColumnizerByName(columnizerName,
                                                                                        PluginRegistry.GetInstance().RegisteredColumnizers);

                _logger.Info("Starting external tool with sysout redirection: {0} {1}", cmd, args);
                startInfo.UseShellExecute        = false;
                startInfo.RedirectStandardOutput = true;
                //process.OutputDataReceived += pipe.DataReceivedEventHandler;
                try
                {
                    process.Start();
                }
                catch (Win32Exception e)
                {
                    _logger.Error(e);
                    MessageBox.Show(e.Message);
                    return;
                }

                SysoutPipe pipe   = new SysoutPipe(process.StandardOutput);
                LogWindow  logWin = AddTempFileTab(pipe.FileName,
                                                   CurrentLogWindow.IsTempFile
                        ? CurrentLogWindow.TempTitleName
                        : Util.GetNameFromPath(CurrentLogWindow.FileName) + "->E");
                logWin.ForceColumnizer(columnizer);
                process.Exited += pipe.ProcessExitedEventHandler;
                //process.BeginOutputReadLine();
            }
            else
            {
                _logger.Info("Starting external tool: {0} {1}", cmd, args);
                try
                {
                    startInfo.UseShellExecute = false;
                    process.Start();
                }
                catch (Exception e)
                {
                    _logger.Error(e);
                    MessageBox.Show(e.Message);
                }
            }
        }