示例#1
0
        public CrcReportDefinition GetReportDefn(string reportPath, string username)
        {
            // first, use the username to get description
            var reportCat = this.GetReportCatalogItem(reportPath, username);

            ReportingService2005Soap   rService = m_ssrsSoapClientFactory.MakeSsrsSoapClient();
            GetReportParametersRequest req      = new GetReportParametersRequest()
            {
                Report       = reportPath,
                ForRendering = true
            };
            var resp = rService.GetReportParameters(req);

            var factory = new CrcReportDefinitionFactory();

            return(factory.Create(reportPath, reportCat, resp.Parameters, m_extraConfiguration));
        }
示例#2
0
        /// <summary>
        /// Applies the specified choices to the already-existing report definition
        /// and updates the dependant parameters
        /// </summary>
        public void RefreshDependantParameters(CrcReportDefinition repDefn, CrcParameterChoiceCollection newChoices)
        {
            var mapResult = repDefn.MapParameterChoices(newChoices);

            if (!mapResult.MappingValid)
            {
                // todo - friendlier message back to ui
                throw new ApplicationException(string.Format("invalid params - could not map supplied values to definitions for report {0}. complaints: {1}",
                                                             repDefn.DisplayName, string.Join(", ", mapResult.Complaints.ToArray())));
            }
            var conv = new CrcParameterConverter();
            List <ParameterValue> valueList = conv.GetParametersValuesForSsrsWebService(repDefn);
            // get new params from web service
            ReportingService2005Soap rService = m_ssrsSoapClientFactory.MakeSsrsSoapClient();

            logger.DebugFormat("RefreshDependantParameters: rep {0} calling WS to get new validvalid. Passing {1} values", repDefn.DisplayName, valueList.Count());

            var grpRequest  = new GetReportParametersRequest(repDefn.ReportPath, null, true, valueList.ToArray(), null);
            var grpResponse = rService.GetReportParameters(grpRequest);

            // work out which params to refresh
            List <string> paramsToRefresh = new List <string>();

            foreach (string updatedParam in newChoices.ParameterChoiceList.Select(p => p.Name))
            {
                var paramDefn = repDefn.ParameterDefinitions.First(p => p.Name == updatedParam);
                paramsToRefresh = paramsToRefresh.Union(paramDefn.DependantParameterNames).ToList();
            }
            logger.DebugFormat("RefreshDependantParameters: rep {0} based on choices, have {1} parameters that need refreshing", repDefn.DisplayName, paramsToRefresh.Count());

            var refresher = new CrcParameterRefresher();

            foreach (string paramLoop in paramsToRefresh)
            {
                var paramDefn          = repDefn.ParameterDefinitions.First(p => p.Name == paramLoop);
                var latestParamDetails = grpResponse.Parameters.FirstOrDefault(p => p.Name == paramLoop);
                if (latestParamDetails == null)
                {
                    throw new ApplicationException(String.Format("Was expecting web service to return new details for parameter {0} but none found",
                                                                 paramLoop));
                }
                refresher.RefreshParameter(paramDefn, latestParamDetails);
            }
        }