public static void SaveReport(string fileName, string _reportName, RE2005.ParameterValue[] para) { 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://spm-sql/reportserver/reportservice2005.asmx"; rsExec.Url = "http://spm-sql/reportserver/reportexecution2005.asmx"; const string historyID = null; const string deviceInfo = null; const string format = "PDF"; Byte[] results; const string _historyID = null; const bool _forRendering = false; RS2005.ParameterValue[] _values = null; RS2005.DataSourceCredentials[] _credentials = null; try { RS2005.ReportParameter[] _parameters = rs.GetReportParameters(_reportName, _historyID, _forRendering, _values, _credentials); RE2005.ExecutionInfo ei = rsExec.LoadReport(_reportName, historyID); RE2005.ParameterValue[] parameters = para; rsExec.SetExecutionParameters(parameters, "en-us"); results = rsExec.Render(format, deviceInfo, out string extension, out string encoding, out string mimeType, out RE2005.Warning[] warnings, out string[] streamIDs); try { File.WriteAllBytes(fileName, results); } catch (Exception e) { Debug.Print(e.Message); //MessageBox.Show(e.Message, "SPM Connect - Save Report", MessageBoxButtons.OK); } } catch (Exception ex) { Debug.Print(ex.Message); //throw ex; } }
private void getDefaultParameters() { RS2005.ReportingService2005 rs = new RS2005.ReportingService2005(); rs.UseDefaultCredentials = true; rs.Url = Properties.Settings.Default.RS2005_ReportingService2005; string encoding = String.Empty; string mimeType = String.Empty; string extension = String.Empty; RS2005.DataSourceCredentials dataSourceCredentials2 = new RS2005.DataSourceCredentials(); dataSourceCredentials2.DataSourceName = Properties.Settings.Default.DataSourceName; dataSourceCredentials2.UserName = Properties.Settings.Default.GenevaUser; dataSourceCredentials2.Password = Properties.Settings.Default.GenevaPass; RS2005.DataSourceCredentials[] _credentials = new RS2005.DataSourceCredentials[] { dataSourceCredentials2 }; RS2005.ReportParameter[] reportParameters = null; try { reportParameters = rs.GetReportParameters(@"/GenevaReports/" + this.Name, null, false, null, _credentials); foreach (var param in reportParameters) { if (param.DefaultValues != null && param.DefaultValues[0] != null && param.PromptUser) { this.AddParameters(param.Name, param.DefaultValues[0].ToString()); } } } catch (Exception ex) { throw ex; } }
private async Task SaveReport(string invoiceno, string fileName, string paymenttype) { 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://spm-sql/reportserver/reportservice2005.asmx"; rsExec.Url = "http://spm-sql/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; string _reportName = @"/GeniusReports/Accounting/SPM_EFT"; 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[2]; if (_parameters.Length > 0) { parameters[0] = new RE2005.ParameterValue { //parameters[0].Label = ""; Name = "pCode", Value = invoiceno }; parameters[1] = new RE2005.ParameterValue { //parameters[0].Label = ""; Name = "pTransNo", Value = paymenttype }; } rsExec.SetExecutionParameters(parameters, "en-us"); results = rsExec.Render(format, deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs); try { File.WriteAllBytes(fileName, results); } catch (Exception e) { Debug.Print(e.Message); //MessageBox.Show(e.Message, "SPM Connect - Save Report", MessageBoxButtons.OK); } } catch (Exception ex) { Debug.Print(ex.Message); //throw ex; } finally { } }
public void SaveReport(string invoiceno, string fileName) { 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://spm-sql/reportserver/reportservice2005.asmx"; rsExec.Url = "http://spm-sql/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; string _reportName = @"/GeniusReports/Job/SPM_ServiceReport"; 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[1]; if (_parameters.Length > 0) { parameters[0] = new RE2005.ParameterValue { //parameters[0].Label = ""; Name = "ReqNumber", Value = invoiceno }; } rsExec.SetExecutionParameters(parameters, "en-us"); results = rsExec.Render(format, deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs); try { File.WriteAllBytes(fileName, results); } catch (Exception e) { Debug.Print(e.Message); //MessageBox.Show(e.Message, "SPM Connect - Save Report", MessageBoxButtons.OK); } } catch (Exception ex) { throw ex; } finally { } Console.WriteLine("Report Creation completed successfully"); Console.WriteLine("Sending email out"); SendEmail("*****@*****.**", "New Service Report " + invoiceno, invoiceno, fileName); }