前言

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

想当年,我也是拿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、验证码、丰富公共类似

框架代码风格:

数据库、仓库代码

 using NFine.Code;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Linq.Expressions; namespace NFine.Data
{
/// <summary>
/// 仓储接口
/// </summary>
/// <typeparam name="TEntity">实体类型</typeparam>
public interface IRepositoryBase<TEntity> where TEntity : class,new()
{
int Insert(TEntity entity);
int Insert(List<TEntity> entitys);
int Update(TEntity entity);
int Delete(TEntity entity);
int Delete(Expression<Func<TEntity, bool>> predicate);
TEntity FindEntity(object keyValue);
TEntity FindEntity(Expression<Func<TEntity, bool>> predicate);
IQueryable<TEntity> IQueryable();
IQueryable<TEntity> IQueryable(Expression<Func<TEntity, bool>> predicate);
List<TEntity> FindList(string strSql);
List<TEntity> FindList(string strSql, DbParameter[] dbParameter);
List<TEntity> FindList(Pagination pagination);
List<TEntity> FindList(Expression<Func<TEntity, bool>> predicate, Pagination pagination);
}
}
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[];
bool sort = isAsc;
if (_orderArry.Length == )
{
isAsc = _orderArry[].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 - )).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[];
bool sort = isAsc;
if (_orderArry.Length == )
{
isAsc = _orderArry[].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 - )).Take<TEntity>(pagination.rows).AsQueryable();
return tempData.ToList();
}
}
}

自动映射对象实体

框架界面展示:

支持多皮肤切换

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

总结:

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

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

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

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

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

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

框架开源地址:

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

最新文章

  1. Meta标签用法大全
  2. [No000035]操作系统Operating System之OS Interface操作系统接口
  3. no-jquery 05 Utilities
  4. Linux上vi(vim)编辑器使用教程
  5. 穿越泥地(mud) (BFS)
  6. arp -s 157.55.85.212 00-aa-00-62-c6-09 .... Adds a static entry.
  7. c# 获取excel所有工作表
  8. 关于同步VSS服务器上的代码发生Eclipse里面的项目全部不见了
  9. [置顶] 宏途_LCD调试流程.
  10. DIR - matlab函数
  11. Windows Server 2003 安装Sql Server 2005 问题处理
  12. isEmpty()
  13. C语言移位运算符
  14. 详解googe Chrome浏览器(理论篇)
  15. 关于laravel5.2仓库的建立,以及简单调用
  16. tfs增加用户
  17. Matlib
  18. CentOS7 安装中文输入法
  19. Java Web之Web组件之间的跳转方式
  20. HISAT2,StringTie,Ballgown处理转录组数据

热门文章

  1. 0003 64位Oracle11gR2不能运行SQL Developer的解决方法
  2. ASP.NET MVC 监控诊断、本地化和缓存
  3. Linux IPC tcp/ip socket 编程
  4. android 利用线程刷新UI方法
  5. Python使用QRCode模块生成二维码
  6. linux 下 mysql 安装(不用编译的方式)
  7. FTP上传与下载
  8. Windows Azure 虚拟机的IP地址操作
  9. [转]ASP.NET MVC Dynamic Themes
  10. [转]ASP.NET 成员资格 Part.1(API)