Beispiel #1
0
        private void FindReportForReport(Guid id, ModuleType moduleType)
        {
            var reportInfo      = _reportQueryService.GetReportInfo(id);
            var templateDetails = GetTemplateDetails(reportInfo.TemplateId);

            switch (moduleType)
            {
            case ModuleType.Arrest:
                _arrestReportBuilder.GetValue(id, reportInfo.IsSupplement ? RelatedToType.SupplementalReport.GetDescription() : RelatedToType.InitialReport.GetDescription(), templateDetails, _reportDetails);
                break;

            case ModuleType.Incident:
                _incidentReportBuilder.GetValue(id, reportInfo.IsSupplement ? RelatedToType.SupplementalReport.GetDescription() : RelatedToType.InitialReport.GetDescription(), templateDetails, _reportDetails);
                break;

            case ModuleType.FieldInterview:
                _fieldInterviewReportBuilder.GetValue(id, reportInfo.IsSupplement ? RelatedToType.SupplementalReport.GetDescription() : RelatedToType.InitialReport.GetDescription(), templateDetails, _reportDetails);
                break;

            case ModuleType.CallForService:
                _callforserviceReportBuilder.GetValue(id, reportInfo.IsSupplement ? RelatedToType.SupplementalReport.GetDescription() : RelatedToType.InitialReport.GetDescription(), templateDetails, _reportDetails);
                break;

            case ModuleType.OtherEvent:
                _otherEventBuilder.GetValue(id, reportInfo.IsSupplement ? RelatedToType.SupplementalReport.GetDescription() : RelatedToType.InitialReport.GetDescription(), templateDetails, _reportDetails);
                break;

            case ModuleType.Citation:
                _citationReportBuilder.GetValue(id, reportInfo.IsSupplement ? RelatedToType.SupplementalReport.GetDescription() : RelatedToType.InitialReport.GetDescription(), templateDetails, _reportDetails);
                break;
            }

            //add workflow status information for report
            _reportDetails.Datas.Add(new Data
            {
                Label           = "ReportWorkflowStatus",
                SectionCount    = 1,
                SectionGroup    = "Header",
                SectionSubGroup = string.Empty,
                FieldPath       = string.Empty,
                Value           = Convert.ToString(reportInfo.State)
            });
        }
        private void RenderReportViewer(Guid id, RelatedToType relatedType, ModuleType moduleType)
        {
            _log.Debug("Rendering [{0}] [{1}] Viewer...", relatedType.GetDescription(), moduleType.GetDescription());
            try
            {
                var  isDraft = false;
                var  reportNumber = string.Empty;
                var  templateQueryService = DependencyContainer.Resolve <ITemplateQueryService>();
                Guid agencyId, templateId;

                if (relatedType != RelatedToType.Summary)
                {
                    using (var iocService = DependencyContainer.Resolve <IReportQueryService>())
                    {
                        //get workflow status detail
                        _reportQueryService = iocService.Instance;
                        var reportsInfo = _reportQueryService.GetReportInfo(id);
                        isDraft    = reportsInfo.State != ReportState.Complete;
                        agencyId   = reportsInfo.Agency.AgencyId;
                        templateId = reportsInfo.TemplateId;
                        if (!reportsInfo.WorkflowRights.CanView && !UserHasAccessRights(reportsInfo.Agency.AgencyId, moduleType))
                        {
                            ReportViewer1.Visible  = false;
                            AccessDisabled.Visible = true;
                            Response.Redirect("~/#/error");
                            return;
                        }
                        reportNumber = reportsInfo.Number;
                    }
                }
                else
                {
                    //get reportnumber for selected summary record
                    using (var iocSummaryService = DependencyContainer.Resolve <ISummaryQueryService>())
                    {
                        //get workflow status detail
                        _summaryQueryService = iocSummaryService.Instance;
                        var summaryInfo = _summaryQueryService.GetSummaryInfo(id);
                        agencyId   = summaryInfo.Agency.AgencyId;
                        templateId = templateQueryService.Instance.GetDefaultTemplate(summaryInfo.Agency.AgencyId, moduleType).Id;

                        if (!UserHasAccessRights(summaryInfo.Agency.AgencyId, moduleType))
                        {
                            ReportViewer1.Visible  = false;
                            AccessDisabled.Visible = true;
                            Response.Redirect("~/#/error");
                            return;
                        }
                        reportNumber = summaryInfo.Number;
                    }
                }

                AccessDisabled.Visible = false;

                var reportServerUri = String.Format("http://{0}/ReportServer",
                                                    ConfigurationManager.AppSettings["ReportServer"]);
                var reportPath = String.Format("/{0}",
                                               ConfigurationManager.AppSettings["ReportRootPath"]);
                ReportViewer1.ServerReport.ReportPath      = reportPath;
                ReportViewer1.ServerReport.ReportServerUrl = new Uri(reportServerUri);
                ReportViewer1.ShowParameterPrompts         = false;
                ReportViewer1.ShowFindControls             = false;
                ReportViewer1.ShowExportControls           = true;
                ReportViewer1.ShowToolBar = true;

                int validity;
                var result = Int32.TryParse(ConfigurationManager.AppSettings["SSRSTokenTimeout"], out validity);
                if (!result)
                {
                    validity = 5;
                }

                var headerText = templateQueryService.Instance.GetTemplateHeaderText(moduleType, reportNumber, agencyId, templateId);

                var svcQuery = String.Format("{0}",
                                             ConfigurationManager.AppSettings["SSRSServiceHost"]) +
                               "api/ssrsreports/getreportsdata/"
                               + id.ToString()
                               + "/" + moduleType.ToString()
                               + "/" + relatedType.ToString() + "?wsSignInKey=" + new JwtTokenGenerator(TokenManagerFactory.GetTokenManager()).GenerateJwtToken(System.Web.HttpContext.Current.User.Identity as ClaimsIdentity, validity);
                var reportParameters = new List <ReportParameter>
                {
                    new ReportParameter("svcQuery", svcQuery),
                    new ReportParameter("isDraft", isDraft.ToString()),
                    new ReportParameter("imageDataSource", ConfigurationManager.ConnectionStrings["InformRMSMediaSSRS"].ConnectionString),
                    new ReportParameter("headerText", headerText)
                };

                _log.Debug("SSRS URI: {0}", reportServerUri);
                reportParameters.ForEach(p =>
                {
                    foreach (var value in p.Values)
                    {
                        _log.Debug("SSRS Parameter {0} = {1}", p.Name, value);
                    }
                });

                ReportViewer1.ServerReport.SetParameters(reportParameters);
                ReportViewer1.ServerReport.Refresh();
            }
            catch (Exception ex)
            {
                _log.Error("Failure to render SSRS Report {0}", ex);
            }
        }
Beispiel #3
0
 public ReportInfo GetInfo(Guid id)
 {
     return(_reportQueryService.GetReportInfo(id));
 }