ModernDevTechx - SharePoint Saturday

Download Report

Transcript ModernDevTechx - SharePoint Saturday

Modern Development
Technologies in
SharePoint
SHAREPOINT SATURDAY OMAHA
APRIL, 2016
Thank you Sponsors!
Use #SPSOmaha in your tweets to thank them!
About Me…
Former Trainer / Consultant with SharePoint
Working with SharePoint since SharePoint 2007
Working for Boys Town as SharePoint Developer / Architect
◦
◦
◦
◦
http://www.Boystown.org
http://www.boystownhospital.org
http://www.boystownpediatrics.org
http://www.yourlifeyourvoice.org
Outline
Background of a SharePoint .NET Developer
What Happened in Development?
SharePoint Development vs. The App Model
vs. Modern Development
Quick Intro to Knockout
◦
◦
◦
◦
What is Knockout?
Defining Your Data
Defining Your Template
Bringing it Together
Quick Intro to Web API for Integration
◦
◦
◦
◦
◦
What is Web API?
Creating a Web API Controller
Deploying Your Web API Service
Calling a Web API Method
Building in Reverse (IOC and TDD)
◦ as time permits only, big topic, but important
◦ Limitations of Web API
Background of a SharePoint Developer
Starts with good ASP.NET 2.0? 3.5?
Web Forms Development – ASP:Controls
Custom Workflows?
XML Parsing for Elements and CAML
SharePoint Object Model
SharePoint as a Storage Layer / Integration Point
While we were doing that… some stuff changed in the rest of the world…
What Happened in Development?
MVC
Web API Methods vs WCF
Responsive Design / HTML5 / Attractive Layouts
Client Side Development with JavaScript
Single Page Application (SPA)
SharePoint Development vs. the App
Model vs. Modern Development
SharePoint Development:
◦ Extend What SharePoint Already Does
◦ Make it “easier” for users to interact with their
data in SharePoint
◦ Integrate other systems using SharePoint
Technologies or Code
◦ Building Bricks
App Model:
◦
◦
◦
◦
◦
Host Web vs. App Web
Trust and Security
Cloud Ready
Multi-Authenticated Users and Apps
Building Houses
Modern Development:
◦ Using More of the Modern Development
Techniques in SharePoint
◦ Back to “Extending SharePoint”, Building Bricks
◦ Integrating External Systems into SharePoint
using SharePoint Technologies or Code
◦ Make SharePoint Easier to Interact with (RWD)
◦ Make SharePoint “Prettier”
◦ Works in Many, but not all of SharePoint
Development Scenarios
What is KnockoutJS?
JavaScript MVVM Development Pattern - http://knockoutjs.com/
What does that mean?
◦ Similar to MVC
◦ Model-View-View Model
◦ Model – Your Data
◦ View – How it Looks
◦ View Model – Your data and other stuff it needs to work
No, really, what does that mean?
◦
◦
◦
◦
Write Objects
Write Event Handlers
Create HTML5 ready template
Let Knockout Bind it up
Knockout: Define Your Data
JavaScript Object for your Model
JavaScript Based Loader to Get the Data to
Your Model
◦ List View Web Part
◦ Content Search Web Part
◦ SharePoint Web API (uses current user’s
security)
Load “Assistance” Data for the View Model
Knockout: Define Your Template
Get template from a designer
Start with pure HTML and CSS
Make Responsive or Good Designs
◦ Don’t do JavaScript events or transitions yet!
Add in the User Controls (Buttons, Drop
Downs, etc.)
Convert HTML Document into Knockout
Bindings
Knockout: Bring It Together
Create a JavaScript Object as Your View Model
On Page Load (document.ready), call your
Loader method and pass an instance of your
view model to ko.applyBindings(…);
What is Web API?
ASP.NET MVC – Resource by Route
◦
◦
◦
◦
Pattern Defined to Determine Code to Invoke
Code Determined View to Return
Highly Dependent on HTTP Verbs (GET, POST, PUT, etc.)
http(s)://url/<controller>/<action>/<param>
Web API – As Opposed to returning HTML, Return Data
SharePoint Exposes a lot of Functionality via Web API Methods
You can create your own to integrate with other systems
Web API: Create a Service
Create an ASP.NET MVC Project
Select Empty (or Web API)
Define a Model – Communication Medium
from Client to Service
Create a Web API Controller – Use VS
Templates
Write Service Code for Each Method You’ll
Support
Web API: Deployment Options
First of all, use Web Deploy
Deploy to a Virtual Directory Under the
SharePoint Web Application
◦ Benefits:
◦ Can use Server Side SharePoint Object Model
◦ Uses the same user security as the user that is logged in to
access resources
◦ Deploys to the Virtual Directory do not Recycle the Web
Application
◦ Drawbacks:
◦ Your code runs on the same server as SharePoint
◦ Not “cloud-ready”
Deploy to a Separate Web Host
◦ Benefits:
◦ Can use SharePoint Client Side Object Model
◦ Deploys do not Recycle SharePoint
◦ Can be invoked by O365 (if URL is Internet Accessible)
◦ Can have different security mechanism than SharePoint Site
◦ Drawbacks:
◦ Have to handle CORS issues (IIS Configuration or MVC
NuGet)
◦ Additional Infrastructure
Web API: Calling a Method from
SharePoint
Call from JavaScript on a SharePoint Page
Create JS Object that will map to Model
Get HTML Control Values
Call the using Ajax Methods
Call from SPD 2013 Workflow Using the Call
HTTP Service Task
Requires Azure Workflow Services Installed
Substitutes for Event Receivers
Web API: Surrounding Technologies
Building in Reverse – Single Responsibility Pattern, Dependency Injection and Inversion of
Control, Mocking Objects, and Test Driven Development
Controller Actions are great at handling requests and returning values to caller – Extract code to
separate objects (Single Responsibility)
Wouldn’t it be nice to test sections in isolation? Inject Simple Objects into the Controller,
SimpleInjector (NuGet)
Simple Object Creators – MOQ (NuGet)
Test Driven Development – Make sure the controller works, make sure logic is extracted, make
sure service objects work, separate repositories
DEMO if time permits
Web API: Managing Limitations
Security
◦ JS calls to SharePoint Web API uses the current
user’s permissions and does not work
anonymously
◦ JS calls to custom Web API requires additional
configuration to use any other credentials than
the Application Pool
◦ Make sure to be prepared for CORS if hosted
remote
◦ You can protect your services with the
[Authorize] Attribute
Not a full replacement for all SharePoint
Development Techniques
◦ Custom Ribbon controls
◦ Event Receivers (Use Workflow)
◦ Timer Jobs (Use Externally Scheduled Console
Applications or PowerShell)
Questions?
T HA N K YOU FOR AT T ENDING!
I F T I ME P E R MI TS, WE CAN TALK MOR E ABOUT HOW TO R E P LACE OT HE R
S HA R EPOINT DE V E LOPMENT OPT I ONS W I T H M OR E “F U T U R E R EA DY ”
DE V E LOPMENT.