Esempio n. 1
0
 public RegexColumnizerConfigDlg(RegexColumnizerConfig config)
 {
     this.config = config;
     this.InitializeComponent();
     this.regexText.Text            = this.config.Regex.ToString();
     this.localTimeCheckBox.Checked = this.config.LocalTimestamps;
     this.timestampField            = this.config.TimestampField;
     this.formatComboBox.Text       = this.config.TimestampFormat;
     this.defaultMessageField       = this.config.DefaultMessageField;
 }
Esempio n. 2
0
        internal void Apply(RegexColumnizerConfig configuration)
        {
            configuration.Regex               = new Regex(this.regexText.Text, RegexOptions.IgnoreCase);
            configuration.LocalTimestamps     = this.localTimeCheckBox.Checked;
            configuration.TimestampField      = this.timestampField;
            configuration.TimestampFormat     = this.formatComboBox.Text;
            configuration.DefaultMessageField = this.defaultMessageField;

            var selectedFields = new string[this.listView1.CheckedItems.Count];

            for (var i = 0; i < selectedFields.Length; i++)
            {
                selectedFields[i] = this.listView1.CheckedItems[i].Text;
            }

            configuration.SelectedFields = selectedFields;
        }
Esempio n. 3
0
        public void Selected(ILogLineColumnizerCallback callback)
        {
            var fileInfo = new FileInfo(callback.GetFileName());

            this.name = BitConverter.ToString(new MD5CryptoServiceProvider()
                                              .ComputeHash(Encoding.Unicode.GetBytes(fileInfo.FullName)))
                        .Replace("-", "")
                        .ToLower();

            var configPath = this.ConfigDir + @"\Regexcolumnizer-" + this.name + "." + ".dat";

            if (!File.Exists(configPath))
            {
                this.config = new RegexColumnizerConfig();
            }
            else
            {
                using (var fs = File.OpenRead(configPath))
                {
                    try
                    {
                        var formatter = new BinaryFormatter();

                        var configuration = (RegexColumnizerConfig)formatter.Deserialize(fs);

                        if (configuration.IsValid())
                        {
                            this.config = configuration;
                        }
                    }
                    catch (SerializationException e)
                    {
                        MessageBox.Show(e.Message, "Deserialize");
                        this.config = new RegexColumnizerConfig();
                    }
                }
            }
        }