예제 #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));
        }
예제 #2
0
        public ActionResult Index(int headeroption = 1)
        {
            LoggingHelper.LogInformation("User goes to the report page...");
            var          vm        = new ReportsModel();
            ReportHelper rptHelper = new ReportHelper();

            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);

            UserPrincipal user = GetCurrentPrincipal();

            if (user != null)
            {
                vm = SetReportViewModel(user);

                try
                {
                    vm.ReportDirectoryHierarchy = rptHelper.CreateReportDirectoryHierarchy(rs.CatalogItems.ToList(), HttpContext);
                }

                catch (ArgumentNullException Ex)
                {
                    LoggingHelper.LogException("No reports found", Ex);
                }
                catch (Exception Ex)
                {
                    LoggingHelper.LogException(Ex);
                }
            }
            else
            {
                throw new Exception("Unable to determine User Principal");
            }
            ViewBag.CurrentUserFirstName = vm.CurrentUserFirstName;
            ViewBag.CurrentUserLastName  = vm.CurrentUserSurName;
            ViewBag.HeaderOption         = headeroption;
            try
            {
                var filepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConfigurationManager.AppSettings["CompanyName"]);
                using (var stream = new StreamReader(filepath))
                {
                    ViewBag.CompanyName = stream.ReadToEnd();
                }
            }
            catch (Exception exc)
            {
                return(Content(exc.Message));
            }
            return(View(vm));
        }