15
Technical Upgrades for Soffront Enterprise CRM v11x

Technical Upgrades

Embed Size (px)

Citation preview

Page 1: Technical Upgrades

Technical Upgrades for Soffront Enterprise CRM v11x

Page 2: Technical Upgrades

Purpose Restrictions & Limitations Proposed Model

New Technologies Comparative Analysis of data flow

Data flow in Version 10x Proposed Data flow in Version 11x

10x vs 11x Based On Technical Aspects Framework 4.6 vs Framework 4.0 Web API Vs Class Library Entity Framework 6.0

Technology Discussion (in details) .NET Framework 4.6

Overview Benefits

Task­based API for Asynchronous Response Flushing Model binding supports task­returning methods HTTP/2 Support (Windows 10) Support for the Token Binding Protocol 64­bit JIT Compiler for managed code Assembly loader improvements Base class library changes

Web API 2.0 Overview

Attribute Routing CORS ­ Cross Origin Resource Sharing OWIN (Open Web Interface for .NET) self hosting IHttpActionResult Web API OData

Benefits Entity Framework 6

Concept of ORM Benefits Things to care about

Page 1

Page 3: Technical Upgrades

Purpose This document aims to discuss all the aspects related to the performance upgraded version of Soffront Enterprise CRM. It also tries to analyse and compare the technologies along with the data flow.

Restrictions & Limitations

Operating system version of hosted/ on premise servers (WIndows Server 2008)

Proposed Model

New Technologies

.NET Framework version upgrade (version 4.0 to version 4.6)

Web API 2.0

Entity Framework 6

Page 2

Page 4: Technical Upgrades

Comparative Analysis of data flow

Data flow in Version 10x

1. Client logged in application using their user credential. In Client side HTML, JavaScript , CSS and JQuery technologies exist. HTML format is used rendering in browser. Javascript and Jquery is used for client side validation. CSS is for maintaining unique style throughout the application.

2. Client sent requests from Browser. Generated request goes to Application in two ways.

3. Application is actual Business Logic. .Net Framework and C# Language is used to create the application.

4. Browser can call directly the application . After that request goes to dbMGR with required parameters. Finally dbMgr calls the Stored Procedure . And Stored Procedure executes in SQL Database .

5. Database Executed result returns as response and finally goes to the browser via dbMgr and application.

6. dbMgr is used as Data Access Layer(DAL). Main purpose of this Layer is accessing the SQL database. Mainly Stored Procedures are used in DAL. Methods in DAL accepts parameters from application . These parameters are passed to Stored Procedures.

Page 3

Page 5: Technical Upgrades

7. Another way of calling application is via webservice. Browser use ajax Post Method to post data in Web service. On the basis of requirements JSON is also used . Posted data in Web Service can request either application or dbMgr directly.

8. Request via Web Service after reaching Application or dbMgr finally goes to Database. From there response returns finally to Browser.

9. SQL Database Tables are used as data storage. Views , user defined functions and Stored Procedures are also used.

Proposed Data flow in Version 11x

1. First time when the user logs in after Application start, all the metadata are fetched from the database and then stored in the Application storage/variable till the application ends and a snapshot of the database (in terms of model/structure) is kept in the Entity framework to serve the requests from the next users.

2. Next time when the user logs in or tries to fetch some data, that request is passed to the the web api from CRM.

3. Now web api decides whether to send the request to the database or to the Application storage. So every time the request, which comes from the user have to go through this decision making process and maximum time it will not be sent to the db if it requests some common data which are previously stored in the Application storage. Thus the database interactions will be quite lesser and thus it will leverage the performance or the speed.

4. In case of accessing the Application storage, one key will be generated for each project.

5. Next is, when the raw data will be rendered, it will take less time as because data will be fed to the entity model/structure which is already defined, so there is no need of type checking of the db columns before that.

Page 4

Page 6: Technical Upgrades

6. After all these steps when data is received by the CRM application, code behind generates the output in user readable HTML format and that will be displayed by the web browser.

10x vs 11x Based On Technical Aspects

Framework 4.6 vs Framework 4.0

New features of the .NET Framework 4.6:

Changes in the Base Class Library

Resizing in Windows Forms controls

Support for code page encodings

Open­source .NET Framework packages

Improvements to event tracing

.NET Native

Page 5

Page 7: Technical Upgrades

Web API Vs Class Library

