private void InitFileLogHelperFromUI(LogFileHelper logFileHelper) { string pathSelectField; List <string> pathGroupByFields; GetPathFields(out pathSelectField, out pathGroupByFields); foreach (var pgbf in pathGroupByFields) { logFileHelper.PathFields.Add(pgbf); } logFileHelper.PathFields.Add(pathSelectField); for (var i = 1; i <= 10; i++) { var fieldComboBox = groupBoxColors.Controls.Find("comboBoxEventField" + i, false)[0] as ComboBox; if (fieldComboBox == null || fieldComboBox.SelectedIndex < 1) { continue; } var valueTextBox = groupBoxColors.Controls.Find("textBoxEventValue" + i, false)[0] as TextBox; if (valueTextBox == null || valueTextBox.Text == "") { continue; } var colorLabel = groupBoxColors.Controls.Find("label1EventColor" + i, false)[0] as Label; if (colorLabel == null) { continue; } var fieldValue = fieldComboBox.SelectedItem + "|" + valueTextBox.Text; logFileHelper.OrderedFieldsValuesForColoring.Add(fieldValue); logFileHelper.MapFieldValueToColor.Add(fieldValue, colorLabel.BackColor.R.ToString("X2") + colorLabel.BackColor.G.ToString("X2") + colorLabel.BackColor.B.ToString("X2")); } }
private void backgroundWorkerCreateLogFile_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { try { AlmHelper.GetEntetiesAfterFilterApplied(comboBoxFilter.SelectedItem.ToString()); } catch (Exception ex) { Text = ex.Message; } int entityCount = AlmHelper.FilteredEntities.Count; if (entityCount == 0) { return; } var logFileHelper = new LogFileHelper(); InitFileLogHelperFromUI(logFileHelper); var counter = 0; var percentReported = -1; foreach (IBaseEntity entity in AlmHelper.FilteredEntities) { if (backgroundWorkerCreateLogFile.CancellationPending) { progressBar1.Value = 0; return; } try { logFileHelper.HandleOneEntity(entity); } catch (Exception) { } counter++; var percent = (int)Math.Ceiling(100.0 * counter / entityCount); if (percent != percentReported) { backgroundWorkerCreateLogFile.ReportProgress(percent); percentReported = percent; } } logFileHelper.SortLogFileEntries(); logFileHelper.SaveEntriesToLogFile(textBoxLogFile.Text); }