예제 #1
0
        public ActionResult CorporateReport_Data(SearchCorporateER search, int LevelIdentifier)
        {
            try
            {
                //Mock Survey Status Parameter. Corporate Reports displays data after Mock Survey Recommendations are approved.
                search.MockSurveyStatusID = (int)MockSurveyStatus.Publish_CCA_Recommendation;

                JsonResult jr = new JsonResult();
                if (search.ProgramIDs == "-1")
                {
                    search.ProgramIDs = null;
                }
                if (search.SelectedChapterIDs == "-1")
                {
                    search.SelectedChapterIDs = null;
                }
                if (search.SelectedStandardIDs == "-1")
                {
                    search.SelectedStandardIDs = null;
                }
                if (search.SelectedMockSurveyIDs == "-1")
                {
                    search.SelectedMockSurveyIDs = null;
                }
                if (search.SelectedMockSurveyLeadIDs == "-1")
                {
                    search.SelectedMockSurveyLeadIDs = null;
                }
                if (search.SelectedMockSurveyMemberIDs == "-1")
                {
                    search.SelectedMockSurveyMemberIDs = null;
                }

                string JCREmailDomain  = "@JCRINC.COM";
                string JCREmailDomain2 = "@JCAHO.COM";
                string encryptionKey   = ConfigurationManager.AppSettings.Get("EncryptionKey");

                switch (LevelIdentifier)
                {
                case (int)WebConstants.CorporateSummaryLevels.Level1_Program:
                {
                    List <CorpProgramFinding> Level1Data = new List <CorpProgramFinding>();
                    Level1Data = CorporateFinding.GetCorpFindingByProgram(search);

                    jr = Json(Level1Data, JsonRequestBehavior.AllowGet);
                    break;
                }

                case (int)WebConstants.CorporateSummaryLevels.Level2_Chapter:
                {
                    if (search.IsDuplicateLoadCall)
                    {
                        jr = TempData["ACS_Level2Data"] as JsonResult;
                    }
                    else
                    {
                        List <CorpChapterFinding> Level2Data = new List <CorpChapterFinding>();
                        Level2Data = CorporateFinding.GetCorpFindingByChapter(search);
                        jr         = Json(Level2Data, JsonRequestBehavior.AllowGet);
                        TempData["ACS_Level2Data"] = jr;
                    }
                    break;
                }

                case (int)WebConstants.CorporateSummaryLevels.Level3_Standard:
                {
                    if (search.IsDuplicateLoadCall)
                    {
                        jr = TempData["ACS_Level3Data"] as JsonResult;
                    }
                    else
                    {
                        List <CorpStandardFinding> Level3Data = new List <CorpStandardFinding>();
                        Level3Data = CorporateFinding.GetCorpFindingByStandard(search);

                        var max = Convert.ToInt32(Level3Data.Max(r => r.CumulativePercentage));
                        Session["MaxStandardCount"] = max >= 100 ? 100 : max;

                        jr = Json(Level3Data, JsonRequestBehavior.AllowGet);
                        TempData["ACS_Level3Data"] = jr;
                    }
                    break;
                }

                case (int)WebConstants.CorporateSummaryLevels.Level4_EP:
                {
                    string tjcFinding = string.Empty;
                    List <CorpEPFinding> Level4Data = new List <CorpEPFinding>();

                    Level4Data = CorporateFinding.GetCorpFindingByEP(search);

                    if (!AppSession.EmailAddress.ToUpper().Contains(JCREmailDomain) && !AppSession.EmailAddress.ToUpper().Contains(JCREmailDomain2))
                    {
                        Level4Data.ToList().ForEach(data => { data.TJCFinding = CryptHelpers.RFIDecrypt(data.TJCFinding, encryptionKey); });
                    }
                    else
                    {
                        Level4Data.ToList().ForEach(data => data.TJCFinding = string.Empty);
                    }

                    jr = Json(Level4Data, JsonRequestBehavior.AllowGet);
                    break;
                }

                case (int)WebConstants.CorporateSummaryLevels.Level5_EPDetails:
                {
                    List <CorpStandardFinding> Level5Data = new List <CorpStandardFinding>();
                    Level5Data = CorporateFinding.GetCorpFindingByStandard(search);
                    jr         = Json(Level5Data, JsonRequestBehavior.AllowGet);
                    break;
                }
                }

                jr.MaxJsonLength  = Int32.MaxValue;
                jr.RecursionLimit = 100;
                return(jr);
            }
            catch (Exception ex)
            {
                ExceptionLog exceptionLog = new ExceptionLog
                {
                    ExceptionText = "Reports: " + ex.Message,
                    PageName      = "CorporatePriorityFinding",
                    MethodName    = "AMPCorporateSummaryCorporateReport_Data",
                    UserID        = Convert.ToInt32(AppSession.UserID),
                    SiteId        = Convert.ToInt32(AppSession.SelectedSiteId),
                    TransSQL      = "",
                    HttpReferrer  = null
                };
                exceptionService.LogException(exceptionLog);

                return(RedirectToAction("Error", "Transfer"));
            }
        }