ASP.NET Web API provides a better HTTP Experience over class libraries. Following are some of the features that provide advantage

Strong Support for URL Routing to produce clean URLs using familiar MVC style routing semantics

Content Negotiation based on Accept headers for request and response serialization

Support for a host of supported output formats including JSON, XML, ATOM

Strong default support for REST semantics but they are optional

Easily extensible Format support to add new input/output types

Deep support for more advanced HTTP features via HttpResponseMessage and HttpRequestMessage

classes and strongly typed Enums to describe many HTTP operations

Convention based design that drives you into doing the right thing for HTTP Services

Very extensible, based on MVC like extensibility model of Formatters and Filters

Self­hostable in non­Web applications

Testable using testing concepts similar to MVC

Web API is meant to handle any kind of HTTP input and produce output and status codes using the full spectrum of HTTP functionality available in a straightforward and flexible manner.

Entity Framework 6.0 Entity Framework 6.0 has introduced many new exciting features for Database­First (designer) and Code­First approaches. Features for Database First (Designer) and Code­First Both:

Connection resiliency

Asynchronous query and save

Code­based configuration

Database command logging

Database command interception

Dependency Resolution

DbSet.AddRange/RemoveRange

Better Transaction Support

Pluggable pluralisation and singularization service

Testability improvements

Page 6

Page 8: Technical Upgrades

Creating context with an open connection

Improved performance and warm­up time

Technology Discussion (in details)

.NET Framework 4.6

Overview .NET Framework is a technology that supports building and running the next generation of applications and XML Web services. The .NET Framework is designed to fulfill the following objectives:

1. To provide a consistent object­oriented programming environment whether object code is stored and executed locally, executed locally but Internet­distributed, or executed remotely.

2. To provide a code­execution environment that minimizes software deployment and versioning conflicts.

3. To provide a code­execution environment that promotes safe execution of code, including code created by an unknown or semi­trusted third party.

4. To provide a code­execution environment that eliminates the performance problems of scripted or interpreted environments.

5. To make the developer experience consistent across widely varying types of applications, such as Windows­based applications and Web­based applications.

6. To build all communication on industry standards to ensure that code based on the .NET Framework can integrate with any other code.

Benefits The following are the new features of the .NET Framework 4.6:

Task-based API for Asynchronous Response Flushing

ASP.NET now provides a simple task­based API for asynchronous response flushing, HttpResponse.FlushAsync, that allows responses to be flushed asynchronously by using your language's async/await support.

Model binding supports task-returning methods In the .NET Framework 4.5, ASP.NET added the Model Binding feature that enabled an extensible, code­focused approach to CRUD­based data operations in Web Forms pages and user controls. The Model Binding system now supports Task­returning model binding methods. This feature allows Web Forms developers to get the scalability benefits of async with the ease of the data­binding system when using newer versions of ORMs, including the Entity Framework.

Page 7

Page 9: Technical Upgrades

HTTP/2 Support (Windows 10)

HTTP/2 is a new version of the HTTP protocol that provides much better connection utilization (fewer round­trips between client and server), resulting in lower latency web page loading for users. Web pages (as opposed to services) benefit the most from HTTP/2, since the protocol optimizes for multiple artifacts being requested as part of a single experience. HTTP/2 support has been added to ASP.NET in the .NET Framework 4.6. Because networking functionality exists at multiple layers, new features were required in Windows, in IIS, and in ASP.NET to enable HTTP/2. You must be running on Windows 10 to use HTTP/2 with ASP.NET.

Support for the Token Binding Protocol

Microsoft and Google have been collaborating on a new approach to authentication, called the Token Binding Protocol. The premise is that authentication tokens (in your browser cache) can be stolen and used by criminals to access otherwise secure resources (e.g. your bank account) without requiring your password or any other privileged knowledge. The new protocol aims to mitigate this problem. The Token Binding Protocol will be implemented in Windows 10 as a browser feature. ASP.NET apps will participate in the protocol, so that authentication tokens are validated to be legitimate. The client and the server implementations establish the end­to­end protection specified by the protocol.

64-bit JIT Compiler for managed code The .NET Framework 4.6 features a new version of the 64­bit JIT compiler (originally code­named RyuJIT). The new 64­bit compiler provides significant performance improvements over the older 64­bit JIT compiler. The new 64­bit compiler is enabled for 64­bit processes running on top of the .NET Framework 4.6. Your app will run in a 64­bit process if it is compiled as 64­bit or AnyCPU and is running on a 64­bit operating system. While care has been taken to make the transition to the new compiler as transparent as possible, changes in behavior are possible. We would like to hear directly about any issues encountered when using the new JIT compiler.

