public void OnPost() { var payees = payeeRepository.GetAll(); var input = new StringBuilder(); using (var reader = new StreamReader(FormFile.OpenReadStream(), Encoding.GetEncoding("ISO-8859-1"))) { while (reader.Peek() >= 0) { input.AppendLine(reader.ReadLine()); } } var inputRecords = MyConverter.GetInputRecords(input.ToString()); var outputRecords = new List <Output>(); foreach (var record in inputRecords) { outputRecords.Add(MyConverter.Convert(record, payees)); } InputRecords.AddRange(inputRecords); OutputRecords.AddRange(outputRecords); Output = MyConverter.GetOutputString(outputRecords); }
protected override StageResult Read() { if (!Success(base.Read(), out StageResult r)) { return(r); } RecordsToAnnotate = InputRecords.Where(record => record.Labels == null || record.Labels.Count == 0 || record.Labels.Any(l => l.Item2 == 0f)).ToList(); Labels = InputRecords.Where(record => record.Labels != null && record.Labels.Count > 0 && record.Labels.Any(l => l.Item2 > 0))? .SelectMany(record => record.Labels) .ToList(); if (Labels == null || Labels.Count == 0) { Error("Did not read any labels from {0} records", InputRecords.Count); return(StageResult.FAILED); } else { Info("Read {0} labels from {1} records", Labels.Count, InputRecords.Count); return(StageResult.SUCCESS); } }