LocalReport 方法渲染的线程文化 [英] Culture of thread for method render of LocalReport

查看:27
本文介绍了LocalReport 方法渲染的线程文化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 asp.net 应用程序中使用 localreport 对象.该报告由一组对象提供.所以在报告的渲染中,类的一些属性被调用.

I'm using a localreport object into an asp.net application. This report is fed by an array of object. So on the render of the report, some properties of the classe are called.

Class ClassForReport
{
  string Date
  {
    get{return _aDate.ToshortDateString();}
  }
}

现在渲染的代码和问题:

Now the code for rendering and the problem:

//first of all, I change de culture for taking in account the choice of the user
CultureInfo ci = CultureInfo.CreateSpecificCulture(isoLanguageName_);
Thread.CurrentThread.CurrentCulture = ci;
Thread.CurrentThread.CurrentUICulture = ci; 
//Here, my culture is now: FR-be

MyLocalReport.render(...) // in this method, the property Date above is called. And when debugging I see that the culture is EN !!!

...
//and here, my culture is still Fr-be

所以似乎当调用 render 方法时,它会启动一个线程并采用服务器的文化,而不是进程的文化.

So it seems that when the method render is called, it launch a thread and take the culture of the server and not the culture of the process.

我看到的唯一解决方法是将我的报告更改为包含日期,然后提供文化参数并将我所有报告中的所有日期格式化为给定文化...

The only workarround I see is changing my report to contains a date and then giving a parameter of culture and formating all my date in all my reports to the given culture...

所以我真的希望有一种方法可以告诉报告采用 asp 线程的当前文化,而不是采用其他来自无处的文化.

So I realy hope there is a way to tell the report to take the curent culture of the asp thread and not taking some other culture comming from nowhere.

提前谢谢

推荐答案

In ".rdlc" Designer 在您的 ReportFile 上,在 Language 的 Report 上设置 属性=User!Language".

In ".rdlc" Designer on your ReportFile, set on the Report in Language property "=User!Language".

<Report>
  ... 
  <Language>=User!Language</Language>
  ...
</Report>

然后你的 System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("de-DE");将处理 report.Render(...); 中的值,如日期等.

then your System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("de-DE"); will work on the values in report.Render(...); like dates,etc.

干杯.

这篇关于LocalReport 方法渲染的线程文化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