private void LoopRoutine() { Task.Run(() => { while (true) { Task.Delay(10000); if (File.Exists(PathFileProblemas)) { List <ProblemaDTO> problemas = File.ReadAllLines(PathFileProblemas) .Select(v => ProblemaDTO.FromCsv(v)) .ToList(); var problemasIntegrationEvents = problemas.Select(x => new ProblemaIntegrationEvent() { IdInceptions = x.IdInceptions, Abreviacao = x.Abreviacao, Descricao = x.Descricao }).ToList(); //Publish a messages problemasIntegrationEvents.ForEach(integrationEvent.Handle); File.Delete(PathFileProblemas); } } }); }
public static ProblemaDTO FromCsv(string csvLine) { string[] values = csvLine.Split(';'); ProblemaDTO problemas = new ProblemaDTO(); problemas.IdInceptions = long.Parse(values[0]); problemas.Abreviacao = values[1]; problemas.Descricao = values[2]; return(problemas); }