public void CarregaMenu() { //tenta carregar a lista configurada. spsWrapper objSps = new spsWrapper(true); try { var objDs = objSps.RetornaListaPorUrl(Lista, "<Orderby><FieldRef Name='Ordem'/></Orderby>").Select(sp => new { Link = Convert.ToString(sp["Link"]), Texto = Convert.ToString(sp["Texto"]), Cor = (sp["COR"]), Classe = getCssClass(Convert.ToString(sp["Link"])) }); this.rptMain.DataSource = objDs; this.rptMain.DataBind(); } catch (Exception ex) { this.lblErro.Text = "<!-- Erro ao carregar este controle, o erro foi: " + ex.Message + "-->"; } }
protected void CarregaControle() { try { spsWrapper objWrapper = new spsWrapper(); string strPasta = ViewState["pasta"] == null ? SPContext.Current.Web.ServerRelativeUrl + "/" + Lista + "/" : ViewState["pasta"].ToString(); SPFolder objPasta = SPContext.Current.Web.GetFolder(strPasta); //Hack p o titulo da wp this.lblHack.Text = string.Format("<div class='ag_hackTitulo' titulo='{0}' url='{1}'></div>", this.Title, objPasta.DocumentLibrary.DefaultViewUrl ); strAddLink = string.Format("{0}/_layouts/Upload.aspx?List={1}&RootFolder={2}", SPContext.Current.Web.Url, objPasta.DocumentLibrary.ID, objPasta.Url ); //Carrega o breadcrumb List <VisualizadorPastaBreadcrumbModel> objBreadCrumb = new List <VisualizadorPastaBreadcrumbModel>(); SPFolder objPastaAtual = objPasta; while (objPastaAtual.ParentFolder.Name != "") { objBreadCrumb.Add(new VisualizadorPastaBreadcrumbModel { name = objPastaAtual.Name, url = objPastaAtual.Url }); objPastaAtual = objPastaAtual.ParentFolder; } if (objBreadCrumb.Count > 0) { objBreadCrumb.Insert(0, new VisualizadorPastaBreadcrumbModel { name = objPasta.DocumentLibrary.Title, url = objPasta.DocumentLibrary.RootFolder.Url }); } this.rptCaminho.DataSource = objBreadCrumb.OrderBy(f => f.url); this.rptCaminho.DataBind(); //Carrega a árvore List <VisualizadorPastasModel> objArvore = new List <VisualizadorPastasModel>(); foreach (SPFolder pst in objPasta.SubFolders) { if (pst.Name != "Forms") { objArvore.Add(new VisualizadorPastasModel { id = pst.UniqueId, name = pst.Name, docIcon = "/_layouts/images/folder.gif", folder = pst.Name, url = pst.Url, tp = 0 }); } } foreach (SPFile arq in objPasta.Files) { objArvore.Add(new VisualizadorPastasModel { id = arq.UniqueId, name = arq.Name, docIcon = "/_layouts/images/" + arq.IconUrl, folder = arq.ParentFolder.Name, url = arq.Url, tp = 1 }); } this.rptArquivos.DataSource = objArvore.OrderBy(f => f.tp.ToString() + f.name); this.rptArquivos.DataBind(); } catch (Exception ex) { this.lblErro.Text = "Erro ao carregar a webpart. o erro foi: " + ex.Message; } }