예제 #2
0
        public byte[] CorporateReportRDLC(SearchCorporateER search, int reportType, string SortBy = "", string SortOrder = "")
        {
            byte[] fileContents    = null;
            string reportDateTitle = "";

            string   rdlcName       = String.Empty;
            string   dsName         = String.Empty;
            string   reportSubTitle = String.Empty;
            string   stdDetail      = string.Empty;
            DataView dv             = null;

            ReportParameterCollection reportParameterCollection = null;

            try
            {
                //Mock Survey Status Parameter. Corporate Reports displays data after Mock Survey Recommendations are approved.
                search.MockSurveyStatusID = (int)MockSurveyStatus.Publish_CCA_Recommendation;

                if (AppSession.ReportScheduleID > 0 && search.ReportTitle != null)
                {
                    search.ReportTitle = String.Concat(search.ReportTitle, " - Report ID: ", AppSession.ReportScheduleID);
                }
                else
                {
                    search.ReportTitle = WebConstants.CORP_REPORT_TITLE_FINDING_REPORT;
                }
                reportDateTitle = CommonService.InitializeReportDateTitle("Observation", search.StartDate, search.EndDate);
                search.EndDate  = (search.EndDate != null && search.EndDate.ToString() != "") ? search.EndDate.Value.Date.AddHours(23).AddMinutes(29).AddSeconds(59) : search.EndDate;

                // Setup ReportViewer
                ReportViewer reportViewer = new ReportViewer();
                reportViewer.ProcessingMode          = ProcessingMode.Local;
                reportViewer.SizeToReportContent     = true;
                reportViewer.LocalReport.DisplayName = search.ReportTitle;

                // LevelIdentifier references the specific RDLC report requested
                switch (search.LevelIdentifier)
                {
                case (int)WebConstants.CorporateSummaryLevels.Level1_Program:
                default:
                {
                    rdlcName       = "rptReportCorporateFindingsByProgram.rdlc";
                    dsName         = "dsReport_CorporateFindingsByProgram";
                    dv             = new DataView(CorporateFinding.GetCorpFindingByProgram(search).ToDataTable());
                    reportSubTitle = "Findings by Program";
                    //stdDetail = "*This graph represents 100% of the total findings for selected sites and criteria.";
                    stdDetail = "  ";
                    break;
                }

                case (int)WebConstants.CorporateSummaryLevels.Level2_Chapter:
                {
                    rdlcName       = "rptReportCorporateFindingsPareto.rdlc";
                    dsName         = "dsReport_CorporateFindingsPareto";
                    dv             = new DataView(CorporateFinding.GetCorpFindingByChapter(search).ToDataTable());
                    reportSubTitle = "Findings by Chapter";
                    //  stdDetail = "*This graph represents 100% of the total findings for selected sites and criteria.";
                    stdDetail = "  ";
                    break;
                }

                case (int)WebConstants.CorporateSummaryLevels.Level3_Standard:
                {
                    rdlcName       = "rptReportCorporateFindingsPareto.rdlc";
                    dsName         = "dsReport_CorporateFindingsPareto";
                    dv             = new DataView(CorporateFinding.GetCorpFindingByStandard(search).ToDataTable());
                    reportSubTitle = "Findings by Standard";
                    stdDetail      = "*This graph represents " + HttpContext.Current.Session["MaxStandardCount"] + "% of the total findings for selected sites and criteria.";
                    break;
                }
                }

                // Setup Report Parmaeters common to all reports
                ReportParameter p1  = new ReportParameter("ReportTitle", search.ReportTitle.ToString());
                ReportParameter p2  = new ReportParameter("Programs", search.ProgramNames.ToString());
                ReportParameter p3  = new ReportParameter("Chapters", search.SelectedChapterNames.ToString());
                ReportParameter p4  = new ReportParameter("Standards", search.SelectedStandardNames.ToString());
                ReportParameter p5  = new ReportParameter("ReportDateTitle", reportDateTitle.ToString());
                ReportParameter p6  = new ReportParameter("HCOID", search.SelectedSiteHCOIDs.ToString());
                ReportParameter p7  = new ReportParameter("MockSurvey", search.SelectedMockSurveyNames.ToString());
                ReportParameter p8  = new ReportParameter("ParticipatedTeamLead", search.SelectedMockSurveyLeadNames.ToString());
                ReportParameter p9  = new ReportParameter("ParticipatedTeamMembers", search.SelectedMockSurveyMemberNames.ToString());
                ReportParameter p10 = new ReportParameter("Copyright", "© " + DateTime.Now.Year.ToString() + WebConstants.Copyright.ToString());
                ReportParameter p11 = new ReportParameter("ReportType", search.ReportType.ToString());
                ReportParameter p12 = new ReportParameter("ReportSubTitle", reportSubTitle.ToString());
                ReportParameter p13 = new ReportParameter("FSA", search.IncludeFsa ? "1" : "0");
                ReportParameter p14 = new ReportParameter("RFI", search.IncludeRFI ? "1" : "0");
                if (search.LevelIdentifier != (int)WebConstants.CorporateSummaryLevels.Level1_Program)
                {
                    ReportParameter p15 = new ReportParameter("StandardDetail", stdDetail);
                    reportParameterCollection = new ReportParameterCollection {
                        p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15
                    };
                }
                else
                {
                    reportParameterCollection = new ReportParameterCollection {
                        p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14
                    }
                };


                if (SortBy != "")
                {
                    dv.Sort = SortBy + " " + SortOrder;
                }
                // Setup Data sources for report
                reportViewer.LocalReport.DataSources.Clear();
                reportViewer.LocalReport.ReportPath = HttpContext.Current.Request.MapPath(HttpContext.Current.Request.ApplicationPath) + @"Areas\Corporate\Reports\" + rdlcName.ToString();
                reportViewer.LocalReport.DataSources.Add(new ReportDataSource(dsName, dv));

                reportViewer.LocalReport.SetParameters(reportParameterCollection);
                Warning[] warnings;
                string[]  streamIds;
                string    mimeType  = string.Empty;
                string    encoding  = string.Empty;
                string    extension = string.Empty;

                string format = WebConstants.REPORT_FORMAT_PDF;      // PDF is default
                if (reportType == (int)WebConstants.ReportFormat.EXCEL)
                {
                    format = WebConstants.REPORT_FORMAT_EXCEL;        // If Excel option chosen
                }
                fileContents = reportViewer.LocalReport.Render(format, null, out mimeType, out encoding, out extension, out streamIds, out warnings);
            }
            catch (Exception ex)
            {
                ExceptionLog exceptionLog = new ExceptionLog
                {
                    ExceptionText = "Reports: " + ex.Message,
                    PageName      = "CorporateReportRDLC",
                    MethodName    = "CorporateReportRDLC",
                    UserID        = Convert.ToInt32(AppSession.UserID),
                    SiteId        = Convert.ToInt32(AppSession.SelectedSiteId),
                    TransSQL      = "",
                    HttpReferrer  = null
                };
                _exceptionService.LogException(exceptionLog);
            }

            return(fileContents);
        }