/// <summary>
        /// Create folder under given parent folder
        /// NOTE: Should check for existence first, throw incase of error
        /// </summary>
        /// <param name="parent">Parent Folder</param>
        /// <param name="folderName">Folder To Create</param>
        /// <returns>Newly created folder path</returns>
        protected virtual string CreateWorkingFolder(string parent, string folderName)
        {
            string workingFolder = string.Empty;
            string itemPath      = string.Empty;

            try
            {
                RSCatalogItem folder = SoapAccessor.Management.CreateFolder(folderName, parent, null);

                workingFolder = folder.Path;
            }
            catch (Exception ex)
            {
                // should check if folder existed.

                if (string.IsNullOrEmpty(workingFolder))
                {
                    if (parent.EndsWith("/"))
                    {
                        workingFolder = parent + folderName;
                    }
                    else
                    {
                        workingFolder = parent + "/" + folderName;
                    }
                }

                Logging.Log("Folder create failed: {0}", ex.Message);
            }

            return(workingFolder);
        }
        /// <summary>
        /// Publish RSD file from source folder to RS.
        /// </summary>
        /// <param name="sharedDataSet">Source RSD file on disk.</param>
        /// <param name="displayName">Name of the SharedDataSets to publish.</param>
        /// <param name="parentFolder">RS detination folder.</param>
        public void PublishSharedDataSet(string sharedDataSet, string displayName, string parentFolder)
        {
            RSWarning[] warns = null;
            XmlDocument doc   = new XmlDocument();

            doc.Load(sharedDataSet);
            byte[] rsdBytes = Encoding.UTF8.GetBytes(doc.OuterXml);

            RSCatalogItem catalogItem = SoapAccessor.Management.CreateCatalogItem("DataSet", displayName, parentFolder, true, rsdBytes, null, out warns);
        }
        public void RndCreateFolder()
        {
            IContentManager instance = this.ContentManager;
            string          folder   = instance.GenerateRndFileName();

            if (!string.IsNullOrEmpty(folder))
            {
                RSCatalogItem item = instance.SoapAccessor.Management.CreateFolder(folder, instance.ToBeDeletedFolder, null);
                if (item != null)
                {
                    instance.RndContentManager.AddFolder(item.Path);
                }
            }
        }
        /// <summary>
        /// Craete a generic report given the name and parent folder.
        /// Name alerady supposed to have extesion
        /// </summary>
        /// <param name="name">Item name to be used on the server</param>
        /// <param name="parent">Parent folder</param>
        /// <returns>Full Path of newly created item</returns>
        public string CreateGenericReport(string name, string parent)
        {
            RSWarning[] warns        = null;
            string      sourceReport = SharedConstants.RuntimeResourcesFolder + @"\Paginated\NoDatasource\ImageOnly.rdl"; // better if we could control this from outside

            byte[]        content    = this.GetItemCotent(sourceReport);                                                  // use cheese report
            string        reportPath = string.Empty;
            RSCatalogItem item       = null;

            item = this.SoapAccessor.Management.CreateCatalogItem("Report", name, parent, true, content, null, out warns);
            if (item != null)
            {
                reportPath = item.Path;
            }

            return(reportPath);
        }
        /// <summary>
        /// Create Data Source On RS Server (NOTE: probably return catalog item instead of path only)
        /// </summary>
        /// <param name="name">Data Source Name</param>
        /// <param name="dsDef">Data Source Definition</param>
        /// <param name="parent">Parent Folder to Crate Data Source</param>
        /// <returns>Path to newly created datasource</returns>
        public virtual string CreateDataSource(string name, RSDataSourceDefinition dsDef, string parent)
        {
            RSCatalogItem dsItem = SoapAccessor.Management.CreateDataSource(name, parent, true, dsDef, null);

            return(dsItem.Path);
        }