Extending SharePoint Online met Windows 8 apps

57
Extending SharePoint Online met Windows 8 apps Michaël Hompus Sander Bosman

description

Michaël Hompus Sander Bosman. Extending SharePoint Online met Windows 8 apps . Voorstellen. Michaël Hompus Principal developer [email protected] @eNeRGy164. Sander Bosman Senior developer [email protected] @ Sander_B. Voorstellen. Onderwijs. Zorg. Goede doelen. - PowerPoint PPT Presentation

Transcript of Extending SharePoint Online met Windows 8 apps

Page 1: Extending SharePoint Online met Windows 8 apps

Extending SharePoint Online met Windows 8 apps

Michaël HompusSander Bosman

Page 3: Extending SharePoint Online met Windows 8 apps

Voorstellen

Innovatieteam

Onderwijs Zorg Goede doelen

Page 4: Extending SharePoint Online met Windows 8 apps

Agenda• Voorstellen• Doelstelling• Authenticatie• SharePoint interfaces• Windows 8 and beyond…

Page 5: Extending SharePoint Online met Windows 8 apps

Doelstelling• Als bedrijf willen we een centrale plek

om informatie over onze projecten en referenties gemakkelijk bij te kunnen houden• Als een medewerker van het bedrijf wil

ik een Windows 8 app zodat ik onderweg informatie over projecten en referenties kan opzoeken ook als ik geen dataverbinding heb

Page 6: Extending SharePoint Online met Windows 8 apps

DEMO

Page 7: Extending SharePoint Online met Windows 8 apps

Authenticatie

Page 8: Extending SharePoint Online met Windows 8 apps

Authenticatie• Hoe krijg je bedrijfsaccounts in

SharePoint Online?• Hoe kan je authenticeren tegen

SharePoint Online vanuit een Windows 8 app?• Hoe sla je credentials op in een Windows

8 app

Page 9: Extending SharePoint Online met Windows 8 apps

AD accounts in SharePoint Online

Page 10: Extending SharePoint Online met Windows 8 apps

AD accounts in SharePoint OnlineWens: Medewerker moet met het bedrijfs-account (AD) kunnen inloggen op de app.

Oplossing: DirSyncVerschillende opties:• DirSync AD Accounts• DirSync AD Accounts met Wachtwoord

Same Sign-On

• DirSync AD Accounts i.c.m. ADFSSingle Sign-On

Page 11: Extending SharePoint Online met Windows 8 apps

AD accounts in SharePoint Online

Page 12: Extending SharePoint Online met Windows 8 apps

AD accounts in SharePoint Online

Page 13: Extending SharePoint Online met Windows 8 apps

Authenticatie

Page 14: Extending SharePoint Online met Windows 8 apps

Authenticatie - Architectuur

https://login.microsoftonline.com/extSTS.srf

https://<tenant>.sharepoint.com/_forms/default.aspx?wa=wsignin1.0

https://<tenant>.sharepoint.com/_vti_bin/ListData.svc

Page 16: Extending SharePoint Online met Windows 8 apps

DEMO

Page 17: Extending SharePoint Online met Windows 8 apps

Authenticatie - Architectuur

https://login.microsoftonline.com/extSTS.srf

Page 18: Extending SharePoint Online met Windows 8 apps

Authenticatie – Token Request

https://<tenant>.sharepoint.com

Sander Bosman
Sander Bosman
Page 19: Extending SharePoint Online met Windows 8 apps

Authenticatie – Token Response

Page 20: Extending SharePoint Online met Windows 8 apps

Authenticatie - Architectuur

https://login.microsoftonline.com/extSTS.srf

https://<tenant>.sharepoint.com/_forms/default.aspx?wa=wsignin1.0

Page 21: Extending SharePoint Online met Windows 8 apps

Authenticatie – Login Request

Page 22: Extending SharePoint Online met Windows 8 apps

Authenticatie – Login Response

Page 23: Extending SharePoint Online met Windows 8 apps

Authenticatie - Architectuur

https://login.microsoftonline.com/extSTS.srf

https://<tenant>.sharepoint.com/_forms/default.aspx?wa=wsignin1.0

https://<tenant>.sharepoint.com/_vti_bin/ListData.svc