Assembly loader improvements

The assembly loader now uses memory more efficiently by unloading IL assemblies after a corresponding NGEN image is loaded. This change decreases virtual memory, which is particularly beneficial for large 32­bit apps (such as Visual Studio), and also saves physical memory.

Base class library changes

iReadOnlyCollection<T> implementations.

CultureInfo.CurrentCulture and CultureInfo.CurrentUICulture.

Enhancements to garbage collection (GC).

SIMD­enabled types.

Cryptography updates

A set of extension methods for X509

Page 8

Page 10: Technical Upgrades

Provides a CNG implementation of the RSA algorithm.

Web API 2.0 Asp.Net Web API is a framework for building HTTP services that can be consumed by a broad range of clients including browsers, mobiles, iphone and tablets. It is very similar to ASP.NET MVC since it contains the MVC features such as routing, controllers, action results, filter, model binders, dependency injection. But it is not a part of the MVC Framework. It is a part of the core ASP.NET platform and can be used with MVC and other types of Web applications like Asp.Net WebForms. It can also be used as an stand­alone Web services application.

Overview

Attribute Routing Along with convention­based routing, Web API 2 now supports attribute routing as well. In case of convention­based routing, we can define multiple route templates. When a request comes, it will be matched against already defined route templates, and forwarded to specific controller action according to matched template.

Page 9

Page 11: Technical Upgrades

CORS - Cross Origin Resource Sharing CORS is a mechanism that allows a web page to make an AJAX call to a domain other than the domain which actually rendered that specific web page.

The general mechanics of CORS are such that when JavaScript is attempting to make a cross­origin AJAX call the browser will “ask” the server if this is allowed by sending headers in the HTTP request (for example, Origin). The server indicates what’s allowed by returning HTTP headers in the response (for example, Access­Control­Allow­Origin). This permission check is done for each distinct URL the client invokes, which means different URLs can have different permissions. In addition to the origin, CORS lets a server indicate which HTTP methods are allowed, which HTTP request headers a client can send, which HTTP response headers a client can read, and if the browser is allowed to automatically send or receive credentials (cookies or authorization headers). Additional request and response headers indicate which of these features are allowed.

OWIN (Open Web Interface for .NET) self hosting ASP.NET Web API 2 comes with a new self hosting package i.e. Microsoft.AspNet.WebApi. OwinSelfHost. According to http://owin.org/, “OWIN defines a standard interface between .NET web servers and web applications. The goal of the OWIN interface is to decouple server and application, encourage the development of simple modules for .NET web development, and, by being an open standard, stimulate the open source ecosystem of .NET web development tools.”

IHttpActionResult ASP.Net Web API 2 has introduced a new way of returning HttpResponseMessage from your controllers – which improves code reusability, and testability. IHttpResponseMessage is basically an interface which acts as a factory for HttpResponseMessage, it comes with custom built in responses such as:

Ok NotFound Exception Unauthorized BadRequest Conflict Redirect Invalid ModelState

Page 10

Page 12: Technical Upgrades

It's very powerful because it extensify web api. Using this approach we can compose any specific type of response. It use the full features of HTTP (like URIs, request/response headers, caching, versioning, various content formats). A Web API controller action can return any of the following:

void HttpResponseMessage IHttpActionResult Some other type

Web API OData The Open Data Protocol (OData) is actually a web protocol for querying and updating data. It has automatic support for OData. Hence by placing the new [Queryable] attribute on a controller method that returns IQueryable, clients can use the method for OData query composition.

Benefits ASP.NET Web API provides a better HTTP Experience. Here are some of the features that Web API provides

Strong Support for URL Routing to produce clean URLs using familiar MVC style routing semantics

Content Negotiation based on Accept headers for request and response serialization

Support for a host of supported output formats including JSON, XML, ATOM

Strong default support for REST semantics but they are optional

Easily extensible Format support to add new input/output types

Deep support for more advanced HTTP features via HttpResponseMessage and HttpRequestMessage

classes and strongly typed Enums to describe many HTTP operations

Convention based design that drives you into doing the right thing for HTTP Services

Page 11

Page 13: Technical Upgrades

Very extensible, based on MVC like extensibility model of Formatters and Filters

