public void ReportFilterTest() { var filter = new ReportFilter(); filter.DepartmentId = Guid.NewGuid(); filter.FromDate = DateTime.Now.Date; filter.ToDate = DateTime.Now.Date; filter.MilestoneStatuses.Add(MilestoneStatus.Open); filter.MilestoneStatuses.Add(MilestoneStatus.Closed); filter.ProjectIds.Add(1); filter.ProjectIds.Add(3); filter.ProjectStatuses.Add(ProjectStatus.Open); filter.ProjectStatuses.Add(ProjectStatus.Closed); filter.ProjectTag = "tag"; filter.TaskStatuses.Add(TaskStatus.Open); filter.TaskStatuses.Add(TaskStatus.Closed); filter.TimeInterval = ReportTimeInterval.Absolute; filter.UserId = Guid.NewGuid(); filter.ViewType = 4; var xml = filter.ToXml(); var uri = filter.ToUri(); AreEquals(filter, ReportFilter.FromXml(xml)); AreEquals(filter, ReportFilter.FromUri(uri)); filter.TimeInterval = ReportTimeInterval.CurrMonth; xml = filter.ToXml(); uri = filter.ToUri(); AreEquals(filter, ReportFilter.FromXml(xml)); AreEquals(filter, ReportFilter.FromUri(uri)); }
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); } }