public void Dispose() { if (_reportsServerInstance2005 != null) { _reportsServerInstance2005.Dispose(); } if (_reportsServerInstance2006 != null) { _reportsServerInstance2006.Dispose(); } }
public static bool TryCreate(ReportServerInfo reportServer, out IWSWrapper result, out Exception exception) { ReportingService2005 proxy = new ReportingService2005() { Url = reportServer.GetServiceUrl(SERVICE_NAME), Timeout = reportServer.Timeout ?? -1, Credentials = reportServer.CreateCredentials(SERVICE_NAME) }; try { proxy.ListSecureMethods(); result = new WSWrapper2005(proxy); exception = null; return(true); } catch (Exception e) { proxy.Dispose(); result = null; exception = e; return(false); } }
//formatType must be: EXCEL, PDF, WORD, CSV, XML, RTF public static void SaveRDL(string reportName, string formatType, Dictionary <string, string> dictValues, string _fileName, SSRSServer server = SSRSServer.New2016) { // Authenticate to the Web service using Windows credentials var netCredentials = new System.Net.NetworkCredential("<windowsUserName>", "<windowsUserPassword>", "<Domain>"); // Create a new proxy to the web service ReportingService2005 rs = new ReportingService2005() { Credentials = netCredentials }; RE2005.ReportExecutionService rsExec = new RE2005.ReportExecutionService() { Credentials = netCredentials }; if (server == SSRSServer.New2016) { rs.Url = $"http://<server>/reportservice2005.asmx"; rsExec.Url = $"http://<server>/reportexecution2005.asmx"; } else { rs.Url = $"http://<server>/reportservice2005.asmx"; rsExec.Url = $"http://<server>/reportexecution2005.asmx"; } string historyId = null; bool forRendering = false; ParameterValue[] values = null; DataSourceCredentials[] credentials = null; ReportParameter[] _parameters = null; byte[] results; try { _parameters = rs.GetReportParameters(reportName, historyId, forRendering, values, credentials); if (_parameters != null) { foreach (ReportParameter rp in _parameters) { Console.WriteLine("Name: {0}", rp.Name); } } RE2005.ParameterValue[] parameters = new RE2005.ParameterValue[dictValues.Count]; int count = 0; foreach (var item in dictValues) { parameters[count] = new RE2005.ParameterValue(); parameters[count].Label = item.Key; parameters[count].Name = item.Key; parameters[count++].Value = item.Value; } RE2005.ExecutionInfo rpt = rsExec.LoadReport(reportName, null); rsExec.SetExecutionParameters(parameters, "en-us"); //Render variables string deviceInfo = null; string encoding = String.Empty; string mimeType = String.Empty; string extension = String.Empty; RE2005.Warning[] warnings = null; string[] streamIDs = null; string formatType2Pass; switch (formatType) { case "RTF": formatType2Pass = "******"; //And we convert afterwards break; case "DOCX": formatType2Pass = "******"; break; default: formatType2Pass = formatType; break; } results = rsExec.Render( formatType2Pass, deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs); string fileNameExt; switch (formatType) { case "EXCEL": fileNameExt = ".XLSX"; break; case "WORDOPENXML": fileNameExt = ".DOCX"; break; case "WORD": fileNameExt = ".DOC"; break; case "RTF": fileNameExt = ".DOC"; //And we convert afterwards break; case "PDF": default: fileNameExt = "." + formatType; break; } string fileName = (Path.GetExtension(_fileName) == "") ? _fileName + fileNameExt : _fileName; using (FileStream stream = File.OpenWrite(fileName)) { stream.Write(results, 0, results.Length); stream.Dispose(); } if (formatType == "RTF") { string fileNameRTF = _fileName + ".rtf"; WordToRtf(fileName, fileNameRTF); } File.SetAttributes(fileName, FileAttributes.Normal); rs.Dispose(); rsExec.Dispose(); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message); } }
public void Dispose() { _proxy.Dispose(); }
void frmEditProperties_Closing(object sender, System.ComponentModel.CancelEventArgs e) { _reportServerProperties2005.Dispose(); ReportServerSource.Dispose(); }