Self­hostable in non­Web applications

Testable using testing concepts similar to MVC

Web API is meant to handle any kind of HTTP input and produce output and status codes using the full spectrum of HTTP functionality available in a straightforward and flexible manner.

No Brainers for Web API

HTTP Services ­ If you're building a comprehensive HTTP API that is to be consumed over the Web, Web API is a perfect fit. You can isolate the logic in Web API and build your application as a service breaking out the logic into controllers as needed. Because the primary interface is the service there's no confusion of what should go where (MVC or API). Perfect fit.

Primary AJAX Backends ­ If you're building rich client Web applications that are relying heavily on AJAX callbacks to serve its data, Web API is the best suite for this.

Generic HTTP Endpoints ­ Another good fit are generic HTTP endpoints that to serve data or handle 'utility' type functionality in typical Web applications.

Entity Framework 6

Concept of ORM The Entity Framework is a set of technologies in ADO.NET that support the development of data­oriented software applications. Architects and developers of data­oriented applications have typically struggled with the need to achieve two very different objectives. They must model the entities, relationships, and logic of the business problems they are solving, and they must also work with the data engines used to store and retrieve the data. The data may span multiple storage systems, each with its own protocols; even applications that work with a single storage system must balance the requirements of the storage system against the requirements of writing efficient and maintainable application code. The Entity Framework enables developers to work with data in the form of domain­specific objects and properties, such as customers and customer addresses, without having to concern themselves with the underlying database tables and columns where this data is stored. With the Entity Framework, developers can work at a higher level of abstraction when they deal with data, and can create and maintain data­oriented applications with less code than in traditional applications. Because the Entity Framework is a component of the .NET Framework, Entity Framework applications can run on any computer on which the .NET Framework (starting with version 3.5 SP1) is installed.

Page 12

Page 14: Technical Upgrades

EDM (Entity Data Model): EDM consists of three main parts - Conceptual model, Mapping and Storage model.

Conceptual Model: The conceptual model contains the model classes and their relationships. This will be independent from your database table design.

Storage Model: Storage model is the database design model which includes tables, views, stored procedures, and their relationships and keys.

Mapping: Mapping consists of information about how the conceptual model is mapped to the storage model.

LINQ to Entities: LINQ to Entities is a query language used to write queries against the object model. It returns entities, which are defined in the conceptual model. You can use your LINQ skills here.

Entity SQL: Entity SQL is another query language just like LINQ to Entities. However, it is a little more difficult than L2E and the developer will have to learn it separately.

Object Service:Object service is a main entry point for accessing data from the database and to return it back. Object service is responsible for materialization, which is the process of converting data returned from an entity client data provider (next layer) to an entity object structure.

Entity Client Data Provider:The main responsibility of this layer is to convert L2E or Entity SQL queries into a SQL query which is understood by the underlying database. It communicates with the ADO.Net data provider which in turn sends or retrieves data from the database.

ADO.Net Data Provider:This layer communicates with the database using standard ADO.Net.

Benefits

1. One common syntax ( LINQ ) for all object queries whether it is database or not , Pretty fast if used as intended , easy to implemented.

2. Less coding required to accomplish complex tasks.

3. It’s fast and straightforward using LINQ/FE objects For Add/Modify/Delete/Update.

4. Easy to map business objects (with drag & drop tables on environment).

Page 13

Page 15: Technical Upgrades

5. It keeps a good performance when you work with a small / middle domain model.

Things to care about Here is list of items which one needs to take care of:

EF Mini Profiling: if you were using mini profiling with EF5 you will have broken code as few of the functionality or variable names had been changed.

Resolution: Upgrade to newer version of EF MiniProfiling

Db­Reindexing: After updating to EF6 it complaints you about change in your model and when you do "Add­Migration" you will see all your index for primary key were getting recreated also its changing name of tables where you have one to one relationship so previously if it generates table name as TableATableB then it will rename table as TableBTableA dont know why.

Resolution 1: Let EF create migrations for create index , just comment out line in up and down function.

Resolution 2: Copy line of code from down function(i.e. drop index) and try to execute it before it create index , simple rule first drop and then create, you need this else EF will complaint about index already present.

Migrations: This will only affect you if you are doing using some tool to deploy you assemblies and which in turns uses migrate.exe typically found at ...#your project location\packages\EntityFramework.6.1.0\tools\migrate.exe copy it to your bin folder and things should work fine.

Page 14