public void CreateReport(string reportName, string parentPath, byte[] definition, IEnumerable <string> dataSourcePaths) { Property[] reportProperties = new Property[1]; Property hidden = new Property(); hidden.Name = "Hidden"; hidden.Value = reportName.StartsWith("_") ? "true" : "false"; reportProperties[0] = hidden; _reportService.CreateReport(reportName, parentPath, true, definition, reportProperties); var sources = new List <DataSource>(); foreach (var dataSourcePath in dataSourcePaths) { DataSourceReference dsRef = new DataSourceReference(); dsRef.Reference = dataSourcePath; var ds = new DataSource(); ds.Item = dsRef; sources.Add(ds); } //DataSourceReference dsRef = new DataSourceReference(); // dsRef.Reference = dataSourcePaths; // DataSource[] Sources = _reportService.GetItemDataSources(parentPath + "/" + reportName); if (sources != null && sources.Count > 0) { try { _reportService.SetItemDataSources(parentPath + "/" + reportName, sources.ToArray()); } catch (Exception) { } } }
private void DeployReport(string targetLocation, ReportInfo report, int progress) { byte[] reportDef; Property propDescr = new Property(); propDescr.Name = "Description"; propDescr.Value = report.Description; Property propHidden = new Property(); propHidden.Name = "Hidden"; propHidden.Value = report.Hidden.ToString().ToLower(); // Don't overwrite if exists if (ItemExists(targetLocation + "/" + report.Name, ItemTypeEnum.Report) && !_drd.OverwriteExisting) { _bgWorker.ReportProgress(progress, String.Format("Skipping report: {0} - Report already exists.", report.Name)); } else { _bgWorker.ReportProgress(progress, String.Format("Deploying report: {0}...", report.Name)); using (FileStream stream = File.OpenRead(report.FileName)) { reportDef = new Byte[stream.Length]; stream.Read(reportDef, 0, (int)stream.Length); } _rs.CreateReport(report.Name, targetLocation, _drd.OverwriteExisting, reportDef, new Property[] { propDescr, propHidden }); } }
private void CreateReport(string folder, string rdlFile, Dictionary <string, DataSourceDefinitionOrReference> dataSources) { var name = Path.GetFileNameWithoutExtension(rdlFile); var reportContents = File.ReadAllBytes(rdlFile); if (!targetFolder.StartsWith("/")) { folder = "/" + folder; } var warnings = rs.CreateReport(name, folder, true, reportContents, null); if (warnings != null) { Console.WriteLine("Report: '{0}':", name); foreach (var warning in warnings) { Console.WriteLine(warning.Message); } } else { Console.WriteLine("Report: '{0}' created successfully with no warnings", name); } UpdateReportDataSources(folder, name, dataSources); }
public void CreateReport(string reportName, string parentPath, byte[] definition, string dataSourcePath) { Property[] reportProperties = new Property[1]; Property hidden = new Property(); hidden.Name = "Hidden"; hidden.Value = reportName.StartsWith("_") ? "true" : "false"; reportProperties[0] = hidden; _reportService.CreateReport(reportName, parentPath, true, definition, reportProperties); DataSourceReference dsRef = new DataSourceReference(); dsRef.Reference = dataSourcePath; DataSource[] Sources = _reportService.GetItemDataSources(parentPath + "/" + reportName); if (Sources != null && Sources.Length > 0) { Sources[0].Item = dsRef; try { _reportService.SetItemDataSources(parentPath + "/" + reportName, Sources); } catch (Exception) { } } }
public static void CreateReport(string reportingServiceUrl, string name, string parent, string[] dataSourcePaths, string definitionFile) { // Open the definition. byte[] definition; using (var stream = File.OpenRead(definitionFile)) { definition = new byte[stream.Length]; stream.Read(definition, 0, (int)stream.Length); stream.Close(); } var service = new ReportingService2005 { Url = reportingServiceUrl, Credentials = System.Net.CredentialCache.DefaultCredentials }; var warnings = service.CreateReport(name, parent, true, definition, null); // If there are data sources then associate them with the report. if (dataSourcePaths != null && dataSourcePaths.Length > 0) { var dataSources = (from dsp in dataSourcePaths select new DataSource { Item = new DataSourceReference { Reference = dsp }, Name = GetName(dsp), }).ToArray(); service.SetItemDataSources(GetPath(name, parent), dataSources); } }
private void UploadReport(ReportItem item) { _Service.CreateReport(item.Name, item.ParentPath, true, item.ReportDefinition, null); var dataSources = GetDataSources(item.DataSources); if (dataSources.Length > 0) { _Service.SetItemDataSources(item.Path, dataSources); } }
private static void CreateReport(ReportingService2005 reportingService, ReportItem report) { if (reportingService == null) { throw new ArgumentNullException("reportingService"); } if (report == null) { throw new ArgumentNullException("report"); } string parent = TesterUtility.GetParentPath(report.Path); ReportingService2005TestEnvironment.CreateFolderFromPath(reportingService, parent); reportingService.CreateReport(report.Name, parent, true, report.Definition, null); }
private static void CreateReports(ReportingService2005 reportingService, string path) { if (reportingService == null) { throw new ArgumentNullException("reportingService"); } if (string.IsNullOrEmpty(path)) { throw new ArgumentException("path"); } foreach (ReportItem report in SetupReportItems) { string fullPath = string.Format(report.Path, path); string parent = TesterUtility.GetParentPath(fullPath); reportingService.CreateReport(report.Name, parent, true, report.Definition, null); } }
public void CreateReport(ReportGroup reportGroup, Report report, int seq) { byte[] definition = report.Process(reportGroup.TargetFolder, reportGroup.DataSource); if (definition == null) { return; } Warning[] warnings = _proxy.CreateReport( report.Name, Util.FormatPath(reportGroup.TargetFolder), true, definition, null); if (warnings != null) { Logger.LogMessage(string.Format("{0} Report:{1} / [{2}] published successfully with some warnings", seq, reportGroup.Name, report.Name)); //foreach(Warning warning in warnings) //{ // Logger.LogMessage(warning.Message); //} } else { Logger.LogMessage(string.Format("{0} Report:{1} / [{2}] published successfully with no warnings", seq, reportGroup.Name, report.Name)); } if (report.CacheOption != null && report.CacheOption.CacheReport && report.CacheOption.ExpirationMinutes != null) { _proxy.SetCacheOptions( string.Format("{0}/{1}", Util.FormatPath(reportGroup.TargetFolder), report.Name), true, new TimeExpiration() { Minutes = report.CacheOption.ExpirationMinutes.Value }); } }
public string SaveReport(string report, Stream file, string name, bool overwrite, ref Guid id) { id = Guid.Empty; string _report = report.ToLower().Replace(".rdl", ""); if (this.CheckExist(ItemTypeEnum.Report, WebConfigurationManager.AppSettings["ReportsRootPath"].ToString(), (name == "" ? _report : name)) == true && overwrite == false) { return("The Report '" + (name == "" ? _report : name) + "' already exists"); } Byte[] definition = null; try { System.IO.BinaryReader br = new System.IO.BinaryReader(file); definition = br.ReadBytes((Int32)file.Length); //Create Report rs.CreateReport((name == string.Empty ? _report : name), WebConfigurationManager.AppSettings["ReportsRootPath"].ToString(), overwrite, definition, null); //Set DataSource DataSourceReference Item1 = new DataSourceReference(); DataSource[] datasources = rs.GetItemDataSources(WebConfigurationManager.AppSettings["ReportsRootPath"].ToString() + "/" + (name == "" ? _report : name)); Item1.Reference = WebConfigurationManager.AppSettings["ReportsRootPath"].ToString() + WebConfigurationManager.AppSettings["MyDataSource"].ToString(); datasources[0].Item = Item1; rs.SetItemDataSources(WebConfigurationManager.AppSettings["ReportsRootPath"].ToString() + "/" + (name == "" ? _report : name), datasources); string _id = GetReportID(WebConfigurationManager.AppSettings["ReportsRootPath"].ToString() + "/" + (name == "" ? _report : name)); id = _id != string.Empty ? new Guid(_id) : Guid.Empty; return(string.Format("Report: {0} created successfully", name == "" ? _report : name)); } catch (Exception ex) { Console.WriteLine(ex.Message); return(ex.Message); } }
private void uploadReport(string destinationPath, string reportName, byte[] reportDef) { try { //Create report destRS.CreateReport(reportName, destinationPath, true, reportDef, null); //Link datasources var reportPath = destinationPath; if (reportPath.EndsWith("/")) { reportPath += reportName; } else { reportPath += "/" + reportName; } var reportDss = destRS.GetItemDataSources(reportPath); List <DataSource> dataSources = new List <DataSource>(); foreach (var reportDs in reportDss) { if (destDS.ContainsKey(reportDs.Name)) { DataSourceReference reference = new DataSourceReference(); reference.Reference = destDS[reportDs.Name]; var ds = new DataSource(); ds.Item = (DataSourceDefinitionOrReference)reference; ds.Name = reportDs.Name; dataSources.Add(ds); } } destRS.SetItemDataSources(reportPath, dataSources.ToArray()); } catch (Exception e) { MessageBox.Show("Upload " + reportName + " failed." + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void browseFile_Click(object sender, EventArgs e) { // Get the full pathname from the treeview control string pathName = ssrsFolders.SelectedNode.FullPath; if (pathName == "Root") { pathName = "/"; } else { // Strip off the Root name from the path and correct the path separators for use with SRS pathName = pathName.Substring(4, pathName.Length - 4); pathName = pathName.Replace(@"\", "/"); } byte[] definition = null; Warning[] warnings = null; string warningMsg = String.Empty; OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "RDL files (*.rdl)|*.rdl|All files (*.*)|*.*"; openFileDialog.FilterIndex = 1; if (openFileDialog.ShowDialog() == DialogResult.OK) { try { // Read the file and put it into a byte array to pass to SRS FileStream stream = File.OpenRead(openFileDialog.FileName); definition = new byte[stream.Length]; stream.Read(definition, 0, (int)(stream.Length)); stream.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } // We are going to use the name of the rdl file as the name of our report string reportName = Path.GetFileNameWithoutExtension(openFileDialog.FileName); reportFile.Text = reportName; // Now lets use this information to publish the report try { warnings = rs.CreateReport(reportName, pathName, true, definition, null); if (warnings != null) { foreach (Warning warning in warnings) { warningMsg += warning.Message + "\n"; } MessageBox.Show("Report creation failed with the following warnings:\n" + warningMsg); } else { MessageBox.Show(String.Format("Report: {0} created successfully with no warnings", reportName)); } } catch (SoapException ex) { MessageBox.Show(ex.Detail.InnerXml.ToString()); } } }
private string DeployReport(string localPath, string serverPath, string dataSourcePath, string dataSourceName) { byte[] definition = null; Warning[] warnings = null; string retRes = String.Empty; try { // Read the file and put it into a byte array to pass to SRS FileStream stream = File.OpenRead(localPath); definition = new byte[stream.Length]; stream.Read(definition, 0, (int)(stream.Length)); stream.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } // We are going to use the name of the rdl file as the name of our report string reportName = Path.GetFileNameWithoutExtension(localPath); // Now lets use this information to publish the report try { warnings = rs.CreateReport(reportName, serverPath, true, definition, null); if (warnings != null) { retRes = String.Format("Report {0} created with warnings :\n", reportName); foreach (Warning warning in warnings) { retRes += warning.Message + "\n"; } } else { retRes = String.Format("Report {0} created successfully with no warnings\n", reportName); } // check xml datasource var isXmlProvider = IsXmlDataProvider(localPath); if (isXmlProvider) { return(retRes); } //set the datasource DataSourceReference dsr = new DataSourceReference(); dsr.Reference = dataSourcePath + "/" + dataSourceName; DataSource[] dsarray = rs.GetItemDataSources(serverPath + "/" + reportName); DataSource ds = new DataSource(); if (dsarray.Length > 0) { ds = dsarray[0]; ds.Item = (DataSourceReference)dsr; rs.SetItemDataSources(serverPath + "/" + reportName, dsarray); retRes += String.Format("Data source succesfully set to {0}\n", dsr.Reference); } } catch (SoapException ex) { return(String.Format("Report {0} failed with exception {1}\n", reportName, ex.Detail.InnerXml.ToString())); } return(retRes); }
public ReportWarning[] CreateReport(string filename, string destination, bool overwrite, Byte[] definition, string properties) { var warnings = webserviceProxy.CreateReport(Path.GetFileNameWithoutExtension(filename), destination, overwrite, definition, null); return(warnings != null?Array.ConvertAll(warnings, ConvertSPWarningToReportWarning) : null); }