protected override void FillItems() { try { foreach (string file in SourceFiles) { using (var streamReader = new StreamReader(file)) { List <string> fileHeaders = streamReader.ReadLine().Split(Separator).ToList(); // Contiene el header(key) y la posicion(value) en el archivo original, que seran incluidos en el reporte. Dictionary <string, int> headers = GetHeadersIndexes(_reportConfiguration.ReportFields, fileHeaders, out int processedIndex, out int resultIndex); if (processedIndex == -1 || resultIndex == -1) { continue; } while (!streamReader.EndOfStream) { string[] lineArray = streamReader.ReadLine().Split(Separator); if (lineArray.Length <= resultIndex || lineArray[processedIndex] != Constants.PROCESS_RESULT_OK) { continue; } var item = new ReportItem(); foreach (string key in headers.Keys) { //index in original file. int value = headers[key]; //index in report int index = value; ReportFieldConfiguration field = _reportConfiguration.ReportFields.FirstOrDefault(x => x.NameInFile == key); if (field != null) { index = field.Position; } item.AddValue(lineArray[value].Trim(), index); } item.ResultId = lineArray[resultIndex]; _items.Add(item); } } } GetDataFromDB(_items, _dateFormat); } catch (Exception) { _logger.Error("Error trying to get report items"); throw; } }
public ReportFieldConfiguration Clone() { var reportFieldConfiguration = new ReportFieldConfiguration(); reportFieldConfiguration.HeaderName = this.HeaderName; reportFieldConfiguration.Position = this.Position; reportFieldConfiguration.NameInFile = this.NameInFile; reportFieldConfiguration.NameInDB = this.NameInDB; return(reportFieldConfiguration); }