SlideShare une entreprise Scribd logo
1  sur  76
AngularJS + Asp.Net Web 
Api + SignalR:前後端整合篇 
開發技巧實戰系列(3/6) - Web 前後端整合 
講師: 郭二文(erhwenkuo@gmail.com)
Document, Source code & Training 
Video (3/6) 
• https://github.com/erhwenkuo/PracticalCoding
Previous Training Session Document, 
Source code & Training Video (2/6) 
• https://www.youtube.com/watch?v= 
EVvC4YGXfDI 
• http://www.slideshare.net/erhwenku 
o/02-integrate-highchart
Agenda 
• Part_1 
• REST (Representational State Transfer) 
• Developing & Testing of ASP.NetWeb API2 
• Highchart , AngularJS & Web API2 Integration 
• Part_2 
• Developing ASP.Net SignalR2 
• Highchart , AngularJS ,Web API2 + SignalR2 Integration
REST (Representational 
State Transfer)
What is REST? 
• REST stands for Representational State Transfer 
• REST is an architecture style for designing networked applications 
• RESTful applications use HTTP requests to post data (create and/or 
update), read data (e.g., make queries), and delete data 
• REST is a lightweight alternative to mechanisms like RPC (Remote 
Procedure Calls) and Web Services (SOAP, WSDL, et al.)
Advantages Of REST 
• Separates server implementation from the client’s perception of 
resources (use standard HTTP GET/POST/PUT/DELETE verbs) 
• Scales well to large numbers of clients 
• Support intermediaries (proxies and gateways) as data 
transformation and caching components
Protocol Usage by Web API 
• REST web api taking over SOAP web services 
• Google deprecated all SOAP web services and 
converted to REST web apis
Developing & Testing of 
ASP.Net Web API2
Develop WEP API to service Chartdata 
• In this portion, an Asp.NetWeb API will be developed to server our 
Chartdata 
• Data Definition: 
• Period: 期間(yyyy-MM-dd) 
• TAIEX: 台股加權指數 
• MonitoringIndex: 景氣對策信號 
• LeadingIndex: 景氣領先指標 
• CoincidentIndex: 景氣同時指標 
• LaggingIndex: 景氣落後指標 
• Data File Path 
• PracticalCodingwebchartdata.csv
Install CsvHelper 3rd Party Library 
1. Use NuGet to search CsvHelper 
2. Click “Install”
Web API demonstration Implementation 
To create our Web API demonstration, 
below 5 files need to be created:
Chartdata.cs (1/5) 
1. Create a POCO class to represent our 
Chartdata 
2. Chartdata contain a private method 
“parseDateToUTC” is used to convert 
date string (yyyy/MM/dd) to milliseconds 
start from 1970/1/1 00:00:00
IDashboardRepo.cs (2/5) 
1. Interface for most basic data repository 
functions (CRUD) 
• C (Create)  CreateChartdata 
• U (Update)  UpdateChartdata 
• D (Delete)  DeleteChartdataById 
• D (Delete)  DeleteChartdata 
• R (Query)  GetAllChartdatas 
• R (Query)  GetChartdataById 
2. Why use interface? 
• It’s a good design/coding practice 
• Allow different implementation 
• Allow dynamic replacement
MemDashboardRepo.cs (3/5) 
1. IDashboard Interface implementation 
using in-memory C# Dictionary object to 
hold our demonstration data 
2. Notes: To simplify demonstration, there 
is no code to prevent multi-concurrent 
access/modification handling
MemDashboardRepoUtil.cs (4/5) 
1. A simple helper static class to keep one 
“MemDashboardRepo” object instance 
in memory 
2. Load “chartdata.csv” data into 
“MemDashboardRepo” data store as 
initialization for demonstration 
3. Why not use “Singleton” pattern 
• Just to simplify code and not confuse 
programmers who are not familiar with 
object oriented DESIGN PATTERNs
DashboardController.cs (5/5) 
1. Choose “Controllers” folder 
2. RighClick and choose below menu item 
• “Add”  “Controller…” 
3. Choose “Web API2 Controller with read/write actions” template
DashboardController.cs (5/5) 
1. Change Controller name to “DashboardController” 
2. A new class named “DashboardController.cs” should be created under 
“Controllers” folder
DashboardController.cs (5/5)
DashboardController.cs (5/5)
Testing ASP.Net Web API–GET, POST, 
PUT, DELETE using Fiddler2 
1. What is “Fiddler2” 
• The free web debugging proxy for any browser, 
system or platform 
• Developed by “Telerick” 
2. Where to get & install 
• Go to “Fiddler” download page 
“http://www.telerik.com/download/fiddler” 
• Click “Download Fiddler2” link 
• Execute “fiddler2set.exe”
Testing ASP.Net Web API–GET 
Demo 
1. Hit “F5” to run “PracticalCoding.Web” project 
2. Find the url and port, for example: 
“http://localhost:53895” 
3. Click “Composer” Tab, Change method to 
“GET”, past our WebUrl with our web api path 
to Fiddler 
http://localhost:53895/api/dashboard/ 
4. Hit “Execute” button
Testing ASP.Net Web API–GET Result 
Demo 
1. Http Status Code (200 – OK) in left panel 
2. Click “JSON” Tab 
3. A JSON object array contains 58 objects
Testing ASP.Net Web API–GET 
Demo 
1. Hit “F5” to run “PracticalCoding.Web” project 
2. Find the url and port, for example: 
“http://localhost:53895” 
3. Click “Composer” Tab, Change method to 
“GET”, past our WebUrl with our web api path 
to Fiddler 
http://localhost:53895/api/dashboard/58 
4. Hit “Execute” button
Testing ASP.Net Web API–GET Result 
Demo 
1. Click Http Status Code (200 – OK) in left panel 
2. Click “JSON” Tab 
3. A JSON object contains Chartdata object in 
JSON notation
Testing ASP.Net Web API–POST 
Demo 
1. Click “Composer” Tab, Change method to 
“POST”, past our WebUrl with our web api 
path to Fiddler 
http://localhost:53895/api/dashboard/ 
2. Add “Content-Type: application/json” to 
indicates the content in the request body is 
JSON object 
3. Hit “Execute” button
Testing ASP.Net Web API–POST 
Demo 
1. Click Http Status Code (201 – Created) in left 
panel 
2. Click “Raw” Tab 
3. “59” is the new Chartdata EntityId
Testing ASP.Net Web API–PUT 
Demo 
1. Click “Composer” Tab, Change method to 
“PUT”, past our WebUrl with our web api path 
with EntityId to Fiddler 
http://localhost:53895/api/dashboard/59 
2. Add “Content-Type: application/json” to 
indicates the content in the request body is 
JSON object 
3. Put Entity Object in JSON style in “Request 
Body” 
4. Hit “Execute” button
Testing ASP.Net Web API–PUT 
Demo 
1. Click Http Status Code (204 – No Content) 
in left panel
Testing ASP.Net Web API–DELETE 
Demo 
1. Click “Composer” Tab, Change method to 
“DELETE”, past our WebUrl with our web 
api path with EntityId to Fiddler 
http://localhost:53895/api/dashboard/59 
2. Hit “Execute” button
Testing ASP.Net Web API–PUT 
Demo 
1. Click Http Status Code (204 – No Content) 
in left panel
Highchart , AngularJS 
& Asp.Net Web API2 
Integration
Setup SPA Folder 
1. Copy “05_AngularWithHighchart” folder 
and paste as “06_AngularWithWebApi”
Integration with WebApi 
• The major code we need to change is “factories.js” 
• The key concepts (thinking in Angular) : 
• Encasuplate communication service with backend WebAPI via 
Factory module 
• Factory can easily be substituted or replaced if needed 
• “factories.js” contains code to demonstrate above points 
• The other code we need to change is “controllers.js” 
• Add more controller methods to support Create / Update & 
Delete operations
Integration with WebApi 
(factories.js) 
• Cleanup all static trainingdatas object array 
Before After
Integration with WebApi 
(factories.js) 
• Change “factory.getTrainingDatas” method to retrieve data 
from remote WebApi “/api/dashboard” 
Before After 
Get the data from 
local static variable 
Get the data via 
remote WebApi using 
angular $http 
service object
Integration with WebApi (Query) 
Demo Page 
1. Select “06_AngularWithWebApi” and Hit “F5” to 
run 
2. Click “03 IntegrationDATATABLE” 
3. The result will show on a table also use Browser 
tools will show XHR result from WebApi
Integration with WebApi 
(factories.js) for Create 
• Add “factory.createTrainingData” method to POST data to 
remote WebApi “/api/dashboard” for creation operation 
POST the data via 
remote WebApi using 
angular $http 
service object 
If POST operation 
success, then 
execute this block 
If POST operation 
error, then execute 
this block
Integration with WebApi 
(factories.js) for Update 
• Add “factory.updateTrainingData” method to PUT data to 
remote WebApi “/api/dashboard/{id}” 
PUT the data via 
remote WebApi using 
angular $http 
service object 
If PUT operation 
success, then 
execute this block 
If PUT operation 
error, then execute 
this block
Integration with WebApi 
(factories.js) for Delete 
• Add “factory.deleteTrainingData” method to PUT data to 
remote WebApi “/api/dashboard/{id}” 
DELETE the data via 
remote WebApi using 
angular $http 
service object 
If DELETE operation 
success, then 
execute this block 
If DELETE operation 
error, then execute 
this block
Integration with WebApi (Create) 
Demo Page 
1. Select “06_AngularWithWebApi” and Hit “F5” to 
run 
2. Click “03 Integration  DATATABLE  Create 
Form” 
3. Input all necessary data and Hit “Create”
Integration with WebApi (Update) 
Demo Page 
1. Select “06_AngularWithWebApi” and Hit “F5” to 
run 
2. Click “03 Integration  DATATABLE  Update 
Form” 
3. Input all necessary data and Hit “Update”
Integration with WebApi (Delete) 
Demo Page 
1. Select “06_AngularWithWebApi” and Hit “F5” to 
run 
2. Click “03 Integration  DATATABLE  Delete 
Form” 
3. Input all necessary data and Hit “Delete”
Developing ASP.Net 
SignalR2
SignarR Web Resources 
• http://signalr.net 
• http://www.asp.net/signalr
What is SignalR? 
• A library of adding real-time web 
functionality to Asp.Net applications 
• Real-time web functionality is the 
ability to have server code push 
content to connected clients instantly 
as it becomes available, rather than 
having the server wait for a client to 
request new data.
Environment Setup 
1. Use NuGet to search “SignalR” 
2. Click “Install”
Environment Setup 
1. Add “OWIN Startup class” named 
“Startup.cs” under “ProjectCoding” 
webroot 
2. Input “app.MapSignalR();” as show below
Simple SignalR Chat Application 
(JQUERY) 
1. Create below files to build a simple SignalR Chat application
Simple SignalR Chat Application 
(JQUERY) – Server “ChatHub.cs” 
1. Add new item -> “SignalR Hub Class(v2)” -> “ChatHub.cs” 
A method which can 
used to broadcast a 
message to all SingnalR 
connected Clients
Simple SignalR Chat Application 
(JQUERY) – Client Html
Simple SignalR Chat Application 
(JQUERY) 
Demo 
1. Select “07_SignalRChat/01_SimpleChat_Jquery.html” and Hit “F5” to run 
2. Open Multi-Browers to chat with each other
Simple SignalR Chat Application 
(AngularJs) 
1. Create below files to build a simple SignalR Chat application using AngularJS
Create SignalR Hub class 
1. Add new item -> “SignalR Hub Class(v2)” -> “ChatHub2.cs” 
A method which can 
used to broadcast a 
message to all SingnalR 
connected Clients 
except message issuer 
A simple POCO class as 
communication 
message object
AngularJs Module wrapped SignalR 
• https://github.com/JustMaier/angular-signalr-hub
Find Good Bootstrap UI Style 
Template 
• http://bootsnipp.com
02_SimpleChat_Angular.html
02_SimpleChat_Angular.html 
Ask AngularJS to inject 
“chatHubFactory” 
Ask AngularJS to inject 
“$rootScope”
Simple SignalR Chat Application 
(AngularJS) 
Demo 
1. Select “07_SignalRChat/02_SimpleChat_Angular.html” and Hit “F5” to run 
2. Open Multi-Browers to chat with each other
Simple SignalR Chat Application 
(EventBus) 
1. The drawback of previous Chat application sample 
• Tightly coupled – Client and Server Hub are very tight coupled, think about how many 
Server Hubs class we need to create for different scenarios? 
2. Let’s refactoring previous SignalR Chat application using “EventBus” concept
Create SignalR Hub class 
1. Add new item -> “SignalR Hub Class(v2)” -> “EventBusHub.cs” 
2. Add new POCO class “SignalREvent.cs” 
A method which can 
used to broadcast a 
message to all SingnalR 
connected 
A simple POCO class as 
communication 
message object
Create Customise AngularJS 
“EventBus” module
UI AngularJS Code 
Delegate message 
sending via 
“EventBusHub” 
Only listen “Event” 
whatever this UI 
interesting
Simple SignalR Chat Application 
(EventBus) 
Demo 
1. Select “07_SignalRChat/02_SimpleChat_EventBus.html” and Hit “F5” to run 
2. Open Multi-Browers to chat with each other
Highchart , AngularJS 
,Web API2 + SignalR2 
Integration
Integration with SignalR 
• Copy “06_AngularWithWebApi” to 
“08_AngularWithSignalR ”
Integration with SignalR – 
**SignalRDashboardController.cs (WebApi)** 
• Copy “DashboardController.cs” to “SignalRDashboardController.cs” 
Get SignalR 
“EventBus” Hub 
Context reference
Integration with SignalR – 
**SignalRDashboardController.cs (WebApi)** 
• Add below code block in WebApi “Post (Create)” method to broadcast a 
“SignalREvent”
Integration with SignalR – 
**SignalRDashboardController.cs (WebApi)** 
• Add below code block in WebApi “PUT (Update) ” method to broadcast a 
“SignalREvent”
Integration with SignalR – 
**SignalRDashboardController.cs (WebApi)** 
• Add below code block in WebApi “Delete” method to broadcast a “SignalREvent”
Integration with SignalR 
• Modify “index.html” to include “SignalR” related 
javascripts
Integration with SignalR 
• Modify “app.js” to have AngularJS include “EventBus” module
Integration with SignalR 
• Modify “controllers.js -> 03_myapp_integrateDataTableCtrl” to 
listen SignalREvent published by “EventBus” 
Inject “EventBusHub”
Integration with SignalR 
• Modify “factories.js -> 03_myapp_integrateLineCtrl” to listen 
SignalREvent published by “EventBus” and refresh chart 
• Modify “factories.js -> 03_myapp_integrateDualAxesCtrl” to 
listen SignalREvent published by “EventBus” and refresh chart 
• Modify “factories.js -> 03_myapp_integrateMultiAxesCtrl” to 
listen SignalREvent published by “EventBus” and refresh chart 
• Modify “factories.js -> 03_myapp_integrateGauageCtrl” to listen 
SignalREvent published by “EventBus” and refresh chart
Integration with SignalR 
Demo 
1. Select “08_AngularWithSignalR/index.html” and Hit “F5” to run 
2. Open Multi-Browers to see charts reflect changes whenever C/U/D 
operations occurred
Next Session: 
AngularJS + Highchart + Asp.Net 
WebApi2 + SignalR2 + Entity 
Framework6

