private void renameToolStripMenuItem_Click(object sender, EventArgs e) { FormGetName formGetName = new FormGetName("Rename item"); formGetName.Name = this.lvItems.SelectedItems[0].Text; if (formGetName.ShowDialog() != DialogResult.OK) { return; } try { this.rs.MoveItem(this.lvItems.SelectedItems[0].ToolTipText, FormSSRSExplorer.GetItemPath(this.lvItems.SelectedItems[0].ToolTipText, false) + "/" + formGetName.Name, (ReportItemTypes)this.lvItems.SelectedItems[0].Tag); this.toolStripStatusLabel.Text = string.Format("Renamed item '{0}' to '{1}'", (object)this.lvItems.SelectedItems[0].Text, (object)(FormSSRSExplorer.GetItemPath(this.lvItems.SelectedItems[0].ToolTipText, false) + "/" + formGetName.Name)); if ((ReportItemTypes)this.lvItems.SelectedItems[0].Tag == ReportItemTypes.Folder) { this.rs.PopulateTreeView(FormSSRSExplorer.SelectedServer.Alias); } this.rs.PopulateItems(this.tvReportServer.SelectedNode.ToolTipText); } catch (Exception ex) { int num = (int)MessageBox.Show(string.Format("An error has occured: {0}", (object)ex.Message)); LogHandler.WriteLogEntry(ex); } }
/// <summary> /// Download an item from the reportserver /// </summary> /// <param name="path">The path on the report server to download</param> /// <param name="destination">The destination on the client to save the downloaded files in</param> /// <param name="type">The type of the selected item to download</param> /// <param name="preserveFolders">if true, the folder structure will be preserved, when false /// all files in subfolders will be saved to the destination folder</param> /// <remarks>Datasources cannot be downloaded, existing items will be overwritten and empty folders will be skipped</remarks> public void DownloadItem(string path, string destination, ReportItemTypes type, bool preserveFolders) { switch (type) { case ReportItemTypes.Folder: foreach (CatalogItem catalogItem in rs.ListChildren(path, true)) { DownloadItem(catalogItem.Path, destination, ConvertItemType(catalogItem.Type), preserveFolders); } break; case ReportItemTypes.Report: try { XmlDocument definition = new XmlDocument(); definition.Load(new MemoryStream(rs.GetReportDefinition(path))); string directory = destination; if (preserveFolders) { if (tvReportServer.SelectedNode.ToolTipText != "/") { directory = String.Format(@"{0}\{1}", destination, FormSSRSExplorer.GetItemPath("/" + path.ToLower().Replace(tvReportServer.SelectedNode.ToolTipText.ToLower(), ""), true)); } else { directory = String.Format(@"{0}\{1}", destination, FormSSRSExplorer.GetItemPath(path, true)); } } string filename = FormSSRSExplorer.GetItemName(path); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } definition.Save(String.Format(@"{0}\{1}.rdl", directory, filename)); toolStripStatusLabel.Text = String.Format("Downloaded '{0}'", filename); Application.DoEvents(); } catch (Exception ex) { MessageBox.Show(String.Format("An error has occured: {0}", ex.Message)); } break; } }