在mvc程序中运行默认的stimulsoft结构

时间:2019-02-08 12:48:31

标签: c# asp.net-mvc stimulsoft

执行报告后,PDF文件显示为输出。我不想要这个,我想展示Stimulsoft的结构。显示此结构:

stimulsoft

这些代码在以下部分中:projectName \ Controllers \ Api \ ReportsApiController.cs

public class ReportsApiController : BaseApiController
{
    private readonly IReportService _reportService;
    private readonly IUnitOfWork _unitOfWork;
    private readonly IDbSet<Reports> _reports;
    // GET: ReportsApi
    public ReportsApiController(IUnitOfWork unitOfWork, 
        IReportService reportService,
        IUserService userService,
        IActionUserService actionUserService, 
        IActionService actionService,IControllersService controllerService) 
        : base(userService, actionUserService, actionService,controllerService)
    {
        this._reportService = reportService;
        _unitOfWork = unitOfWork;
        _reports = _unitOfWork.Set<Reports>();
    }


    [System.Web.Http.AcceptVerbs("GET")]
    [System.Web.Http.HttpGet]
    public ReportVM GetStatisticRepor()
    {
        ReportVM result = new ReportVM();
        string fileName = "UserStatistics.pdf"/*CommonUtils.generateFileName(".pdf")*/;
        string path   = ConstantData.PdfFiles + fileName;
        result = _reportService.GetStatisticReport(path);
        string baseUrl = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority +
                    HttpContext.Current.Request.ApplicationPath.TrimEnd('/') + "/";
        result.UrlFile =baseUrl+ path;
        return result;
    }

    [System.Web.Http.AcceptVerbs("POST")]
    [System.Web.Http.HttpGet]
    public ReportVM ReportUserDetails(ReportVM result)
    {
        string fileName = "ReportUserDetails.pdf"/*CommonUtils.generateFileName(".pdf")*/;
        string path = ConstantData.PdfFiles + fileName;
        result = _reportService.ReportUserDetails(path,result);
        string baseUrl = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority +
                    HttpContext.Current.Request.ApplicationPath.TrimEnd('/') + "/";
        result.UrlFile = baseUrl + path;
        return result;
    }

    [System.Web.Http.AcceptVerbs("GET")]
    [System.Web.Http.HttpGet]
    public List<ReportsModel> GetReportTypes()
    {
        return _reportService.GetReportTypes().Reports;
    }

}

这也是ReportService代码的一部分,其中包含报告的详细信息,这些代码位于以下部分中:projectName.ServiceLayer \ EfServices \ Business \ ReportService.cs:

    public ReportVM GetStatisticReport(string filePath)
    {
        ReportVM result = new ReportVM();
        try
        {
            var _UserID = HttpContext.Current != null ? HttpContext.Current.GetUserId() : (int?)null;
            CurrentUser = _userService.FindById(_UserID.Value);
            int KardaniCount = _userService.GetCountMaghtae(ConstantData.Kardani);
            int Karshenasi = _userService.GetCountMaghtae(ConstantData.Karshenasi);
            int Arshad = _userService.GetCountMaghtae(ConstantData.Arshad);
            int PHD = _userService.GetCountMaghtae(ConstantData.PHD);
            string baseUrl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority);
            var report = CommonUtils.generateStatisticReport(filePath, KardaniCount,Karshenasi,Arshad,PHD,CurrentUser.Name  +" "+CurrentUser.Family);
            result.UrlFile = report;
        }
        catch (CustomException ex)
        {
            result.Errors = ErrorVM.errorCustom(result.Errors, ex.MessageCustom);
            result.isError = true;
        }
        catch (Exception ex)
        {
            result.Errors = ErrorVM.errorCustom(result.Errors, ex.Message);
            result.isError = true;
        }
        return result;
    }

0 个答案:

没有答案