Contenu connexe

Tendances

RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norris
RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff NorrisRESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norris
RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norris
mfrancis
 
An Overview of Node.js
An Overview of Node.jsAn Overview of Node.js
An Overview of Node.js
Ayush Mishra
 

Tendances (20)

The Spring Update
The Spring UpdateThe Spring Update
The Spring Update
 
Ajug - The Spring Update
Ajug - The Spring UpdateAjug - The Spring Update
Ajug - The Spring Update
 
Spring Projects Infrastructure
Spring Projects InfrastructureSpring Projects Infrastructure
Spring Projects Infrastructure
 
Spring Batch Performance Tuning
Spring Batch Performance TuningSpring Batch Performance Tuning
Spring Batch Performance Tuning
 
Greach 2014 - Road to Grails 3.0
Greach 2014  - Road to Grails 3.0Greach 2014  - Road to Grails 3.0
Greach 2014 - Road to Grails 3.0
 
S2GX 2012 - Spring Projects Infrastructure
S2GX 2012 - Spring Projects InfrastructureS2GX 2012 - Spring Projects Infrastructure
S2GX 2012 - Spring Projects Infrastructure
 
RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norris
RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff NorrisRESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norris
RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norris
 
Building a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to SpaceBuilding a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to Space
 
Prototyping applications with heroku and elasticsearch
 Prototyping applications with heroku and elasticsearch Prototyping applications with heroku and elasticsearch
