Esempio n. 1
0
        public void DownloadItem(string path, string destinationFolder, ReportItemTypes type, bool preserveFolders)
        {
            switch (type)
            {
            case ReportItemTypes.Folder:
                foreach (ReportItemDTO listChild in this.RsFacade.ListChildren(path, true))
                {
                    this.DownloadItem(listChild.Path, destinationFolder, listChild.Type, preserveFolders);
                }
                break;

            case ReportItemTypes.Report:
                XmlDocument definition1 = new XmlDocument();
                definition1.Load((Stream) new MemoryStream(this.RsFacade.GetReportDefinition(path)));
                this.SaveItem(path, type, destinationFolder, preserveFolders, definition1);
                break;

            case ReportItemTypes.Model:
                XmlDocument definition2 = new XmlDocument();
                definition2.Load((Stream) new MemoryStream(this.RsFacade.GetModelDefinition(path)));
                this.SaveItem(path, type, destinationFolder, preserveFolders, definition2);
                break;
            }
            this.toolStripStatusLabel.Text = string.Format("Downloaded '{0}'", (object)path);
            Application.DoEvents();
        }
        public void DownloadItem(string path, string destinationFolder, ReportItemTypes type, bool preserveFolders)
        {
            switch (type)
            {
            case ReportItemTypes.Folder:
                foreach (var catalogItem in RsFacade.ListChildren(path, true))
                {
                    DownloadItem(catalogItem.Path, destinationFolder, catalogItem.Type, preserveFolders);
                }
                break;

            case ReportItemTypes.Report:

                var definition = new XmlDocument();

                definition.Load(new MemoryStream(RsFacade.GetReportDefinition(path)));

                SaveItem(path, type, destinationFolder, preserveFolders, definition);

                break;

            case ReportItemTypes.Model:
                var model = new XmlDocument();

                model.Load(new MemoryStream(RsFacade.GetModelDefinition(path)));

                SaveItem(path, type, destinationFolder, preserveFolders, model);

                break;
            }

            toolStripStatusLabel.Text = String.Format("Downloaded '{0}'", path);
            Application.DoEvents();
        }
        private void SaveItem(string filename, ReportItemTypes type, string destination, bool preserveFolders, XmlDocument definition)
        {
            if (!RsFacade.PathIncludesExtension)
            {
                filename = AppendFileSuffix(filename, type);
            }

            if (preserveFolders)
            {
                var sourceBaseDirectory = tvReportServer.SelectedNode.ToolTipText;

                var relativeFilePath = Path.GetDirectoryName(filename.Substring(sourceBaseDirectory.Length));

                destination = Path.Combine(destination, relativeFilePath);
                destination = destination.Replace('/', '\\');
            }

            filename = Path.GetFileName(filename);

            if (!Directory.Exists(destination))
            {
                Directory.CreateDirectory(destination);
            }

            definition.Save(String.Format(@"{0}\{1}", destination, filename));
        }
        public void SetDatasource(string item, string datasource, ReportItemTypes type)
        {
            switch (type)
            {
            case ReportItemTypes.Folder:
                foreach (var catalogItem in RsFacade.ListChildren(item, true))
                {
                    SetDatasource(catalogItem.Path, datasource, catalogItem.Type);
                }
                break;

            case ReportItemTypes.Report:
            case ReportItemTypes.Model:

                RsFacade.SetItemDataSources(item, datasource);

                toolStripStatusLabel.Text = String.Format("Updated datasource of {0}", item);

                break;

            default:
                toolStripStatusLabel.Text = String.Format("Cannot set datasource of item {0}", item);
                break;
            }
        }
Esempio n. 5
0
 public FormProperties(string _path, ReportItemTypes _type)
 {
     this.InitializeComponent();
     this.rs       = ReportingServicesFactory.CreateFromSettings(FormSSRSExplorer.SelectedServer, (TreeView)null, (ToolStripStatusLabel)null, (ListView)null);
     this.path     = _path;
     this.itemType = _type;
 }
        public FormProperties(string path, ReportItemTypes itemType)
        {
            InitializeComponent();

            controller = ReportingServicesFactory.CreateFromSettings(FormSSRSExplorer.SelectedServer, null, null, null);

            this.path     = path;
            this.itemType = itemType;
        }
Esempio n. 7
0
        private void DeleteItem(string path, ReportItemTypes checkType, string checkName)
        {
            facade.DeleteItem(path);

            var folder = facade.ListChildren(facade.BaseUrl, false)
                         .FirstOrDefault(i => i.Name == checkName && i.Type == checkType);

            Assert.IsNull(folder);
        }
