/// <summary> /// Return Parent Folder with object /// </summary> /// <param name="siteSetting">Site Setting</param> /// <param name="folder">Folder to retreive</param> /// <returns></returns> public Folder GetParentFolder(ISiteSetting siteSetting, Folder folder) { SPBaseFolder spFolder = folder as SPBaseFolder; string folderPath = spFolder.WebUrl.CombineUrl(spFolder.FolderPath).TrimEnd(new char[] { '/' }); if (folderPath.Equals(siteSetting.Url, StringComparison.OrdinalIgnoreCase) == true) { return(null); } //folderPath = folderPath.Substring(0, folderPath.LastIndexOf('/'));//JD folderPath = folderPath.TrimEnd('/'); ISharePointService spService = new SharePointService(); if (folder as SPList != null) { //return spService.GetWeb(siteSetting, folderPath); return(spService.GetList(siteSetting, folderPath)); } else if (folder as SPWeb != null) { return(spService.GetWeb(siteSetting, folderPath)); } else { if (folder.GetRoot() == folder.GetUrl()) { return(spService.GetList(siteSetting, folderPath)); } return(spService.GetList(siteSetting, folderPath)); //return spService.GetFolder(siteSetting, folderPath); } }
private void FillFoldersTreeFromURL(ISiteSetting siteSetting, SPBaseFolder parentFolder, string remainingUrl) { parentFolder.Folders = this.GetFolders(siteSetting, parentFolder); SPBaseFolder currentFolder = null; string currentFolderName; if (remainingUrl.IndexOf('/') > -1) { currentFolderName = remainingUrl.Substring(0, remainingUrl.IndexOf('/')); remainingUrl = remainingUrl.Substring(remainingUrl.IndexOf(currentFolderName) + currentFolderName.Length + 1); } else { return; //currentFolderName = remainingUrl; //remainingUrl = string.Empty; } foreach (SPBaseFolder tempFolder in parentFolder.Folders) { string folderName = tempFolder.GetPath(); if (folderName.LastIndexOf("/") > -1) { folderName = folderName.Substring(folderName.LastIndexOf("/") + 1); } if (folderName.Equals(currentFolderName) == true) { currentFolder = tempFolder; break; } } if (currentFolder != null) { FillFoldersTreeFromURL(siteSetting, currentFolder, remainingUrl); } }
private void AddFolders(SPBaseFolder parentFolder, DataSet dataset, List <Folder> folders) { OC_DataTable table = dataset.Tables[0] as OC_DataTable; if (parentFolder != null) { OC_Datarow newRow = (OC_Datarow)table.NewRow(); newRow.Tag = parentFolder; newRow["ID"] = parentFolder.UniqueIdentifier; newRow["Title"] = ".."; newRow["URL"] = parentFolder.UniqueIdentifier; newRow["Picture"] = ImageManager.GetInstance().GetUpFolderImage(); table.Rows.Add(newRow); } foreach (Folder subfolder in folders) { OC_Datarow newRow = (OC_Datarow)table.NewRow(); newRow.Tag = subfolder; newRow["ID"] = subfolder.UniqueIdentifier; newRow["Title"] = subfolder.Title; newRow["URL"] = subfolder.UniqueIdentifier; string picturePath = string.Empty; if (subfolder as SPWeb != null) { picturePath = ImageManager.GetInstance().GetWebImage(); } else if (subfolder as SPList != null) { picturePath = ImageManager.GetInstance().GetListImage(); } else { picturePath = ImageManager.GetInstance().GetFolderImage(); } newRow["Picture"] = picturePath; table.Rows.Add(newRow); } }
private void FillFoldersTreeFromURL(ISiteSetting siteSetting, SPBaseFolder parentFolder, string remainingUrl) { throw new Exception("Not implemented yet"); }