public void UpdateTimes(List <BusLine> times) { if (this.Lines.SafeCount() > 0) { times.SafeForEach(time => { BusLine line = this.Lines.Where(l => l.Stop == time.Stop && l.Line == time.Line).FirstOrDefault(); line.Seconds = time.Seconds; }); } }
public static TimeTable ReadCSV(string cat, string root_url) { TimeTable ret = new TimeTable(); ret.Category = cat.Safe(); WebClient client = new WebClient(); string url = $"{root_url}/csv/buses.csv"; //string url = "http://busmon.westeurope.cloudapp.azure.com/csv/buses.csv"; Stream stream = client.OpenRead(url); StreamReader reader = new StreamReader(stream); String content = reader.ReadToEnd(); ret.Lines = new List <BusLine>(); content.SafeSplit(Environment.NewLine).SafeForEach((line, idx) => { // # es comentario if (!line.TrimStart().StartsWith("#")) { string category = line.SafeSplit("|").SafeIndexer(0); if (category.SameText(cat)) { BusLine bl = new BusLine() { Stop = line.SafeSplit("|").SafeIndexer(1), Line = line.SafeSplit("|").SafeIndexer(2), Desc = line.SafeSplit("|").SafeIndexer(3).RemoveDiacritics() }; ret.Lines.Add(bl); } } }); //var fileContents = System.IO.File.ReadAllText( .MapPath(@"~/csv/buses.csv")); return(ret); }