Mostrando postagens com marcador SharePoint 2010. Mostrar todas as postagens
Mostrando postagens com marcador SharePoint 2010. Mostrar todas as postagens

segunda-feira, 19 de novembro de 2012

Criando itens de toolpart

Caros, segue abaixo código para criação de toolpart.

No arquivo .cs da webpart:
namespace test.VisualWebPart1
{
    [ToolboxItemAttribute(false)]
    public class VisualWebPart1 : WebPart
    {
        #region Properties
        [WebBrowsable(true),
        Personalizable(PersonalizationScope.Shared),
        WebDisplayName("Título"),
        Category("teste")]
        public string title { get; set; }
        [WebBrowsable(true),
        Personalizable(PersonalizationScope.Shared),
        WebDisplayName("Texto"),
        Category("teste")]
        public string text { get; set; }
        #endregion
        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/destaque/VisualWebPart1/VisualWebPart1UserControl.ascx";
        protected override void CreateChildControls()
        {
            VisualWebPart1UserControl control = Page.LoadControl(_ascxPath) as VisualWebPart1UserControl;
            control.text = text;//tem que criar o objeto no .cs do ascx como public
            control.title = title;//tem que criar o objeto no .cs do ascx como public
            Controls.Add(control);
        }
    }
}

Customizando arquivo .webpart

Seguem abaixo alguns exemplos de customizações que podem ser feitas na sua webpart de modo a configura-la pelo xml do arquivo .webpart:

Vale lembrar que o ideal são imagens com tamanho máximo de 16X16px

<? xml version="1.0" encoding="utf-8"?>

< webParts>

<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">

<metaData>

<type name="webpartdestaque.VisualWebPart1.VisualWebPart1, $SharePoint.Project.AssemblyFullName$" />

<importErrorMessage>$Resources:core,ImportErrorMessage;</importErrorMessage>

</metaData>

<data>

<properties>

<property name="Title" type="string">Título da webpart</property>

<property name="Description" type="string">descrição de sua webpart</property>

<property name="ChromeType" type="chrometype">None</property>

<property name="TitleIconImageUrl" type="string">url da imagem.png</property>

<property name="CatalogIconImageUrl" type="string">url da imagem.png</property>

</properties>

</data>

</webPart>

</webParts>

Adicionando ícone à Feature

Para adicionar um ícone à Feature de alguma solution criada, abra o xml de sua feature e insira a tag imageurl, conforme exemplo abaixo:

<?

xml version="1.0" encoding="utf-8" ?>
<

Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Scope="Site"
Title="Vídeo externo"
ImageUrl="../../PublishingImages/icons/starGde.png"
>
</
 
Feature>

quarta-feira, 22 de agosto de 2012

Código para inclusão de mimetype no SP2010

Copie e cole o código abaixo no bloco de notas e salve com a extensão ps1 no arquivo...

$mimetypes = "application/pdf"
$webApp = Get-SPWebApplication [[WEB_APPLICATION_URL]]

foreach($mime in $mimetypes)
{
    If ($webApp.AllowedInlineDownloadedMimeTypes -notcontains $mime)
    {
        Write-Host -ForegroundColor White "Adding MIME Type "$mime

        $webApp.AllowedInlineDownloadedMimeTypes.Add($mime)
        $webApp.Update()

        Write-Host -ForegroundColor Green "MIME Type added and saved."
    }
    Else {
        Write-Host -ForegroundColor Yellow $mime" MIME type is already added."
    }
}


Logo após é necessário que você coloque o icone .gif 16X16 no local:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES

Edite o documento DOCICO.XML no local:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML

Adicione a seguinte entrada:

<Mapping Key=”pdf” Value=”icpdf.gif” OpenControl=”"/>

Para finalizar, faça um iisreset.

terça-feira, 31 de julho de 2012

Definindo ícone de webparts

Segue abaixo o código a ser colocado no elements.xml para definir uma imagem como ícone dessa webpart:

<properties>
  <property name="Title" type="string">NomeDaWebPart</property>
  <property name="TitleIconImageUrl" type="string">PastaImagem/Imagem.png</property>
  <property name="CatalogIconImageUrl" type="string">/PastaImagem/Imagem.png</property>
</properties>
 
Vale lembrar que a imagem deve ter 16X16 pixels.

sexta-feira, 27 de julho de 2012

Modal window nativa do SP2010 via Javascript

Caros,

Segue abaixo uma função em javascript que chama o modal nativo do SP2010:

function openDialog() {

var options = {

html: divModalDialogContent,

width: 300,

height: 150,

title:
" ",

allowMaximize: false,

showClose: true,

};

SP.UI.ModalDialog.showModalDialog(options);

document.getElementById(
'divModalDialogContent').style.visibility = 'visible';

}

No html basta colocar uma div qualquer em que o ID dela seja identificado na option html do javascript.

quarta-feira, 25 de julho de 2012

Tabela de referência CAML para iniciantes

Segue abaixo tabela de referência para quem está iniciando o uso de CAML:

Tabela de referência
Operador Lógico (CAML)Sinônimos SQL
Eq=
Gt>
Lt<
Geq>=
Leq<=
Neq<>
ContainsLike
IsNullNull
IsNotNullNotNull
BeginsWithBeginning with word
DateRangesOverlapcompare the dates in a recurring event with a specified DateTime value, to determine whether they overlap

Programa para construção de CAML

Caros, segue abaixo o link para download de um programa que é muito bom para quem utiliza CAML. Além de auxiliar com a sintaxe de sua query, ele testa seu código retornando os itens da lista.

DOWNLOAD

Retornar dados de listas c#

Ae Pessoal, segue abaixo código para retornar itens de lista do SP2010 com query em CAML:

SPWeb mySite = SPContext.Current.Web;
            using (SPSite site = new SPSite(mySite.Url))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPList list = web.Lists["NomeLista"];
                    SPQuery myquery = new SPQuery();
                    myquery.Query = "<Where><Eq><FieldRef Name='NomeColuna' /><Value Type='Text'></Value>ValorFiltro</Eq></Where>";
                    SPListItemCollection items = list.GetItems(myquery);
                    foreach (SPListItem item in items)
                    {
                        if (item != null)
                        {
                               //Seu código aqui
                        }
                    }
                }
            }

Criando listas do SP2010 via c#

Caros, segue abaixo código para criação de listas do SP2010 via c#:

public void CreateList()
        {
                   SPWeb web = SPContext.Current.Web;
                   web.AllowUnsafeUpdates = true;
                   web.Lists.Add("NomeLista", "Descrição da lista", SPListTemplateType.GenericList);
                    SPList listName= web.Lists["NomeLista"];
                    SPView viewName = listName.DefaultView;
                    listName.Fields.Add("NomeCampo", SPFieldType.Text, true);
                    listName.Fields.Add("NomeCampoData", SPFieldType.DateTime, true);
                    viewName .ViewFields.Add("NomeCampo");
                    viewName .ViewFields.Add("NomeCampoData");
                    viewName .Update();
                    web.AllowUnsafeUpdates = false;
        }

Inserindo itens em listas

Caros, segue abaixo código para inserção de itens em listas do SharePoint:


public void SendComment()
        {
            SPWeb theSite = SPControl.GetContextWeb(Context);
            SPWeb mySite = SPContext.Current.Web;
            using (SPSite oSite = new SPSite(mySite.Url))
            {
                using (SPWeb oWeb = oSite.RootWeb)
                {
                    oWeb.AllowUnsafeUpdates = true;
                    SPList oList = oWeb.Lists["NomeDaLista"];
                    SPListItem oSPListItem = oList.Items.Add();
                    oSPListItem["NomeColuna"] = "teste";
                    oSPListItem["NomeColuna"] = "teste";
                    oSPListItem["NomeColuna"] = "1";
                    oSPListItem.Update();
                    oWeb.AllowUnsafeUpdates = false;
                }
            }
        }

quinta-feira, 5 de julho de 2012

URL's administrativas do SharePoint 2010

Caros, seguem abaixo algumas URL's administrativas do SP2010:

Função / URL de Referência
  • Painel para Adicionar nova web Part na página - ?ToolPaneView=2
  • Criar novos conteúdos para o Site - /_layouts/create.aspx
  • Galeria de Templates – /_catalogs/lt
  • Gerenciar os administradores do Site - /_layouts/mngsiteadmin.aspx
  • Gerencirar ou Criar Sites – /_layouts/mngsubwebs.aspx
  • Gerenciamento de Usuários do Site – /_layouts/people.aspx
  • Gerenciamento de Grupos de usuários - /_layouts/user.aspx
  • Galeria de Master Page - /_catalogs/masterpage
  • Navegação do Site - /_layouts/AreaNavigationSettings.aspx
  • Recycle Bin – /_layouts/AdminRecycleBin.aspx
  • Gelerias de Colunas do Site – /_layouts/mngfield.aspx
  • Geleria de Tipos de Conteúdos - /_layouts/mngctype.aspx
  • Conteúdo e estrutura do Site - /_layouts/sitemanager.aspx
  • Site Settings – /_layouts/settings.aspx
  • Alertas dos Usuários – /_layouts/sitesubs.aspx
  • Ver todo o conteúdo do Site – /_layouts/viewlsts.aspx
  • Galeria de Web Parts - /_catalogs/wp
  • Manutenção de Páginas de Web Part – ?contents=1
  • Workflows – /_layouts/wrkmng.aspx

