public string ConvertToString(JournalRecord item) { IConverter<string> converterIp=new ConverterIp(); IConverter<string> converterDate=new ConverterDate(); var result = string.Format( "{0} - - [{1}] {2} {3}://{4}{5} {6} {7}", converterIp.Convert(new ConverterParametersIp{Ip=item.Ip}), converterDate.Convert(new ConverterParametersDate{DateTime = item.Date}),item.Method, item.Protocol, item.FileName, item.FileExtension,item.StatusCode, item.NumberOfBytes); return result; }
private void button1_Click(object sender, EventArgs e) { var result = openFileDialog1.ShowDialog(); var filePath = string.Empty; richTextBox1.ResetText(); if (result == DialogResult.OK) { filePath = openFileDialog1.FileName; } _logReader = new LogReader(filePath); var converterIp = new ConverterIp(); var converterDate = new ConverterDate(); dataGridView1.RowCount = _logReader.EventList.Count(); for (var i = 0; i < _logReader.EventList.Count(); i++) { dataGridView1[0, i].Value = converterIp.Convert(new ConverterParametersIp { Ip = _logReader.EventList.ElementAt(i).Ip }); dataGridView1[1, i].Value = "-"; dataGridView1[2, i].Value = converterDate.Convert(new ConverterParametersDate { DateTime = _logReader.EventList.ElementAt(i).Date }); dataGridView1[3, i].Value = _logReader.EventList.ElementAt(i).Method; dataGridView1[4, i].Value = _logReader.EventList.ElementAt(i).Protocol; dataGridView1[5, i].Value = _logReader.EventList.ElementAt(i).FileName; dataGridView1[6, i].Value = _logReader.EventList.ElementAt(i).FileExtension; dataGridView1[7, i].Value = _logReader.EventList.ElementAt(i).StatusCode; dataGridView1[8, i].Value = _logReader.EventList.ElementAt(i).NumberOfBytes; } startDate.Text = @"2009-12-29T12:54:59"; endDate.Text = @"2009-12-29T12:54:59"; }