Prototyping applications with heroku and elasticsearch
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017
 
Dropwizard Internals
Dropwizard InternalsDropwizard Internals
Dropwizard Internals
 
An Overview of Node.js
An Overview of Node.jsAn Overview of Node.js
An Overview of Node.js
 
Iac d.damyanov 4.pptx
Iac d.damyanov 4.pptxIac d.damyanov 4.pptx
Iac d.damyanov 4.pptx
 
Mule 2.2.1-users-guide
Mule 2.2.1-users-guideMule 2.2.1-users-guide
Mule 2.2.1-users-guide
 
Apache spark with akka couchbase code by bhawani
Apache spark with akka couchbase code by bhawaniApache spark with akka couchbase code by bhawani
Apache spark with akka couchbase code by bhawani
 
Oozie @ Riot Games
Oozie @ Riot GamesOozie @ Riot Games
Oozie @ Riot Games
 
Grails Plugin Best Practices
Grails Plugin Best PracticesGrails Plugin Best Practices
Grails Plugin Best Practices
 
More Cache for Less Cash (DevLink 2014)
More Cache for Less Cash (DevLink 2014)More Cache for Less Cash (DevLink 2014)
More Cache for Less Cash (DevLink 2014)
 
Hazelcast
HazelcastHazelcast
Hazelcast
 
