Quartz.net Windows服务不执行引用SSRS Web服务的作业

时间:2016-03-12 14:09:36

标签: reporting-services tcp windows-services quartz-scheduler quartz.net

我使用ssrs报告执行服务的两个Web引用来生成报告。我使用quartz.net Windows服务来安排ssrs报告。当我使用StdSchedulerFactory.GetDefaultScheduler()时,我的Windows服务正在工作,但是当我在Quartz服务中远程执行我的工作并使用GetScheduler()时,它无效。

public void Execute(IJobExecutionContext context)
{


        RS2005.ReportingService2005 rs;
        RE2005.ReportExecutionService rsExec;



        // Create a new proxy to the web service
        rs = new RS2005.ReportingService2005();
        rsExec = new RE2005.ReportExecutionService();

        // Authenticate to the Web service using Windows credentials
        rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
        rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;

        rs.Url = "http://127.0.0.1:7001/ReportServer/reportservice2005.asmx";
        rsExec.Url = "http://127.0.0.1:7001/ReportServer/reportexecution2005.asmx";

        string historyID = null;
        string deviceInfo = null;
        string format = "PDF";
        Byte[] results;
        string encoding = String.Empty;
        string mimeType = String.Empty;
        string extension = String.Empty;
        RE2005.Warning[] warnings = null;
        string[] streamIDs = null;

        // Path of the Report - XLS, PDF etc.
        string fileName = "samplereport.pdf";
        // Name of the report - Please note this is not the RDL file.
        string _reportName = @"/reports_Debug/reportname";
        string _historyID = null;
        bool _forRendering = false;
        RS2005.ParameterValue[] _values = null;
        RS2005.DataSourceCredentials[] _credentials = null;
        RS2005.ReportParameter[] _parameters = null;

        try
        {
            _parameters = rs.GetReportParameters(_reportName, _historyID, _forRendering, _values, _credentials);
            RE2005.ExecutionInfo ei = rsExec.LoadReport(_reportName, historyID);
            RE2005.ParameterValue[] parameters = new RE2005.ParameterValue[8];

            if (_parameters.Length > 0)
            {

                parameters[0] = new RE2005.ParameterValue();
                parameters[0].Name = "FromDate";
                parameters[0].Value = "1/1/2016";
                parameters[1] = new RE2005.ParameterValue();
                parameters[1].Name = "ToDate";
                parameters[1].Value = "1/21/2016"; // June

            }
            rsExec.SetExecutionParameters(parameters, "en-us");

            results = rsExec.Render(format, deviceInfo,
                      out extension, out encoding,
                      out mimeType, out warnings, out streamIDs);

            using (FileStream stream = File.OpenWrite(fileName))
            {
                stream.Write(results, 0, results.Length);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
}

0 个答案:

没有答案