/// <summary> /// Deploys the report. /// </summary> /// <param name="rsSource">Report Server Source object //ReportingService2005</param> /// <param name="filePath">Report Source Path (local)</param> /// <param name="reportDestinationPath">Report Destination Path</param> /// <param name="dataSource">Report Destination DataSource</param> /// <param name="dataSourceLocation">Report DataSource Path</param> /// <returns>True or False</returns> public bool DeployReport(ReportingService2005 rsSource, string filePath, string reportDestinationPath, string dataSource, string dataSourceLocation) { bool resVal; try { reportDestinationPath = reportDestinationPath.Substring(reportDestinationPath.Length - 1, 1) == @"\" ? reportDestinationPath.Substring(0, reportDestinationPath.Length - 1).Replace(@"\", @"/") : reportDestinationPath.Replace(@"\", @"/"); if (rsSource == null) { return(false); } var fileInfo = new FileInfo(filePath); string fileName = fileInfo.Name.Replace(fileInfo.Extension, string.Empty); DeleteItem(ItemTypeEnum.Report, reportDestinationPath.Replace(fileName, string.Empty).Replace(@"\", "/"), fileName); ReportsServerInstance2005.CreateReport(fileName, reportDestinationPath.Replace(fileName, string.Empty).Replace(@"\", "/"), true, File.ReadAllBytes(filePath), null); try { AttachDataSourceToReport(dataSource, dataSourceLocation.Replace(dataSource, string.Empty).Replace(@"\", "/"), fileName, reportDestinationPath.Replace(fileName, string.Empty).Replace(@"\", "/")); } catch (Exception) { MessageBox.Show(string.Format("The Report {0} was created but the report's Datasource cannot be updated! Please do it manually... (if you want)", fileName)); } resVal = true; } catch (Exception) { resVal = false; } return(resVal); }
/// <summary> /// Deploys the report. /// </summary> /// <param name="rsSource">Report Server Source object //ReportingService2005</param> /// <param name="reportNameSource">Report Source Name</param> /// <param name="reportSourcePath">Report Source path</param> /// <param name="reportDestinationPath">Report Destination Path</param> /// <param name="dataSource">Report Destination DataSource</param> /// <param name="dataSourceLocation">Report DataSource Path</param> /// <returns>True or False</returns> public bool DeployReport(ReportingService2005 rsSource, string reportNameSource, string reportSourcePath, string reportDestinationPath, string dataSource, string dataSourceLocation) { bool resVal; try { if (rsSource == null) { return(false); } byte[] reportDefinition = rsSource.GetReportDefinition(reportSourcePath.Replace(@"\", "/")); DeleteItem(ItemTypeEnum.Report, reportDestinationPath.Replace(reportNameSource, string.Empty).Replace(@"\", "/"), reportNameSource); ReportsServerInstance2005.CreateReport(reportNameSource, reportDestinationPath.Replace(reportNameSource, string.Empty).Replace(@"\", "/"), true, reportDefinition, null); try { AttachDataSourceToReport(dataSource, dataSourceLocation.Replace(dataSource, string.Empty).Replace(@"\", "/"), reportNameSource, reportDestinationPath.Replace(reportNameSource, string.Empty).Replace(@"\", "/")); } catch (Exception) { MessageBox.Show(string.Format("The Report {0} was created but the report's Datasource cannot be updated! Please do it manually... (if you want)", reportNameSource)); } resVal = true; } catch (Exception) { resVal = false; } return(resVal); }