开源:ASP.NET MVC+EF6+Bootstrap开发框架

 

前言

我在博客园潜水两三年了,在这里看过很多大神的文章,也学到了很多东西。可以说我是汲取着博客园的营养成长的。

想当年,我也是拿10个G的精神粮食从一个博客园大神那里换来一套开发框架,正式走上开发之路,到后来成为主力开发,再到项目经理再后来顺利拿下美工妹,也算是走上人生巅峰。

只索取,不分享就是自私,大家都这么自私还怎么做技术交流,说到分享首先想到的就是我那120G的精神粮食,但是分享这个好像有点法律风险,所以我把这几年在.net开发生涯中积累的一套框架分享给大家。

早上发过一篇博客,一会儿就让管理员拿掉了,这里我解释下完全没有广告推广的意思,我不会放置任何推广信息,没那个必要,房子、车子、妹子都有了,在一家还不错的单位上着班,不然也没这个闲心来做什么开源框架,目的是有,就是出来在新手面前装个逼。这样吧大家下了代码去看,里面如果有一点点广告嫌疑作者我小JJ自动缩短一厘米。

废话少说,先来介绍下这个开发框架。

框架名称:NFine.Framwork,牛逼框架,好框架

框架使用场景:OA、ERP、BPM、CRM、WMS、TMS、MIS等业务管理系统及后台系统

框架解决方案:

解决方案简介:

1、NFine.Code 底层核心类(开发时不涉及,可编绎成dll提供)。

2、NFine.Data 数据层(开发时不涉及,可编绎成dll提供)。

3、NFine.Application  应用(有点类似业务逻辑层)

4、NFine.Domain 领域层。

5、NFine.Mapping 数据库映射。

6、NFine.Repository 数据访问。

7、NFine.Web 前端视图及控制器。

框架主要运用技术:

  • 1、前端技术

  • JS框架:jquery-2.1.1、Bootstrap.js、JQuery UI

  • CSS框架:Bootstrap v3.3.4(稳定是后台,UI方面根据需求自己升级改造吧)。

  • 客户端验证:jQuery Validation Plugin 1.9.0。

  • 在线编辑器:ckeditor、simditor

  • 上传文件:Uploadify v3.2.1

  • 动态页签:Jerichotab(自己改造)

  • 数据表格:jqGrid、Bootstrap Talbe

  • 对话框:layer-v2.3

  • 下拉选择框:jQuery Select2

  • 树结构控件:jQuery zTree、jQuery wdtree

  • 页面布局:jquery.layout.js 1.4.4

  • 图表插件:echarts、highcharts

  • 日期控件: My97DatePicker

  • 2、后端技术

  • 核心框架:ASP.NET MVC5、WEB API

  • 持久层框架:EntityFramework 6.0

  • 定时计划任务:Quartz.Net组件

  • 安全支持:过滤器、Sql注入、请求伪造

  • 服务端验证:实体模型验证、自己封装Validator

  • 缓存框架:微软自带Cache、Redis

  • 日志管理:Log4net、登录日志、操作日志

  • 工具类:NPOI、Newtonsoft.Json、验证码、丰富公共类似

框架代码风格:

数据库、仓库代码

 1 using NFine.Code;
