Beispiel #1
0
        /// <summary>
        /// Gets the report by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="parameter">The parameter.</param>
        /// <returns></returns>
        public BaseReport GetReportById(int reportId, ReportParameter parameter)
        {
            if (reportId > 0)
            {
                var standardReport = new StandardReport(reportId)
                {
                    ResultDataTable       = StandardReportRepository.GetReportById(reportId, parameter),
                    Columns               = StandardReportRepository.GetReportColumns(reportId).ToList(),
                    ExtraHeaderCollection = StandardReportRepository.GetExtraHeaderById(reportId).ToList()
                };

                if (parameter.Unit != null && parameter.Unit != ConstValues.Unit_100M)
                {
                    foreach (var c in standardReport.Columns)
                    {
                        if (c.ColumnType == null || !c.ColumnType.Equals("decimal"))
                        {
                            continue;
                        }
                        foreach (var r in standardReport.ResultDataTable.AsEnumerable())
                        {
                            if (r[c.ColumnName] != null && r[c.ColumnName].GetType() != typeof(DBNull))
                            {
                                r[c.ColumnName] = Convert.ToDecimal(SwitchAmountUnit(parameter.Unit, Convert.ToDouble(r[c.ColumnName])));
                            }
                        }
                    }
                }
                return(standardReport);
            }
            return(new StandardReport(reportId));
        }
        public void TestGetReportById()
        {
            var target = new StandardReportRepository();

            var actual = target.GetReportById(30100,
                                              new ReportParameter
            {
                StartDate =
                    null,
                EndDate    = null,
                Unit       = null,
                TableName  = "cfets_FOGCUYSpRep_FORGCURYSpot",
                ColumnList = null
            });

            Console.WriteLine(actual);
        }