public async Task GetBikeTheftsAsync() { var assembly = typeof(BikeTheftViewModel).GetTypeInfo().Assembly; Stream stream = assembly.GetManifestResourceStream("Project4Bicycle.Data.b59c159338.csv"); var reader = new StreamReader(stream); BikeTheftFactory factory = new BikeTheftFactory(reader); BikeTheft bikeTheft; while (factory.HasNext()) { bikeTheft = factory.GetCurrent(); brandsHash.Add(bikeTheft.Brand); colorsHash.Add(bikeTheft.Color); neighbourhoodHash.Add(bikeTheft.Neighbourhood); BikeThefts.Add(bikeTheft); } foreach (var color in colorsHash) { colors.Add(color); } foreach (var brand in brandsHash) { brands.Add(brand); } foreach (var neighbourhood in neighbourhoodHash) { neighbourhoods.Add(neighbourhood); } }
public async void GenerateGraph4() { List <BikeTheft> theftContainer = new List <BikeTheft>(); List <int> theftsOverYear = new List <int>(); List <string> theftsMonths = new List <string>(); var assembly = typeof(BikeTheftViewModel).Assembly; Stream stream = assembly.GetManifestResourceStream("Project4Bicycle.Data.b59c159338.csv"); var reader = new StreamReader(stream); Project4Bicycle.BikeTheftFactory factory = new Project4Bicycle.BikeTheftFactory(reader); BikeTheft bikeTheft; while (factory.HasNext()) { bikeTheft = factory.GetCurrent(); theftContainer.Add(bikeTheft); } theftContainer = theftContainer.Where(theft => theft.Object == "FIETS").Where(theft => theft.City == "ROTTERDAM").ToList(); int max2004 = theftContainer.Where(theft => theft.Year == 2004).Count(); int max2005 = theftContainer.Where(theft => theft.Year == 2005).Count(); int max2006 = theftContainer.Where(theft => theft.Year == 2006).Count(); int max2007 = theftContainer.Where(theft => theft.Year == 2007).Count(); int max2008 = theftContainer.Where(theft => theft.Year == 2008).Count(); int max2009 = theftContainer.Where(theft => theft.Year == 2009).Count(); int max2010 = theftContainer.Where(theft => theft.Year == 2010).Count(); int max2011 = theftContainer.Where(theft => theft.Year == 2011).Count(); int max2012 = theftContainer.Where(theft => theft.Year == 2012).Count(); int max2013 = theftContainer.Where(theft => theft.Year == 2013).Count(); theftsOverYear.Add(max2004); theftsOverYear.Add(max2005); theftsOverYear.Add(max2006); theftsOverYear.Add(max2007); theftsOverYear.Add(max2008); theftsOverYear.Add(max2009); theftsOverYear.Add(max2010); theftsOverYear.Add(max2011); theftsOverYear.Add(max2012); theftsOverYear.Add(max2013); theftsMonths.Add("2004"); theftsMonths.Add("2005"); theftsMonths.Add("2006"); theftsMonths.Add("2007"); theftsMonths.Add("2008"); theftsMonths.Add("2009"); theftsMonths.Add("2010"); theftsMonths.Add("2011"); theftsMonths.Add("2012"); theftsMonths.Add("2013"); chart3.Series[0].Points.DataBindXY(theftsMonths, theftsOverYear); chart3.Series[0].Name = "Bike Thefts"; }
private async Task GetStolenBicyclesAsync() { var assembly = typeof(BikeTheftViewModel).GetTypeInfo().Assembly; Stream stream = assembly.GetManifestResourceStream("Project4Bicycle.Data.b59c159338.csv"); var reader = new StreamReader(stream); BikeTheftFactory factory = new BikeTheftFactory(reader); BikeTheft bikeTheft; string incidentNeighboorhood = "Unknown"; string incidentMonth = "Unknown"; incidentMonthList.AddRange(months); while (factory.HasNext()) { bikeTheft = factory.GetCurrent(); incidentNeighboorhood = bikeTheft.Neighbourhood; //Convert the month number to the short name variant (Eg. 01 = Jan) incidentMonth = CultureInfo.InvariantCulture.DateTimeFormat.GetMonthName(bikeTheft.Month); incidentMonth = DateTime.ParseExact(incidentMonth, "MMMM", CultureInfo.InvariantCulture).ToString("MMM"); switch (incidentMonth) { case "mrt": incidentMonth = "mar"; break; case "mei": incidentMonth = "may"; break; case "okt": incidentMonth = "oct"; break; } //Find the corresponding month and add the amount to this month foreach (string month in incidentMonthList) { if (month == UpperFirst(incidentMonth)) { //HighTemperature.Add(new ChartDataPoint(month, randomDiefstallen++)); int index = Array.IndexOf(months, month); monthThefts[index]++; //Add 1 incident to the corresponding month break; } } } }