Ejemplo n.º 1
0
        internal void SaveMainStatistics(XLWorkbook workbook)
        {
            IXLWorksheet worksheet = workbook.Worksheets.Add("Общая статистика");

            worksheet.Cell(1, 1).Value = "№";
            MainMethods.SetStyleHeader(worksheet.Cell(1, 1));

            foreach (ColumnMainStatistics itemColumns in _columns)
            {
                worksheet.Cell(1, itemColumns.Id + 1).Value = itemColumns.Description;
                MainMethods.SetStyleHeader(worksheet.Cell(1, itemColumns.Id + 1));
            }


            for (int i = 0; i < TournamentReplays.Count; i++)
            {
                worksheet.Cell(i + 2, 1).Value = i.ToString();

                foreach (ColumnMainStatistics itemColumns in _columns)
                {
                    worksheet.Cell(i + 2, itemColumns.Id + 1).Value = GetValueReplay(TournamentReplays[i], itemColumns);
                }
            }

            worksheet.Columns(_columns[0].Id + 1, _columns.Last().Id + 1).AdjustToContents();
        }
Ejemplo n.º 2
0
        internal void SavePersonalStatistics(XLWorkbook workbook, bool isCurrentUser = false)
        {
            Statistics.Statistic statistic = new Statistics.Statistic();
            statistic.Init();
            statistic.FillDataReplays(TournamentReplays, isCurrentUser);


            List <Models.ItemUserStatisticsItemUpdater> itemUserStatistics = statistic.GetAllStatistics();

            IXLWorksheet worksheet = workbook.Worksheets.Add("Личная статистика");

            foreach (AreaPersonalStatistics itemArea in _areas.Where(f => f.Name == null))
            {
                worksheet.Cell(itemArea.RowId, itemArea.ColumnId).Value = itemArea.Description;
                MainMethods.SetStyleHeader(worksheet.Cell(itemArea.RowId, itemArea.ColumnId));
            }

            foreach (Models.ItemUserStatisticsItemUpdater itemStatistic in itemUserStatistics)
            {
                AreaPersonalStatistics areaStatistics = _areas.FirstOrDefault(f => f.Name == itemStatistic.Key);

                if (areaStatistics == null)
                {
                    continue;
                }

                int rowID = areaStatistics.RowId;

                IXLRange header = worksheet.Range(rowID, areaStatistics.ColumnId + 1, rowID, areaStatistics.ColumnId).Merge();

                MainMethods.SetStyleHeader(header);

                worksheet.Cell(rowID, areaStatistics.ColumnId).Value = areaStatistics.Description;

                rowID++;

                List <Models.UserStatisticsItemValueItem> userStatistics = itemStatistic.GetValueAction();
                foreach (Models.UserStatisticsItemValueItem itemUser in userStatistics)
                {
                    worksheet.Cell(rowID, areaStatistics.ColumnId).Value       = itemUser.Header;
                    worksheet.Cell(rowID++, areaStatistics.ColumnId + 1).Value = itemUser.Value;
                }

                worksheet.Columns(_areas[0].ColumnId, _areas.Last().ColumnId + 1).AdjustToContents();
            }
        }