protected /*private*/ void DoWithShift(Graphes graphByYears, int shift) { var s = shift == 0 ? null : string.Format("_сдвиг_{0}год", shift); var rows = EventtypesByYears.Do(graphByYears, shift); var subname = string.Format( "сводная{0}{1}{2}", graphByYears.TwoAndMoreEventtypes ? "_filter2_" : null, graphByYears.Legends != null ? "Группирована" : null, s); Output( rows, subname, FileOutputType); // Output(rows, "проценты" + s, true, null, true); if (!graphByYears.TwoAndMoreEventtypes && graphByYears.Legends == null) { Output( EventtypesByYears.Do(graphByYears, shift), // 822, 1852), "сводная" + Filter.Length + s, OutputType.Csv, Filter); } }
protected virtual Graphes GroupEventsByYear( ExcelManager man, Dictionary <string, string> legends = null, bool twoAndMoreEventtypes = false) { var result = new Graphes(legends, twoAndMoreEventtypes); foreach (HSSFRow row in man.Records) { var indices = man.GetValue(row, "Индекс"); if (!string.IsNullOrEmpty(indices) && (!twoAndMoreEventtypes || indices.Split(IndicesSeparator).Count(i => !string.IsNullOrEmpty(i)) >= 2)) { if (legends != null) { var indicesFromLegend = new List <string>(); foreach (var index in indices.Split(IndicesSeparator)) { indicesFromLegend.Add(legends.ContainsKey(index) ? legends[index] : index); } indices = indicesFromLegend.Aggregate((a, b) => a + IndicesSeparator + b); } var eventOrYear = twoAndMoreEventtypes ? row.RowNum : int.Parse(man.GetValue(row, "-99000")); result.Add(eventOrYear, indices); } } return(result); }
public void Do_Shift() { var graphByYears = new Graphes(new Dictionary <int, string> { { 1, "a,b" }, { 2, "b" }, { 3, "c,a" } }); var rows = EventtypesByYears.Do(graphByYears, 1); Assert.AreEqual( @"$, a, b, c, a, 0, 1, 0, b, 1, 1, 1, c, 0, 0, 0, ", Outputer.OutputConsole(rows).Replace("\r", null)); rows = EventtypesByYears.Do(graphByYears, 2); Assert.AreEqual( @"$, a, b, c, a, 1, 0, 1, b, 1, 0, 1, c, 0, 0, 0, ", Outputer.OutputConsole(rows).Replace("\r", null)); }
protected override Graphes GroupEventsByYear(ExcelManager man, Dictionary <string, string> legends = null, bool twoAndMoreEventtypes = false) { var result = new Graphes(legends, twoAndMoreEventtypes); foreach (HSSFRow row in man.Records) { for (int colGroup = 0; colGroup < 12; colGroup++) { var i = colGroup * 2; if (row.RowNum >= 3058 && colGroup >= 11 || row.RowNum >= 6663 && colGroup >= 10 || row.RowNum >= 8563 && colGroup >= 9 || row.RowNum >= 19683 && colGroup >= 8 || row.RowNum >= 25229 && colGroup >= 7 || row.RowNum >= 37180 && colGroup >= 6 || row.RowNum >= 45344 && colGroup >= 5 || row.RowNum >= 54304 && colGroup >= 4 ) { } else { var year = (int)row.Cells[i].NumericCellValue; var index = row.Cells[i + 1].ToString(); result.Add(year, index); } } } return(result); }
public void Do_Count() { var graphByYears = new Graphes(new Dictionary <int, string> { { 1, "b,a,b" } }); var rows = EventtypesByYears.Do(graphByYears); Assert.AreEqual(1, rows["b"]["a"]); Assert.AreEqual(1, rows["a"]["b"]); }
public void Do_Symmetric() { var graphByYears = new Graphes(new Dictionary <int, string> { { 1, "a,b,c" }, { 2, "b,a,c" } }); var rows = EventtypesByYears.Do(graphByYears); Assert.AreEqual(2, rows["a"]["b"]); Assert.AreEqual(2, rows["a"]["c"]); Assert.AreEqual(2, rows["b"]["c"]); }