/// <summary>
        /// Gets the catalog items.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="recursive">if set to <c>true</c> [recursive].</param>
        /// <returns></returns>
        private static API.CatalogItem[] GetCatalogItems(string path, bool recursive)
        {
            ReportingServicesProvider provider = new ReportingServicesProvider();

            path = provider.GetFolderPath(path);
            var apiClient = provider.GetAPIClient(UserType.Browser);

            API.CatalogItem[] catalog;
            apiClient.ListChildren(null, path, recursive, out catalog);

            return(catalog);
        }
        /// <summary>
        /// Gets the item by path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns></returns>
        public static ReportingServiceItem GetItemByPath(string path)
        {
            ReportingServicesProvider provider = new ReportingServicesProvider();

            path = provider.GetFolderPath(path);

            ReportingServiceItem rsItem = GetItemsFlat(provider.ReportPath, true, true)
                                          .Where(i => i.Path.Equals(path, StringComparison.InvariantCultureIgnoreCase))
                                          .FirstOrDefault();

            return(rsItem);
        }
        /// <summary>
        /// Gets the folder tree.
        /// </summary>
        /// <param name="rootPath">The root path.</param>
        /// <param name="recursive">if set to <c>true</c> [recursive].</param>
        /// <param name="includeHidden">if set to <c>true</c> [include hidden].</param>
        /// <returns></returns>
        public static ReportingServiceItem GetFoldersTree(string rootPath, bool recursive, bool includeHidden)
        {
            var rawItems = GetFoldersFlat(rootPath, recursive, includeHidden);

            rootPath = new ReportingServicesProvider().GetFolderPath(rootPath);
            ReportingServiceItem rsi = new ReportingServiceItem {
                Type = ItemType.Folder, Path = rootPath, Name = rootPath.Substring(rootPath.LastIndexOf("/") + 1)
            };

            rsi.Children = LoadChildren(rawItems, rsi.Path);

            return(rsi);
        }
        /// <summary>
        /// Gets the report parameter list.
        /// </summary>
        /// <param name="provider">The provider.</param>
        /// <param name="reportPath">The report path.</param>
        /// <returns></returns>
        public static List <string> GetReportParameterList(ReportingServicesProvider provider, string reportPath)
        {
            var client = provider.GetAPIClient(UserType.Browser);

            ItemParameter[] reportParams = null;
            client.GetItemParameters(null, reportPath, null, true, null, null, out reportParams);

            var paramNames = new List <string>();

            foreach (var p in reportParams)
            {
                paramNames.Add(p.Name);
            }

            return(paramNames);
        }
        /// <summary>
        /// Gets the report tree.
        /// </summary>
        /// <param name="rootPath">The root path.</param>
        /// <param name="recursive">if set to <c>true</c> [recursive].</param>
        /// <param name="includeHidden">if set to <c>true</c> [include hidden].</param>
        /// <returns></returns>
        public static ReportingServiceItem GetReportTree(string rootPath, bool recursive, bool includeHidden)
        {
            var rawItems = GetItemsFlat(rootPath, recursive, includeHidden);

            rawItems.RemoveAll(i => i.Type == ItemType.DataSource);

            ReportingServiceItem rsi = new ReportingServiceItem();

            rootPath = new ReportingServicesProvider().GetFolderPath(rootPath);
            rsi.Name = rootPath.Substring(rootPath.LastIndexOf("/") + 1);
            rsi.Path = rootPath;
            rsi.Type = ItemType.Folder;

            rsi.Children = LoadChildren(rawItems, rsi.Path);

            return(rsi);
        }