async Task <ReportInfo> GetReportInfoDesktop(DesktopReport dr, String url, ExpandoObject prms)
        {
            var rc = new ReportContext()
            {
                UserId   = dr.UserId,
                TenantId = dr.TenantId,
            };

            if (_baseController.Host.IsMultiCompany)
            {
                rc.CompanyId = dr.CompanyId;
            }
            return(await _reportHelper.GetReportInfo(rc, url, dr.Id, prms));
        }
Beispiel #2
0
        public async Task ExportDesktop(DesktopReport rep, HttpResponseBase response)
        {
            // TODO: query string ???
            _reportHelper.SetupLicense();
            try
            {
                using (var rr = Profiler.CurrentRequest.Start(ProfileAction.Report, $"export: {rep.Report}"))
                {
                    var        url = $"/_report/{rep.Base.RemoveHeadSlash()}/{rep.Report}/{rep.Id}";
                    ReportInfo ri  = await GetReportInfoDesktop(rep, url, CreateParamsFromQueryString());

                    ExportReportResult err = null;
                    switch (ri.Type)
                    {
                    case RequestReportType.stimulsoft:
                        err = await _reportHelper.ExportStiReportStreamAsync(ri, rep.Format, response.OutputStream);

                        break;

                    case RequestReportType.xml:
                        throw new NotImplementedException("ExportDesktop. RequestReportType.xml");

                    case RequestReportType.json:
                        throw new NotImplementedException("ExportDesktop. RequestReportType.json");
                    }
                    if (err != null)
                    {
                        response.ContentType = err.ContentType;
                        if (rep.AddContentDisposition)
                        {
                            var cdh = new ContentDispositionHeaderValue("attachment")
                            {
                                FileNameStar = $"{_baseController.Localize(ri.Name)}.{err.Extension}"
                            };
                            response.Headers.Add("Content-Disposition", cdh.ToString());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                response.ContentType     = "text/html";
                response.ContentEncoding = Encoding.UTF8;
                if (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                response.Write(ex.Message);
            }
        }