Пример #1
0
        private static ReportViewModel GenerateGeneric(ReportViewModel viewModel, ItemReport itemReport, Item item, bool fromExcel)
        {
            //deal with the column names
            foreach (var ir in itemReport.Columns)
            {
                viewModel.ColumnNames.Add(!string.IsNullOrWhiteSpace(ir.Format) && !fromExcel
                                              ? string.Format("{0} ({1})", ir.Name, ir.Format)
                                              : ir.Name);
            }

            // deal with the row values, if there are any quantity properties, we need to go through the quantity values
            if (itemReport.Columns.Any(a => a.Quantity))
            {
                // go through all the transactions
                foreach (var x in item.Transactions.Where(a => a.ParentTransaction == null))
                {
                    // go through all the unqiue quantity ids
                    foreach (var y in x.QuantityAnswers.Select(a => a.QuantityId).Distinct())
                    {
                        // this represents one row worth of data
                        var row = new List<string>();

                        // go through all the requested columns, x=transaction, y=quantityId
                        foreach (var z in itemReport.Columns)
                        {
                            row.Add(ExtractValue(z, x, y));
                        }

                        viewModel.RowValues.Add(row.ToArray());
                    }
                }
            }
            // otherwise it's a transaction level report
            else
            {
                // go through all the transactions
                foreach (var x in item.Transactions.Where(a => a.ParentTransaction == null))
                {
                    var row = new List<string>();

                    foreach (var z in itemReport.Columns)
                    {
                        row.Add(ExtractValue(z, x, null));
                    }

                    viewModel.RowValues.Add(row.ToArray());
                }
            }

            return viewModel;
        }
Пример #2
0
        public static ReportViewModel Create(IRepository repository, ItemReport itemReport, Item item, bool fromExcel = true)
        {
            Check.Require(repository != null, "Repository is required.");

            var viewModel = new ReportViewModel
            {
                ItemId = item.Id,
                ReportName = itemReport.Name,
                ItemReportId = itemReport.Id
            };

            if (itemReport.Name == "Checks" && itemReport.SystemReusable)
            {
                return GenerateChecks(viewModel, itemReport, item);
            }

            return GenerateGeneric(viewModel, itemReport, item, fromExcel);
        }
Пример #3
0
        private static ReportViewModel GenerateChecks(ReportViewModel viewModel, ItemReport itemReport, Item item)
        {
            //deal with the column names
            foreach (var ir in itemReport.Columns)
            {
                viewModel.ColumnNames.Add(ir.Name);
            }

            // go through all the transactions
            foreach (var x in item.Transactions.Where(a => a.ParentTransaction == null))
            {
                // go through all the unqiue quantity ids
                foreach (var y in x.PaymentLogs.Where(a => a.Check && a.Accepted))
                {
                    // this represents one row worth of data
                    var row = new List<string>();

                    // go through all the requested columns, x=transaction, y=quantityId
                    foreach (var z in itemReport.Columns)
                    {
                        row.Add(ExtractCheckValue(y, z.Name));
                    }

                    viewModel.RowValues.Add(row.ToArray());
                }
            }

            return viewModel;
        }