Chef Actions: Delightful near real-time activity tracking!
Chef Actions: Delightful near real-time activity tracking!Chef Actions: Delightful near real-time activity tracking!
Chef Actions: Delightful near real-time activity tracking!
 

Similaire à 03 integrate webapisignalr

夜宴42期《Gadgets》
夜宴42期《Gadgets》夜宴42期《Gadgets》
夜宴42期《Gadgets》
Koubei Banquet
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testing
drewz lin
 

Similaire à 03 integrate webapisignalr (20)

Oracle JavaScript Extension Toolkit Web Components Bring Agility to App Devel...
Oracle JavaScript Extension Toolkit Web Components Bring Agility to App Devel...Oracle JavaScript Extension Toolkit Web Components Bring Agility to App Devel...
Oracle JavaScript Extension Toolkit Web Components Bring Agility to App Devel...
 
Using HttpWatch Plug-in with Selenium Automation in Java
Using HttpWatch Plug-in with Selenium Automation in JavaUsing HttpWatch Plug-in with Selenium Automation in Java
Using HttpWatch Plug-in with Selenium Automation in Java
 
Summit Australia 2019 - PowerApp Portals - Andrew Ly & Lachlan Wright
Summit Australia 2019 - PowerApp Portals - Andrew Ly & Lachlan WrightSummit Australia 2019 - PowerApp Portals - Andrew Ly & Lachlan Wright
Summit Australia 2019 - PowerApp Portals - Andrew Ly & Lachlan Wright
 
Code First with Serverless Azure Functions
Code First with Serverless Azure FunctionsCode First with Serverless Azure Functions
Code First with Serverless Azure Functions
 
Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.
 
Automatizacion de Procesos en Modelos Tabulares
Automatizacion de Procesos en Modelos TabularesAutomatizacion de Procesos en Modelos Tabulares
Automatizacion de Procesos en Modelos Tabulares
 
06 web api
06 web api06 web api
06 web api
 
Build pipelines with TeamCity and Kotlin DSL
Build pipelines with TeamCity and Kotlin DSLBuild pipelines with TeamCity and Kotlin DSL
Build pipelines with TeamCity and Kotlin DSL
 
Integrate any Angular Project into WebSphere Portal
Integrate any Angular Project into WebSphere PortalIntegrate any Angular Project into WebSphere Portal
Integrate any Angular Project into WebSphere Portal
 
Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)
Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)
Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)
 
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
 
Running Vue Storefront in production (PWA Magento webshop)
Running Vue Storefront in production (PWA Magento webshop)Running Vue Storefront in production (PWA Magento webshop)
Running Vue Storefront in production (PWA Magento webshop)
 
夜宴42期《Gadgets》
夜宴42期《Gadgets》夜宴42期《Gadgets》
夜宴42期《Gadgets》
 
Banquet 42
Banquet 42Banquet 42
Banquet 42
 
DEVICE CHANNELS
DEVICE CHANNELSDEVICE CHANNELS
DEVICE CHANNELS
 
Disrupting the application eco system with progressive web applications
Disrupting the application eco system with progressive web applicationsDisrupting the application eco system with progressive web applications
Disrupting the application eco system with progressive web applications
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testing
 
ASP.NET Core 1.0
ASP.NET Core 1.0ASP.NET Core 1.0
ASP.NET Core 1.0
 
Spring insight what just happened
Spring insight   what just happenedSpring insight   what just happened
Spring insight what just happened
 
Selenium Automation in Java Using HttpWatch Plug-in
 Selenium Automation in Java Using HttpWatch Plug-in  Selenium Automation in Java Using HttpWatch Plug-in
Selenium Automation in Java Using HttpWatch Plug-in
 

Plus de Erhwen Kuo

Plus de Erhwen Kuo (17)

