我能够通过创建自定义 SSRS 程序集来解决这个问题,该程序集生成位图图像并将其作为字节数组返回,然后在图像表达式字段中使用。
如果有人感兴趣,用于根据视频的观看部分生成图像的部分 C# 代码如下:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace SSRSExtensions
{
public class ReportFunctions
{
public static Byte[] GetViewingRangeImage(String ranges, String imageFormatString, Single width, Single height, String backgroundColor, String foregroundColor, String separatorColor)
{
Byte[] retValue = null;
ImageFormat imageFormat = GetImageFormat(imageFormatString);
if (imageFormat != null)
{
ImageCodecInfo imageCodec = GetImageEncoderInfo(imageFormat);
Bitmap bitmap = GetViewingRangeImageBitmap(ranges, width, height, backgroundColor, foregroundColor, separatorColor);
using (EncoderParameters encoderParameters = new EncoderParameters(1))
{
using (EncoderParameter encoderParameter = new EncoderParameter(Encoder.Quality, 100L))
{
encoderParameters.Param[0] = encoderParameter;
using (MemoryStream memoryStream = new MemoryStream())
{
bitmap.Save(memoryStream, imageFormat);
retValue = memoryStream.ToArray();
}
}
}
}
return retValue;
}
}
}
图像表达式为:=SSRSExtensions.ReportFunctions.GetViewingRangeImage(Fields!ViewingRange.Value, "PNG", 200, 25, "White", "#808080", "#bfbfbf")
实际范围以逗号分隔的字符串指定,如下所示:
0.000000-10.000000,20.000000-50.000000,90.000000-100.000000.,用户先观看 10%,跳到 20%,观看到 50%,然后跳到 90%,然后终于看完了。
这篇较早的博文 (https://blog.oraylis.de/2012/04/ssrs-custom-drawing-code/) 讨论了如何绘制动态图像并在报告中使用它们。它使用内联VB。如果您想使用 C#,您必须创建一个外部程序集,将其复制到 C:\Program Files\Microsoft SQL Server[SSRS INSTALL FOLDER]\Reporting Services\ReportServer\bin 文件夹并在您的报告中引用它。
如果有人需要有关如何将所有这些都插入 SSRS 报告的更多详细信息,请告诉我,我很乐意提供帮助。