예제 #1
0
        /// <summary>
        /// Require Create permission for the module in the agency to continue execution.
        /// </summary>
        public void RequireCreatePermissions(IdentityContext identity, Guid agencyId, ModuleType moduleType)
        {
            if (identity.Permissions.DataEntryCreateGranted(agencyId, moduleType))
            {
                return;
            }

            Unauthorized(identity, "Insufficient permissions to Create " + moduleType.GetDescription());
        }
예제 #2
0
 private bool UserHasAccessRights(Guid agencyId, ModuleType moduleType)
 {
     _log.Debug("Checking User Rights...");
     using (var iocUserService = DependencyContainer.Resolve <IUserQueryService>())
     {
         var identity      = iocUserService.Instance.GetIdentityContext();
         var accessGranted = identity.Permissions.DataEntryViewGranted(agencyId, moduleType);
         _log.Debug("View Access to Module " + moduleType.GetDescription() + (accessGranted ? " Granted" : " Denied") + " for " + identity.GivenName);
         return(accessGranted);
     }
 }
예제 #3
0
 /// <summary>
 /// Returns the name of the DataEntryContract based on the Module Type and the DefaultNamingConvention.
 /// </summary>
 public static string GetContractNameForModule(ModuleType module)
 {
     return(string.Format(DefaultNamingConvention, module.GetDescription()));
 }
예제 #4
0
        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);
            }
        }