Datacon 2019-ksql-kubernetes-prometheus
Datacon 2019-ksql-kubernetes-prometheusDatacon 2019-ksql-kubernetes-prometheus
Datacon 2019-ksql-kubernetes-prometheus
 
Cncf k8s Ingress Example-03
Cncf k8s Ingress Example-03Cncf k8s Ingress Example-03
Cncf k8s Ingress Example-03
 
Cncf k8s Ingress Example-02
Cncf k8s Ingress Example-02Cncf k8s Ingress Example-02
Cncf k8s Ingress Example-02
 
Cncf k8s Ingress Example-01
Cncf k8s Ingress Example-01Cncf k8s Ingress Example-01
Cncf k8s Ingress Example-01
 
Cncf k8s_network_03 (Ingress introduction)
Cncf k8s_network_03 (Ingress introduction)Cncf k8s_network_03 (Ingress introduction)
Cncf k8s_network_03 (Ingress introduction)
 
Cncf k8s_network_02
Cncf k8s_network_02Cncf k8s_network_02
Cncf k8s_network_02
 
Cncf k8s_network_part1
Cncf k8s_network_part1Cncf k8s_network_part1
Cncf k8s_network_part1
 
Cncf explore k8s_api_go
Cncf explore k8s_api_goCncf explore k8s_api_go
Cncf explore k8s_api_go
 
CNCF explore k8s api using java client
CNCF explore k8s api using java clientCNCF explore k8s api using java client
CNCF explore k8s api using java client
 
CNCF explore k8s_api
CNCF explore k8s_apiCNCF explore k8s_api
CNCF explore k8s_api
 
Cncf Istio introduction
Cncf Istio introductionCncf Istio introduction
Cncf Istio introduction
 
TDEA 2018 Kafka EOS (Exactly-once)
TDEA 2018 Kafka EOS (Exactly-once)TDEA 2018 Kafka EOS (Exactly-once)
TDEA 2018 Kafka EOS (Exactly-once)
 
啟動你的AI工匠魂
啟動你的AI工匠魂啟動你的AI工匠魂
啟動你的AI工匠魂
 
Realtime analytics with Flink and Druid
Realtime analytics with Flink and DruidRealtime analytics with Flink and Druid
Realtime analytics with Flink and Druid
 
Spark手把手:[e2-spk-s03]
Spark手把手:[e2-spk-s03]Spark手把手:[e2-spk-s03]
Spark手把手:[e2-spk-s03]
 
Spark手把手:[e2-spk-s02]
Spark手把手:[e2-spk-s02]Spark手把手:[e2-spk-s02]
Spark手把手:[e2-spk-s02]
 
Spark手把手:[e2-spk-s01]
Spark手把手:[e2-spk-s01]Spark手把手:[e2-spk-s01]
Spark手把手:[e2-spk-s01]
 

Dernier

一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
pxcywzqs
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
ydyuyu
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
ayvbos
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
JOHNBEBONYAP1
 
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
gajnagarg
 

Dernier (20)

一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
 
Mira Road Housewife Call Girls 07506202331, Nalasopara Call Girls
Mira Road Housewife Call Girls 07506202331, Nalasopara Call GirlsMira Road Housewife Call Girls 07506202331, Nalasopara Call Girls
Mira Road Housewife Call Girls 07506202331, Nalasopara Call Girls
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac RoomVip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
 
Best SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasBest SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency Dallas
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
 
Local Call Girls in Seoni 9332606886 HOT & SEXY Models beautiful and charmin...
Local Call Girls in Seoni  9332606886 HOT & SEXY Models beautiful and charmin...Local Call Girls in Seoni  9332606886 HOT & SEXY Models beautiful and charmin...
Local Call Girls in Seoni 9332606886 HOT & SEXY Models beautiful and charmin...
 
Call girls Service in Ajman 0505086370 Ajman call girls
Call girls Service in Ajman 0505086370 Ajman call girlsCall girls Service in Ajman 0505086370 Ajman call girls
Call girls Service in Ajman 0505086370 Ajman call girls
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
 
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime BalliaBallia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
 

