SSRS CreateSubscription - 设置区域设置

问题描述 投票:1回答:2

我们有一个基于silverlight的自定义构建应用程序,它管理我们的报告订阅。问题是,无论何时添加新订阅,它都会将“订阅”表中的“区域设置”值设置为“en-US”。

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

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

您是否知道在SSRS中创建订阅时设置Locale的任何方法?

ssrs-2008 reporting-services
2个回答
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中的“Days”字段将依赖于区域设置(请参阅:https://stackoverflow.com/questions/16011008/ssrs-monthlyrecurrence-formatting-for-different-languages


0
投票

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

我决定通过服务获取报告语言/语言环境的解决方案,然后直接在ReportServer数据库中进行更改,作为SubscriptionID上的UPDATE语句。

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

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;
}
© www.soinside.com 2019 - 2024. All rights reserved.