示例#1
0
        protected override void PageLoad()
        {
            if (Participant.IsVisitor)
            {
                Response.Redirect(PathProvider.BaseVirtualPath, true);
            }

            Page.RegisterBodyScripts(ResolveUrl("~/js/third-party/sorttable.js"));
            Page.RegisterBodyScripts(PathProvider.GetFileStaticRelativePath("reports.js"));

            exportReportPopup.Options.IsPopup = true;
            HasData                              = true;
            TemplateNotFound                     = false;
            Master.DisabledSidePanel             = true;
            Master.Master.DisabledTopStudioPanel = true;

            int.TryParse(UrlParameters.ReportType, out GenerateReportType);
            var repType = (ReportType)GenerateReportType;

            var    filter = new TaskFilter();
            int    templateID;
            var    reportName = "";
            Report report;

            if (int.TryParse(UrlParameters.EntityID, out templateID))
            {
                var template = Global.EngineFactory.GetReportEngine().GetTemplate(templateID);
                if (template != null)
                {
                    filter             = template.Filter;
                    repType            = template.ReportType;
                    GenerateReportType = (int)template.ReportType;
                    Title      = HeaderStringHelper.GetPageTitle(string.Format(ReportResource.ReportPageTitle, HttpUtility.HtmlDecode(template.Name)));
                    reportName = string.Format(ReportResource.ReportPageTitle, template.Name);
                }
                else
                {
                    TemplateNotFound = true;
                    HasData          = false;
                    emptyScreenControlPh.Controls.Add(new ElementNotFoundControl
                    {
                        Header        = ReportResource.TemplateNotFound_Header,
                        Body          = ReportResource.TemplateNotFound_Body,
                        RedirectURL   = "reports.aspx?reportType=0",
                        RedirectTitle = ReportResource.TemplateNotFound_RedirectTitle
                    });
                    Master.DisabledSidePanel = false;
                }
            }
            else
            {
                filter = TaskFilter.FromUri(HttpContext.Current.Request.GetUrlRewriter());

                report = Report.CreateNewReport(repType, filter);

                Title      = HeaderStringHelper.GetPageTitle(string.Format(ReportResource.ReportPageTitle, report.ReportInfo.Title));
                reportName = string.Format(ReportResource.ReportPageTitle, report.ReportInfo.Title);
            }

            report = Report.CreateNewReport(repType, filter);

            var filters = (ReportFilters)LoadControl(PathProvider.GetControlVirtualPath("ReportFilters.ascx"));

            filters.Report = report;
            _filter.Controls.Add(filters);

            var outputFormat = GetOutputFormat();
            var result       = ReportHelper.BuildReport(repType, filter, outputFormat, templateID);

            OutputData(result, reportName, report, outputFormat);
        }
示例#2
0
        protected override void PageLoad()
        {
            ((IStudioMaster)Master).DisabledSidePanel = true;

            AjaxPro.Utility.RegisterTypeForAjax(typeof(Reports));

            TemplateNotFound = false;
            HasData          = true;

            InitActionPanel();

            int.TryParse(UrlParameters.ReportType, out reportType);
            var repType = (ReportType)reportType;

            if (IsGenerate)
            {
                Master.DisabledSidePanel = true;

                var filter     = new ReportFilter();
                var templateID = 0;
                if (int.TryParse(UrlParameters.EntityID, out templateID))
                {
                    var template = Global.EngineFactory.GetReportEngine().GetTemplate(templateID);
                    if (template != null)
                    {
                        filter     = template.Filter;
                        Filter     = template.Filter;
                        repType    = template.ReportType;
                        reportType = (int)template.ReportType;
                        Master.BreadCrumbs.Add(new BreadCrumb {
                            Caption = string.Format(ReportResource.ReportPageTitle, HttpUtility.HtmlDecode(template.Name))
                        });
                        Title = HeaderStringHelper.GetPageTitle(string.Format(ReportResource.ReportPageTitle, HttpUtility.HtmlDecode(template.Name)), Master.BreadCrumbs);
                    }
                    else
                    {
                        TemplateNotFound = true;
                        HasData          = false;
                        emptyScreenControlPh.Controls.Add(new ElementNotFoundControl
                        {
                            Header        = ReportResource.TemplateNotFound_Header,
                            Body          = ReportResource.TemplateNotFound_Body,
                            RedirectURL   = "templates.aspx",
                            RedirectTitle = ReportResource.TemplateNotFound_RedirectTitle
                        });

                        Master.DisabledSidePanel = false;
                    }
                }
                else
                {
                    filter = ReportFilter.FromUri(HttpContext.Current.Request.GetUrlRewriter());
                    Master.BreadCrumbs.Add(new BreadCrumb {
                        Caption = string.Format(ReportResource.ReportPageTitle, ReportHelper.GetReportInfo(repType).Title)
                    });
                    Title = HeaderStringHelper.GetPageTitle(string.Format(ReportResource.ReportPageTitle, ReportHelper.GetReportInfo(repType).Title), Master.BreadCrumbs);
                }

                var outputFormat = ReportViewType.Html;
                switch (HttpContext.Current.Request["format"])
                {
                case "csv": outputFormat = ReportViewType.Csv; break;

                case "xml": outputFormat = ReportViewType.Xml; break;

                case "email": outputFormat = ReportViewType.EMail; break;

                case "html": outputFormat = ReportViewType.Html; break;
                }

                var result = ReportHelper.BuildReport(repType, filter, outputFormat);

                switch (outputFormat)
                {
                case ReportViewType.Html:
                    if (result != null)
                    {
                        reportResult.Text = result;
                    }
                    else
                    {
                        HasData = false;
                        emptyScreenControlPh.Controls.Add(new ASC.Web.Projects.Controls.EmptyScreenControl(ProjectsCommonResource.NoData));
                    }
                    reportFilter.Text = ParseFilter(repType, filter);
                    Filter            = filter;
                    break;

                case ReportViewType.Csv:
                case ReportViewType.Xml:
                case ReportViewType.EMail:
                    if (result != null)
                    {
                        var ext = outputFormat.ToString().ToLower();
                        Response.Clear();
                        Response.ContentType     = "text/" + ext + "; charset=utf-8";
                        Response.ContentEncoding = Encoding.UTF8;
                        Response.Charset         = Encoding.UTF8.WebName;
                        Response.AppendHeader("Content-Disposition", string.Format("attachment; filename={0}.{1}", ReportHelper.GetReportFileName(repType).Replace(' ', '_'), ext));
                        Response.Write(result);
                        Response.End();
                    }
                    break;
                }
            }
            else
            {
                Master.BreadCrumbs.Add(new BreadCrumb {
                    Caption = ReportResource.Reports
                });
                Title = HeaderStringHelper.GetPageTitle(ReportResource.Reports, Master.BreadCrumbs);

                var filters = (ReportFilters)LoadControl(PathProvider.GetControlVirtualPath("ReportFilters.ascx"));
                filters.ReportType = repType;
                filters.Filter     = string.IsNullOrEmpty(HttpContext.Current.Request.Url.Query) ? new ReportFilter() : ReportFilter.FromUri(HttpContext.Current.Request.Url);
                reportFiltersPh.Controls.Add(filters);
            }
        }