Esempio n. 8
0
        public void MoveItem(string source, string destination, ReportItemTypes type)
        {
            if (!destination.EndsWith(".rsds") && type == ReportItemTypes.Datasource)
            {
                destination += ".rsds";
            }
            else if (!destination.EndsWith(".rdl") && type == ReportItemTypes.Report)
            {
                destination += ".rdl";
            }

            webserviceProxy.MoveItem(source, destination);
        }
        /// <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;
            }
        }
        /// <summary>
        /// Set the datasource of a report
        /// </summary>
        /// <param name="item">path of the item</param>
        /// <param name="datasource">path of the datasource to bind</param>
        public void SetDatasource(string item, string datasource, ReportItemTypes type)
        {
            string dataSourceName = ("/" + datasource.Split('/')[datasource.Split('/').GetUpperBound(0)]).Trim('/').Replace(".rsds", "");

            switch (type)
            {
            case ReportItemTypes.Folder:
                foreach (CatalogItem catalogItem in GetCatalogItems(item, true))
                {
                    SetDatasource(catalogItem.Path, datasource, ConvertItemType(catalogItem.Type));
                }
                break;

            case ReportItemTypes.Report:
                try
                {
                    foreach (DataSource availableDataSource in rs.GetItemDataSources(item))
                    {
                        // Only update the report when the selected datasource is used in that report
                        if (availableDataSource.Name == dataSourceName)
                        {
                            DataSourceReference dsr = new DataSourceReference();
                            dsr.Reference = datasource;

                            DataSource[] dataSources = new DataSource[1];

                            DataSource ds = new DataSource();
                            ds.Item        = (DataSourceDefinitionOrReference)dsr;
                            ds.Name        = dataSourceName;
                            dataSources[0] = ds;

                            rs.SetItemDataSources(item, dataSources);
                            Application.DoEvents();

                            toolStripStatusLabel.Text = String.Format("Updated datasource of {0}", item);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(String.Format("An error has occured: {0}", ex.Message));
                }
                break;

            default:
                toolStripStatusLabel.Text = String.Format("Cannot set datasource of item {0}", item);
                break;
            }
        }
        /// <summary>
        /// Convert the item type of the reportserver class to our own item type enum
        /// </summary>
        /// <param name="type">The reportserver type to convert</param>
        /// <returns>The converted type</returns>
        private ReportItemTypes ConvertItemType(ItemTypeEnum type)
        {
            ReportItemTypes convertedType = ReportItemTypes.Unknown;

            switch (type)
            {
            case ItemTypeEnum.Folder: convertedType = ReportItemTypes.Folder; break;

            case ItemTypeEnum.Report: convertedType = ReportItemTypes.Report; break;

            case ItemTypeEnum.DataSource: convertedType = ReportItemTypes.Datasource; break;
            }

            return(convertedType);
        }
Esempio n. 12
0
        private string AppendFileSuffix(string path, ReportItemTypes type)
        {
            string str = path;

            switch (type)
            {
            case ReportItemTypes.Report:
                str += ".rdl";
                break;

            case ReportItemTypes.Model:
                str += ".smdl";
                break;
            }
            return(str);
        }
Esempio n. 13
0
        private string AppendFileSuffix(string path, ReportItemTypes type)
        {
            var filename = path;

            switch (type)
            {
            case ReportItemTypes.Model:
                filename = filename + ".smdl";
                break;

            case ReportItemTypes.Report:
                filename = filename + ".rdl";
                break;
            }

            return(filename);
        }
Esempio n. 14
0
 private void SaveItem(string filename, ReportItemTypes type, string destination, bool preserveFolders, XmlDocument definition)
 {
     if (!this.RsFacade.PathIncludesExtension)
     {
         filename = this.AppendFileSuffix(filename, type);
     }
     if (preserveFolders)
     {
         string toolTipText   = this.tvReportServer.SelectedNode.ToolTipText;
         string directoryName = Path.GetDirectoryName(filename.Substring(toolTipText.Length));
         destination = Path.Combine(destination, directoryName);
         destination = destination.Replace('/', '\\');
     }
     filename = Path.GetFileName(filename);
     if (!Directory.Exists(destination))
     {
         Directory.CreateDirectory(destination);
     }
     definition.Save(string.Format("{0}\\{1}", (object)destination, (object)filename));
 }
Esempio n. 15
0
        public void SetDatasource(string item, string datasource, ReportItemTypes type)
        {
            switch (type)
            {
            case ReportItemTypes.Folder:
                foreach (ReportItemDTO listChild in this.RsFacade.ListChildren(item, true))
                {
                    this.SetDatasource(listChild.Path, datasource, listChild.Type);
                }
                break;

            case ReportItemTypes.Report:
            case ReportItemTypes.Model:
                this.RsFacade.SetItemDataSources(item, datasource);
                this.toolStripStatusLabel.Text = string.Format("Updated datasource of {0}", (object)item);
                break;

            default:
                this.toolStripStatusLabel.Text = string.Format("Cannot set datasource of item {0}", (object)item);
                break;
            }
        }
Esempio n. 16
0
 public void MoveItem(string source, string destination, ReportItemTypes type)
 {
     this.RsFacade.MoveItem(source, destination, type);
 }
Esempio n. 17
0
 public void MoveItem(string source, string destination, ReportItemTypes type)
 {
     webserviceProxy.MoveItem(source, destination.StartsWith("/") ? destination : "/" + destination);
 }