Beispiel #1
0
        public ActionResult GetReportTable(string reportType, int reportId, string startDate, string endDate,
                                           string unit)
        {
            var reportInfo = ReportService.GetReportInfoById(reportId);
            var reportData = ReportService.GetReportById(reportId,
                                                         new ReportParameter
            {
                StartDate =
                    string.IsNullOrEmpty(startDate) ? (DateTime?)null : DateTime.Parse(startDate),
                EndDate    = string.IsNullOrEmpty(endDate) ? (DateTime?)null : DateTime.Parse(endDate),
                Unit       = unit,
                TableName  = reportInfo.TableName,
                ColumnList = string.IsNullOrEmpty(endDate)?null:reportInfo.ColumnList
            });

            var viewModel = reportType == "basic"
                ? new BasicReportViewModel(reportId, (StandardReport)reportData)
                : new StatisticalReportViewModel(
                reportId,
                (StandardReport)reportData,
                (StandardReport)ReportService.GetReportById(
                    reportId,
                    new ReportParameter
            {
                StartDate =
                    string.IsNullOrEmpty(startDate)
                                    ? (DateTime?)null
                                    : DateTime.Parse(startDate),
                EndDate =
                    string.IsNullOrEmpty(endDate) ? (DateTime?)null : DateTime.Parse(endDate),
                Unit       = unit,
                RowName    = "1",
                TableName  = reportInfo.TableName,
                ColumnList = reportInfo.ColumnList
            }));

            viewModel.Name = reportInfo.DisplayName;
            viewModel.Unit = HtmlUtil.GetUnitOptionByKey(unit);
            viewModel.Initialization();
            ViewData["StartDate_" + reportId] = startDate;
            ViewData["EndDate_" + reportId]   = endDate;
            ViewData["Unit_" + reportId]      = unit;

            if (reportType == "basic")
            {
                return(View("_ReportTable", viewModel.StandardReport));
            }
            var themeName         = ThemeHelper.GetTheme(Request);
            var staticalViewModel = (StatisticalReportViewModel)viewModel;

            staticalViewModel.TopChartModel.Theme    = themeName;
            staticalViewModel.BottomChartModel.Theme = themeName;
            return(View("_StatisticalReportTable", staticalViewModel));
        }
Beispiel #2
0
        public ActionResult GetIssueAmountReportContent(int reportId, string reportName, string type, string typeList, string useSubType, string subType, string startDate, string endDate, string unit)
        {
            var param = new BondIssueAmountParams
            {
                Type       = type,
                TypeList   = typeList.Split(',').ToList(),
                UseSubType = useSubType == "true",
                SubType    = subType,
                StartDate  = DateTime.Parse(startDate),
                EndDate    = DateTime.Parse(endDate),
                Unit       = unit
            };

            IEnumerable <BondIssueAmount> topGrid;
            IEnumerable <BondDetail>      bottomGrid;

            GetIssueAmountReportData(param, out topGrid, out bottomGrid);
            var model = new BondIssueAmountReport(
                reportId,
                reportName,
                HtmlUtil.GetUnitOptionByKey(unit),     // for display
                topGrid, bottomGrid);

            if (topGrid == null || topGrid.Count() == 0)
            {
                return(new EmptyResult());
            }

            ViewData["StartDate"]      = param.StartDate;
            ViewData["EndDate"]        = param.EndDate;
            ViewData["Type"]           = param.Type;
            ViewData["TypeList"]       = typeList;
            ViewData["SubType"]        = param.SubType;
            ViewData["UseSubType"]     = param.UseSubType && type != subType;
            ViewData["UseSecType"]     = (param.UseSubType && type != subType) ? "y" : "n";
            ViewData["Unit"]           = param.Unit;
            ViewData["TopGridName"]    = model.TopGridName;
            ViewData["TypeValue"]      = model.TopGrid.Select(t => t.Type).First();
            ViewData["SubTypeValue"]   = "";
            ViewData["TopGridName"]    = model.TopGridName;
            ViewData["BottomGridName"] = model.BottomGridName;

            return(View("_IssueAmountReportContent", model));
        }