03 integrate webapisignalr

  • 1. AngularJS + Asp.Net Web Api + SignalR:前後端整合篇 開發技巧實戰系列(3/6) - Web 前後端整合 講師: 郭二文(erhwenkuo@gmail.com)
  • 2. Document, Source code & Training Video (3/6) • https://github.com/erhwenkuo/PracticalCoding
  • 3. Previous Training Session Document, Source code & Training Video (2/6) • https://www.youtube.com/watch?v= EVvC4YGXfDI • http://www.slideshare.net/erhwenku o/02-integrate-highchart
  • 4. Agenda • Part_1 • REST (Representational State Transfer) • Developing & Testing of ASP.NetWeb API2 • Highchart , AngularJS & Web API2 Integration • Part_2 • Developing ASP.Net SignalR2 • Highchart , AngularJS ,Web API2 + SignalR2 Integration
  • 6. What is REST? • REST stands for Representational State Transfer • REST is an architecture style for designing networked applications • RESTful applications use HTTP requests to post data (create and/or update), read data (e.g., make queries), and delete data • REST is a lightweight alternative to mechanisms like RPC (Remote Procedure Calls) and Web Services (SOAP, WSDL, et al.)
  • 7. Advantages Of REST • Separates server implementation from the client’s perception of resources (use standard HTTP GET/POST/PUT/DELETE verbs) • Scales well to large numbers of clients • Support intermediaries (proxies and gateways) as data transformation and caching components
  • 8. Protocol Usage by Web API • REST web api taking over SOAP web services • Google deprecated all SOAP web services and converted to REST web apis
  • 9. Developing & Testing of ASP.Net Web API2
  • 10. Develop WEP API to service Chartdata • In this portion, an Asp.NetWeb API will be developed to server our Chartdata • Data Definition: • Period: 期間(yyyy-MM-dd) • TAIEX: 台股加權指數 • MonitoringIndex: 景氣對策信號 • LeadingIndex: 景氣領先指標 • CoincidentIndex: 景氣同時指標 • LaggingIndex: 景氣落後指標 • Data File Path • PracticalCodingwebchartdata.csv
  • 11. Install CsvHelper 3rd Party Library 1. Use NuGet to search CsvHelper 2. Click “Install”
  • 12. Web API demonstration Implementation To create our Web API demonstration, below 5 files need to be created:
  • 13. Chartdata.cs (1/5) 1. Create a POCO class to represent our Chartdata 2. Chartdata contain a private method “parseDateToUTC” is used to convert date string (yyyy/MM/dd) to milliseconds start from 1970/1/1 00:00:00
  • 14. IDashboardRepo.cs (2/5) 1. Interface for most basic data repository functions (CRUD) • C (Create)  CreateChartdata • U (Update)  UpdateChartdata • D (Delete)  DeleteChartdataById • D (Delete)  DeleteChartdata • R (Query)  GetAllChartdatas • R (Query)  GetChartdataById 2. Why use interface? • It’s a good design/coding practice • Allow different implementation • Allow dynamic replacement
  • 15. MemDashboardRepo.cs (3/5) 1. IDashboard Interface implementation using in-memory C# Dictionary object to hold our demonstration data 2. Notes: To simplify demonstration, there is no code to prevent multi-concurrent access/modification handling
  • 16. MemDashboardRepoUtil.cs (4/5) 1. A simple helper static class to keep one “MemDashboardRepo” object instance in memory 2. Load “chartdata.csv” data into “MemDashboardRepo” data store as initialization for demonstration 3. Why not use “Singleton” pattern • Just to simplify code and not confuse programmers who are not familiar with object oriented DESIGN PATTERNs
  • 17. DashboardController.cs (5/5) 1. Choose “Controllers” folder 2. RighClick and choose below menu item • “Add”  “Controller…” 3. Choose “Web API2 Controller with read/write actions” template
  • 18. DashboardController.cs (5/5) 1. Change Controller name to “DashboardController” 2. A new class named “DashboardController.cs” should be created under “Controllers” folder
  • 21. Testing ASP.Net Web API–GET, POST, PUT, DELETE using Fiddler2 1. What is “Fiddler2” • The free web debugging proxy for any browser, system or platform • Developed by “Telerick” 2. Where to get & install • Go to “Fiddler” download page “http://www.telerik.com/download/fiddler” • Click “Download Fiddler2” link • Execute “fiddler2set.exe”
  • 22. Testing ASP.Net Web API–GET Demo 1. Hit “F5” to run “PracticalCoding.Web” project 2. Find the url and port, for example: “http://localhost:53895” 3. Click “Composer” Tab, Change method to “GET”, past our WebUrl with our web api path to Fiddler http://localhost:53895/api/dashboard/ 4. Hit “Execute” button
  • 23. Testing ASP.Net Web API–GET Result Demo 1. Http Status Code (200 – OK) in left panel 2. Click “JSON” Tab 3. A JSON object array contains 58 objects
  • 24. Testing ASP.Net Web API–GET Demo 1. Hit “F5” to run “PracticalCoding.Web” project 2. Find the url and port, for example: “http://localhost:53895” 3. Click “Composer” Tab, Change method to “GET”, past our WebUrl with our web api path to Fiddler http://localhost:53895/api/dashboard/58 4. Hit “Execute” button
  • 25. Testing ASP.Net Web API–GET Result Demo 1. Click Http Status Code (200 – OK) in left panel 2. Click “JSON” Tab 3. A JSON object contains Chartdata object in JSON notation
  • 26. Testing ASP.Net Web API–POST Demo 1. Click “Composer” Tab, Change method to “POST”, past our WebUrl with our web api path to Fiddler http://localhost:53895/api/dashboard/ 2. Add “Content-Type: application/json” to indicates the content in the request body is JSON object 3. Hit “Execute” button
  • 27. Testing ASP.Net Web API–POST Demo 1. Click Http Status Code (201 – Created) in left panel 2. Click “Raw” Tab 3. “59” is the new Chartdata EntityId
  • 28. Testing ASP.Net Web API–PUT Demo 1. Click “Composer” Tab, Change method to “PUT”, past our WebUrl with our web api path with EntityId to Fiddler http://localhost:53895/api/dashboard/59 2. Add “Content-Type: application/json” to indicates the content in the request body is JSON object 3. Put Entity Object in JSON style in “Request Body” 4. Hit “Execute” button
  • 29. Testing ASP.Net Web API–PUT Demo 1. Click Http Status Code (204 – No Content) in left panel
  • 30. Testing ASP.Net Web API–DELETE Demo 1. Click “Composer” Tab, Change method to “DELETE”, past our WebUrl with our web api path with EntityId to Fiddler http://localhost:53895/api/dashboard/59 2. Hit “Execute” button
  • 31. Testing ASP.Net Web API–PUT Demo 1. Click Http Status Code (204 – No Content) in left panel
  • 32. Highchart , AngularJS & Asp.Net Web API2 Integration
  • 33. Setup SPA Folder 1. Copy “05_AngularWithHighchart” folder and paste as “06_AngularWithWebApi”
  • 34. Integration with WebApi • The major code we need to change is “factories.js” • The key concepts (thinking in Angular) : • Encasuplate communication service with backend WebAPI via Factory module • Factory can easily be substituted or replaced if needed • “factories.js” contains code to demonstrate above points • The other code we need to change is “controllers.js” • Add more controller methods to support Create / Update & Delete operations
  • 35. Integration with WebApi (factories.js) • Cleanup all static trainingdatas object array Before After
  • 36. Integration with WebApi (factories.js) • Change “factory.getTrainingDatas” method to retrieve data from remote WebApi “/api/dashboard” Before After Get the data from local static variable Get the data via remote WebApi using angular $http service object
  • 37. Integration with WebApi (Query) Demo Page 1. Select “06_AngularWithWebApi” and Hit “F5” to run 2. Click “03 IntegrationDATATABLE” 3. The result will show on a table also use Browser tools will show XHR result from WebApi
  • 38. Integration with WebApi (factories.js) for Create • Add “factory.createTrainingData” method to POST data to remote WebApi “/api/dashboard” for creation operation POST the data via remote WebApi using angular $http service object If POST operation success, then execute this block If POST operation error, then execute this block
  • 39. Integration with WebApi (factories.js) for Update • Add “factory.updateTrainingData” method to PUT data to remote WebApi “/api/dashboard/{id}” PUT the data via remote WebApi using angular $http service object If PUT operation success, then execute this block If PUT operation error, then execute this block
  • 40. Integration with WebApi (factories.js) for Delete • Add “factory.deleteTrainingData” method to PUT data to remote WebApi “/api/dashboard/{id}” DELETE the data via remote WebApi using angular $http service object If DELETE operation success, then execute this block If DELETE operation error, then execute this block
  • 41. Integration with WebApi (Create) Demo Page 1. Select “06_AngularWithWebApi” and Hit “F5” to run 2. Click “03 Integration  DATATABLE  Create Form” 3. Input all necessary data and Hit “Create”
  • 42. Integration with WebApi (Update) Demo Page 1. Select “06_AngularWithWebApi” and Hit “F5” to run 2. Click “03 Integration  DATATABLE  Update Form” 3. Input all necessary data and Hit “Update”
  • 43. Integration with WebApi (Delete) Demo Page 1. Select “06_AngularWithWebApi” and Hit “F5” to run 2. Click “03 Integration  DATATABLE  Delete Form” 3. Input all necessary data and Hit “Delete”
  • 45. SignarR Web Resources • http://signalr.net • http://www.asp.net/signalr
  • 46. What is SignalR? • A library of adding real-time web functionality to Asp.Net applications • Real-time web functionality is the ability to have server code push content to connected clients instantly as it becomes available, rather than having the server wait for a client to request new data.
  • 47. Environment Setup 1. Use NuGet to search “SignalR” 2. Click “Install”
  • 48. Environment Setup 1. Add “OWIN Startup class” named “Startup.cs” under “ProjectCoding” webroot 2. Input “app.MapSignalR();” as show below
  • 49. Simple SignalR Chat Application (JQUERY) 1. Create below files to build a simple SignalR Chat application
  • 50. Simple SignalR Chat Application (JQUERY) – Server “ChatHub.cs” 1. Add new item -> “SignalR Hub Class(v2)” -> “ChatHub.cs” A method which can used to broadcast a message to all SingnalR connected Clients
  • 51. Simple SignalR Chat Application (JQUERY) – Client Html
  • 52. Simple SignalR Chat Application (JQUERY) Demo 1. Select “07_SignalRChat/01_SimpleChat_Jquery.html” and Hit “F5” to run 2. Open Multi-Browers to chat with each other
  • 53. Simple SignalR Chat Application (AngularJs) 1. Create below files to build a simple SignalR Chat application using AngularJS
  • 54. Create SignalR Hub class 1. Add new item -> “SignalR Hub Class(v2)” -> “ChatHub2.cs” A method which can used to broadcast a message to all SingnalR connected Clients except message issuer A simple POCO class as communication message object
  • 55. AngularJs Module wrapped SignalR • https://github.com/JustMaier/angular-signalr-hub
  • 56. Find Good Bootstrap UI Style Template • http://bootsnipp.com
  • 58. 02_SimpleChat_Angular.html Ask AngularJS to inject “chatHubFactory” Ask AngularJS to inject “$rootScope”
  • 59. Simple SignalR Chat Application (AngularJS) Demo 1. Select “07_SignalRChat/02_SimpleChat_Angular.html” and Hit “F5” to run 2. Open Multi-Browers to chat with each other
  • 60. Simple SignalR Chat Application (EventBus) 1. The drawback of previous Chat application sample • Tightly coupled – Client and Server Hub are very tight coupled, think about how many Server Hubs class we need to create for different scenarios? 2. Let’s refactoring previous SignalR Chat application using “EventBus” concept
  • 61. Create SignalR Hub class 1. Add new item -> “SignalR Hub Class(v2)” -> “EventBusHub.cs” 2. Add new POCO class “SignalREvent.cs” A method which can used to broadcast a message to all SingnalR connected A simple POCO class as communication message object
  • 62. Create Customise AngularJS “EventBus” module
  • 63. UI AngularJS Code Delegate message sending via “EventBusHub” Only listen “Event” whatever this UI interesting
  • 64. Simple SignalR Chat Application (EventBus) Demo 1. Select “07_SignalRChat/02_SimpleChat_EventBus.html” and Hit “F5” to run 2. Open Multi-Browers to chat with each other
  • 65. Highchart , AngularJS ,Web API2 + SignalR2 Integration
  • 66. Integration with SignalR • Copy “06_AngularWithWebApi” to “08_AngularWithSignalR ”
  • 67. Integration with SignalR – **SignalRDashboardController.cs (WebApi)** • Copy “DashboardController.cs” to “SignalRDashboardController.cs” Get SignalR “EventBus” Hub Context reference
  • 68. Integration with SignalR – **SignalRDashboardController.cs (WebApi)** • Add below code block in WebApi “Post (Create)” method to broadcast a “SignalREvent”
  • 69. Integration with SignalR – **SignalRDashboardController.cs (WebApi)** • Add below code block in WebApi “PUT (Update) ” method to broadcast a “SignalREvent”
  • 70. Integration with SignalR – **SignalRDashboardController.cs (WebApi)** • Add below code block in WebApi “Delete” method to broadcast a “SignalREvent”
  • 71. Integration with SignalR • Modify “index.html” to include “SignalR” related javascripts
  • 72. Integration with SignalR • Modify “app.js” to have AngularJS include “EventBus” module
  • 73. Integration with SignalR • Modify “controllers.js -> 03_myapp_integrateDataTableCtrl” to listen SignalREvent published by “EventBus” Inject “EventBusHub”
  • 74. Integration with SignalR • Modify “factories.js -> 03_myapp_integrateLineCtrl” to listen SignalREvent published by “EventBus” and refresh chart • Modify “factories.js -> 03_myapp_integrateDualAxesCtrl” to listen SignalREvent published by “EventBus” and refresh chart • Modify “factories.js -> 03_myapp_integrateMultiAxesCtrl” to listen SignalREvent published by “EventBus” and refresh chart • Modify “factories.js -> 03_myapp_integrateGauageCtrl” to listen SignalREvent published by “EventBus” and refresh chart
  • 75. Integration with SignalR Demo 1. Select “08_AngularWithSignalR/index.html” and Hit “F5” to run 2. Open Multi-Browers to see charts reflect changes whenever C/U/D operations occurred
  • 76. Next Session: AngularJS + Highchart + Asp.Net WebApi2 + SignalR2 + Entity Framework6

