static void Main(string[] args) { var parametersValidator = new ParametersValidator(); var parametersAreValid = parametersValidator.Validate(args); if (parametersAreValid) { string nameOfFile; var parameters = CommandLineParser.Parse(args); if (parameters.TryGetValue("nameoffile", out nameOfFile)) { string analyzerType, startDate, finishDate; parameters.TryGetValue("analyzer", out analyzerType); parameters.TryGetValue("startdate", out startDate); parameters.TryGetValue("finishdate", out finishDate); var logReader = new LogFileReader(); var records = logReader.GiveAllRecordsInFile(nameOfFile); var dateFilter = new DateFilter { Records = records }; records = dateFilter.Filtrate(startDate, finishDate); var analyzerByType = new FileAnalyzer { Records = records }; Console.WriteLine(analyzerByType.AnalyzeByType(analyzerType)); } else { Console.WriteLine("Входные параметры не соответствуют шаблону."); } } else Console.WriteLine(parametersValidator.ValidationInformation); Console.ReadKey(); }
private void GetReportButton_Click_1(object sender, EventArgs e) { if (AllRecords == null) MessageBox.Show(@"File not found."); else { TempAnalyzer = new FileAnalyzer { Records = Records }; if (IpRadioButton.Checked) { ReportBox.Text = TempAnalyzer.AnalyzeByType("analyzerbyip"); } if (WeightsRadioButton.Checked) { ParametersForm = new Form { Size = new Size(new Point(200, 200)) }; ParametersForm.Show(); ParametersForm.Text = @"Parameters for WeightsAnalyzer"; MethodsRadioButton = new RadioButton{Location = new Point(10, 15), Text = @"Methods" }; ExtensionsRadioButton = new RadioButton { Location = new Point(10, 40), Text = @"Extensions"}; ServerResponseCodesRadioButton = new RadioButton { Location = new Point(10, 65), Text = @"Codes"}; var groupBox = new GroupBox {Text = @"Type ofWeightsReport", Size = new Size(new Point(150, 90)), Location = new Point(10,10)}; var applyButton3 = new Button { Text = @"Apply", Width = 60, Location = new Point(10, 125)}; var applyHandler = new EventHandler(applyButton3_Click); applyButton3.Click += applyHandler; groupBox.Controls.AddRange(new Control[]{MethodsRadioButton, ExtensionsRadioButton, ServerResponseCodesRadioButton}); ParametersForm.Controls.AddRange(new Control[]{groupBox, applyButton3}); } if (SumOfBytesRadioButton.Checked) { ReportBox.Text = TempAnalyzer.AnalyzeByType("analyzerbysumofbytes"); } } }