Esempio n. 1
0
        public ActionResult Report(string reportPath, int headeroption = 1)
        {
            var vm = new ReportsModel();

            if (!string.IsNullOrEmpty(reportPath))
            {
                UserPrincipal user = GetCurrentPrincipal();
                vm            = SetReportViewModel(user);
                vm.ReportPath = reportPath;
                LoggingHelper.LogInformation("Retrieving Report - " + reportPath);
            }

            // getting report service from cache
            if (ReportServer.IsSessionExpired(HttpContext))
            {
                if (headeroption == 1)
                {
                    return(RedirectToAction("LogOff", "Account"));
                }
                else
                {
                    var returnUrl = "/Grids?headeroption=2";
                    return(RedirectToAction("LogOff", "Account", new { returnUrl = returnUrl }));
                }
            }
            //ReportServer rs = new ReportServer(HttpContext);

            //getting report parameters
            ItemParameter[] parameters = ReportServer.GetItemParameters(HttpContext, reportPath, null, true, null, null);

            ViewBag.CurrentUserFirstName = vm.CurrentUserFirstName;
            ViewBag.CurrentUserLastName  = vm.CurrentUserSurName;
            ViewBag.HeaderOption         = headeroption;
            ViewBag.ReportParameters     = parameters;
            ViewBag.SamAccount           = vm.SamAccount;
            ViewBag.Password             = LoginUser.Password;
            return(View(vm));
        }
Esempio n. 2
0
        public ActionResult GetDependentParameters(ReportExecutionBE reportexecution)
        {
            try
            {
                string reportPath = reportexecution.ReportPath;
                List <ReportService.ParameterValue> values = new List <ReportService.ParameterValue>();

                for (int i = 0; i < reportexecution.Parameters.Count; ++i)
                {
                    ReportParameterBE valueList = reportexecution.Parameters[i];

                    if (valueList.Value != null)
                    {
                        for (int j = 0; j < valueList.Value.Length; ++j)
                        {
                            ReportService.ParameterValue value = new ReportService.ParameterValue();
                            value.Name  = valueList.Name;
                            value.Label = valueList.Label;
                            value.Value = valueList.Value[j];
                            values.Add(value);
                        }
                    }
                }
                ItemParameter[] output = ReportServer.GetItemParameters(HttpContext, reportPath, null, true, values.ToArray(), null);

                return(Json(output, JsonRequestBehavior.AllowGet));
            }
            catch (SqlException ex)
            {
                LoggingHelper.LogException("Unable to generate dependent parameters from report service.", ex);
                throw;
            }
            catch (Exception ex)
            {
                LoggingHelper.LogException("Unable to generate dependent parameters from report service.", ex);
                throw;
            }
        }