private ActionResult ReportRedirect(ReportLinkModel model)
 {
     Session[ReportLinkModel.SessionActiveReport] = model.ReportName;
     // Add Dashboards to path to allow dashboard reporting style to work
     if (model.Path.Contains("Dashboards"))
     {
         return(RedirectToAction("Dashboards", "Reporting", new { rn = model.ReportName }));
     }
     else
     {
         return(RedirectToAction("ReportViewer", "Reporting", new { rn = model.ReportName }));
     }
 }
Example #2
0
        /// <summary>
        /// Gets an instance of <see cref="ReportLinkModel"/> that represents the URL of the report on an external site.  This
        /// is used for the case where an Izenda report is displayed in an iFrame from an external site.  The <paramref name="customerId"/>
        /// is appended to the URL as a parameter customerId such that external site can optionally act on that value.
        /// </summary>
        /// <param name="customerId">The customer id</param>
        /// <param name="reportAction">String that represents one of the place-holder Actions in the MVC Controller Duncan.PEMS.Web.Areas.city.Controllers.ReportsController</param>
        /// <returns>An instance of <see cref="ReportLinkModel"/></returns>
        public ReportLinkModel GetReportLink(int customerId, string reportAction)
        {
            var report = RbacEntities.CustomerReports.FirstOrDefault(m => m.CustomerId == customerId && m.ReportAction.Equals(reportAction, StringComparison.CurrentCultureIgnoreCase));


            var model = new ReportLinkModel()
            {
                Host       = report.Host,
                Path       = report.Path,
                Parameters = report.Parameters
            };

            model.Parameters += "&customerId=" + customerId;


            // Parse out report name from report.Parameter

            string[] tokens = report.Parameters.Split(new char[] { '=', '&' });
            model.ReportName = string.Empty;

            if (tokens.Length == 1)
            {
                model.ReportName = tokens[0];
            }
            if (tokens.Length % 2 == 0)
            {
                // Find the parameter that was "rn", take next token.
                for (int i = 0; i < tokens.Length; i += 2)
                {
                    if (tokens[i].Equals("rn", StringComparison.CurrentCultureIgnoreCase))
                    {
                        model.ReportName = tokens[i + 1];
                        break;
                    }
                }
            }

            return(model);
        }