2 using System;
3 using System.Collections.Generic;
4 using System.Data.Common;
5 using System.Linq;
6 using System.Linq.Expressions;
7
8 namespace NFine.Data
9 {
10 /// <summary>
11 /// 仓储接口
12 /// </summary>
13 /// <typeparam name="TEntity">实体类型</typeparam>
14 public interface IRepositoryBase<TEntity> where TEntity : class,new()
15 {
16 int Insert(TEntity entity);
17 int Insert(List<TEntity> entitys);
18 int Update(TEntity entity);
19 int Delete(TEntity entity);
20 int Delete(Expression<Func<TEntity, bool>> predicate);
21 TEntity FindEntity(object keyValue);
22 TEntity FindEntity(Expression<Func<TEntity, bool>> predicate);
23 IQueryable<TEntity> IQueryable();
24 IQueryable<TEntity> IQueryable(Expression<Func<TEntity, bool>> predicate);
25 List<TEntity> FindList(string strSql);
26 List<TEntity> FindList(string strSql, DbParameter[] dbParameter);
27 List<TEntity> FindList(Pagination pagination);
28 List<TEntity> FindList(Expression<Func<TEntity, bool>> predicate, Pagination pagination);
29 }
30 }
using NFine.Code;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text.RegularExpressions; namespace NFine.Data
{
/// <summary>
/// 仓储实现
/// </summary>
/// <typeparam name="TEntity"></typeparam>
public class RepositoryBase<TEntity> : IRepositoryBase<TEntity> where TEntity : class,new()
{
public NFineDbContext dbcontext = new NFineDbContext();
public int Insert(TEntity entity)
{
dbcontext.Entry<TEntity>(entity).State = EntityState.Added;
return dbcontext.SaveChanges();
}
public int Insert(List<TEntity> entitys)
{
foreach (var entity in entitys)
{
dbcontext.Entry<TEntity>(entity).State = EntityState.Added;
}
return dbcontext.SaveChanges();
}
public int Update(TEntity entity)
{
dbcontext.Set<TEntity>().Attach(entity);
PropertyInfo[] props = entity.GetType().GetProperties();
foreach (PropertyInfo prop in props)
{
if (prop.GetValue(entity, null) != null)
{
if (prop.GetValue(entity, null).ToString() == "&nbsp;")
dbcontext.Entry(entity).Property(prop.Name).CurrentValue = null;
dbcontext.Entry(entity).Property(prop.Name).IsModified = true;
}
}
return dbcontext.SaveChanges();
}
public int Delete(TEntity entity)
{
dbcontext.Set<TEntity>().Attach(entity);
dbcontext.Entry<TEntity>(entity).State = EntityState.Deleted;
return dbcontext.SaveChanges();
}
public int Delete(Expression<Func<TEntity, bool>> predicate)
{
var entitys = dbcontext.Set<TEntity>().Where(predicate).ToList();
entitys.ForEach(m => dbcontext.Entry<TEntity>(m).State = EntityState.Deleted);
return dbcontext.SaveChanges();
}
public TEntity FindEntity(object keyValue)
{
return dbcontext.Set<TEntity>().Find(keyValue);
}
public TEntity FindEntity(Expression<Func<TEntity, bool>> predicate)
{
return dbcontext.Set<TEntity>().FirstOrDefault(predicate);
}
public IQueryable<TEntity> IQueryable()
{
return dbcontext.Set<TEntity>();
}
public IQueryable<TEntity> IQueryable(Expression<Func<TEntity, bool>> predicate)
{
return dbcontext.Set<TEntity>().Where(predicate);
}
public List<TEntity> FindList(string strSql)
{
return dbcontext.Database.SqlQuery<TEntity>(strSql).ToList<TEntity>();
}
public List<TEntity> FindList(string strSql, DbParameter[] dbParameter)
{
return dbcontext.Database.SqlQuery<TEntity>(strSql, dbParameter).ToList<TEntity>();
}
public List<TEntity> FindList(Pagination pagination)
{
bool isAsc = pagination.sord.ToLower() == "asc" ? true : false;
string[] _order = pagination.sidx.Split(',');
MethodCallExpression resultExp = null;
var tempData = dbcontext.Set<TEntity>().AsQueryable();
foreach (string item in _order)
{
string _orderPart = item;
_orderPart = Regex.Replace(_orderPart, @"\s+", " ");
string[] _orderArry = _orderPart.Split(' ');
string _orderField = _orderArry[0];
bool sort = isAsc;
if (_orderArry.Length == 2)
{
isAsc = _orderArry[1].ToUpper() == "ASC" ? true : false;
}
var parameter = Expression.Parameter(typeof(TEntity), "t");
var property = typeof(TEntity).GetProperty(_orderField);
var propertyAccess = Expression.MakeMemberAccess(parameter, property);
var orderByExp = Expression.Lambda(propertyAccess, parameter);
resultExp = Expression.Call(typeof(Queryable), isAsc ? "OrderBy" : "OrderByDescending", new Type[] { typeof(TEntity), property.PropertyType }, tempData.Expression, Expression.Quote(orderByExp));
}
tempData = tempData.Provider.CreateQuery<TEntity>(resultExp);
pagination.records = tempData.Count();
tempData = tempData.Skip<TEntity>(pagination.rows * (pagination.page - 1)).Take<TEntity>(pagination.rows).AsQueryable();
return tempData.ToList();
}
public List<TEntity> FindList(Expression<Func<TEntity, bool>> predicate, Pagination pagination)
{
bool isAsc = pagination.sord.ToLower() == "asc" ? true : false;
string[] _order = pagination.sidx.Split(',');
MethodCallExpression resultExp = null;
var tempData = dbcontext.Set<TEntity>().Where(predicate);
foreach (string item in _order)
{
string _orderPart = item;
_orderPart = Regex.Replace(_orderPart, @"\s+", " ");
string[] _orderArry = _orderPart.Split(' ');
string _orderField = _orderArry[0];
bool sort = isAsc;
if (_orderArry.Length == 2)
{
isAsc = _orderArry[1].ToUpper() == "ASC" ? true : false;
}
var parameter = Expression.Parameter(typeof(TEntity), "t");
var property = typeof(TEntity).GetProperty(_orderField);
var propertyAccess = Expression.MakeMemberAccess(parameter, property);
var orderByExp = Expression.Lambda(propertyAccess, parameter);
resultExp = Expression.Call(typeof(Queryable), isAsc ? "OrderBy" : "OrderByDescending", new Type[] { typeof(TEntity), property.PropertyType }, tempData.Expression, Expression.Quote(orderByExp));
}
tempData = tempData.Provider.CreateQuery<TEntity>(resultExp);
pagination.records = tempData.Count();
tempData = tempData.Skip<TEntity>(pagination.rows * (pagination.page - 1)).Take<TEntity>(pagination.rows).AsQueryable();
return tempData.ToList();
}
}
}