PlaceHolders que devem constar na Master Page

Caros, tive sérios problemas com isso, e após apanhar muito, descobri que os seguintes itens devem constar na nossa Master Page:

Name of Content Placeholder Description
PlaceHolderAdditionalPageHeadAdditional content that needs to be within the <head> tag of the page, for example, references to script in style sheets
PlaceHolderBodyAreaClassAdditional body styles in the page header
PlaceHolderBodyLeftBorderBorder element for the main page body
PlaceHolderBodyRightMarginRight margin of the main page body
PlaceHolderCalendarNavigatorShows a date picker for navigating in a calendar when a calendar is visible on the page
PlaceHolderFormDigestThe “form digest” security control
PlaceHolderGlobalNavigationThe global navigation breadcrumb
PlaceHolderHorizontalNavTop navigation menu for the page
PlaceHolderLeftActionsBottom of the left navigation area
PlaceHolderLeftNavBarLeft navigation area
PlaceHolderLeftNavBarBorderBorder element on the left navigation bar
PlaceHolderLeftNavBarDataSourceData source for the left navigation menu
PlaceHolderLeftNavBarTopTop of the left navigation area
PlaceHolderMainPage’s main content
PlaceHolderMiniConsoleA place to show page-level commands, for example, WIKI commands such as Edit Page, History, and Incoming Links
PlaceHolderNavSpacerThe width of the left navigation area
PlaceHolderPageDescriptionDescription of the page contents
PlaceHolderPageImagePage icon in the upper left area of the page
PlaceHolderPageTitleThe page <Title> that is shown in the browser’s title bar
PlaceHolderSearchAreaSearch box area
PlaceHolderSiteNameSite name
PlaceHolderTitleAreaClassAdditional styles in the page header
PlaceHolderTitleAreaSeparatorShows shadows for the title area
PlaceHolderTitleBreadcrumbMain content breadcrumb area
PlaceHolderTitleInTitleAreaPage title shown immediately below the breadcrumb
PlaceHolderTitleLeftBorderLeft border of the title area
PlaceHolderTitleRightMarginRight margin of the title area
PlaceHolderTopNavBarTop navigation area
PlaceHolderUtilityContentExtra content that needs to be at the bottom of the page
SPNavigationEmpty by default in Windows SharePoint Services. Can be used for additional page editing controls.
WSSDesignConsoleThe page editing controls when the page is in Edit Page mode (after clicking Site Actions, then Edit Page)

Obtendo ajuda no powershell do SP2010

Existem muitos comandos úteis no PowerShell, e às vezes pinta aquela dúvida sobre alguns comandos, então segue abaixo um comando que lhe ajudará a ter todas respostas que precisa:
 
Busca completa:
Get-Command *enterprisesearch*
Busca por nome:
Get-Command *enterprisesearch* | select Name
Busca excluindo resultados de SPWeb:
Get-Command -noun SPWeb
Busca específica:
Get-Help Get-SPWeb -full

Adicionando pacote wsp na site collection

Depois de gerado o pacote wsp, execute o powershell do SP2010 como admin e execute os seguintes comandos:

Add-SPSolution -literalpath c:\suasolution.wsp

Ele retornará uma mensagem onde constará que sua solution não está com deploy feito. Para isso, entre no Central Admin do SharePoint e vá até Farm Solution Manager, clique no item que você inseriu e selecione 'deploy', será aberto modal de opções, escolha o site collection e clique em ok.
Após isso, vá nas opções do site, Features e ative a feature que você acabou de inserir. Pronto, agora sua webpart está disponível para uso.

Update de Solution via PowerShell

Caros, segue um comando muito útil quando se deseja atualizar a solution no SharePoint 2010:

Update-SPSolution -identity solutionname.wsp -LiteralPath c:\solutionname.wsp

Não se esqueçam de alterar o solutioname para o nome do seu wsp, assim como o caminho onde está localizado seu arquivo novo.

Caso tenham problemas com o GAC, utilizem o comando a seguir:

Update-SPSolution -identity solutionname.wsp -LiteralPath c:\solutionname.wsp -G