Notes de l'éditeur

  1. 開發技巧實戰 1. AngularJS入門篇 2. AngularJS + HighChart:完美網頁圖表整合篇 3. AngularJS + Asp.Net WebApi 2:前後端整合篇 4. AngularJS + Asp.Net WebApi 2+Entity Framework 6 (ORM):前後端整合篇 5. AngularJS + Asp.Net WebApi 2+Entity Framework 6 (ORM) + Redis (Nosql):前後端整合篇 6. AngularJS + Asp.Net WebApi 2+Entity Framework 6 (ORM) + Redis (Nosql) + Elasticsearch (全文檢索):前後端整合篇
  2. 本章節的內容會延續前一個Session的知識與內容, 如果對前一章節不熟悉的話, 可以在Yoube或Slideshare找到文件與教學錄影
  3. 什麼是REST跟RESTful? REST 是一種分散式超媒體系統(如WWW)的軟體架構風格, 你可以想像它是一個良好設計的Web應用程式規則: 一組網路Web頁面(虛擬的狀態機器),其中 Client 透過點選超連結(狀態變換), 結果是下個Web頁面(表示應用程式的下一個狀態)。
  4. REST 有什麼優點? 在HTTP之上不依存其他機制跟軟體。 跟其他連結方式相比(如RPC),可以提供相等的功能。 不需要其他的 discovery 機制,因為使用超連結了。 提供比RPC更好的長期相容性,因為 : 如同HTML這種文件具有後前及向後的相容能力 支援新的內容格式不需要丟掉舊的 支援快取 caching 將改善反應時間跟server的負載能力。 因為不必維持連結狀態,大大改善 server 的 scalability 能力。這表示不同server可以處理同一串 requests。 一個瀏覽器就可以存取任一應用程式跟資源,client 端不需使用別的軟體。
  5. axes.
  6. There’s our HTML file. We will use Bootstrap to help with our styling. Notice that we also load up ui-router in addition to loading Angular. UI Router is separate from the Angular core, just like ngRoute is separate. When creating a link with UI-Router, you will useui-sref. The href will be generated from this and you want this to point to a certain state of your application. These are created in your app.js. We also use <div ui-view></div> instead of ngRoute’s <div ng-view></div>.
  7. axes.
  8. axes.
  9. axes.
  10. axes.
  11. 本章節的內容會延續前一個Session的知識與內容, 如果對前一章節不熟悉的話, 可以在Yoube或Slideshare找到文件與教學錄影
  12. ASP .NET SignalR 是一個ASP .NET下的類別庫,可以在ASP .NET的Web項目中實現實時通信。  什麼是即時通信(Real-time) 的Web呢?  就是讓客戶端(Web頁面)和服務器端可以即時也互相通知消息及調用方法。 WebSocket s是HTML5提供的新的API,可以在Web網頁與服務器端間建立Socket連接, 當WebSockets可用時(即瀏覽器支持Html5)SignalR使用WebSockets, 當不支持時SignalR將使用其它技術來保證達到相同效果。 SignalR當然也提供了非常簡單易用的高階API,使服務器端可以單個或批量調用客戶端上的JavaScript函數,並且非常方便地進行連接管理,例如客戶端連接到服務器端,或斷開連接,客戶端分組,以及客戶端授權,使用SignalR都非常容易實現。
  13. axes.
  14. axes.
  15. axes.
  16. axes.
  17. axes.