"Open Source Project Sugarsite" ASP. mvc+ layui+ Sqlsugar+restsharp Project Explained

Source: Internet
Author: User
Tags mysql version pack sqlite

Sugarsite a front-end support mobile Enterprise website, currently only support simple features, followed by the Forum and so on.

SOURCE git address:

Https://github.com/sunkaixuan/SugarSite

Technical Introduction Layui

Personally do not like to quote a bunch of things, the more concise the better, Layui just to meet my demand, it is a lightweight ui,js part of the use of modular Design (AMD), mobile support is quite good.

The only disadvantage is that there are few components currently supported, and people who need a certain amount of front-end scalability can use it.

Usage:

For example I want to use form.js and uploda.js I just need to write using (Form,upload) (as shown in the code below) instead of referencing two JS files

/*   demo1.js  uses Layui's form and upload components */layui.use (['form'  'upload'], function () {  // If only one component is loaded, you can not fill in the array. such as: Layui.use (' form ')  var// Get form component  //  Get Upload component     // Listen submit button });      

Sqlsugar

A high-performance, lightweight and powerful ORM framework that supports multiple databases and supports. NET CORE. The MySQL version supports read and write separations, and SQL supports parallel computing.

sqlite orm 

TD style= "Background-color: #f0f8ff; Text-align:left; " >
ASP. 4.+ ASP. NET Core Description Depend on
SqlSugar.dll SqlSugarCore.dll

SQL Server ORM

No
MysqlSugar.dll MysqlSugarCore.dll

MYSQL ORM

MySql.Data.dll
sqlitesugar.dll sqlitesugarcore.dll

system.data.sqlite.dll

oraclesugar.dll -

oracle ORM

oracle.manageddataaccess.dll
SqlSugarRepository.dll - SQL Server MYSQL Sqlite Oracle Four Unity

MySql.Data.dll

System.Data.SQLite.dll

Oracle.ManagedDataAccess.dll

SQLite.Interop.dll

Restsharp

The role in my project is similar to WCF, a core element of service-oriented programming, which is simpler and lighter than WCF, and only supports the HTTP protocol

varClient =NewRestclient ("Http://localhost/home/getjson");//client. Authenticator = new Httpbasicauthenticator (username, password);varRequest =NewRestrequest ("Resource/{id}", method.post); request. Addparameter ("name","value");//Add Request ParametersRequest. Addurlsegment ("ID","123");//Add token//Add an HTTP headerRequest. AddHeader ("Header","value");//Add Filerequest. AddFile (path);//Execute RequestIrestresponse response =client. Execute (request);varContent = Response. Content;//return Request Object//or automatically deserialize result//return content type is sniffed but can be explicitly set via Restclient.addhandler ();Restresponse<person> response2 = client. Execute<person>(request);varName =Response2. Data.name;//Asynchronous SupportClient. Executeasync (Request, response ={Console.WriteLine (response). Content);});varAsynchandle = client. Executeasync<person> (Request, response ={Console.WriteLine (response). Data.name);});Asynchandle.abort ();

The design idea adopted

From ancient times to design patterns are more complex people like to learn, even if it is not entirely understood to understand what is a thing, think that the technology is brilliant, may write people from a not understand, and the contrary code to write the more people want to write simple.

There is no good or bad in the pattern of this kind of thing:

Different people use different patterns to play out the level is not the same

My understanding.

The nesting logic cannot be more than 3 layers, and if it does not conform to this constraint, you have to compromise in beauty.

1. Redundant code as long as good maintenance is also acceptable, copy and paste a ling, because the simple logic led to the code redundancy, if you want to do not redundant that the writing will be more complex, according to the circumstances of the pros and cons of their own choice, fish and bear paw many times can not be combined.

2. Be sure to layer your business as the core

3. Easy-to-read code and changes in the wording of the conflict I will use easy-to-read writing (others can not understand, but also talk about what maintainability, self-made that is indifferent)

Code explanation

Code structure diagram:

I call this mode: Commander mode

Word Interpretation:

viewaction: Action of type ActionResult type

apiaction: an action of type Jsonresult type, where it is used as a business interface

Pack: is a business block, and the business block and the business block are isolated, each business block has multiple apiaction and multiple viewaction,

The traffic between the business block and the business block is used by the Restsharp to invoke the other pack's

Outsourcing: Some common code in a business block, which can be a class or a folder, depends on the complexity of the project

This architecture model has 3 advantages over the traditional three tier.

1. Easy layering and clearer code

The previous notation is to use a data table as a service, if the SOA architecture is also in the abstract layer, of course, a complex business will have more than 10 table processing, there will be a few tables of this machine code a few of the service

        Private x1 X1service;         Private x2 x2service;         Private X3 x3service;          Public Doccontentcontroller (x1 x1service, X3 x1service, X4x1service) {            this. X1service = x1service;             this. X2service = x2service;             this. X3service = x4service;        }

Now, you can get a finished business interface directly, instead of getting each thin table service.

_service.command{                var DocLIST= API. Get (Url.action ("getdoc"new {typeId = typeId});

2. Can use a set of code multi-platform

Because it's all based on Apiaction. If the permissions are reasonable and can be a mobile interface, it is virtually an SOA architecture.

3. Simple Hierarchy

Simple to more streamlined than three layers

Complete the feature preview front end

The front-end perfectly supports all major mobile

Background

Background simple and generous, not for the UI to design, practical-oriented, published IIS can be a good sense of fluency

At present, only the basic functions are completed, and the following will keep the open source project in writing.

If you like it, please recommend

SOURCE git address:

Https://github.com/sunkaixuan/SugarSite

"Open Source Project Sugarsite" ASP. mvc+ layui+ Sqlsugar+restsharp Project Explained

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.