Git Product home page Git Product logo

sharepointapp-timerjob's Introduction

SharePointApp-TimerJob

Esse exemplo mostra como criar um TimerJob utilizando SharePoint apps.

Rodando esse projeto

Para rodar esse exemplo você precisará:

  • Visual Studio 2013
  • SharePoint 2013 / SharePoint Online

1 - Clonar ou fazer o download do Repositório

Rode o comando abaixo no Git Shell:

git clone https://github.com/RARomano/SharePointApp-TimerJob.git

2 - Registrar um novo App

Abrir a URL "_layouts/AppRegNew.aspx" no seu SharePoint

Clicar no botão gerar do ID do Cliente e do Segredo do Cliente. Digitar o Título da App preencher um domínio para a APP (pode ser localhost) e uma URL de redirecionamento (pode ser a URL do seu SharePoint)

Criar um App

3 - Alterar o arquivo App.Config

App.Config

4 - Dar permissões ao App

Abrir a URL “_layouts/AppInv.aspx” no seu SharePoint e digite o ClientID criado na etapa 2.

Permissões

No campo XML de Solicitação de Permissão do Aplicativo cole o XML abaixo:

<AppPermissionRequests AllowAppOnlyPolicy="true">
    <AppPermissionRequest Scope="http://sharepoint/content/tenant" Right="Manage" />
</AppPermissionRequests>

Com esse XML, você dará permissão em todo o Tenant para o App. Altere se for necessário.

5 - Alterar o código

Alterar a Url e incluir a funcionalidade desejada.

string siteUrl = "http://localhost";
Uri uri = new Uri(siteUrl);

string realm = TokenHelper.GetRealmFromTargetUrl(uri);

//Get the access token for the URL.  
//   Requires this app to be registered with the tenant
string accessToken = TokenHelper.GetAppOnlyAccessToken(
    TokenHelper.SharePointPrincipal,
    uri.Authority, realm).AccessToken;

using (var ctx = TokenHelper.GetClientContextWithAccessToken(uri.ToString(), accessToken))
{
    /// codigo vai aqui
    ctx.Load(ctx.Web);
    var webTitle = ctx.Web.Title;

    ctx.ExecuteQuery();

    Console.Write(webTitle);
}

sharepointapp-timerjob's People

Contributors

raromano avatar

Stargazers

 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.