2

我们有一个基于 silverlight 的定制应用程序,用于管理我们的报告订阅。问题是,每当您添加新订阅时,它会将 Subscriptions 表中的 Locale 值设置为“en-US”。

当您直接在报表管理器中创建订阅时,Locale 字段中的值由您的浏览器语言设置决定(这正是我们想要实现的)。

在调用 CreateSubscription 方法之前,我们找不到设置 Locale 字段的方法,因为它似乎不接受 Locale 参数,并且默认为 en-US (我认为这是服务器设置)。

在 SSRS 中创建订阅时,您知道设置语言环境的任何方法吗?

4

2 回答 2

1

据我所知,没有办法做到这一点;我一直在通过 C# 使用该服务。

我决定通过服务获取报告的语言/区域设置,然后直接在 ReportServer 数据库中进行更改,作为UPDATESubscriptionID 上的声明。

要获取报告的语言/区域设置,我使用以下内容:

private static void Main()
{
    ReportingService2010 service = new ReportingService2010();

    service.Url = "URL of service";
    service.Credentials = System.Net.CredentialCache.DefaultCredentials;

    string reportItemPath = "Path of report";

    string language = GetReportPropertyValue(service, reportItemPath, "Language", "en-GB");

    // Create the subscription, then update the database using the returned SubscriptionID.
}

private static string GetReportPropertyValue(ReportingService2010 service, string itemPath, string propertyName, string defaultValue)
{
    Property[] properties = service.GetProperties(itemPath, null);

    if (properties.Any(p => p.Name == propertyName))
        return properties.First(p => p.Name == propertyName).Value;
    else
        return defaultValue;
}
于 2019-03-27T10:38:34.397 回答
0

我还没有通过 SOAP API 尝试过,但不应该可以设置 Accept-Language 标头吗?我在以不同语言呈现报告时这样做。每个报告的语言设置为=User!Language。使用 WCF 访问报表服务时,可以这样做(例如 VB.NET)

Using oReportingService As New ReportingService2010SoapClient
    oReportingService.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation

    Using oScope As OperationContextScope = New OperationContextScope(oReportingService.InnerChannel)
      If i_oSubscription.Language IsNot Nothing Then
        ' Accept-Language
        Dim oHttpRequestProperty As New HttpRequestMessageProperty
        oHttpRequestProperty.Headers.Add(HttpRequestHeader.AcceptLanguage, i_oSubscription.Language)
        OperationContext.Current.OutgoingMessageProperties(HttpRequestMessageProperty.Name) = oHttpRequestProperty
      End If

      oReportingService.CreateSubscription(New ReportingService2010.TrustedUserHeader(), i_oSubscription.Path, oExtensionSettings, i_oSubscription.Description, "TimedSubscription", sMatchData, lstParameters.ToArray(), sSubscriptionId)

      Return sSubscriptionId
    End Using
  End Using

编辑:这是我自己做的方式,它似乎工作:)

i_oSubscription只是一个简单的容器,其属性如下Description

注意:这似乎在大多数情况下都有效。但是,MonthlyRecurrence 中的“天”字段的格式取决于区域设置(请参阅:https ://stackoverflow.com/questions/16011008/ssrs-monthlyrecurrence-formatting-for-different-languages )

于 2013-04-15T07:09:42.853 回答