Esempio n. 1
0
        public ActionResult ERLevelSites()
        {
            try
            {
                string selectedSiteIds = "";
                var    reportService   = new SearchInputService();
                //Not applying filter for Task Report
                var siteLst  = AppSession.ReportID == 42 ? CMSService.GetCMSSitesFiltered(AppSession.Sites.ToList()) : CMSService.GetCMSSitesFiltered(AppSession.Sites.Where(m => m.IsAMPAccess == 1).ToList());
                var levelMap = reportService.GetLevelMap(siteLst);

                AppSession.SessionERLevelInformation = reportService.GetLevelInformation(AppSession.SelectedSiteId);
                levelMap = levelMap.OrderByDescending(l => l.ERLevel1.ERLevel1ID)
                           .ThenBy(l => l.ERLevel2.ERLevel2Name)
                           .ThenBy(l => l.ERLevel3.ERLevel3Name)
                           .ToList();

                bool hasLevel1 = levelMap.Where(l => l.ERLevel1ID > 0).Count() > 0 ? true : false;
                bool hasLevel2 = levelMap.Where(l => l.ERLevel2ID > 0).Count() > 0 ? true : false;
                bool hasLevel3 = levelMap.Where(l => l.ERLevel3ID > 0).Count() > 0 ? true : false;

                // if there are no level 1 names (or (None)), set to false
                if (hasLevel1)
                {
                    if (levelMap.Where(l => !String.IsNullOrEmpty(l.ERLevel1.ERLevel1Name)).Count() == 0)
                    {
                        hasLevel1 = false;
                    }
                }

                //Get the selected sites for the saved report
                if (AppSession.ReportScheduleID > 0 && TempData["SavedParameters"] != null)
                {
                    var oScheduleDate = new SaveAndSchedule();
                    oScheduleDate   = (SaveAndSchedule)TempData["SavedParameters"];
                    selectedSiteIds = string.Join(",", oScheduleDate.ReportSiteMaps.Select(siteMaps => siteMaps.SiteID).ToList());
                }

                var sites = string.Join(",", levelMap.Select(levelM => levelM.SiteID).ToList());;

                var siteSelectorViewModel = new SiteSelectorViewModel
                {
                    ERLevelMap        = levelMap,
                    HasLevel1         = hasLevel1,
                    HasLevel2         = hasLevel2,
                    HasLevel3         = hasLevel3,
                    SelectedSiteIds   = selectedSiteIds,
                    IsCorporateAccess = new CommonService().CheckCorporateAccess(sites)
                };

                switch ((ReportsListEnum)AppSession.ReportID)
                {
                case ReportsListEnum.EPScoringReport:
                case ReportsListEnum.TaskAssignment:
                case ReportsListEnum.EPAssignmentScoring:
                case ReportsListEnum.CMSCompliance:
                case ReportsListEnum.EPsNotScoredinPeriod:
                case ReportsListEnum.EPScoringReportFinalMockSurvey:
                case ReportsListEnum.TaskReport:
                    return(PartialView("Search/_SitesTreeForEPScoring", siteSelectorViewModel));

                case ReportsListEnum.ComprehensiveScoringReport:
                    return(PartialView("Search/_SitesTreeForEPScoring", siteSelectorViewModel));

                default:
                    return(PartialView("Search/_SitesTree", siteSelectorViewModel));
                }
            }
            catch (Exception ex)
            {
                ExceptionLog exceptionLog = new ExceptionLog
                {
                    ExceptionText = "Reports: " + ex.Message,
                    PageName      = "CorporatePriorityFinding",
                    MethodName    = "ERLevelSites",
                    UserID        = Convert.ToInt32(AppSession.UserID),
                    SiteId        = Convert.ToInt32(AppSession.SelectedSiteId),
                    TransSQL      = "",
                    HttpReferrer  = null
                };
                exceptionService.LogException(exceptionLog);

                return(RedirectToAction("Error", "Transfer"));
            }
        }