Combine the fast, fluid and immersive experience of Windows Store apps with SharePoint 2013 to discover, organize and manage content. This session will walk through planning and building an app to interact with SharePoint content by utilizing the new APIs available with SharePoint 2013.
1. 6000 Greenwood Plaza Blvd
Suite 110
Greenwood Village, CO 80111
303.798.5458
www.aspenware.com
Windows Store App
for SharePoint 2013
2. Waughn
Hughes
Waughn has over 14 years of consulting experience, and has worked extensively with SharePoint for the past
seven years as a developer and solutions architect.
Waughn Hughes, Solutions Architect | w.hughes@aspenware.com
3. Agenda
• Start
• Plan
• Design
• Build
• Demo
Building Windows Store apps for SharePoint 2013 3
9. Activities to support…
• Find content in numerous SharePoint environments
• Bookmark content for easy access
• Provide notification when content is updated
Building Windows Store apps for SharePoint 2013 9
10. Features to include…
• Search and discover content (e.g. sites, lists and documents)
• Add and remove content from favorite list
• View dashboard of content
• Preview content before launching another application
• Create shortcut to a particular site
• Share content with other people and applications
Building Windows Store apps for SharePoint 2013 10
15. Environment and Tools
• Window 8
– and –
• Visual Studio Express 2012 for Windows 8
• Visual Studio 2012
– and –
• Office 365 (Developer Site)
• SharePoint (Foundation or Server) 2013 Farm
Building Windows Store apps for SharePoint 2013 16
16. Windows Store app: Languages
• VB/C#/C++ and XAML
• JavaScript and HTML
• C++ and DirectX
Building Windows Store apps for SharePoint 2013 17
17. SharePoint 2013 APIs
Building Windows Store apps for SharePoint 2013 18
http://msdn.microsoft.com/en-us/library/jj164060
Custom Client Application
SharePoint
server object model
_api
ODATA
REST
Execute
Query
JavaScript
object model
Silverlight & Mobile
client object model
.NET
client object model
Server
Client
18. What’s New?
• Search
• User Profile
• Taxonomy
• Feeds
• Publishing
• Sharing
Building Windows Store apps for SharePoint 2013 19
• Workflow
• E-Discovery
• IRM
• Analytics
• Business Data
19. Web: CSOM Example
// create the client context
using (ClientContext context = new ClientContext("http://sharepoint.demo.com"))
{
// set credentials for authentication
context.Credentials = CredentialCache.DefaultCredentials;
// the sharepoint web at the url
Web web = context.Web;
// retrieve the web properties
context.Load(web);
// retrieve the specified web properties
// context.Load(web, w => w.Title, w => w.Description);
// execute query
context.ExecuteQuery();
// access properties
string title = web.Title;
string description = web.Description;
}
Building Windows Store apps for SharePoint 2013 20
20. Web: REST Example
// create handler to handle authentication for the httpclient
HttpClientHandler handler = new HttpClientHandler();
handler.UseDefaultCredentials = true;
using (HttpClient client = new HttpClient(handler))
{
// specify format of results (atom/xml or json)
client.DefaultRequestHeaders.Add("Accept", "application/atom+xml");
client.DefaultRequestHeaders.Add("ContentType", "application/atom+xml;type=entry");
// create the rest url
string restUrl = "http://sharepoint.demo.com/_api/web";
// string restUrl = "http://sharepoint.demo.com/_api/web?$select=Title,Description";
// send asynchronous get request
HttpResponseMessage response = await client.GetAsync(restUrl);
// verify that the request was successful
response.EnsureSuccessStatusCode();
// write the http content to string
string responseBodyAsText = await response.Content.ReadAsStringAsync();
// read the xml into xdocument to use LINQ to XML
StringReader reader = new StringReader(responseBodyAsText);
XDocument responseXml = XDocument.Load(reader, LoadOptions.None);
// namespaces required to query xml document
XNamespace atom = "http://www.w3.org/2005/Atom";
XNamespace d = "http://schemas.microsoft.com/ado/2007/08/dataservices";
XNamespace m = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";
// access properties
string title = responseXml.Element(atom + "content").Element(m + "properties").Element(d + "Title").Value;
string description = responseXml.Element(atom + "content").Element(m + "properties").Element(d + "Description").Value;
}
Building Windows Store apps for SharePoint 2013 21
21. Search: CSOM Example
// create the client context
using (ClientContext context = new ClientContext("http://sharepoint.demo.com"))
{
// set credentials for authentication
context.Credentials = CredentialCache.DefaultCredentials;
// describe the query
var keywordQuery = new KeywordQuery(context);
keywordQuery.QueryText = "search term";
// used to execute queries against search engine
SearchExecutor searchExecutor = new SearchExecutor(context);
// execute the search query
ClientResult<ResultTableCollection> results = searchExecutor.ExecuteQuery(keywordQuery);
// execute query
context.ExecuteQuery();
// access search properties and results
int totalCount = results.Value[0].TotalRows;
IEnumerable<IDictionary<string, object>> rows = results.Value[0].ResultRows;
}
Building Windows Store apps for SharePoint 2013 22
22. Search: REST Example
// create handler to handle authentication for the httpclient
HttpClientHandler handler = new HttpClientHandler();
handler.UseDefaultCredentials = true;
using (HttpClient client = new HttpClient(handler))
{
// specify format of results (atom/xml or json)
client.DefaultRequestHeaders.Add("Accept", "application/atom+xml");
client.DefaultRequestHeaders.Add("ContentType", "application/atom+xml;type=entry");
// create the rest url for search
string searchRestUrl = "http://sharepoint.demo.com/_api/search/query?querytext='searchterm'";
// send asynchronous get request
HttpResponseMessage response = await client.GetAsync(restUrl);
// verify that the request was successful
response.EnsureSuccessStatusCode();
// write the http content to string
string responseBodyAsText = await response.Content.ReadAsStringAsync();
// read the xml into xdocument to use LINQ to XML
StringReader reader = new StringReader(responseBodyAsText);
XDocument responseXml = XDocument.Load(reader, LoadOptions.None);
// namespaces required to query xml document
XNamespace atom = "http://www.w3.org/2005/Atom";
XNamespace d = "http://schemas.microsoft.com/ado/2007/08/dataservices";
XNamespace m = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";
// retrieve search results
XElement relavantResults = responseXml.Descendants(d + "query").Elements(d + "PrimaryQueryResult").Elements(d + "RelevantResults").FirstOrDefault();
List<XElement> items = responseXml.Descendants(d + "query").Elements(d + "PrimaryQueryResult").Elements(d + "RelevantResults")
.Elements(d + "Table").Elements(d + "Rows").Elements(d + "element").ToList();
}
Building Windows Store apps for SharePoint 2013 23
25. References: Windows Store apps
Learn to build Windows Store apps
http://msdn.microsoft.com/en-us/library/windows/apps/br229519
Concepts and architecture
http://msdn.microsoft.com/en-us/library/windows/apps/br211361
Developing Windows Store apps
http://msdn.microsoft.com/en-us/library/windows/apps/xaml/br229566
Windows 8 app samples
http://code.msdn.microsoft.com/windowsapps/Windows-8-Modern-Style-App-Samples
Creating Windows Runtime Components in C# and Visual Basic
http://msdn.microsoft.com/en-us/library/windows/apps/br230301
Building Windows Store apps for SharePoint 2013 26
26. References: SharePoint 2013 APIs
What’s new for developers in SharePoint 2013
http://msdn.microsoft.com/en-us/library/jj163091
Choose the right API set in SharePoint 2013
http://msdn.microsoft.com/en-us/library/jj164060
Reference for SharePoint 2013
http://msdn.microsoft.com/en-us/library/jj193038
How to: Complete basic operations using SharePoint 2013 client library code
http://msdn.microsoft.com/en-us/library/fp179912
Programming using the SharePoint 2013 REST service
http://msdn.microsoft.com/en-us/library/fp142385
Building Windows Store apps for SharePoint 2013 27