Custom SharePoint 2010 solutions without server access


Published on

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Custom SharePoint 2010 solutions without server access

  1. 1. Developing Custom SharePoint 2010 Solutions without server access<br />Phil Wicklund<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  2. 2. About Me…<br />Working with SP since 2004<br />Started as a trainer for Mindsharp<br />Now consulting through RBA in MN<br />Blog:<br />Writing a 2010 book:<br />
  3. 3. Agenda<br />The Problem: how to develop custom <br />solutions that won’t impair the farm<br />SharePoint Designer 2010<br />Sandboxed Solutions<br />Client Object Model<br />Questions<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  4. 4. SharePoint Designer 2010<br />Used for:<br />Browser alternative (administrate pages, content types, web parts, etc)<br />Branding<br />XsltListViewWebPart<br />Workflow<br />External Data<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  5. 5. Demo 1: Workflow with SPD<br />Model Workflow in Office Visio<br />Import Workflow into SharePoint Designer<br />Publish to SharePoint, and test<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  6. 6. Sandboxed Solutions<br />Solutions are cab based file with wspextenion<br />can contain web parts, features, workflows, etc.<br />Scoped to a Site Collection<br />Site Collection Administrators Install, Manage and Monitor the solutions<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  7. 7. Sandboxed Solutions<br />Solution Gallery:<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  8. 8. Sandboxed Solutions<br />Debugging Sandboxed Solutions<br />Farm Solutions run in the w3wp.exe process<br />Sandboxed Solutions run in the SPUCWorkerProcess.exe process<br />Hitting F5 automatically attaches to SPUCWorkerProcess.exe, then simply drop web part on a page, for example<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  9. 9. Sandboxed Solutions<br />Caveats<br />Full API swapped out at runtime with sandboxed subset. SPSecurity.RunWithElevatedPrivledges, for example, won’t work.<br />IntelliSense is also truncated to help prevent runtime errors since compiler compiles against full API<br />Try to avoid cut and paste<br />All classes below SPSite are available<br />Partial trust prevents access to anything outside the scope of the Site Collection (Internet, Web service, file system, etc)<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  10. 10. Sandboxed Solutions<br />Monitoring<br />“Point” quotas set in Central Administration. Default is 300 points.<br />Shows usage reports, for today and a 14 day average<br />Points – next slide<br />Validators<br />Fire on upload of solution into Gallery<br />Can enfore, only web parts, singed cod with a particular token, log/catalog solutions, etc.<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  11. 11. Sandboxed Solutions<br />Courtesy John W Powell - MSDN<br />
  12. 12. Demo 2: Sandboxed Web Part<br />New Visual Studio Project<br />Create a Web Part<br />Deploy as Sandboxed Solution<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  13. 13. Client Side Object Model<br />Not enough web services in SP 2007<br />Rather than create more services, COM provides the complete API<br />COM provides a consistent development experience:<br />Windows Applications<br />ASP.NET web sites<br />Silverlight Applications<br />JavaScript, www client side scripting<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  14. 14. COM Architecture<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  15. 15. Assembly References<br />SharePoint, Server Side<br />Microsoft.SharePoint (ISAPI)<br />.NET clients<br />Microsoft.SharePoint.Client (ISAPI)<br />Silverlight clients<br />Microsoft.SharePoint.Client.Silverlight (Layouts/clientbin)<br />Javascript clients<br />SP.js & SP.Core.js (Layouts)<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  16. 16. Comparable Objects<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  17. 17. Starter Code<br />Using Microsoft.SharePoint.Client;<br />...<br />using (ClientContext context = new ClientContext("http://intranet"))<br />{<br /> Web web = context.Web;<br />context.Load(web);<br />context.ExecuteQuery(); <br /> string title = web.Title;<br /> // ListCollection lists = web.Lists; <br />}<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  18. 18. Iterating through Lists in a Web<br />using (ClientContext context = new ClientContext("http://intranet"))<br />{<br /> Web web = context.Web;<br />context.Load(web);<br />context.Load(web.Lists);<br />context.ExecuteQuery(); <br />foreach(List list in web.Lists)<br /> {<br /> //do something<br /> }<br />}<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  19. 19. Efficiencies… Don’t be Lazy!<br />Web web = context.Web;<br />context.Load(web, wprop => wprop.Title));<br />ListCollection lists = web.Lists;<br />IEnumerable<List> filtered = context.<br />LoadQuery(lists.Include(l=>l.Title));<br />context.ExecuteQuery(); <br />foreach(List list in filtered)<br />{ }<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  20. 20. Working with List Items<br />Web web = context.Web;<br />List list = context.Web.Lists.<br />GetByTitle(“List Title");<br />CamlQuery query = CamlQuery.CreateAllItemsQuery();<br />ListItemCollection items = lst.GetItems(query);<br />context.Load(items);<br />context.ExecuteQuery();<br />foreach (ListItem item in items)<br />{<br /> string title = item["Title"];<br />}<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  21. 21. Efficencies with List Items<br />CamlQuery query = new CamlQuery();<br />query.ViewXml = "<View><Query><Where><Eq><br /> <FieldRef Name='Title'/><Value Type='Text'>Phil</Value><br /> </Eq></Where></Query></View>";<br />ListItemCollection items = list.GetItems(query);<br />context.Load(items, x => x.Include(<br /> item => item["ID"],<br /> item => item["Title"],<br /> item => item.DisplayName));<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  22. 22. Adding new List Items<br />List list = context.Web.Lists.<br />GetByTitle(“List Title");<br />context.Load(list);<br />ListItemnewItem = list.AddItem(new ListItemCreationInformation());<br />newItem["Title"] = "My new item";<br />newItem.Update();<br />context.ExecuteQuery();<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  23. 23. Silverlight & Asynchronous Calls<br />private void Button_Click(object sender, RoutedEventArgs e)<br />{<br /> // Load a bunch of stuff<br />clientContext.ExecuteQueryAsync(success, failure);<br />}<br />private void success(object sender, ClientRequestSucceededEventArgsargs)<br />{<br />RunQueryrunQuery= Run;<br />this.Dispatcher.BeginInvoke(runQuery);<br />}<br />private delegate void RunQuery(); <br />private void Run() { /* do something */ }<br />private void failure(object sender, ClientRequestFailedEventArgsargs) { /* do something */ }<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  24. 24. Demo 3: .NET COM<br />Build a Console (client) Application<br />Render all theList Titles from a remoteSharePoint site.<br />Create a new list itemin a remote SharePointsite.<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />
  25. 25. Questions & Comments<br />Phil Wicklund<br />SharePoint FREEWARE<br /> <br />SharePoint CONSULTING<br /><br />