自动映射对象实体

框架界面展示:

支持多皮肤切换

下一篇给大家讲解下如何实现动态皮肤切换

总结:

1:本文并没有详细讲解实现机制。

2:本文并没有详细讲解开发方式。

但,至少你可以:看源码、看API、看Demo,还可以加入技术交流群进行交流分享。

当然,后续我会补充相关文章,更加细化和完善的机制及开发方式。

如果您支持开源精神,在精神层面可以点赞以示鼓励

另外补充:有Bug及漏洞,请私下提交

框架开源地址:

1、源码下载地址:http://download.csdn.net/detail/nfine_2016/9608074

感谢您的阅读。如果文章对您有用,那么请轻轻点个推荐,以资鼓励。 
作者:NFine 
技术交流群:549652099 

NET MVC+EF6+Bootstrap的更多相关文章

  1. 开源:ASP.NET MVC+EF6+Bootstrap开发框架

    前言 我在博客园潜水两三年了,在这里看过很多大神的文章,也学到了很多东西.可以说我是汲取着博客园的营养成长的. 想当年,我也是拿10个G的精神粮食从一个博客园大神那里换来一套开发框架,正式走上开发之路 ...

  2. 【开源分享:入门到精通ASP.NET MVC+EF6+Bootstrap】从这里开始,一起搭框架(1)开篇介绍

    框架简介 这几年一直在做ASP.NET开发,几年前做项目都是老老实实一行行的写代码,后来发现那些高手基本都会有自己积累起来的代码库,现在称之为开发框架,基础代码不用再去堆,主要精力可以集中在业务逻辑实 ...

  3. 使用MiniProfiler跟踪MVC + EF + Bootstrap 2 权限管理系统的性能消耗

    安装MiniProfiler 在MVC + EF + Bootstrap 2 权限管理系统入门级(附源码)文章中下载了它的源码,调试模式下打开一个页面都要再2.5秒以上,所以使用MiniProfile ...

  4. mvc5+ef6+Bootstrap 项目心得--身份验证和权限管理

    1.mvc5+ef6+Bootstrap 项目心得--创立之初 2.mvc5+ef6+Bootstrap 项目心得--身份验证和权限管理 3.mvc5+ef6+Bootstrap 项目心得--WebG ...

  5. mvc5+ef6+Bootstrap 项目心得--创立之初

    1.mvc5+ef6+Bootstrap 项目心得--创立之初 2.mvc5+ef6+Bootstrap 项目心得--身份验证和权限管理 3.mvc5+ef6+Bootstrap 项目心得--WebG ...

  6. 基于ASP.NET MVC和Bootstrap搭建响应式个人博客站(一)

    1.0 为什么要做这个博客站? www.zynblog.com   在工作学习中,经常要搜索查找各种各样的资料,每次找到相关资料后都会顺手添加到浏览器书签中,时间一长,书签也就满了.而且下次再点击这个 ...

  7. [转]mvc5+ef6+Bootstrap 项目心得--身份验证和权限管理

    本文转自:http://www.cnblogs.com/shootingstar/p/5629668.html 1.mvc5+ef6+Bootstrap 项目心得--创立之初 2.mvc5+ef6+B ...

  8. mvc5+ef6+Bootstrap 项目心得--WebGrid

    1.mvc5+ef6+Bootstrap 项目心得--创立之初 2.mvc5+ef6+Bootstrap 项目心得--身份验证和权限管理 3.mvc5+ef6+Bootstrap 项目心得--WebG ...

  9. ASP.NET MVC使用Bootstrap系列(3)——使用Bootstrap 组件

    阅读目录 Bootstrap 导航条 列表组 徽章 媒体对象 页头 路径导航 分页 输入框组 按钮式下拉菜单 警告框 进度条 小结 Bootstrap为我们提供了十几种的可复用组件,包括字体图标.下拉 ...