Beispiel #3
0
        private ChartData GetIssuMaturesTopChart(string rate, string chartType, string columnType, DateTime start, DateTime end, string category, string itemList, string unit, int isUseSubCategory = 0, string subCategory = "Bond_Class", string subCategoryValue = "", bool isTotal = false)
        {
            if (start > end)
            {
                return(new ChartData());
            }
            var chartData = new ChartData
            {
                ChartType = chartType,
                YText     = Resources.Global.Unit + "(" + HtmlUtil.GetUnitOptionByKey(unit) + ")"
            };

            switch (columnType)
            {
            case "InitialBalance":
                chartData.Decimal = 2;
                break;

            case "Issues":
                chartData.YText   = string.Empty;
                chartData.Decimal = 0;
                break;

            case "IssuesPercent":
                chartData.YText   = string.Empty;
                chartData.Decimal = 2;
                break;

            case "IssuesAmount":
                chartData.Decimal = 2;
                break;

            case "IssuesAmountPercent":
                chartData.YText   = string.Empty;
                chartData.Decimal = 2;
                break;

            case "MaturityBonds":
                chartData.YText   = string.Empty;
                chartData.Decimal = 0;
                break;

            case "MaturityAmount":
                chartData.Decimal = 2;
                break;

            case "EndBalance":
                chartData.Decimal = 2;
                break;

            case "EndIssuesPercent":
                chartData.YText   = string.Empty;
                chartData.Decimal = 2;
                break;
            }
            var typeName    = "TypeCn";
            var subTypeName = "SubTypeCn";

            if (CultureHelper.IsEnglishCulture())
            {
                typeName    = "TypeEn";
                subTypeName = "SubTypeEn";
            }
            if (chartType == "bar" || chartType == "line")
            {
                var yearsDic = new Dictionary <string, DataTable>();
                var dates    = PopulateRateTimes(start, end, rate);
                for (var i = 0; i < dates.Count; i += 2)
                {
                    var currentStart = dates[i];
                    var currentEnd   = dates[i + 1];
                    var summaryData  = BondReportRepository.GetBondDepositoryBalanceChart(columnType, currentStart, currentEnd, category, itemList, unit, isUseSubCategory, subCategory, subCategoryValue);
                    yearsDic.Add(rate == "y" ? currentEnd.ToString("yyyy") : currentEnd.ToString("yyyy-M"), summaryData);
                }
                chartData.ColumnCategories = yearsDic.Keys.Select(x => x.ToString()).ToArray();
                var groupDic = new Dictionary <string, List <double> >();
                if (isTotal)
                {
                    groupDic.Add(Resources.Global.Total, new List <double>());
                    foreach (var keyValue in yearsDic)
                    {
                        double total = 0;
                        for (var j = 0; j < keyValue.Value.Rows.Count; j++)
                        {
                            total += Convert.ToDouble(keyValue.Value.Rows[j][columnType]);
                        }
                        groupDic[Resources.Global.Total].Add(total);
                    }
                }
                else
                {
                    foreach (var keyValue in yearsDic)
                    {
                        for (var j = 0; j < keyValue.Value.Rows.Count; j++)
                        {
                            var name = keyValue.Value.Rows[j][typeName].ToString();
                            if (string.IsNullOrEmpty(subCategoryValue))
                            {
                                if (!groupDic.ContainsKey(name))
                                {
                                    groupDic.Add(name, new List <double>());
                                }
                            }
                            else
                            {
                                name = string.Format("{0}({1})", keyValue.Value.Rows[j][typeName], keyValue.Value.Rows[j][subTypeName]);
                                if (!groupDic.ContainsKey(name))
                                {
                                    groupDic.Add(name, new List <double>());
                                }
                            }
                            groupDic[name].Add(Convert.ToDouble(keyValue.Value.Rows[j][columnType]));
                        }
                    }
                }
                var seriesDataList = new List <SeriesData>();
                foreach (var keyValue in groupDic)
                {
                    var sData = new SeriesData {
                        name = keyValue.Key
                    };
                    if (keyValue.Value != null)
                    {
                        sData.data = keyValue.Value.ToArray();
                        seriesDataList.Add(sData);
                    }
                }
                chartData.ColumnSeriesData = seriesDataList.ToArray();
            }
            else
            {
                var groupData = BondReportRepository.GetBondDepositoryBalanceChart(columnType, start, end, category, itemList, unit, isUseSubCategory, subCategory, subCategoryValue);
                var pieData   = new List <PieSectionData>();
                for (int j = 0; j < groupData.Rows.Count; j++)
                {
                    var currentSection = new PieSectionData {
                        name = groupData.Rows[j][typeName].ToString(), y = Convert.ToDouble(groupData.Rows[j][columnType])
                    };
                    pieData.Add(currentSection);
                }
                chartData.PieSeriesData = pieData.ToArray();
            }


            return(chartData);
        }