Working with the DNN Service Framework

20
Working With the DNN Service Framework Saturday, October 19, 13

description

As a consultant, I am often times asked to move the sun and stars for clients in a short amount of time. Often times, this means creating creative solutions to expose data from existing 3rd party DNN which do not offer a rich API for me to work with. With technologies such as Knockout and Backbone, having a rich JSON service to access data from 3rd party DNN modules allows me to deliver the ''impossible'' for clients. In past years hacks such as creating generic handlers have been used to create an API, but recently DNN has included a framework which extends the Microsoft Web API and makes delivering data from your module, or other DNN modules a snap. In this session we will explore the tools and strategies for exposing a rich API within your DNN project.

Transcript of Working with the DNN Service Framework

  • 1. Working With the DNN Service Framework Saturday, October 19, 13
  • 2. Working With the DNN Service Framework Saturday, October 19, 13
  • 3. THANKS TO ALL OF OUR GENEROUS SPONSORS! Saturday, October 19, 13
  • 4. Gravity Works DNNCon Contest #gwDNNContest First Place: $100 gift card to Best Buy Runners Up: Two $25 gift cards ThinkGeek 2 Steps to Win: 1) Follow Gravity Works Design & Development on Twitter @gravityworksdd 2) Complete the 3 challenges announced from our account throughout the day & submit your visual proof by tweeting photos to @gravityworksdd with the hashtag #gwDNNContest Last entry by 4pm Winners announced & prizes awarded at Closing Ceremonies Saturday, October 19, 13
  • 5. Gravity Works DNNCon Contest #gwDNNContest First Place: $100 gift card to Best Buy Runners Up: Two $25 gift cards ThinkGeek 2 Steps to Win: 1) Follow Gravity Works Design & Development on Twitter @gravityworksdd 2) Complete the 3 challenges announced from our account throughout the day & submit your visual proof by tweeting photos to @gravityworksdd with the hashtag #gwDNNContest Last entry by 4pm Winners announced & prizes awarded at Closing Ceremonies Saturday, October 19, 13
  • 6. THANKS TO ALL OF OUR GENEROUS SPONSORS! Saturday, October 19, 13
  • 7. The Old Way http://ditchnet.org/httpclient/ http://ddler2.com/ http://discover-devtools.codeschool.com/ http://msdn.microsoft.com/en-us/library/ms973893.aspx Saturday, October 19, 13
  • 8. The Old Way http://ditchnet.org/httpclient/ http://ddler2.com/ http://discover-devtools.codeschool.com/ http://msdn.microsoft.com/en-us/library/ms973893.aspx Saturday, October 19, 13
  • 9. Same Origin Policy http://en.wikipedia.org/wiki/Same-origin_policy http://www.html5rocks.com/en/tutorials/cors/ http://en.wikipedia.org/wiki/List_of_HTTP_header_elds http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api Saturday, October 19, 13
  • 10. Same Origin Policy The policy permits scripts running on pages originating from the same sitea combination of scheme, hostname, and port numberto access each other's methods and properties with no specic restrictions, but prevents access to most methods and properties across pages on different sites. Same-origin policy also applies to XMLHttpRequest and to robots.txt. context.Response.AddHeader("Access-Control-Allow-Origin", "*"); http://en.wikipedia.org/wiki/Same-origin_policy http://www.html5rocks.com/en/tutorials/cors/ http://en.wikipedia.org/wiki/List_of_HTTP_header_elds http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api Saturday, October 19, 13
  • 11. Web API http://www.asp.net/web-api http://james.newtonking.com/json http://odetocode.com/blogs/scott/ http://haacked.com/ Saturday, October 19, 13
  • 12. Web API public class RouteMapper : IServiceRouteMapper { public void RegisterRoutes(IMapRoute mapRouteManager) { mapRouteManager.MapHttpRoute("DNNService", "default", "{controller}/{action}", new[] { "DNNService" }); mapRouteManager.MapHttpRoute("DNNService", "GetUser", "{controller}/{action}/{portalId}/{userId}", new[] { "DNNService" }); mapRouteManager.MapHttpRoute("DNNService", "GetUsers", "{controller}/{action}/portalId}", new[] { "DNNService" }); } } http://www.asp.net/web-api http://james.newtonking.com/json http://odetocode.com/blogs/scott/ http://haacked.com/ Saturday, October 19, 13
  • 13. DNN Context http://www.github.com/gravityworks https://bitbucket.org/gravityworks Saturday, October 19, 13
  • 14. DNN Context [AllowAnonymous] [HttpGet] public HttpResponseMessage GetUsers(int portalId) { var allUsers = DotNetNuke.Entities.Users.UserController.GetUsers(portalId); var allMappedUsers = new List(); foreach (UserInfo item in allUsers) { allMappedUsers.Add(new UserInfoMap(item)); } return Request.CreateResponse(HttpStatusCode.OK, allMappedUsers); } [AllowAnonymous] [HttpGet] public HttpResponseMessage ChangePassword(int portalId, int userId, string password, string newValue) { UserInfo user = DotNetNuke.Entities.Users.UserController.GetUserById(portalId, userId); var result = new DotNetNuke.Security.Membership.AspNetMembershipProvider().ChangePassword(user, password, newValue); DotNetNuke.Entities.Users.UserController.UpdateUser(portalId, user); return Request.CreateResponse(HttpStatusCode.OK, result); } http://www.github.com/gravityworks https://bitbucket.org/gravityworks Saturday, October 19, 13
  • 15. Knockout http://www.knockoutjs.com http://learn.knockoutjs.com/ http://opendata.socrata.com/resource/2brv-dhpz.json? http://bit.ly/15SaKoT http://channel9.msdn.com/Events/TechEd/NorthAmerica/2012/DEV361 Saturday, October 19, 13
  • 16. Knockout Name Status Pollutants Zip Code Score http://www.knockoutjs.com http://learn.knockoutjs.com/ http://opendata.socrata.com/resource/2brv-dhpz.json? http://bit.ly/15SaKoT http://channel9.msdn.com/Events/TechEd/NorthAmerica/2012/DEV361 Saturday, October 19, 13
  • 17. Angular http://angularjs.org/ http://www.youtube.com/watch?v=i9MHigUZKEM http://bit.ly/17QgEJ2 http://bit.ly/19vB70M http://www.slideshare.net/gravityworksdd/ Saturday, October 19, 13
  • 18. Angular
    Name Status Pollutants Zip Code Score {{entry.name}} {{entry.status}} {{entry.pollutants}} {{entry.zipcode}} {{entry.score}}
    http://angularjs.org/ http://www.youtube.com/watch?v=i9MHigUZKEM http://bit.ly/17QgEJ2 http://bit.ly/19vB70M http://www.slideshare.net/gravityworksdd/ Saturday, October 19, 13
  • 19. Jeff Mcwherter Partner & Director of Development [email protected] @jmcw Saturday, October 19, 13
  • 20. Jeff Mcwherter Partner & Director of Development [email protected] @jmcw Saturday, October 19, 13