上载SSRS报告会导致数据源需要凭据

时间:2018-05-04 13:32:53

标签: .net reporting-services

我目前有一份报告,其数据源不需要凭据

Datasource doesn't require credentials

我想以编程方式将此报告上传到我的报告服务器,为此,我正在使用ReportingService2010类和以下代码。 https://msdn.microsoft.com/en-us/library/reportservice2010.reportingservice2010_methods.aspx

Dim service As New ReportingService2010()
service.Credentials = System.Net.CredentialCache.DefaultCredentials  
service.Url = _reportServerUrl & "/reportservice2010.asmx?"
service.CreateCatalogItem("Report", reportName, pathinServer, True,
                              fileBytes, Nothing, warnings)

这会上传报告,问题是报告的数据源配置在上传后没有被保留。

Setting was changed from "Do not use credentials" to "Prompt for credentials"

我的问题是为什么会发生这种情况以及解决方法是什么?我找不到以编程方式更改此设置的方法。

1 个答案:

答案 0 :(得分:0)

我发现可以使用Dim sources = service.GetItemDataSources(itemFullPath) For Each dataSource In sources CType(dataSource.Item, DataSourceDefinition).CredentialRetrieval = CredentialRetrievalEnum.None Next service.SetItemDataSources(itemFullPath, sources) 方法更改凭据设置。

DataSourceDefinition

当我第一次检查dataSource项目时,我错过了我必须将其转换为CredentialRetrieval以访问<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <script src="https://d3js.org/d3.v4.min.js"></script> <style type="text/css"> /* Legend Font Style */ body { font: 11px sans-serif; background-color: #ffffff; } /* Legend Position Style */ .legend { position:absolute; left:20px; top:30px; } .axis text { font: 10px sans-serif; } .axis line, .axis path { fill: none; stroke: #000; shape-rendering: crispEdges; } </style> </head> <body> <script type="text/javascript"> //Width and height of map var width = 960; var height = 500; var lowColor = '#f9f9f9' var highColor = '#bc2a66' // D3 Projection var projection = d3.geoAlbersUsa() .translate([width / 2, height / 2]) // translate to center of screen .scale([1000]); // scale things down so see entire US // Define path generator var path = d3.geoPath() // path generator that will convert GeoJSON to SVG paths .projection(projection); // tell path generator to use albersUsa projection //Create SVG element and append map to the SVG var svg = d3.select("body") .append("svg") .attr("width", width) .attr("height", height); // Load in my states data! d3.csv("statesdata.csv", function(data) { var dataArray = []; for (var d = 0; d < data.length; d++) { dataArray.push(parseFloat(data[d].value)) } var minVal = d3.min(dataArray) var maxVal = d3.max(dataArray) var ramp = d3.scaleLinear().domain([minVal,maxVal]).range([lowColor,highColor]) // Load GeoJSON data and merge with states data d3.json("us-states.json", function(json) { // Loop through each state data value in the .csv file for (var i = 0; i < data.length; i++) { // Grab State Name var dataState = data[i].state; // Grab data value var dataValue = data[i].value; // Find the corresponding state inside the GeoJSON for (var j = 0; j < json.features.length; j++) { var jsonState = json.features[j].properties.name; if (dataState == jsonState) { // Copy the data value into the JSON json.features[j].properties.value = dataValue; // Stop looking through the JSON break; } } } // Bind the data to the SVG and create one path per GeoJSON feature svg.selectAll("path") .data(json.features) .enter() .append("path") .attr("d", path) .style("stroke", "#fff") .style("stroke-width", "1") .style("fill", function(d) { return ramp(d.properties.value) }); g.selectAll("text") .data(json.features) .enter() .append("svg:text") .text(function(d){ return d.properties.name; }) .attr("x", function(d){ return path.centroid(d)[0]; }) .attr("y", function(d){ return path.centroid(d)[1]; }) .attr("text-anchor","middle") .attr('font-size','6pt'); // add a legend var w = 140, h = 300; var key = d3.select("body") .append("svg") .attr("width", w) .attr("height", h) .attr("class", "legend"); var legend = key.append("defs") .append("svg:linearGradient") .attr("id", "gradient") .attr("x1", "100%") .attr("y1", "0%") .attr("x2", "100%") .attr("y2", "100%") .attr("spreadMethod", "pad"); legend.append("stop") .attr("offset", "0%") .attr("stop-color", highColor) .attr("stop-opacity", 1); legend.append("stop") .attr("offset", "100%") .attr("stop-color", lowColor) .attr("stop-opacity", 1); key.append("rect") .attr("width", w - 100) .attr("height", h) .style("fill", "url(#gradient)") .attr("transform", "translate(0,10)"); var y = d3.scaleLinear() .range([h, 0]) .domain([minVal, maxVal]); var yAxis = d3.axisRight(y); key.append("g") .attr("class", "y axis") .attr("transform", "translate(41,10)") .call(yAxis) }); }); </script> </body> </html> 属性的事实