In my window service when I run window service from manage ,ScheduledService.txt file does not contain "Get Connection". I think there is problem in GetConnectionOfReportServer, it may it take more time.
When I debug it is working fine.
I debug the code problem is in "this.reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote" in GetConnectionOfReportServer(),after this line control does not go ahead.
My code is
protected override void OnStart(string[] args)
{
TraceService("start service");
timer = new System.Timers.Timer(1000);
timer.Elapsed += new ElapsedEventHandler(OnElapsedTime);
timer.Interval = 90000;
timer.Enabled = true;
}
protected override void OnStop()
{
TraceService("stopping service");
}
private void OnElapsedTime(object source, ElapsedEventArgs e)
{
time_elapsed();
TraceService("Another entry at " + DateTime.Now);
}
private void time_elapsed()
{
TraceService("Call susseccfully");
GetConnectionOfReportServer();
TraceService("Get Connection");
DailyReportFile = getReportFrmServer(reportName, param);
}
public void GetConnectionOfReportServer()
{
TraceService("I am in GetConnectionOfReportServer.");
try
{
TraceService("I am in Try.");
NetworkCredential credential = new NetworkCredential("administrator", "epass@123");
this.reportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials = credential;
TraceService("I am in Try end");
this.reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote;
TraceService("I am in Try ProcessingMode.Remote");
this.reportViewer1.ServerReport.ReportServerUrl = new Uri(@"http://xxx.xxx.xxx.xxx/ReportServer");
TraceService("I am in Try end");
}
catch (Exception ex)
{
}
}
private void TraceService(string content)
{
FileStream fs = new FileStream(@"c:\ScheduledService.txt", FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.BaseStream.Seek(0, SeekOrigin.End);
sw.WriteLine(content);
sw.Flush();
sw.Close();
}
In ScheduledService.txt file
start service
Call susseccfully
I am in GetConnectionOfReportServer.
I am in Try.
I am in Try end
Call susseccfully
I am in GetConnectionOfReportServer.
I am in Try.
I am in Try end