随机推荐

  1. 【模拟】XMU 1599 斐波那契汤

    题目链接: http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1599 题目大意: 给k,m,q以及f[1]...f[k],当n<m时,f[n]= ...

  2. HDOJ(HDU) 2083 简易版之最短距离(中位数)

    Problem Description 寒假的时候,ACBOY要去拜访很多朋友,恰巧他所有朋友的家都处在坐标平面的X轴上.ACBOY可以任意选择一个朋友的家开始访问,但是每次访问后他都必须回到出发点, ...

  3. 敏捷软件开发模型--SCRUM

    敏捷软件开发模型--SCRUM 一 什么是Scrum?Scrum (英式橄榄球争球队), 软件开发模型是敏捷开发的一种,在最近的一两年内逐渐流行起来. Scrum的基本假设是: 开发软件就像开发新产品 ...

  4. MYSQL转MSSQL

    SSMA 2008 for MySQL 1.0.exe SSMA 2008 for MySQL 1.0 Extension Pack.exe mysql-connector-odbc-5.1.11-w ...

  5. Java学习日记-2 零零碎碎

    一.使用Scanner类进行控制台的输入 文档中Scanner类的定义为A simple text scanner which can parse primitive types and string ...

  6. C#三层开发做学生管理系统

    1.定义各个层 2.添加各个层之间的引用 DAL 层调用Model BLL层调用DAL和Model UI层调用BLL和Model层 Model层供各个层调用 3.根据数据库建立实体类,每张表对应一个实 ...

  7. 搭建完整邮件系统(postfix+dovecot+clamAV+Spamassassin+amavisd-new)

    ============================ 相关软件: 1. 发送邮件 --- postfix 2. 身份认证 --- sasl2 3. 接收邮件 --- dovecot 4. 防病毒邮 ...

  8. hdu 4540 威威猫系列故事——打地鼠 dp小水题

    威威猫系列故事——打地鼠 Time Limit: 300/100 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total ...

  9. txt文件导入mysql--转

    MySQL写入数据通常用insert语句,如 insert into person values(张三,20),(李四,21),(王五,70)…; 但有时为了更快速地插入大批量数据或交换数据,需要从文 ...

  10. IPC进程间通信 - AIDL+Binder

      原理 http://www.linuxidc.com/Linux/2012-07/66195.htm   服务端,客户端处在用户空间,而binder驱动处在内核空间. 服务器端.一个Binder服 ...