Page 24: Extending SharePoint Online met Windows 8 apps

Authenticatie – Data Request

Page 25: Extending SharePoint Online met Windows 8 apps

Authenticatie – Data Response

Page 26: Extending SharePoint Online met Windows 8 apps

Credentials opslaan in de app

Page 27: Extending SharePoint Online met Windows 8 apps

Password Vault - Store

var passwordVault = new PasswordVault();var passwordCredentials = passwordVault.RetrieveAll(); foreach (var passwordCredential in passwordCredentials){ try { if (passwordCredential.Resource == WinvisionDosyeAccount && passwordCredential.UserName == credentials.Username) {

passwordVault.Remove(passwordCredential); } } catch (COMException) { // No password found }} var credential = new PasswordCredential(WinvisionDosyeAccount, credentials.Username, credentials.Password); passwordVault.Add(credential);

Page 28: Extending SharePoint Online met Windows 8 apps

Password Vault - Retrievevar passwordVault = new PasswordVault();var credentials = passwordVault.RetrieveAll();

foreach (var passwordCredential in credentials){ try { if (passwordCredential.Resource != WinvisionDosyeAccount) {

continue; }  passwordCredential.RetrievePassword();  return new Credentials

{ Username = passwordCredential.UserName, Password = passwordCredential.Password,

}; } catch (COMException) { // No password found }}

Page 29: Extending SharePoint Online met Windows 8 apps

Credential Manager

Page 30: Extending SharePoint Online met Windows 8 apps

SharePoint interfaces

Page 31: Extending SharePoint Online met Windows 8 apps

SharePoint interfaces• Welke SharePoint interfaces kan ik

gebruiken• Hoe kan ik lijsten, managed metadata

en bestanden opvragen• Welke voor- en nadelen hebben de

verschillende interfaces

Page 32: Extending SharePoint Online met Windows 8 apps

SharePoint interfaces• Server object model• Silverlight client object model• JavaScript client object model• .NET Framework client object model• Mobile client object model• REST/OData endpoints• Web Services• Remote Procedure Call

Page 33: Extending SharePoint Online met Windows 8 apps

SharePoint lijsten

Page 34: Extending SharePoint Online met Windows 8 apps

SharePoint lijstenWCF Data Services• LINQ queries tegen databron• …/_vti_bin/listdata.svc• WCF Data Services Tools for Windows

Store Appshttp://www.microsoft.com/en-us/download/details.aspx?id=30714

Standaard niet awaitable• Async extension methods for

DataServiceContexthttps://gist.github.com/Phanatic/3427256

Page 35: Extending SharePoint Online met Windows 8 apps

var context = new InnovatieDataContext(new Uri(string.Format("{0}/_vti_bin/listdata.svc", this.settingsService.GetSharePointUri())));context.SendingRequest += this.ContextOnSendingRequest;

var result = new List<Customer>();

var query = (DataServiceQuery<Customer>)context.Klanten.Select(c => new Customer { Id = c.Id, Name = c.Titel, AccountManagerId = c.AccountManagerId, ServiceManagerId = c.ServiceManagerId, VerticalId = c.VerticalId, LogoPath = c.Logo, Telephone = c.Telefoonnummer, Website = c.Website, Email = c.Email });

var customers = await query.ExecuteAsync();

result.AddRange(customers);

SharePoint lijstenCookie moet meegegeven worden

private void ContextOnSendingRequest(object sender, SendingRequestEventArgs sendingRequestEventArgs){

sendingRequestEventArgs.RequestHeaders["Cookie"] = this.settingsService.GetCookieContainer();}

Page 36: Extending SharePoint Online met Windows 8 apps

SharePoint lijstenIssue:• Veldnamen in queries zijn taalafhankelijk• Na enige inactiviteit regeert SharePoint

Online op het eerste request altijd in het Engels!• DataServiceClientException

Page 37: Extending SharePoint Online met Windows 8 apps

Managed metadata

Page 38: Extending SharePoint Online met Windows 8 apps

Managed metadataKan je niet ophalen met listdata.svc

REST API• …/_api/• HttpClient

/_api/web/lists/getbytitle('Referenties')/Items?$select=Id,Microsoft_x0020_technieken

Page 39: Extending SharePoint Online met Windows 8 apps

Managed metadata• Cookie moet meegegeven worden• JSON.NET om resultaten te verwerken

var cookieContainer = new CookieContainer();cookieContainer.SetCookies(new Uri(this.settingsService.GetSharePointUri()), cookieHeader);

var client = new HttpClient(new HttpClientHandler { CookieContainer = cookieContainer });client.DefaultRequestHeaders.Add("Cookie", cookieHeader);client.DefaultRequestHeaders.Accept.ParseAdd("application/json;odata=verbose");

var response = await client.GetStringAsync( string.Format("{0}/_api/web/lists/getbytitle('Referenties')/Items? $select=Id,Microsoft_x0020_technieken", this.settingsService.GetSharePointUri()));

var json = JObject.Parse(response);

var managedMetadata = from i in json["d"]["results"].Children().Where(g => g["Microsoft_x0020_technieken"]["results"].Any()) select new { Id = (int)i["Id"], Labels = i["Microsoft_x0020_technieken"]["results"].Values<string>("Label").ToArray() };

var microsoftTechnologies = managedMetadata.ToDictionary(m => m.Id, m => m.Labels);

Page 40: Extending SharePoint Online met Windows 8 apps

Bestanden

Page 41: Extending SharePoint Online met Windows 8 apps

Bestanden

Page 42: Extending SharePoint Online met Windows 8 apps

Bestanden

Attachments = c.Bijlagen.Select(b => new Attachment { Title = b.Name, SharePointPath = string.Format("{0}/Lists/{1}/Attachments/{2}/{3}",

this.settingsService.GetSharePointUri(), b.EntitySet, b.ItemId, b.Name)

}),

Page 43: Extending SharePoint Online met Windows 8 apps

Bestanden

var cookieContainer = new CookieContainer();cookieContainer.SetCookies(new Uri(this.settingsService.GetSharePointUri()), cookieHeader);

var buffer = new byte[] { }

using (var client = new HttpClient(new HttpClientHandler { CookieContainer = cookieContainer })){ buffer = await client.GetByteArrayAsync(uri);}

var images = await ApplicationData.Current.LocalFolder.CreateFolderAsync(folder, CreationCollisionOption.OpenIfExists);var file = await images.CreateFileAsync(cacheKey, CreationCollisionOption.ReplaceExisting);

await FileIO.WriteBytesAsync(file, buffer);

Page 44: Extending SharePoint Online met Windows 8 apps

“run-with-cookies”

Page 45: Extending SharePoint Online met Windows 8 apps

UitdagingenAlles in Windows 8 Async• Wat doe je als je nog geen cookie hebt• Wat doe je als je cookie is verlopen• Met meerdere requests tegelijk• Met meerdere technieken

− DataContext− HttpClient

• En met mogelijke fouten die optreden

Page 46: Extending SharePoint Online met Windows 8 apps

“run-with-cookies”Start

Lees cookie uit opgeslagen settings

Is er een cookie?

Remote Request

Is er een fout opgestreden?

Done

Wordt er al een cookie opgehaald

J a

J a

Nee

Haal cookie op en sla op in settingsNee Nee

Is het de Office 365 bug?

Is het cookie verlopen?

J a

J a Nee

J a

Nee

Exception

Page 47: Extending SharePoint Online met Windows 8 apps

Windows 8 and beyond

Page 48: Extending SharePoint Online met Windows 8 apps

Andere devicesUniversal apps• Windows 8.1 update• Windows Phone 8.1• Xbox One

Page 49: Extending SharePoint Online met Windows 8 apps

DEMO

Page 50: Extending SharePoint Online met Windows 8 apps

Windows 8.1 app

Page 51: Extending SharePoint Online met Windows 8 apps

Make universal

Page 52: Extending SharePoint Online met Windows 8 apps

Windows Phone 8.1

Page 53: Extending SharePoint Online met Windows 8 apps

Andere devicesXamarin• Android• iOS

Page 54: Extending SharePoint Online met Windows 8 apps

DEMO

Page 55: Extending SharePoint Online met Windows 8 apps

Android

Page 56: Extending SharePoint Online met Windows 8 apps

Vragen?

Page 57: Extending SharePoint Online met Windows 8 apps

THANK YOU