Example #1
0
        /// <summary>
        /// Determines whether the user has the permission to use all of the
        /// methods in this adapter.
        /// </summary>
        /// <param name="server">The name of the server that has Reporting Service.</param>
        /// <param name="virtualRoot">The virtual directory in the server.</param>
        /// <returns>True is has requested permissions; False if doesn't</returns>
        public bool HasAppropriatePermissions(string server, string virtualRoot)
        {
            bool perm;

            try
            {
                perm = (bool)_rsFac.Execute(PermissionsAlgo.Singleton, server, virtualRoot, "/",
                                            _requiredPermissions);
            }
            catch (WebException ex)
            {
                _viewAdapter.DisplayMessageBox(String.Format("Bad Reporting Services address. No server found at location {0}{1}/{2}.  As a result, the operation timed out.  Even if Reporting Services is on a named instance of SQL Server, please only specify the name of the computer.  Reporting Services knows which instance of SQL Server it is on.  To find the report server virtual directory name, please look in the Internet Information Services in the Administrative Tools of the Control Panel.",
                                                             _http, server, virtualRoot), "Reporting Service Connection Error!");
                return(false);
            }
            catch (Exception ex1)
            {
                _viewAdapter.DisplayMessageBox(String.Format("Error communicating with reporting server {0}: {1}.", server, ex1.Message), "Reporting Service Connection Error!");
                return(false);
            }
            if (perm == false)
            {
                _viewAdapter.DisplayMessageBox("User running this application does not have appropriate role set in Report Manager (Content Manager is required).", "Permissions Error!");
            }
            return(perm);
        }
        /// <summary>
        /// Adds a folder to the report server database.
        /// </summary>
        /// <param name="host">The IProxyFactory that the algorithm or 'visitor' is executed on.</param>
        /// <param name="param[0]">The name of the server that has Reporting Service.</param>
        /// <param name="param[1]">The virtual directory in the server.</param>
        /// <param name="param[2]">The full path name of the parent folder to which to add
        /// the new folder. </param>
        /// <param name="param[3]">The name of the new folder. </param>
        /// <param name="param[4]">The value of a property for a folder.</param>
        /// <returns>True for successful; False for otherwise</returns>
        public object Execute(IProxyFactory host, params object[] param)
        {
            string server            = (string)param[0];
            string virtualRoot       = (string)param[1];
            string parentPath        = (string)param[2];
            string folderName        = (string)param[3];
            string folderDescription = (string)param[4];

            int index = folderName.IndexOf(@"/");

            if (index < 0)
            {
                if ((bool)host.Execute(DoesFolderExistAlgo.Singleton, server, virtualRoot,
                                       parentPath + folderName))
                {
                    return(true);
                }
                else
                {
                    if (parentPath.Equals(@"/"))
                    {
                        return(host.Execute(CreateFolderAlgo.Singleton, server, virtualRoot, parentPath,
                                            folderName, folderDescription));
                    }
                    else
                    {
                        return(host.Execute(CreateFolderAlgo.Singleton, server, virtualRoot, parentPath.Remove(parentPath.Length - 1, 1),
                                            folderName, folderDescription));
                    }
                }
            }
            else
            {
                string sub       = folderName.Substring(0, index);
                string newFolder = folderName.Remove(0, index + 1);

                host.Execute(CreateSubFoldersAlgo.Singleton, server, virtualRoot, parentPath,
                             sub, folderDescription);

                return(host.Execute(CreateSubFoldersAlgo.Singleton, server, virtualRoot,
                                    parentPath + sub + @"/", newFolder, folderDescription));
            }
        }