private void BuildYears( List <string> values, string[] names, List <YearAndDataLengthModel> yearAndDataLengthModels) { for (int i = 2016; i < 2020; i++) { YearAndDataLengthModel yearAndDataLengthModel = yearAndDataLengthModels.SingleOrDefault(x => x.Year == i); if (yearAndDataLengthModel == null) { continue; } int counter = 0; foreach (string name in names) { if (counter > yearAndDataLengthModel.DataLength) { break; } if (!name.Contains("{SP}")) { return; } values.Add(name.Replace("{SP}", (i - 1).ToString()).Replace("{SY}", i.ToString().Substring(2))); counter++; } } }
private void BuildTotals( int endYear, List <string> values, string[] names, List <YearAndDataLengthModel> yearAndDataLengthModels) { if (names.Length < 7) { return; } for (int i = ReportingConstants.StartYear; i <= endYear; i++) { YearAndDataLengthModel yearAndDataLengthModel = yearAndDataLengthModels.SingleOrDefault(x => x.Year == i); if (yearAndDataLengthModel == null) { continue; } var year = i == ReportingConstants.StartYear ? i + 1 : i; var startMonthIndex = i == ReportingConstants.StartYear ? 8 : 0; var length = 12 - startMonthIndex; var yearlyNames = new string[length]; Array.Copy(names, startMonthIndex, yearlyNames, 0, length); int counter = 0; foreach (string name in yearlyNames) { if (counter > yearAndDataLengthModel.DataLength) { break; } if (!name.Contains("{Y}")) { return; } if (i != 2015 && counter == 5) { year++; } values.Add(name.Replace("{Y}", year.ToString())); counter++; } } }