我们使用优秀的RSBuild批量上传报告到SQL Server Reporting Services(SSRS),但我发现无法批量上传图片。使用报表管理器一次上传一张图片很愚蠢。困难在于RSBuild使用的SQL Server报告Web服务不支持图像上载。有没有办法以其他方式批量上传图像到SSRS?
答案 0 :(得分:1)
您需要先手动上传一个图像,以便读取它在ReportServer数据库中插入的图像行的Catalog表内容,并在以下脚本中使用ParentId,PolicyId和CreatedById以及ModifiedById。
当然,这可以进一步抽象到应用程序中,并且更加精彩。
BEGIN TRAN
DECLARE @ReportFolderPath NVARCHAR(MAX)
DECLARE @ImageFolderPath NVARCHAR(MAX)
DECLARE @ImageFileName NVARCHAR(MAX)
DECLARE @ImageFullFileName NVARCHAR(MAX)
DECLARE @ImageFileExtension NVARCHAR(MAX)
DECLARE @ImageMime NVARCHAR(MAX)
DECLARE @ImageFullPath NVARCHAR(MAX)
DECLARE @ParentId NVARCHAR(MAX)
DECLARE @PolicyId NVARCHAR(MAX)
DECLARE @CreatedModifiedId NVARCHAR(MAX)
DECLARE @SqlToGetImageContent NVARCHAR(MAX)
DECLARE @ImageContent VARBINARY(MAX)
SET @ReportFolderPath = '/MyReports/'
SET @ImageFolderPath = 'C:\Users\jdoe\Desktop\Reports\images\'
SET @ImageFileName = 'logo'
SET @ImageFileExtension = 'bmp'
SET @ImageFullFileName = @ImageFileName + '.' + @ImageFileExtension
SET @ImageFullPath = @ImageFolderPath + @ImageFileName
SET @ParentId = '0AAFF0D8-0616-4E63-9B1D-EBF99153B443'
SET @PolicyId = '8632B07A-EE75-4097-970C-18BE9958F7A2'
SET @CreatedModifiedId = 'C6121121-D0E4-4B25-BD4E-177EDA709ECB'
SET @SqlToGetImageContent = 'SELECT @ImageContent = BulkColumn FROM Openrowset(Bulk '''+ @ImageFolderPath + @ImageFullFileName +''', Single_Blob) AS ImageData'
IF(@ImageFileExtension = 'jpg')
BEGIN
SET @ImageMime = 'image/jpeg'
END
ELSE
BEGIN
SET @ImageMime = 'image/' + @ImageFileExtension
END
EXEC SP_EXECUTESQL
@Query = @SqlToGetImageContent
, @Params = N'@ImageContent VARBINARY(MAX) OUTPUT'
, @ImageContent = @ImageContent OUTPUT
INSERT INTO [ReportServer$DEV2012].[dbo].[Catalog] (ItemID, [Path], Name, ParentID, [Type], Content, [Intermediate], SnapshotDataID, LinkSourceID, Property, [Description], Hidden, CreatedByID, CreationDate, ModifiedByID, ModifiedDate, MimeType, SnapshotLimit, Parameter, PolicyID, PolicyRoot, ExecutionFlag, ExecutionTime, SubType, ComponentID)
VALUES(
NEWID(),
@ReportFolderPath + @ImageFullFileName,
@ImageFullFileName,
@ParentId,
3,
(SELECT @ImageContent),
NULL,
NULL,
NULL,
'<Properties />',
NULL,
0,
@CreatedModifiedId,
GETDATE(),
@CreatedModifiedId,
GETDATE(),
@ImageMime,
NULL,
NULL,
@PolicyId,
0,
1,
NULL,
NULL,
NULL
)
COMMIT TRAN
答案 1 :(得分:1)
要在SSRS解决方案中加载多个图像,我使用了以下方法。这很容易 首先,在报表管理器中创建要在报表中链接外部图像的新图像文件夹
导航到“Debug”菜单并选择Solution Properties,如此处所示 Solution Properties
暂时更改TargetReportFolder以匹配您在报表管理器中创建的新图像文件夹的名称
验证Visual Studio中的部署是否成功,然后导航到Report Manager文件夹并验证图像是否存在!
请勿忘记:将TargetReportFolder重置为之前的值!