450 likes | 642 Views
Построение Windows 8 приложений для доступа к SharePoint 2013. Бельский Сергей. Agenda. Getting started with Windows 8 Apps Which SharePoint APIs are suitable? Binding SharePoint data Searching SharePoint Notification. What is a Window 8 app ?. Touch First.
E N D
Построение Windows 8приложений для доступа к SharePoint 2013 Бельский Сергей
Agenda • Getting started with Windows 8Apps • Which SharePoint APIs are suitable? • Binding SharePoint data • Searching SharePoint • Notification
Touch First • No chrome – full screen experience • Designed for Touch and Pen input
What is a Windows 8 app? • Full screen window with multiple views • Supports touch and works great without • Runs on a variety of devices • Sandboxed • Uses tiles instead of icons • Can be distribute via Windows Store
Why Windows 8 App and SharePoint? • Great way to visualize data • Business Intelligence • Charts / Graphs • Reports • Brings SharePoint to the Desktop • Executives love “touch” • Great app opportunity • Easy to develop
Getting Started - Environment • At least two machines required • Server running SharePoint 2013 • SQL, Active Directory, Workflow, WAC optionally on other servers • Client running Windows 8 • Pro or Enterprise works best • Ideally both machines are on the same domain
Getting Started - Server • Windows Server running SharePoint 2013 • Visual Studio not required • More memory is ideal
Getting Started - Client • Client running Windows 8 • Pro or Enterprise ideal • Connected to same domain • Visual Studio 2012 RTM • 2 GB – 4 GB of memory • Internet connection required
Which Language? • HTML5 + JavaScript • XAML with C#, Visual Basic, or C++ code-behind • DirectX with native C++ and HLSL
SharePoint Integration Points • Authorization • Data binding • Contracts • Search • Live Tiles • Notification
Data binding steps • Retrieve data from SharePoint • Bind data to default view model • Customize template
SharePoint 2013 APIs • RSS • Client Script Object Model • Web Services • REST
What’s covered in the new CSOM/REST APIs? Search Social Taxonomy Workflow Analytics Sharing Publishing eDiscovery IRM BCS And much, much more!
Why is REST the best choice? • Simple and Easy to Use • Much easier to use than SOAP-based Web service • Higher productivity when using JavaScript and jQuery • Results can be returned in JSON and ATOM format • Test in a browser
ODATA URIs • URI has three significant parts • Service root URI • Resource path • Query string options (select, filter)
REST URLs in SharePoint 2013 _api is new alias for _vti_bin/client.svc Server Client CSOM REST OData JSON JavaScript Library Silverlight Library .Net CLR Library Custom Client Code
Mapping Objects to Resources • Example REST URLs targeting SharePoint sites _api/web/lists _api/web/lists/getByTitle('Announcements') _api/web/lists/getByTitle('Announcements')/$select=title,body,expirationdate
ATOM XML or JSON? • Response data format selected with ACCEPT header • XML can be easier to deal with from managed code • To get ATOM XML response use "application/atom+xml" • JSON is easier to deal with when using JavaScript • To get JSON response use "application/json"
REST Queries from Windows 8 Apps • Use HttpClientobject to GET SharePoint data • Use HttpClientHandler object for authentication • Add headers to request data in ATOM XML format • Parse data with LINQ to XML
Data Templates • Bind data to SharePoint fields • Change look and feel of results • Can be defined in: • Page.Resources • StandardStyles.xaml <DataTemplate x:Key="Standard250x250ItemTemplate"> <Grid HorizontalAlignment="Left" Width="250" Height="250"> <Border Background="{StaticResourceListViewItemPlaceholderBackgroundThemeBrush}"> <Image Source="{Binding Image}" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}"/> </Border> <StackPanelVerticalAlignment="Bottom" Background="{StaticResourceListViewItemOverlayBackgroundThemeBrush}"> …
Package.appmanifest • Specify information about your app • i.e.: Name, logo, supported orientations, splash screen • Declares capabilities your app requires • SharePoint typically requires: • Enterprise Authentication (not for office 365) • Internet (Client) • Private Networks (Client & Server) (not for office 365)
What is App Contract? • An agreement between one or more apps • Built with special Visual Studio project items File Picker Play To Search Share Settings
Search Contract • Great for SharePoint • Add SharePoint Search to the Charms menu • Touch friendly interface • App automatically launched if not open • Can be activated on keyboard input
Creating a Search Contract • Use Search Contract Project Item • Query search via REST • Format XML into expected format • Bind results to this.DefaultViewModel[“Results”]
Searching SharePoint • Search Web Service deprecated • REST API preferred query method • Search REST URL
Tiles • Combination of text and images • Defined by XML • 34 Templates Available • Can be updated by app
Tile XML <tile> <visual> <binding template="TileSquareBlock"> <text id="1">Text Field 1</text> <text id="2">Text Field 2</text> </binding> </visual> </tile> <tile> <visual> <binding template="TileWideImageAndText01"> <image id="1" src="image1.png" alt="alt text"/> <text id="1">Text Field 1</text> </binding> </visual> </tile>
Apps can notify users with • Tiles • Badges • Toast • Lock Screen
Types of notification • Periodic • Polling – occurs at regular intervals until stopped • Scheduled – occurs at a scheduled time • Push
Strategy for updating Tiles with SharePoint • No client side code executed when polling Tile XML • Avoid custom code in SharePoint • Solution: Custom RSS
Resources Windows 8 Apps + new Office 365 (SharePoint Online) http://blogs.msdn.com/b/omarv/archive/2012/10/25/windows-8-store-apps-office-365-enterprise-preview-sharepoint-online.aspx My technical blog http://blogs.msdn.com/b/sergey_belskiy_technical_blog/ Programming using the SharePoint 2013 REST service http://msdn.microsoft.com/en-us/library/fp142385.aspx