├── .nuget ├── NuGet.exe ├── NuGet.Config └── NuGet.targets ├── QuickBootstrap ├── Views │ ├── _ViewStart.cshtml │ ├── Shared │ │ ├── _PartialTongJiCode.cshtml │ │ ├── Error.cshtml │ │ ├── _PartialPagingInfo.cshtml │ │ └── _Layout.cshtml │ ├── Profile │ │ ├── Shared │ │ │ └── _QuickMenu.cshtml │ │ ├── Index.cshtml │ │ └── ChangePassword.cshtml │ ├── Home │ │ ├── Index.cshtml │ │ └── Login.cshtml │ ├── UserManage │ │ ├── Shared │ │ │ └── _QuickMenu.cshtml │ │ ├── Create.cshtml │ │ └── Index.cshtml │ └── Web.config ├── favicon.ico ├── Global.asax ├── Content │ ├── img │ │ └── page-bg-black.png │ └── base.css ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.ttf │ └── glyphicons-halflings-regular.woff ├── Services │ ├── Util │ │ ├── Paged.cs │ │ ├── Paging.cs │ │ ├── PagedResult.cs │ │ ├── ServiceContext.cs │ │ └── ValidateCodeHelper.cs │ ├── IManageService.cs │ ├── Models │ │ └── UserManagePageItem.cs │ ├── IUserManageService.cs │ ├── IProfileService.cs │ └── Impl │ │ ├── ProfileService.cs │ │ ├── ManageService.cs │ │ └── UserManageService.cs ├── install.bat ├── Sessions │ └── UserSession.cs ├── App_Start │ ├── FilterConfig.cs │ ├── RouteConfig.cs │ └── BundleConfig.cs ├── Scripts │ ├── base.js │ ├── _references.js │ ├── respond.min.js │ ├── jquery.validate.unobtrusive.min.js │ ├── respond.js │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.min.js ├── Extendsions │ ├── IO │ │ └── StreamExtensions.cs │ ├── ImageExtendsions.cs │ ├── ControllerExtendsions.cs │ ├── ObjectExtendsions.cs │ ├── ByteExtendsions.cs │ ├── Linq │ │ ├── ParameterRebinder.cs │ │ └── PredicateBuilder.cs │ ├── Web │ │ └── HttpResponseExtendsions.cs │ ├── StringExtendsions.cs │ ├── DateTimeExtendsions.cs │ └── PagingExtendsions.cs ├── Entities │ ├── DefaultDbContext.cs │ ├── InitData.cs │ └── User.cs ├── Filters │ ├── ValidateModelStateAttribute.cs │ └── UserAuthorizationAttribute.cs ├── Cache │ ├── EnyimMemcachedContext.cs │ ├── RedisContext.cs │ ├── CacheContext.cs │ └── Extendsions │ │ └── StackExchangeRedisExtensions.cs ├── Models │ ├── HomeLoginRequest.cs │ ├── UserCreateRequest.cs │ ├── UserManageChangePassword.cs │ └── ProfileChangePasswordRequest.cs ├── Web.Debug.config ├── Web.Release.config ├── Properties │ └── AssemblyInfo.cs ├── Global.asax.cs ├── Controllers │ ├── UserManageController.cs │ ├── HomeController.cs │ └── ProfileController.cs ├── packages.config ├── Web.config └── QuickBootstrap.csproj ├── README.md ├── .gitignore └── QuickBootstrap.sln /.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smartbooks/QuickBootstrap/HEAD/.nuget/NuGet.exe -------------------------------------------------------------------------------- /QuickBootstrap/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } 4 | -------------------------------------------------------------------------------- /QuickBootstrap/Views/Shared/_PartialTongJiCode.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = null; 3 | } 4 | 5 | -------------------------------------------------------------------------------- /QuickBootstrap/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smartbooks/QuickBootstrap/HEAD/QuickBootstrap/favicon.ico -------------------------------------------------------------------------------- /QuickBootstrap/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="QuickBootstrap.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /QuickBootstrap/Content/img/page-bg-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smartbooks/QuickBootstrap/HEAD/QuickBootstrap/Content/img/page-bg-black.png -------------------------------------------------------------------------------- /QuickBootstrap/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smartbooks/QuickBootstrap/HEAD/QuickBootstrap/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /QuickBootstrap/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smartbooks/QuickBootstrap/HEAD/QuickBootstrap/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /QuickBootstrap/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smartbooks/QuickBootstrap/HEAD/QuickBootstrap/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /QuickBootstrap/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model System.Web.Mvc.HandleErrorInfo 2 | 3 | @{ 4 | ViewBag.Title = "错误"; 5 | } 6 | 7 |

错误。

8 |

处理你的请求时出错。

9 | 10 | -------------------------------------------------------------------------------- /QuickBootstrap/Services/Util/Paged.cs: -------------------------------------------------------------------------------- 1 | namespace QuickBootstrap.Services.Util 2 | { 3 | /// 4 | /// 分页后 5 | /// 6 | public class Paged : Paging 7 | { 8 | public int SizeCount { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /QuickBootstrap/install.bat: -------------------------------------------------------------------------------- 1 | 2 | echo off 3 | set target=%USERPROFILE%\Documents\Visual Studio 2013\Templates\ProjectTemplates\Visual C#\Web 4 | set targetFileName=QuickBootstrap.zip 5 | 6 | mkdir "%target%" 7 | 8 | copy /y %targetFileName% "%target%"\%targetFileName% 9 | 10 | pause -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | QuickBootstrap 2 | ============== 3 | 4 | 基于ASP.NET MVC、EntityFramework、Memcached、Bootstrap的快速项目开发框架,只需3秒钟即可创建一个带有简单用户管理的项目。 5 | 6 | 7 | QuickBootstrap开源项目交流群开通啦: 8 | QQ群号:229853793(QuickBootstrap) 9 | 10 | 11 | 文章介绍:http://www.cnblogs.com/smartbooks/p/3814927.html 12 | -------------------------------------------------------------------------------- /QuickBootstrap/Services/Util/Paging.cs: -------------------------------------------------------------------------------- 1 | namespace QuickBootstrap.Services.Util 2 | { 3 | /// 4 | /// 分页前 5 | /// 6 | public class Paging 7 | { 8 | public int PageIndex { get; set; } 9 | 10 | public int PageSize { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /QuickBootstrap/Services/IManageService.cs: -------------------------------------------------------------------------------- 1 | using QuickBootstrap.Sessions; 2 | 3 | namespace QuickBootstrap.Services 4 | { 5 | public interface IManageService 6 | { 7 | void LoginOut(string username, string ipAddress); 8 | 9 | UserSession GetUserSession(string username, string password, string ipAddress); 10 | } 11 | } -------------------------------------------------------------------------------- /QuickBootstrap/Sessions/UserSession.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace QuickBootstrap.Sessions 4 | { 5 | [Serializable] 6 | public class UserSession 7 | { 8 | public string UserName { get; set; } 9 | 10 | public string LoginIpAddress { get; set; } 11 | 12 | public DateTime LoginDateTime { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /QuickBootstrap/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Mvc; 3 | 4 | namespace QuickBootstrap 5 | { 6 | public class FilterConfig 7 | { 8 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 9 | { 10 | filters.Add(new HandleErrorAttribute()); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /QuickBootstrap/Services/Util/PagedResult.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace QuickBootstrap.Services.Util 4 | { 5 | public sealed class PagedResult : Paged where T : class 6 | { 7 | public IList Result { get; set; } 8 | 9 | public PagedResult() 10 | { 11 | Result = new List(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /QuickBootstrap/Services/Models/UserManagePageItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace QuickBootstrap.Services.Models 4 | { 5 | public class UserManagePageItem 6 | { 7 | public string UserName { get; set; } 8 | 9 | public string Nick { get; set; } 10 | 11 | public bool IsEnable { get; set; } 12 | 13 | public DateTime CreateTime { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /QuickBootstrap/Scripts/base.js: -------------------------------------------------------------------------------- 1 | 2 | $(function () { 3 | 4 | //鼠标经过导航栏特效 5 | $('.navbar-nav li').mouseover(function () { 6 | $(this).addClass('active').siblings().removeClass('active'); 7 | }); 8 | 9 | if ($.support.style == false) { 10 | alert('你的浏览器已经Out了,赶快升级你的浏览器到Chrome吧!'); 11 | window.open('https://www.google.com/intl/zh-CN/chrome/browser'); 12 | } 13 | 14 | }); -------------------------------------------------------------------------------- /QuickBootstrap/Views/Profile/Shared/_QuickMenu.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = null; 3 | } 4 | 5 | -------------------------------------------------------------------------------- /QuickBootstrap/Extendsions/IO/StreamExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace QuickBootstrap.Extendsions.IO 4 | { 5 | public static class StreamExtensions 6 | { 7 | public static byte[] ToByteArray(this Stream stream) 8 | { 9 | var buffer = new byte[stream.Length]; 10 | 11 | stream.Read(buffer, 0, buffer.Length); 12 | 13 | stream.Seek(0, SeekOrigin.Begin); 14 | 15 | return buffer; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /QuickBootstrap/Extendsions/ImageExtendsions.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | using System.Drawing.Imaging; 3 | using System.IO; 4 | 5 | namespace QuickBootstrap.Extendsions 6 | { 7 | public static class ImageExtendsions 8 | { 9 | public static byte[] ToImageBytes(this Image bitmap) 10 | { 11 | using (var ms = new MemoryStream()) 12 | { 13 | bitmap.Save(ms, ImageFormat.Jpeg); 14 | return ms.ToArray(); 15 | } 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /QuickBootstrap/Scripts/_references.js: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | /// 5 | /// 6 | /// 7 | /// 8 | /// 9 | /// 10 | /// 11 | /// 12 | -------------------------------------------------------------------------------- /QuickBootstrap/Services/IUserManageService.cs: -------------------------------------------------------------------------------- 1 | using QuickBootstrap.Entities; 2 | using QuickBootstrap.Services.Models; 3 | using QuickBootstrap.Services.Util; 4 | 5 | namespace QuickBootstrap.Services 6 | { 7 | public interface IUserManageService 8 | { 9 | PagedResult GetList(Paging paging); 10 | 11 | User Get(string username = ""); 12 | 13 | bool Edit(User model); 14 | 15 | bool Create(User model); 16 | 17 | bool Delete(string username); 18 | 19 | bool ExistsUser(string username); 20 | } 21 | } -------------------------------------------------------------------------------- /QuickBootstrap/Services/IProfileService.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2014,SmartBooks 3 | // All rights reserved. 4 | // 5 | // 文件名称:IProfileService.cs 6 | // 项目名称:WY.DC.Service 7 | // 摘 要:简要描述本文件的内容 8 | // 9 | // 当前版本:1.0 10 | // 作 者:ya wang 11 | // 完成日期:2014年05月09日 12 | // 13 | 14 | using QuickBootstrap.Entities; 15 | 16 | namespace QuickBootstrap.Services 17 | { 18 | public interface IProfileService 19 | { 20 | User GetUserInfo(string username = ""); 21 | 22 | bool ChangePassword(string username = "", string newPassword = ""); 23 | } 24 | } -------------------------------------------------------------------------------- /QuickBootstrap/Extendsions/ControllerExtendsions.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | using QuickBootstrap.Filters; 3 | 4 | namespace QuickBootstrap.Extendsions 5 | { 6 | public static class ControllerExtendsions 7 | { 8 | public static string GetCookieUserName(this Controller controller) 9 | { 10 | var username = string.Empty; 11 | 12 | if (controller.Request.Cookies[UserAuthorizationAttribute.CookieUserName] != null) 13 | { 14 | username = controller.Request.Cookies[UserAuthorizationAttribute.CookieUserName].Value; 15 | } 16 | 17 | return username; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /QuickBootstrap/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | 8 | namespace QuickBootstrap 9 | { 10 | public class RouteConfig 11 | { 12 | public static void RegisterRoutes(RouteCollection routes) 13 | { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | routes.MapRoute( 17 | name: "Default", 18 | url: "{controller}/{action}/{id}", 19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 20 | ); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /QuickBootstrap/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "平台概况"; 3 | } 4 | 5 |
6 |
7 | 8 | 12 | 13 |
14 | 15 |

QuickBootstrap

16 |

每个程序员都要有个车轮子。

17 |

关于作者

18 |
19 | 20 |
21 |
-------------------------------------------------------------------------------- /QuickBootstrap/Extendsions/ObjectExtendsions.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Runtime.Serialization.Formatters.Binary; 3 | 4 | namespace QuickBootstrap.Extendsions 5 | { 6 | public static class ObjectExtendsions 7 | { 8 | public static byte[] ToObjectBytes(this T t) where T : class 9 | { 10 | if (t == null) 11 | { 12 | return null; 13 | } 14 | 15 | var binaryFormatter = new BinaryFormatter(); 16 | using (var memoryStream = new MemoryStream()) 17 | { 18 | binaryFormatter.Serialize(memoryStream, t); 19 | return memoryStream.ToArray(); 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /QuickBootstrap/Views/UserManage/Shared/_QuickMenu.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = null; 3 | } 4 | 5 | 16 | 17 | 18 |
19 |
20 |

帮助提示

21 |
22 |
23 | 亲,记得要至少保留一个“用户账号”。你懂的! 24 |
25 |
-------------------------------------------------------------------------------- /QuickBootstrap/Entities/DefaultDbContext.cs: -------------------------------------------------------------------------------- 1 | using System.Data.Entity; 2 | using System.Data.Entity.ModelConfiguration.Conventions; 3 | 4 | namespace QuickBootstrap.Entities 5 | { 6 | /// 7 | /// 默认数据上下文 8 | /// 9 | public class DefaultDbContext : DbContext 10 | { 11 | /// 12 | /// 用户表 13 | /// 14 | public DbSet User { get; set; } 15 | 16 | protected override void OnModelCreating(DbModelBuilder modelBuilder) 17 | { 18 | //移除复数表名 19 | modelBuilder.Conventions.Remove(); 20 | 21 | base.OnModelCreating(modelBuilder); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /packages 2 | /*.suo 3 | /QuickBootstrap/Properties/PublishProfiles/*.pubxml 4 | /QuickBootstrap/Properties/PublishProfiles/*.user 5 | /QuickBootstrap/bin 6 | /QuickBootstrap/logs 7 | /QuickBootstrap/obj 8 | /QuickBootstrap/QuickBootstrap.csproj.user 9 | /QuickBootstrap/Content/bootstrap-theme.css 10 | /QuickBootstrap/Content/bootstrap-theme.css.map 11 | /QuickBootstrap/Content/bootstrap-theme.min.css 12 | /QuickBootstrap/Content/bootstrap.css.map 13 | /QuickBootstrap/Scripts/jquery-2.1.1.intellisense.js 14 | /QuickBootstrap/Scripts/jquery-2.1.1.js 15 | /QuickBootstrap/Scripts/jquery-2.1.1.min.js 16 | /QuickBootstrap/Scripts/jquery-2.1.1.min.map 17 | /QuickBootstrap/Scripts/modernizr-2.8.3.js 18 | /QuickBootstrap/Scripts/respond.matchmedia.addListener.js 19 | /QuickBootstrap/Scripts/respond.matchmedia.addListener.min.js 20 | -------------------------------------------------------------------------------- /QuickBootstrap/Filters/ValidateModelStateAttribute.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | 3 | namespace QuickBootstrap.Filters 4 | { 5 | /// 6 | /// 默认模型字典验证过滤器 7 | /// 8 | public class ValidateModelStateAttribute : ActionFilterAttribute 9 | { 10 | public override void OnActionExecuting(ActionExecutingContext filterContext) 11 | { 12 | if (!filterContext.Controller.ViewData.ModelState.IsValid) 13 | { 14 | filterContext.Result = new ViewResult 15 | { 16 | ViewData = filterContext.Controller.ViewData, 17 | TempData = filterContext.Controller.TempData 18 | }; 19 | } 20 | 21 | base.OnActionExecuting(filterContext); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /QuickBootstrap/Entities/InitData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Data.Entity; 4 | 5 | namespace QuickBootstrap.Entities 6 | { 7 | /// 8 | /// 数据库初始化种子 9 | /// 10 | public sealed class InitData : CreateDatabaseIfNotExists 11 | { 12 | protected override void Seed(DefaultDbContext context) 13 | { 14 | //默认用户 15 | new List 16 | { 17 | new User{ 18 | UserName="mr.wangya@qq.com", 19 | UserPwd= "670b14728ad9902aecba32e22fa4f6bd", 20 | CreateTime = DateTime.Now, 21 | IsEnable = true, 22 | Nick = "SmartBooks"} 23 | }.ForEach(m => context.User.Add(m)); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /QuickBootstrap/Extendsions/ByteExtendsions.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | using System.IO; 3 | using System.Runtime.Serialization.Formatters.Binary; 4 | 5 | namespace QuickBootstrap.Extendsions 6 | { 7 | public static class ByteExtendsions 8 | { 9 | public static Image ToBitmap(this byte[] data) 10 | { 11 | var ms = new MemoryStream(data); 12 | return Image.FromStream(ms); 13 | } 14 | 15 | public static T To(this byte[] date) where T : class 16 | { 17 | if (date == null) 18 | { 19 | return default(T); 20 | } 21 | 22 | var binaryFormatter = new BinaryFormatter(); 23 | using (var memoryStream = new MemoryStream(date)) 24 | { 25 | return (T)binaryFormatter.Deserialize(memoryStream); 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /QuickBootstrap/Entities/User.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | namespace QuickBootstrap.Entities 6 | { 7 | /// 8 | /// 用户表 9 | /// 10 | public class User 11 | { 12 | [Key] 13 | [MaxLength(50)] 14 | [DisplayName("登录账号")] 15 | public string UserName { get; set; } 16 | 17 | [Required] 18 | [MaxLength(32)] 19 | [DisplayName("登录密码")] 20 | public string UserPwd { get; set; } 21 | 22 | [Required] 23 | [MaxLength(50)] 24 | [DisplayName("昵称")] 25 | public string Nick { get; set; } 26 | 27 | [Required] 28 | [DisplayName("是否启用")] 29 | public bool IsEnable { get; set; } 30 | 31 | [Required] 32 | public DateTime CreateTime { get; set; } 33 | } 34 | } -------------------------------------------------------------------------------- /QuickBootstrap/Services/Impl/ProfileService.cs: -------------------------------------------------------------------------------- 1 | using System.Data.Entity; 2 | using System.Linq; 3 | using QuickBootstrap.Entities; 4 | using QuickBootstrap.Services.Util; 5 | 6 | namespace QuickBootstrap.Services.Impl 7 | { 8 | public sealed class ProfileService : ServiceContext, IProfileService 9 | { 10 | public User GetUserInfo(string username = "") 11 | { 12 | return DbContext.User.FirstOrDefault(p => p.UserName == username); 13 | } 14 | 15 | public bool ChangePassword(string username = "", string newPassword = "") 16 | { 17 | var userInfo = GetUserInfo(username); 18 | 19 | if (userInfo == null) return false; 20 | 21 | userInfo.UserPwd = newPassword; 22 | DbContext.Entry(userInfo).State = EntityState.Modified; 23 | return DbContext.SaveChanges() > 0; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /QuickBootstrap/Services/Impl/ManageService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using QuickBootstrap.Services.Util; 4 | using QuickBootstrap.Sessions; 5 | 6 | namespace QuickBootstrap.Services.Impl 7 | { 8 | public sealed class ManageService : ServiceContext, IManageService 9 | { 10 | 11 | public void LoginOut(string username, string ipAddress) 12 | { 13 | } 14 | 15 | public UserSession GetUserSession(string username, string password, string ipAddress) 16 | { 17 | if (DbContext.User.Any(p => p.UserName == username && p.UserPwd == password && p.IsEnable)) 18 | { 19 | return new UserSession 20 | { 21 | LoginDateTime = DateTime.Now, 22 | LoginIpAddress = ipAddress, 23 | UserName = username, 24 | }; 25 | } 26 | 27 | return null; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /QuickBootstrap/Cache/EnyimMemcachedContext.cs: -------------------------------------------------------------------------------- 1 | using Enyim.Caching; 2 | using Enyim.Caching.Memcached; 3 | 4 | namespace QuickBootstrap.Cache 5 | { 6 | public sealed class EnyimMemcachedContext : CacheContext 7 | { 8 | private readonly MemcachedClient _memcachedClient = new MemcachedClient("SmartBooks/memcached"); 9 | 10 | public override void Init() { } 11 | 12 | public override T Get(string key) 13 | { 14 | return _memcachedClient.Get(key); 15 | } 16 | 17 | public override bool Set(string key, T t) 18 | { 19 | return _memcachedClient.Store(StoreMode.Set, key, t); 20 | } 21 | 22 | public override bool Remove(string key) 23 | { 24 | return _memcachedClient.Remove(key); 25 | } 26 | 27 | public override void Dispose() 28 | { 29 | if (_memcachedClient != null) 30 | { 31 | _memcachedClient.Dispose(); 32 | } 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /QuickBootstrap/Models/HomeLoginRequest.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace QuickBootstrap.Models 4 | { 5 | public class HomeLoginRequest 6 | { 7 | public HomeLoginRequest() 8 | { 9 | UserName = string.Empty; 10 | Password = string.Empty; 11 | } 12 | 13 | [StringLength(32)] 14 | [Required] 15 | [RegularExpression(@"[A-Za-z0-9._%+-]+@[A-Za-z0-9._]+\.[A-Za-z]{2,4}", ErrorMessage = "邮箱地址格式不正确")] 16 | [Display(Name = "邮箱地址")] 17 | [DataType(DataType.EmailAddress)] 18 | public string UserName { get; set; } 19 | 20 | [StringLength(32)] 21 | [Required] 22 | [Display(Name = "登录密码")] 23 | [DataType(DataType.Password)] 24 | public string Password { get; set; } 25 | 26 | public void Trim() 27 | { 28 | if (!string.IsNullOrEmpty(UserName)) UserName = UserName.Trim(); 29 | 30 | if (!string.IsNullOrEmpty(Password)) Password = Password.Trim(); 31 | 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /QuickBootstrap/Views/Shared/_PartialPagingInfo.cshtml: -------------------------------------------------------------------------------- 1 | @using QuickBootstrap.Extendsions 2 | @using QuickBootstrap.Services.Util 3 | 4 | @{ 5 | var paging = Model as Paged; 6 | if (paging != null && paging.SizeCount > 0) 7 | { 8 | //得到现有query参数 9 | var queryString = string.Empty; 10 | for (var i = 0; i < Request.QueryString.AllKeys.Length; i++) 11 | { 12 | var currentKey = Request.QueryString.AllKeys[i] ?? string.Empty; 13 | currentKey = currentKey.ToLower(); 14 | if (currentKey != "pageindex" && currentKey != "pagesize" && currentKey.Length > 0) 15 | { 16 | queryString += string.Format("{0}={1}&", currentKey, Request.QueryString[currentKey]); 17 | } 18 | } 19 | 20 | @Html.Paging(paging.PageIndex, paging.PageSize, paging.SizeCount, queryString) 21 | } 22 | 23 | if (paging != null && paging.SizeCount <= 0) 24 | { 25 |
26 | 提示 没有查询到记录。 27 |
28 | } 29 | } 30 | -------------------------------------------------------------------------------- /QuickBootstrap/Extendsions/Linq/ParameterRebinder.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq.Expressions; 3 | 4 | namespace QuickBootstrap.Extendsions.Linq 5 | { 6 | public class ParameterRebinder : ExpressionVisitor 7 | { 8 | private readonly Dictionary _map; 9 | 10 | public ParameterRebinder(Dictionary map) 11 | { 12 | _map = map ?? new Dictionary(); 13 | } 14 | 15 | public static Expression ReplaceParameters(Dictionary map, Expression exp) 16 | { 17 | return new ParameterRebinder(map).Visit(exp); 18 | } 19 | 20 | protected override Expression VisitParameter(ParameterExpression p) 21 | { 22 | ParameterExpression replacement; 23 | if (_map.TryGetValue(p, out replacement)) 24 | { 25 | p = replacement; 26 | } 27 | return base.VisitParameter(p); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /QuickBootstrap/Models/UserCreateRequest.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace QuickBootstrap.Models 4 | { 5 | public class UserCreateRequest 6 | { 7 | public UserCreateRequest() 8 | { 9 | UserName = string.Empty; 10 | Password = string.Empty; 11 | } 12 | 13 | [MaxLength(50)] 14 | [Required] 15 | [DataType(DataType.EmailAddress)] 16 | [RegularExpression(@"[A-Za-z0-9._%+-]+@[A-Za-z0-9._]+\.[A-Za-z]{2,4}", ErrorMessage = "电邮邮件格式不正确")] 17 | [Display(Name = "邮箱地址")] 18 | public string UserName { get; set; } 19 | 20 | [MinLength(6)] 21 | [MaxLength(12)] 22 | [Required] 23 | [DataType(DataType.Password)] 24 | [Display(Name = "登录密码")] 25 | public string Password { get; set; } 26 | 27 | [MaxLength(50)] 28 | [Required] 29 | [Display(Name = "真实姓名")] 30 | public string Nick { get; set; } 31 | 32 | [Required] 33 | [Display(Name = "账号状态")] 34 | public bool IsEnable { get; set; } 35 | } 36 | } -------------------------------------------------------------------------------- /QuickBootstrap/Models/UserManageChangePassword.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace QuickBootstrap.Models 4 | { 5 | public sealed class UserManageChangePassword 6 | { 7 | [StringLength(32)] 8 | [Required] 9 | [RegularExpression(@"[A-Za-z0-9._%+-]+@[A-Za-z0-9._]+\.[A-Za-z]{2,4}", ErrorMessage = "邮箱地址格式不正确")] 10 | [Display(Name = "邮箱地址")] 11 | [DataType(DataType.EmailAddress)] 12 | public string UserName { get; set; } 13 | 14 | [StringLength(32)] 15 | [Required] 16 | [Display(Name = "当前密码")] 17 | [DataType(DataType.Password)] 18 | 19 | public string CurrentPassword { get; set; } 20 | 21 | [StringLength(32)] 22 | [Required] 23 | [Display(Name = "新密码")] 24 | [DataType(DataType.Password)] 25 | public string NewPassword { get; set; } 26 | 27 | [StringLength(32)] 28 | [Required] 29 | [Display(Name = "重复新密码")] 30 | [DataType(DataType.Password)] 31 | [Compare("NewPassword")] 32 | public string ConfirmPassword { get; set; } 33 | } 34 | } -------------------------------------------------------------------------------- /QuickBootstrap/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /QuickBootstrap/App_Start/BundleConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Optimization; 3 | 4 | namespace QuickBootstrap 5 | { 6 | public class BundleConfig 7 | { 8 | // 有关绑定的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkId=301862 9 | public static void RegisterBundles(BundleCollection bundles) 10 | { 11 | bundles.Add(new ScriptBundle("~/bundles/jquery").Include( 12 | "~/Scripts/jquery-{version}.js")); 13 | 14 | bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( 15 | "~/Scripts/jquery.validate*")); 16 | 17 | bundles.Add(new ScriptBundle("~/bundles/modernizr").Include( 18 | "~/Scripts/modernizr-*")); 19 | 20 | bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include( 21 | "~/Scripts/bootstrap.js", 22 | "~/Scripts/respond.js", 23 | "~/Scripts/base.js")); 24 | 25 | bundles.Add(new StyleBundle("~/Content/css").Include( 26 | "~/Content/bootstrap.css", 27 | "~/Content/base.css")); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /QuickBootstrap/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /QuickBootstrap/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息是通过以下项进行控制的 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("QuickBootstrap")] 9 | [assembly: AssemblyDescription("基于ASP.NET MVC、EntityFramework、Memcached、Bootstrap的快速项目开发框架,只需3秒钟即可创建一个带有简单用户管理的项目")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("SmartBooks")] 12 | [assembly: AssemblyProduct("QuickBootstrap")] 13 | [assembly: AssemblyCopyright("版权所有(C) 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 将使此程序集中的类型 18 | // 对 COM 组件不可见。如果需要 19 | // 从 COM 访问此程序集中的某个类型,请针对该类型将 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于 typelib 的 ID 23 | [assembly: Guid("381e3ee1-e723-4a52-9725-61ae540bdb9d")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 内部版本号 30 | // 修订版本 31 | // 32 | // 你可以指定所有值,也可以让修订版本和内部版本号采用默认值, 33 | // 方法是按如下所示使用 "*": 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | 37 | //启用log4日志组件 38 | [assembly: log4net.Config.XmlConfigurator(Watch = true)] -------------------------------------------------------------------------------- /QuickBootstrap/Cache/RedisContext.cs: -------------------------------------------------------------------------------- 1 | using QuickBootstrap.Cache.Extendsions; 2 | using StackExchange.Redis; 3 | 4 | namespace QuickBootstrap.Cache 5 | { 6 | /// 7 | /// 连接池需要重新设计 8 | /// 9 | public class RedisContext : CacheContext 10 | { 11 | public static IDatabase RedisDatabase; 12 | 13 | public override void Init() { } 14 | 15 | public override T Get(string key) 16 | { 17 | try 18 | { 19 | return RedisDatabase.Get(key); 20 | } 21 | catch 22 | { 23 | return null; 24 | } 25 | } 26 | 27 | public override bool Set(string key, T t) 28 | { 29 | try 30 | { 31 | RedisDatabase.Set(key, t); 32 | 33 | return true; 34 | } 35 | catch 36 | { 37 | return false; 38 | } 39 | } 40 | 41 | public override bool Remove(string key) 42 | { 43 | try 44 | { 45 | return RedisDatabase.KeyDelete(key); 46 | } 47 | catch 48 | { 49 | return false; 50 | } 51 | } 52 | 53 | public override void Dispose() { } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /QuickBootstrap/Extendsions/Web/HttpResponseExtendsions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Text; 4 | using System.Web; 5 | using System.Xml.Serialization; 6 | 7 | namespace QuickBootstrap.Extendsions.Web 8 | { 9 | public static class HttpResponseExtendsions 10 | { 11 | public static void WriteCsv(this HttpResponse response, string content) 12 | { 13 | using (var ms = new MemoryStream(Encoding.Default.GetBytes(content))) 14 | { 15 | response.AppendHeader("content-disposition", string.Format("attachment;filename={0}.csv", Guid.NewGuid())); 16 | response.ContentType = "application/ms-excel"; 17 | response.BinaryWrite(ms.ToArray()); 18 | response.End(); 19 | } 20 | } 21 | 22 | public static void WriteXml(this HttpResponse response, T t) where T : class 23 | { 24 | var stringBuilder = new StringBuilder(); 25 | 26 | using (TextWriter tw = new StringWriter(stringBuilder)) 27 | { 28 | var xmlSerializer = new XmlSerializer(typeof(T)); 29 | xmlSerializer.Serialize(tw, t); 30 | } 31 | 32 | response.ContentType = "text/xml"; 33 | response.Write(stringBuilder); 34 | response.End(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /QuickBootstrap/Cache/CacheContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace QuickBootstrap.Cache 4 | { 5 | /// 6 | /// 策略模式缓存组件,可实现动态插拔 7 | /// 8 | public abstract class CacheContext : IDisposable 9 | { 10 | /// 11 | /// 初始化缓存组件 12 | /// 13 | public abstract void Init(); 14 | 15 | /// 16 | /// 获取缓存项 17 | /// 18 | /// 缓存对象类型 19 | /// 键 20 | /// 缓存对象 21 | public abstract T Get(string key) where T : class; 22 | 23 | /// 24 | /// 设置缓存项 25 | /// 26 | /// 缓存对象类型 27 | /// 键 28 | /// 缓存对象 29 | /// true成功,false失败 30 | public abstract bool Set(string key, T t) where T : class; 31 | 32 | /// 33 | /// 移除一个缓存项 34 | /// 35 | /// 缓存项key 36 | /// true成功,false失败 37 | public abstract bool Remove(string key); 38 | 39 | /// 40 | /// 释放缓存组件 41 | /// 42 | public abstract void Dispose(); 43 | } 44 | } -------------------------------------------------------------------------------- /QuickBootstrap/Views/Profile/Index.cshtml: -------------------------------------------------------------------------------- 1 | @using QuickBootstrap.Filters 2 | @{ 3 | ViewBag.Title = "个人中心"; 4 | } 5 | 6 | 7 |
8 | 9 |
10 | 11 | @Html.Partial("Shared/_QuickMenu") 12 | 13 |
14 |
15 | 16 | 21 | 22 |
23 | 24 |
25 | 26 |
27 | 28 |
29 |

30 | @Request.Cookies[UserAuthorizationAttribute.CookieUserName].Value 31 |

32 |
33 |
34 | 35 |
36 | 37 |
38 | 39 |
40 | 获取最佳体验效果,请升级您的Google Chrome 简体中文浏览器至最新版本。 41 |
42 | 43 |
44 | 45 |
-------------------------------------------------------------------------------- /QuickBootstrap.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30110.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickBootstrap", "QuickBootstrap\QuickBootstrap.csproj", "{C1CB7B0B-5E99-4559-88E5-8BC36BAE472E}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{637DBFEF-122F-4075-8BC4-3215B77C0FD5}" 9 | ProjectSection(SolutionItems) = preProject 10 | .nuget\NuGet.Config = .nuget\NuGet.Config 11 | .nuget\NuGet.exe = .nuget\NuGet.exe 12 | .nuget\NuGet.targets = .nuget\NuGet.targets 13 | EndProjectSection 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {C1CB7B0B-5E99-4559-88E5-8BC36BAE472E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {C1CB7B0B-5E99-4559-88E5-8BC36BAE472E}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {C1CB7B0B-5E99-4559-88E5-8BC36BAE472E}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {C1CB7B0B-5E99-4559-88E5-8BC36BAE472E}.Release|Any CPU.Build.0 = Release|Any CPU 25 | EndGlobalSection 26 | GlobalSection(SolutionProperties) = preSolution 27 | HideSolutionNode = FALSE 28 | EndGlobalSection 29 | EndGlobal 30 | -------------------------------------------------------------------------------- /QuickBootstrap/Views/Home/Login.cshtml: -------------------------------------------------------------------------------- 1 | @model QuickBootstrap.Models.HomeLoginRequest 2 | @{ 3 | ViewBag.Title = "用户登录"; 4 | } 5 | 6 |
7 | 8 | @using (Html.BeginForm("Login", "Home", FormMethod.Post, new { @class = "form-horizontal", style = "max-width: 350px;padding: 15px; margin: 0 auto;" })) 9 | { 10 |
11 |
12 |

用户登录

13 |
14 |
15 | 16 |
17 |
18 | @Html.TextBoxFor(model => model.UserName, new { @class = "form-control input-lg", placeholder = "登录邮箱" }) 19 |
20 |
21 | 22 |
23 |
24 | @Html.PasswordFor(model => model.Password, new { @class = "form-control input-lg", placeholder = "登录密码" }) 25 |
26 |
27 | 28 |
29 |
30 | @Html.ValidationSummary(false) 31 |
32 |
33 | 34 |
35 |
36 | 37 |
38 |
39 | } 40 | 41 |
-------------------------------------------------------------------------------- /QuickBootstrap/Models/ProfileChangePasswordRequest.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace QuickBootstrap.Models 4 | { 5 | public sealed class ProfileChangePasswordRequest 6 | { 7 | public ProfileChangePasswordRequest() 8 | { 9 | UserName = string.Empty; 10 | CurrentPassword = string.Empty; 11 | NewPassword = string.Empty; 12 | ConfirmPassword = string.Empty; 13 | } 14 | 15 | [Required] 16 | [Display(Name = "用户账号")] 17 | public string UserName { get; set; } 18 | 19 | [StringLength(32)] 20 | [Required] 21 | [DataType(DataType.Password)] 22 | [Display(Name = "当前密码")] 23 | public string CurrentPassword { get; set; } 24 | 25 | [StringLength(32)] 26 | [Required] 27 | [DataType(DataType.Password)] 28 | [Display(Name = "新的密码")] 29 | public string NewPassword { get; set; } 30 | 31 | [Compare("NewPassword")] 32 | [Display(Name = "确认密码")] 33 | public string ConfirmPassword { get; set; } 34 | 35 | public void Trim() 36 | { 37 | if (!string.IsNullOrEmpty(UserName)) UserName = UserName.Trim(); 38 | 39 | if (!string.IsNullOrEmpty(CurrentPassword)) CurrentPassword = CurrentPassword.Trim(); 40 | 41 | if (!string.IsNullOrEmpty(NewPassword)) NewPassword = NewPassword.Trim(); 42 | 43 | if (!string.IsNullOrEmpty(ConfirmPassword)) ConfirmPassword = ConfirmPassword.Trim(); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /QuickBootstrap/Extendsions/Linq/PredicateBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Linq.Expressions; 4 | 5 | namespace QuickBootstrap.Extendsions.Linq 6 | { 7 | public static class PredicateBuilder 8 | { 9 | public static Expression> True() { return f => true; } 10 | public static Expression> False() { return f => false; } 11 | public static Expression Compose(this Expression first, Expression second, Func merge) 12 | { 13 | // build parameter map (from parameters of second to parameters of first) 14 | var map = first.Parameters.Select((f, i) => new { f, s = second.Parameters[i] }).ToDictionary(p => p.s, p => p.f); 15 | 16 | // replace parameters in the second lambda expression with parameters from the first 17 | var secondBody = ParameterRebinder.ReplaceParameters(map, second.Body); 18 | 19 | // apply composition of lambda expression bodies to parameters from the first expression 20 | return Expression.Lambda(merge(first.Body, secondBody), first.Parameters); 21 | } 22 | 23 | public static Expression> And(this Expression> first, Expression> second) 24 | { 25 | return first.Compose(second, Expression.And); 26 | } 27 | 28 | public static Expression> Or(this Expression> first, Expression> second) 29 | { 30 | return first.Compose(second, Expression.Or); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /QuickBootstrap/Content/base.css: -------------------------------------------------------------------------------- 1 | /* 2 | * 基础页面样式 3 | * author mr.wangya@qq.com 4 | */ 5 | 6 | body { 7 | padding-top: 50px; 8 | padding-bottom: 20px; 9 | /*background-image: url(/Content/img/page-bg-black.png);*/ 10 | } 11 | 12 | /* Set padding to keep content from hitting the edges */ 13 | .body-content { 14 | margin-top: 15px; 15 | padding: 15px; 16 | } 17 | 18 | .container { 19 | background-color: #ffffff; 20 | } 21 | 22 | /* styles for validation helpers */ 23 | .field-validation-error { 24 | color: #b94a48; 25 | } 26 | 27 | .field-validation-valid { 28 | display: none; 29 | } 30 | 31 | input.input-validation-error { 32 | border: 1px solid #b94a48; 33 | } 34 | 35 | input[type="checkbox"].input-validation-error { 36 | border: 0 none; 37 | } 38 | 39 | .validation-summary-errors { 40 | color: #b94a48; 41 | } 42 | 43 | .validation-summary-valid { 44 | display: none; 45 | } 46 | 47 | .footer { 48 | text-align: center; 49 | padding-top: 20px; 50 | } 51 | 52 | /*标注样式*/ 53 | .callout { 54 | float: left; 55 | width: 100%; 56 | margin: 10px 0; 57 | padding: 10px; 58 | border-left: 3px solid #eee; 59 | } 60 | 61 | .callout-primary { 62 | background-color: #f5f5f5; 63 | border-color: #428bca; 64 | } 65 | 66 | .callout-success { 67 | background-color: #f5f5f5; 68 | border-color: #d6e9c6; 69 | } 70 | 71 | .callout-info { 72 | background-color: #f5f5f5; 73 | border-color: #bce8f1; 74 | } 75 | 76 | .callout-warning { 77 | background-color: #f5f5f5; 78 | border-color: #ebccd1; 79 | } 80 | 81 | .callout-danger { 82 | background-color: #f5f5f5; 83 | border-color: #eed3d7; 84 | } 85 | -------------------------------------------------------------------------------- /QuickBootstrap/Views/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /QuickBootstrap/Cache/Extendsions/StackExchangeRedisExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Runtime.Serialization.Formatters.Binary; 4 | using StackExchange.Redis; 5 | 6 | namespace QuickBootstrap.Cache.Extendsions 7 | { 8 | public static class StackExchangeRedisExtensions 9 | { 10 | public static T Get(this IDatabase cache, string key) 11 | { 12 | return Deserialize(cache.StringGet(key)); 13 | } 14 | 15 | public static object Get(this IDatabase cache, string key) 16 | { 17 | return Deserialize(cache.StringGet(key)); 18 | } 19 | 20 | public static void Set(this IDatabase cache, string key, object value) 21 | { 22 | cache.StringSet(key, Serialize(value)); 23 | } 24 | 25 | static byte[] Serialize(object o) 26 | { 27 | if (o == null) 28 | { 29 | return null; 30 | } 31 | 32 | var binaryFormatter = new BinaryFormatter(); 33 | using (var memoryStream = new MemoryStream()) 34 | { 35 | binaryFormatter.Serialize(memoryStream, o); 36 | var objectDataAsStream = memoryStream.ToArray(); 37 | return objectDataAsStream; 38 | } 39 | } 40 | 41 | static T Deserialize(byte[] stream) 42 | { 43 | if (stream == null) 44 | { 45 | return default(T); 46 | } 47 | 48 | var binaryFormatter = new BinaryFormatter(); 49 | using (var memoryStream = new MemoryStream(stream)) 50 | { 51 | var result = (T)binaryFormatter.Deserialize(memoryStream); 52 | return result; 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /QuickBootstrap/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Configuration; 3 | using System.Data.Entity; 4 | using System.Linq; 5 | using System.Runtime.ExceptionServices; 6 | using System.Threading.Tasks; 7 | using System.Web.Mvc; 8 | using System.Web.Optimization; 9 | using System.Web.Routing; 10 | using log4net; 11 | using QuickBootstrap.Cache; 12 | using QuickBootstrap.Entities; 13 | using StackExchange.Redis; 14 | 15 | namespace QuickBootstrap 16 | { 17 | public class MvcApplication : System.Web.HttpApplication 18 | { 19 | private readonly static string RedisConnection = ConfigurationManager.AppSettings["RedisConnection"]; 20 | private readonly ILog _logger = LogManager.GetLogger(typeof(MvcApplication)); 21 | 22 | protected void Application_Start() 23 | { 24 | AppDomain.CurrentDomain.FirstChanceException += CurrentDomainOnFirstChanceException; 25 | 26 | AreaRegistration.RegisterAllAreas(); 27 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 28 | RouteConfig.RegisterRoutes(RouteTable.Routes); 29 | BundleConfig.RegisterBundles(BundleTable.Bundles); 30 | 31 | Task.Factory.StartNew(() => 32 | { 33 | Database.SetInitializer(new CreateDatabaseIfNotExists()); 34 | Database.SetInitializer(new InitData()); 35 | var count = new DefaultDbContext().User.Count(); 36 | 37 | if (RedisContext.RedisDatabase == null) 38 | { 39 | RedisContext.RedisDatabase = ConnectionMultiplexer.Connect(RedisConnection).GetDatabase(); 40 | } 41 | }); 42 | } 43 | 44 | private void CurrentDomainOnFirstChanceException(object sender, FirstChanceExceptionEventArgs e) 45 | { 46 | _logger.Error(e.Exception); 47 | } 48 | 49 | protected void Application_Error(Object sender, EventArgs e) 50 | { 51 | var lastError = Server.GetLastError().GetBaseException(); 52 | { 53 | _logger.Error(lastError); 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /QuickBootstrap/Filters/UserAuthorizationAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.Mvc; 3 | using QuickBootstrap.Sessions; 4 | 5 | namespace QuickBootstrap.Filters 6 | { 7 | public class UserAuthorizationAttribute : ActionFilterAttribute 8 | { 9 | public static readonly string CookieUserName = "username"; 10 | public static readonly string ManageLoginUrl = "/home/login"; 11 | 12 | public override void OnActionExecuting(ActionExecutingContext filterContext) 13 | { 14 | //用户授权验证 15 | if (filterContext.HttpContext.Request.Cookies[CookieUserName] == null || 16 | filterContext.HttpContext.Session == null || 17 | filterContext.HttpContext.Session[filterContext.HttpContext.Session.SessionID] == null) 18 | { 19 | //跳转到登录界面 20 | filterContext.Result = new RedirectResult(ManageLoginUrl); 21 | } 22 | else 23 | { 24 | var cookieUserName = filterContext.HttpContext.Request.Cookies[CookieUserName].Value; 25 | var currentUserSession = filterContext.HttpContext.Session[filterContext.HttpContext.Session.SessionID] as UserSession; 26 | if (string.IsNullOrEmpty(cookieUserName) || currentUserSession == null) 27 | { 28 | filterContext.Result = new RedirectResult(ManageLoginUrl); 29 | } 30 | else 31 | { 32 | if (string.Compare(cookieUserName, currentUserSession.UserName, StringComparison.CurrentCultureIgnoreCase) != 0 || 33 | String.Compare(currentUserSession.LoginIpAddress, filterContext.HttpContext.Request.UserHostAddress, StringComparison.CurrentCultureIgnoreCase) != 0) 34 | { 35 | filterContext.Result = new RedirectResult(ManageLoginUrl); 36 | } 37 | else 38 | { 39 | //用户权限菜单 40 | //filterContext.Controller.TempData["UserPermissions"] = null; 41 | } 42 | } 43 | } 44 | 45 | base.OnActionExecuting(filterContext); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /QuickBootstrap/Controllers/UserManageController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.Mvc; 3 | using QuickBootstrap.Entities; 4 | using QuickBootstrap.Extendsions; 5 | using QuickBootstrap.Filters; 6 | using QuickBootstrap.Models; 7 | using QuickBootstrap.Services; 8 | using QuickBootstrap.Services.Impl; 9 | using QuickBootstrap.Services.Util; 10 | 11 | namespace QuickBootstrap.Controllers 12 | { 13 | [UserAuthorization] 14 | public class UserManageController : Controller 15 | { 16 | #region 私有字段 17 | 18 | private readonly IUserManageService _userManageService = new UserManageService(); 19 | 20 | #endregion 21 | 22 | #region action method 23 | 24 | public ActionResult Index(int pageIndex = 0, int pageSize = 20) 25 | { 26 | var paging = new Paging { PageIndex = pageIndex, PageSize = pageSize }; 27 | return View(_userManageService.GetList(paging)); 28 | } 29 | 30 | public ActionResult Create() 31 | { 32 | var viewModel = new UserCreateRequest {IsEnable = true}; 33 | 34 | return View(viewModel); 35 | } 36 | 37 | [HttpPost] 38 | public ActionResult Create(UserCreateRequest model) 39 | { 40 | if (ModelState.IsValid == false) 41 | { 42 | return View(model); 43 | } 44 | 45 | if (_userManageService.ExistsUser(model.UserName) == false) 46 | { 47 | _userManageService.Create(new User 48 | { 49 | UserName = model.UserName, 50 | UserPwd = model.Password.ToMd5(), 51 | Nick = model.Nick, 52 | CreateTime = DateTime.Now, 53 | IsEnable = model.IsEnable 54 | }); 55 | 56 | return RedirectToAction("Index"); 57 | } 58 | 59 | ModelState.AddModelError("_error", "登录账号已存在"); 60 | 61 | return View(model); 62 | } 63 | 64 | public ActionResult Delete(string username = "") 65 | { 66 | if (username.Length > 0) 67 | { 68 | _userManageService.Delete(username); 69 | } 70 | 71 | return RedirectToAction("Index"); 72 | } 73 | 74 | #endregion 75 | } 76 | } -------------------------------------------------------------------------------- /QuickBootstrap/Services/Impl/UserManageService.cs: -------------------------------------------------------------------------------- 1 | using System.Data.Entity; 2 | using System.Linq; 3 | using EntityFramework.Extensions; 4 | using QuickBootstrap.Entities; 5 | using QuickBootstrap.Services.Models; 6 | using QuickBootstrap.Services.Util; 7 | 8 | namespace QuickBootstrap.Services.Impl 9 | { 10 | public sealed class UserManageService : ServiceContext, IUserManageService 11 | { 12 | public PagedResult GetList(Paging paging) 13 | { 14 | var queryPageResult = new PagedResult 15 | { 16 | PageIndex = paging.PageIndex, 17 | PageSize = paging.PageSize, 18 | }; 19 | 20 | var query = from user in DbContext.User 21 | orderby user.CreateTime descending 22 | select new UserManagePageItem 23 | { 24 | UserName = user.UserName, 25 | Nick = user.Nick, 26 | IsEnable = user.IsEnable, 27 | CreateTime = user.CreateTime, 28 | }; 29 | 30 | queryPageResult.SizeCount = query.Count(); 31 | queryPageResult.Result = query.Skip(paging.PageIndex * paging.PageSize).Take(paging.PageSize).ToList(); 32 | 33 | return queryPageResult; 34 | } 35 | 36 | public bool Create(User model) 37 | { 38 | DbContext.User.Add(model); 39 | return DbContext.SaveChanges() > 0; 40 | } 41 | 42 | public bool ExistsUser(string username) 43 | { 44 | return DbContext.User.FirstOrDefault(p => p.UserName == username) != null; 45 | } 46 | 47 | public User Get(string username = "") 48 | { 49 | return DbContext.User.FirstOrDefault(p => p.UserName == username); 50 | } 51 | 52 | public bool Edit(User model) 53 | { 54 | DbContext.Entry(model).State = EntityState.Modified; 55 | return DbContext.SaveChanges() > 0; 56 | } 57 | 58 | public bool Delete(string username) 59 | { 60 | return DbContext.User.Delete(p => p.UserName == username) > 0; 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /QuickBootstrap/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /QuickBootstrap/Services/Util/ServiceContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using QuickBootstrap.Cache; 4 | using QuickBootstrap.Entities; 5 | 6 | namespace QuickBootstrap.Services.Util 7 | { 8 | public abstract class ServiceContext : IDisposable 9 | { 10 | /// 11 | /// 数据库操作上下文 12 | /// 13 | public readonly DefaultDbContext DbContext = new DefaultDbContext(); 14 | 15 | /// 16 | /// 缓存组件 17 | /// 18 | public CacheContext CacheContext { get; private set; } 19 | 20 | /// 21 | /// 动态设置缓存对象的新实例 22 | /// 23 | /// 缓存实例对象 24 | public void SetCacheInstance(CacheContext cacheContext) 25 | { 26 | //先释放现有的缓存组件 27 | if (CacheContext != null) 28 | { 29 | CacheContext.Dispose(); 30 | CacheContext = null; 31 | } 32 | 33 | //初始化缓存组件新的实例 34 | CacheContext = cacheContext; 35 | } 36 | 37 | public void SetCacheInstance(Type cacheContextType) 38 | { 39 | if (cacheContextType == null) 40 | { 41 | throw new ArgumentNullException("cacheContextType"); 42 | } 43 | 44 | if (!typeof(CacheContext).IsAssignableFrom(cacheContextType)) 45 | { 46 | throw new ArgumentException( 47 | string.Format(CultureInfo.CurrentCulture, "该类型 {0} 必须继承自抽象类CacheContext", cacheContextType), 48 | "cacheContextType"); 49 | } 50 | 51 | try 52 | { 53 | CacheContext = Activator.CreateInstance(cacheContextType) as CacheContext; 54 | } 55 | catch (Exception ex) 56 | { 57 | throw new InvalidOperationException( 58 | String.Format( 59 | CultureInfo.CurrentCulture, 60 | "创建抽象类 CacheContext 的实例 {0} 失败", 61 | cacheContextType), 62 | ex); 63 | } 64 | } 65 | 66 | public void Dispose() 67 | { 68 | if (DbContext != null) 69 | { 70 | DbContext.Dispose(); 71 | } 72 | 73 | if (CacheContext != null) 74 | { 75 | CacheContext.Dispose(); 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /QuickBootstrap/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Mvc; 3 | using QuickBootstrap.Extendsions; 4 | using QuickBootstrap.Filters; 5 | using QuickBootstrap.Models; 6 | using QuickBootstrap.Services; 7 | using QuickBootstrap.Services.Impl; 8 | 9 | namespace QuickBootstrap.Controllers 10 | { 11 | public class HomeController : Controller 12 | { 13 | #region 私有字段 14 | 15 | private readonly IManageService _manageService = new ManageService(); 16 | 17 | #endregion 18 | 19 | #region index method 20 | 21 | [UserAuthorization] 22 | public ActionResult Index() 23 | { 24 | return View(); 25 | } 26 | 27 | #endregion 28 | 29 | #region 登录操作 30 | 31 | public ActionResult Login() 32 | { 33 | return View(new HomeLoginRequest()); 34 | } 35 | 36 | [HttpPost] 37 | [ValidateModelState] 38 | public ActionResult Login(HomeLoginRequest model) 39 | { 40 | model.Trim(); 41 | 42 | var loginUserSession = _manageService.GetUserSession(model.UserName, model.Password.ToMd5(), Request.UserHostAddress); 43 | 44 | if (loginUserSession != null) 45 | { 46 | Session[Session.SessionID] = loginUserSession; 47 | 48 | var userCookie = new HttpCookie(UserAuthorizationAttribute.CookieUserName, model.UserName); 49 | 50 | Response.Cookies.Add(userCookie); 51 | 52 | return RedirectToAction("Index"); 53 | } 54 | 55 | ModelState.AddModelError("_error", "登录密码错误或用户不存在或用户被禁用。"); 56 | 57 | return View(); 58 | } 59 | 60 | #endregion 61 | 62 | #region 注销操作 63 | 64 | [UserAuthorization] 65 | public ActionResult LoginOut() 66 | { 67 | if (Request.Cookies[UserAuthorizationAttribute.CookieUserName] != null && 68 | !string.IsNullOrWhiteSpace(Request.Cookies[UserAuthorizationAttribute.CookieUserName].Value)) 69 | { 70 | //退出登录日志记录操作 71 | _manageService.LoginOut(Request.Cookies[UserAuthorizationAttribute.CookieUserName].Value, Request.UserHostAddress); 72 | 73 | Session[Session.SessionID] = null; 74 | 75 | Response.Cookies.Add(new HttpCookie(UserAuthorizationAttribute.CookieUserName, string.Empty)); 76 | } 77 | 78 | return RedirectToAction("Login"); 79 | } 80 | 81 | #endregion 82 | } 83 | } -------------------------------------------------------------------------------- /QuickBootstrap/Controllers/ProfileController.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | using QuickBootstrap.Extendsions; 3 | using QuickBootstrap.Filters; 4 | using QuickBootstrap.Models; 5 | using QuickBootstrap.Services; 6 | using QuickBootstrap.Services.Impl; 7 | 8 | 9 | namespace QuickBootstrap.Controllers 10 | { 11 | [UserAuthorization] 12 | public class ProfileController : Controller 13 | { 14 | #region private 15 | 16 | private readonly IProfileService _profileService = new ProfileService(); 17 | 18 | #endregion 19 | 20 | #region action method 21 | 22 | public ActionResult Index() 23 | { 24 | return View(); 25 | } 26 | 27 | public ActionResult ChangePassword() 28 | { 29 | var httpCookie = Request.Cookies[UserAuthorizationAttribute.CookieUserName]; 30 | 31 | if (httpCookie == null) { return View(new ProfileChangePasswordRequest()); } 32 | 33 | var model = new ProfileChangePasswordRequest 34 | { 35 | UserName = httpCookie.Value 36 | }; 37 | 38 | return View(model); 39 | } 40 | 41 | [HttpPost] 42 | [ValidateModelState] 43 | public ActionResult ChangePassword(ProfileChangePasswordRequest model) 44 | { 45 | model.Trim(); 46 | 47 | if (model.CurrentPassword == model.ConfirmPassword) 48 | { 49 | ModelState.AddModelError("_error", "新密码与当前密码相同"); 50 | return View(model); 51 | } 52 | 53 | model.CurrentPassword = model.CurrentPassword.ToMd5(); 54 | model.ConfirmPassword = model.ConfirmPassword.ToMd5(); 55 | 56 | var userInfo = _profileService.GetUserInfo(model.UserName); 57 | 58 | if (userInfo != null) 59 | { 60 | if (userInfo.UserPwd == model.CurrentPassword) 61 | { 62 | if (_profileService.ChangePassword(model.UserName, model.ConfirmPassword)) 63 | { 64 | return RedirectToAction("LoginOut", "Home"); 65 | } 66 | 67 | ModelState.AddModelError("_error", "修改密码失败"); 68 | } 69 | else 70 | { 71 | ModelState.AddModelError("_error", "当前密码不正确"); 72 | } 73 | } 74 | else 75 | { 76 | ModelState.AddModelError("_error", string.Format("账号 {0} 不存在", model.UserName)); 77 | } 78 | 79 | return View(model); 80 | } 81 | 82 | #endregion 83 | } 84 | } -------------------------------------------------------------------------------- /QuickBootstrap/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | @using QuickBootstrap.Filters 2 | 3 | 4 | 5 | 6 | 7 | @ViewBag.Title - 极速管理后台 8 | 9 | @Styles.Render("~/Content/css") 10 | @Scripts.Render("~/bundles/modernizr") 11 | 12 | @Scripts.Render("~/bundles/jquery") 13 | @Scripts.Render("~/bundles/bootstrap") 14 | @RenderSection("scripts", required: false) 15 | 16 | 17 | 18 | 19 | 61 | 62 |
63 |
64 | @RenderBody() 65 |
66 |
67 |
68 |

© @DateTime.Now.Year SmartBooks 版权所有

69 |
70 |
71 | 72 | @Html.Partial("_PartialTongJiCode") 73 | 74 | 75 | -------------------------------------------------------------------------------- /QuickBootstrap/Views/Profile/ChangePassword.cshtml: -------------------------------------------------------------------------------- 1 | @model QuickBootstrap.Models.ProfileChangePasswordRequest 2 | @{ 3 | ViewBag.Title = "修改密码"; 4 | } 5 | 6 |
7 | 8 |
9 | 10 | @Html.Partial("Shared/_QuickMenu") 11 | 12 |
13 |
14 | 15 | 20 | 21 | 22 |
23 | 24 | @using (Html.BeginForm("ChangePassword", "Profile", FormMethod.Post, new { @class = "form-horizontal" })) 25 | { 26 |
27 | @Html.LabelFor(model => model.UserName, new { @class = "col-md-2 control-label" }) 28 |
29 | @Html.HiddenFor(model => model.UserName) 30 | @Html.TextBoxFor(model => model.UserName, new { @class = "form-control", style = "width: 280px", disabled = "" }) 31 |
32 |
33 | 34 |
35 | @Html.LabelFor(model => model.CurrentPassword, new { @class = "col-md-2 control-label" }) 36 |
37 | @Html.PasswordFor(model => model.CurrentPassword, new { @class = "form-control", style = "width: 280px" }) 38 |
39 |
40 | 41 |
42 | @Html.LabelFor(model => model.NewPassword, new { @class = "col-md-2 control-label" }) 43 |
44 | @Html.PasswordFor(model => model.NewPassword, new { @class = "form-control", style = "width: 280px" }) 45 |
46 |
47 | 48 |
49 | @Html.LabelFor(model => model.ConfirmPassword, new { @class = "col-md-2 control-label" }) 50 |
51 | @Html.PasswordFor(model => model.ConfirmPassword, new { @class = "form-control", style = "width: 280px" }) 52 |
53 |
54 | 55 |
56 |
57 | @Html.ValidationSummary(false) 58 |
59 |
60 | 61 |
62 |
63 | 64 |
65 |
66 | } 67 | 68 |
69 |
70 |
-------------------------------------------------------------------------------- /QuickBootstrap/Extendsions/StringExtendsions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Security.Cryptography; 3 | using System.Text; 4 | 5 | namespace QuickBootstrap.Extendsions 6 | { 7 | public static class StringExtendsions 8 | { 9 | public static string MaxSubstring(this string origin, int maxLength) 10 | { 11 | return MaxSubstring(origin, maxLength, string.Empty); 12 | } 13 | 14 | public static string MaxSubstring(this string origin, int maxLength, string ellipsis) 15 | { 16 | return origin.Length >= maxLength ? origin.Substring(0, maxLength) + ellipsis : origin; 17 | } 18 | 19 | public static string ToMd5(this string origin) 20 | { 21 | if (string.IsNullOrWhiteSpace(origin)) 22 | { 23 | return string.Empty; 24 | } 25 | 26 | var md5Algorithm = MD5.Create(); 27 | var utf8Bytes = Encoding.UTF8.GetBytes(origin); 28 | var md5Hash = md5Algorithm.ComputeHash(utf8Bytes); 29 | var hexString = new StringBuilder(); 30 | foreach (var hexByte in md5Hash) 31 | { 32 | hexString.Append(hexByte.ToString("x2")); 33 | } 34 | return hexString.ToString(); 35 | } 36 | 37 | public static string ToUtf8Base64String(this string origin) 38 | { 39 | return string.IsNullOrEmpty(origin) ? string.Empty : Convert.ToBase64String(Encoding.UTF8.GetBytes(origin)); 40 | } 41 | 42 | public static string[] ToQueryString(this string origin, char separator = '&') 43 | { 44 | return origin.Split(separator); 45 | } 46 | 47 | public static string[] ToKeyValues(this string origin, char separator = '=') 48 | { 49 | return origin.Split(separator); 50 | } 51 | 52 | public static string GetUriOriginName(this string originUri) 53 | { 54 | if (string.IsNullOrEmpty(originUri)) 55 | { 56 | return "直接访问"; 57 | } 58 | 59 | if (originUri.Contains("m.baidu.com")) 60 | { 61 | return "百度移动搜索"; 62 | } 63 | 64 | if (originUri.Contains("cpro.baidu.com")) 65 | { 66 | return "百度推广"; 67 | } 68 | 69 | if (originUri.Contains("pos.baidu.com")) 70 | { 71 | return "百度联盟"; 72 | } 73 | 74 | if (originUri.Contains("baidu.com")) 75 | { 76 | return "百度搜索"; 77 | } 78 | 79 | if (originUri.Contains("sogou.com")) 80 | { 81 | return "搜狗"; 82 | } 83 | 84 | if (originUri.Contains("so.com") || originUri.Contains("so.360.cn")) 85 | { 86 | return "360"; 87 | } 88 | return originUri; 89 | } 90 | } 91 | } -------------------------------------------------------------------------------- /QuickBootstrap/Extendsions/DateTimeExtendsions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace WY.Extendsions 4 | { 5 | public static class DateTimeExtendsions 6 | { 7 | public static int ToUnixTimeStamp(this DateTime dateTime) 8 | { 9 | var startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1, 0, 0, 0, 0)); 10 | return (int)(dateTime - startTime).TotalSeconds; 11 | } 12 | 13 | public static DateTime ToDateTime(this long unixTimeStamp, int millisecond = 0) 14 | { 15 | var dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1, 0, 0, 0, millisecond)); 16 | var toNow = new TimeSpan(unixTimeStamp); 17 | return dtStart.Add(toNow); 18 | } 19 | 20 | public static DateTime ToDateTime(this string unixTimeStamp, int millisecond = 0) 21 | { 22 | return ToDateTime(long.Parse(unixTimeStamp + "0000000"), millisecond); 23 | } 24 | 25 | /// 26 | /// 一年中第几季度 27 | /// 28 | /// 29 | /// 30 | public static int ToSeason(this DateTime dateTime) 31 | { 32 | if (dateTime.Month >= 1 && dateTime.Month <= 3) 33 | { 34 | return 1; 35 | } 36 | 37 | if (dateTime.Month >= 4 && dateTime.Month <= 6) 38 | { 39 | return 2; 40 | } 41 | 42 | if (dateTime.Month >= 7 && dateTime.Month <= 9) 43 | { 44 | return 3; 45 | } 46 | 47 | if (dateTime.Month >= 10 && dateTime.Month <= 12) 48 | { 49 | return 4; 50 | } 51 | 52 | return 0; 53 | } 54 | 55 | /// 56 | /// 一年中第几周 57 | /// 58 | /// 59 | /// 60 | public static int ToWeek(this DateTime dateTime) 61 | { 62 | if (dateTime.DayOfYear % 7 == 0) 63 | { 64 | return dateTime.DayOfYear / 7; 65 | } 66 | 67 | return (dateTime.DayOfYear / 7) + 1; 68 | } 69 | 70 | /// 71 | /// 一小时内第几刻钟 72 | /// 73 | /// 74 | /// 75 | public static int ToQuarterHour(this DateTime dateTime) 76 | { 77 | if (dateTime.Minute >= 0 && dateTime.Minute < 15) 78 | { 79 | return 1; 80 | } 81 | 82 | if (dateTime.Minute >= 15 && dateTime.Minute < 30) 83 | { 84 | return 2; 85 | } 86 | 87 | 88 | if (dateTime.Minute >= 30 && dateTime.Minute < 45) 89 | { 90 | return 3; 91 | } 92 | 93 | if (dateTime.Minute >= 45 && dateTime.Minute < 59) 94 | { 95 | return 4; 96 | } 97 | 98 | return 0; 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /QuickBootstrap/Views/UserManage/Create.cshtml: -------------------------------------------------------------------------------- 1 | @model QuickBootstrap.Models.UserCreateRequest 2 | @{ 3 | ViewBag.Title = "添加用户"; 4 | } 5 | 6 |
7 | 8 |
9 | @Html.Partial("Shared/_QuickMenu") 10 |
11 | 12 |
13 | 14 | 19 | 20 |
21 | 22 | @using (Html.BeginForm("Create", "UserManage", FormMethod.Post, new { @class = "form-horizontal" })) 23 | { 24 |
25 | @Html.LabelFor(model => model.UserName, new { @class = "col-md-2 control-label" }) 26 |
27 | @Html.TextBoxFor(model => model.UserName, new { @class = "form-control", style = "width: 280px", placeholder = "邮箱地址" }) 28 | @Html.ValidationMessageFor(model => model.UserName) 29 |
30 |
31 | 32 |
33 | @Html.LabelFor(model => model.Nick, new { @class = "col-md-2 control-label" }) 34 |
35 | @Html.TextBoxFor(model => model.Nick, new { @class = "form-control", style = "width: 280px", placeholder = "账号昵称" }) 36 | @Html.ValidationMessageFor(model => model.Nick) 37 |
38 |
39 | 40 |
41 | @Html.LabelFor(model => model.Password, new { @class = "col-md-2 control-label" }) 42 |
43 | @Html.PasswordFor(model => model.Password, new { @class = "form-control", style = "width: 280px", placeholder = "账号密码" }) 44 | @Html.ValidationMessageFor(model => model.Password) 45 |
46 |
47 | 48 |
49 | @Html.LabelFor(model => model.IsEnable, new { @class = "col-md-2 control-label" }) 50 |
51 | @Html.CheckBoxFor(model => model.IsEnable, new { @class = "form-control", style = "width: 280px" }) 52 | @Html.ValidationMessageFor(model => model.IsEnable) 53 | 注:选中"启用",不选中"禁止登陆"。 54 |
55 |
56 | 57 |
58 |
59 | @Html.ValidationSummary(false) 60 |
61 |
62 | 63 |
64 |
65 | 66 | 取消 67 |
68 |
69 | } 70 | 71 |
72 |
73 |
74 | -------------------------------------------------------------------------------- /QuickBootstrap/Scripts/respond.min.js: -------------------------------------------------------------------------------- 1 | /*! Respond.js v1.4.2: min/max-width media query polyfill * Copyright 2013 Scott Jehl 2 | * Licensed under https://github.com/scottjehl/Respond/blob/master/LICENSE-MIT 3 | * */ 4 | 5 | !function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='­',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){u(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))};if(c.ajax=f,c.queue=d,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\([\s]*min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/,maxw:/\([\s]*max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var g,h,i,j=a.document,k=j.documentElement,l=[],m=[],n=[],o={},p=30,q=j.getElementsByTagName("head")[0]||k,r=j.getElementsByTagName("base")[0],s=q.getElementsByTagName("link"),t=function(){var a,b=j.createElement("div"),c=j.body,d=k.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=j.createElement("body"),c.style.background="none"),k.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&k.insertBefore(c,k.firstChild),a=b.offsetWidth,f?k.removeChild(c):c.removeChild(b),k.style.fontSize=d,e&&(c.style.fontSize=e),a=i=parseFloat(a)},u=function(b){var c="clientWidth",d=k[c],e="CSS1Compat"===j.compatMode&&d||j.body[c]||d,f={},o=s[s.length-1],r=(new Date).getTime();if(b&&g&&p>r-g)return a.clearTimeout(h),h=a.setTimeout(u,p),void 0;g=r;for(var v in l)if(l.hasOwnProperty(v)){var w=l[v],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?i||t():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?i||t():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(m[w.rules]))}for(var C in n)n.hasOwnProperty(C)&&n[C]&&n[C].parentNode===q&&q.removeChild(n[C]);n.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=j.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,q.insertBefore(E,o.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(j.createTextNode(F)),n.push(E)}},v=function(a,b,d){var e=a.replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var g=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},h=!f&&d;b.length&&(b+="/"),h&&(f=1);for(var i=0;f>i;i++){var j,k,n,o;h?(j=d,m.push(g(a))):(j=e[i].match(c.regex.findStyles)&&RegExp.$1,m.push(RegExp.$2&&g(RegExp.$2))),n=j.split(","),o=n.length;for(var p=0;o>p;p++)k=n[p],l.push({media:k.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:m.length-1,hasquery:k.indexOf("(")>-1,minw:k.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:k.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}u()},w=function(){if(d.length){var b=d.shift();f(b.href,function(c){v(c,b.href,b.media),o[b.href]=!0,a.setTimeout(function(){w()},0)})}},x=function(){for(var b=0;b 2 | @{ 3 | ViewBag.Title = "用户管理"; 4 | } 5 | 6 |
7 | 8 |
9 | @Html.Partial("Shared/_QuickMenu") 10 |
11 | 12 |
13 | 14 | 21 | 22 |
23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |
开始时间:结束时间:
用户账号:用户角色:
38 |
39 | 40 |
41 |
42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 |
50 |
51 | 52 |
53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | @for (var i = 0; i < Model.Result.Count; i++) 67 | { 68 | 69 | 70 | 71 | 72 | 73 | 74 | 86 | 87 | } 88 | 89 |
序号邮箱地址真实姓名账号状态创建时间操作
@(i + 1)@Model.Result[i].UserName @Model.Result[i].Nick @Html.Raw(Model.Result[i].IsEnable ? "正常" : "禁用")@Model.Result[i].CreateTime 75 |
76 | 77 | 81 | 84 |
85 |
90 | 91 | @Html.Partial("_PartialPagingInfo") 92 | 93 |
94 |
95 | -------------------------------------------------------------------------------- /QuickBootstrap/Scripts/jquery.validate.unobtrusive.min.js: -------------------------------------------------------------------------------- 1 | /* NUGET: BEGIN LICENSE TEXT 2 | * 3 | * Microsoft grants you the right to use these script files for the sole 4 | * purpose of either: (i) interacting through your browser with the Microsoft 5 | * website or online service, subject to the applicable licensing or use 6 | * terms; or (ii) using the files as included with a Microsoft product subject 7 | * to that product's license terms. Microsoft reserves all other rights to the 8 | * files not expressly granted by Microsoft, whether by implication, estoppel 9 | * or otherwise. Insofar as a script file is dual licensed under GPL, 10 | * Microsoft neither took the code under GPL nor distributes it thereunder but 11 | * under the terms set out in this paragraph. All notices and licenses 12 | * below are for informational purposes only. 13 | * 14 | * NUGET: END LICENSE TEXT */ 15 | /* 16 | ** Unobtrusive validation support library for jQuery and jQuery Validate 17 | ** Copyright (C) Microsoft Corporation. All rights reserved. 18 | */ 19 | (function(a){var d=a.validator,b,e="unobtrusiveValidation";function c(a,b,c){a.rules[b]=c;if(a.message)a.messages[b]=a.message}function j(a){return a.replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g)}function f(a){return a.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g,"\\$1")}function h(a){return a.substr(0,a.lastIndexOf(".")+1)}function g(a,b){if(a.indexOf("*.")===0)a=a.replace("*.",b);return a}function m(c,e){var b=a(this).find("[data-valmsg-for='"+f(e[0].name)+"']"),d=b.attr("data-valmsg-replace"),g=d?a.parseJSON(d)!==false:null;b.removeClass("field-validation-valid").addClass("field-validation-error");c.data("unobtrusiveContainer",b);if(g){b.empty();c.removeClass("input-validation-error").appendTo(b)}else c.hide()}function l(e,d){var c=a(this).find("[data-valmsg-summary=true]"),b=c.find("ul");if(b&&b.length&&d.errorList.length){b.empty();c.addClass("validation-summary-errors").removeClass("validation-summary-valid");a.each(d.errorList,function(){a("
  • ").html(this.message).appendTo(b)})}}function k(d){var b=d.data("unobtrusiveContainer"),c=b.attr("data-valmsg-replace"),e=c?a.parseJSON(c):null;if(b){b.addClass("field-validation-valid").removeClass("field-validation-error");d.removeData("unobtrusiveContainer");e&&b.empty()}}function n(){var b=a(this);b.data("validator").resetForm();b.find(".validation-summary-errors").addClass("validation-summary-valid").removeClass("validation-summary-errors");b.find(".field-validation-error").addClass("field-validation-valid").removeClass("field-validation-error").removeData("unobtrusiveContainer").find(">*").removeData("unobtrusiveContainer")}function i(b){var c=a(b),f=c.data(e),i=a.proxy(n,b),g=d.unobtrusive.options||{},h=function(e,d){var c=g[e];c&&a.isFunction(c)&&c.apply(b,d)};if(!f){f={options:{errorClass:g.errorClass||"input-validation-error",errorElement:g.errorElement||"span",errorPlacement:function(){m.apply(b,arguments);h("errorPlacement",arguments)},invalidHandler:function(){l.apply(b,arguments);h("invalidHandler",arguments)},messages:{},rules:{},success:function(){k.apply(b,arguments);h("success",arguments)}},attachValidation:function(){c.off("reset."+e,i).on("reset."+e,i).validate(this.options)},validate:function(){c.validate();return c.valid()}};c.data(e,f)}return f}d.unobtrusive={adapters:[],parseElement:function(b,h){var d=a(b),f=d.parents("form")[0],c,e,g;if(!f)return;c=i(f);c.options.rules[b.name]=e={};c.options.messages[b.name]=g={};a.each(this.adapters,function(){var c="data-val-"+this.name,i=d.attr(c),h={};if(i!==undefined){c+="-";a.each(this.params,function(){h[this]=d.attr(c+this)});this.adapt({element:b,form:f,message:i,params:h,rules:e,messages:g})}});a.extend(e,{__dummy__:true});!h&&c.attachValidation()},parse:function(c){var b=a(c),e=b.parents().addBack().filter("form").add(b.find("form")).has("[data-val=true]");b.find("[data-val=true]").each(function(){d.unobtrusive.parseElement(this,true)});e.each(function(){var a=i(this);a&&a.attachValidation()})}};b=d.unobtrusive.adapters;b.add=function(c,a,b){if(!b){b=a;a=[]}this.push({name:c,params:a,adapt:b});return this};b.addBool=function(a,b){return this.add(a,function(d){c(d,b||a,true)})};b.addMinMax=function(e,g,f,a,d,b){return this.add(e,[d||"min",b||"max"],function(b){var e=b.params.min,d=b.params.max;if(e&&d)c(b,a,[e,d]);else if(e)c(b,g,e);else d&&c(b,f,d)})};b.addSingleVal=function(a,b,d){return this.add(a,[b||"val"],function(e){c(e,d||a,e.params[b])})};d.addMethod("__dummy__",function(){return true});d.addMethod("regex",function(b,c,d){var a;if(this.optional(c))return true;a=(new RegExp(d)).exec(b);return a&&a.index===0&&a[0].length===b.length});d.addMethod("nonalphamin",function(c,d,b){var a;if(b){a=c.match(/\W/g);a=a&&a.length>=b}return a});if(d.methods.extension){b.addSingleVal("accept","mimtype");b.addSingleVal("extension","extension")}else b.addSingleVal("extension","extension","accept");b.addSingleVal("regex","pattern");b.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url");b.addMinMax("length","minlength","maxlength","rangelength").addMinMax("range","min","max","range");b.addMinMax("minlength","minlength").addMinMax("maxlength","minlength","maxlength");b.add("equalto",["other"],function(b){var i=h(b.element.name),j=b.params.other,d=g(j,i),e=a(b.form).find(":input").filter("[name='"+f(d)+"']")[0];c(b,"equalTo",e)});b.add("required",function(a){(a.element.tagName.toUpperCase()!=="INPUT"||a.element.type.toUpperCase()!=="CHECKBOX")&&c(a,"required",true)});b.add("remote",["url","type","additionalfields"],function(b){var d={url:b.params.url,type:b.params.type||"GET",data:{}},e=h(b.element.name);a.each(j(b.params.additionalfields||b.element.name),function(i,h){var c=g(h,e);d.data[c]=function(){return a(b.form).find(":input").filter("[name='"+f(c)+"']").val()}});c(b,"remote",d)});b.add("password",["min","nonalphamin","regex"],function(a){a.params.min&&c(a,"minlength",a.params.min);a.params.nonalphamin&&c(a,"nonalphamin",a.params.nonalphamin);a.params.regex&&c(a,"regex",a.params.regex)});a(function(){d.unobtrusive.parse(document)})})(jQuery); -------------------------------------------------------------------------------- /QuickBootstrap/Extendsions/PagingExtendsions.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using System.Web.Mvc; 3 | 4 | namespace QuickBootstrap.Extendsions 5 | { 6 | public static class PagingExtendsions 7 | { 8 | /// 9 | /// 分页工具栏 10 | /// 11 | /// 12 | /// 当前页码 13 | /// 分页大小 14 | /// 记录总数 15 | /// 起始页码:默认1 16 | /// 每页页码个数:默认10 17 | /// queryString查询参数 18 | /// 19 | public static MvcHtmlString Paging(this HtmlHelper htmlHelper, int pageIndex = 0, int pageSize = 10, int sizeCount = 0, int startPageNum = 1, int pageOfNumber = 10, string queryString = "") 20 | { 21 | //第一页,上一页 ... 5,6,7,8,9 ... 下一页,最后一页,转到{0}页,确定 22 | 23 | //计算出总页数 24 | var pageCount = sizeCount % pageSize == 0 ? sizeCount / pageSize : sizeCount / pageSize + 1; 25 | 26 | //如果只有一页不需要分页 27 | if (pageCount == 1) return new MvcHtmlString(""); 28 | 29 | var pagedHtmlString = new StringBuilder(); 30 | pagedHtmlString.Append("
      "); 31 | 32 | //第一页 33 | if (pageIndex > startPageNum) 34 | { 35 | pagedHtmlString.AppendFormat("
    • 第一页
    • ", 36 | startPageNum, 37 | pageSize, 38 | queryString); 39 | } 40 | else 41 | { 42 | pagedHtmlString.Append("
    • 第一页
    • "); 43 | } 44 | 45 | 46 | //上一页 47 | if (pageIndex - 1 >= startPageNum && pageIndex - 1 <= pageCount) 48 | { 49 | pagedHtmlString.AppendFormat("
    • 上一页
    • ", 50 | pageIndex - 1, 51 | pageSize, 52 | queryString); 53 | } 54 | else 55 | { 56 | pagedHtmlString.Append("
    • 上一页
    • "); 57 | } 58 | 59 | //当前页 60 | var pageItem = pageOfNumber - 1 >= startPageNum ? pageOfNumber - 1 : startPageNum; 61 | var pageStartIndex = pageIndex - pageItem / 2 >= startPageNum ? pageIndex - pageItem / 2 : startPageNum; 62 | var pageEndIndex = pageIndex + pageItem / 2 <= pageCount ? pageIndex + pageItem / 2 : pageCount; 63 | 64 | //尽量平均分配分页按钮的数量 65 | var offset = pageItem - (pageEndIndex - pageStartIndex); 66 | if (offset > 0) 67 | { 68 | var leftPatch = pageStartIndex - offset > startPageNum; 69 | if (leftPatch) 70 | { 71 | //向前扩展 72 | pageStartIndex = pageStartIndex - offset; 73 | } 74 | else 75 | { 76 | //向后扩展 77 | pageEndIndex = pageEndIndex + offset < pageCount ? pageEndIndex + offset : pageEndIndex; 78 | } 79 | } 80 | 81 | for (var i = pageStartIndex; i < pageEndIndex; i++) 82 | { 83 | if (i == pageIndex) 84 | { 85 | pagedHtmlString.AppendFormat("
    • {0}(current)
    • ", 86 | pageIndex + 1); 87 | } 88 | else 89 | { 90 | pagedHtmlString.AppendFormat("
    • {4}
    • ", 91 | i, 92 | pageSize, 93 | queryString, 94 | i, 95 | i + 1); 96 | } 97 | } 98 | 99 | //下一页 100 | if (pageIndex + 1 >= startPageNum && pageIndex + 1 < pageCount) 101 | { 102 | pagedHtmlString.AppendFormat("
    • 下一页
    • ", 103 | pageIndex + 1, 104 | pageSize, 105 | queryString); 106 | } 107 | else 108 | { 109 | pagedHtmlString.Append("
    • 下一页
    • "); 110 | } 111 | 112 | //最后一页 113 | if (pageCount > pageIndex + 1) 114 | { 115 | pagedHtmlString.AppendFormat("
    • 最后一页
    • ", 116 | pageCount - 1, 117 | pageSize, 118 | queryString); 119 | } 120 | else 121 | { 122 | pagedHtmlString.Append("
    • 最后一页
    • "); 123 | } 124 | 125 | 126 | pagedHtmlString.Append("
    "); 127 | 128 | return new MvcHtmlString(pagedHtmlString.ToString()); 129 | } 130 | 131 | /// 132 | /// 分页工具栏 133 | /// 134 | /// 135 | /// 当前页码 136 | /// 分页大小 137 | /// 记录总数 138 | /// queryString查询参数 139 | /// 140 | public static MvcHtmlString Paging(this HtmlHelper htmlHelper, int pageIndex = 0, int pageSize = 10, int sizeCount = 0, string queryString = "") 141 | { 142 | return Paging(htmlHelper, pageIndex, pageSize, sizeCount, 0, 10, queryString); 143 | } 144 | } 145 | } -------------------------------------------------------------------------------- /.nuget/NuGet.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildProjectDirectory)\..\ 5 | 6 | 7 | false 8 | 9 | 10 | false 11 | 12 | 13 | true 14 | 15 | 16 | false 17 | 18 | 19 | 20 | 21 | 22 | 26 | 27 | 28 | 29 | 30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) 31 | 32 | 33 | 34 | 35 | $(SolutionDir).nuget 36 | 37 | 38 | 39 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config 40 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config 41 | 42 | 43 | 44 | $(MSBuildProjectDirectory)\packages.config 45 | $(PackagesProjectConfig) 46 | 47 | 48 | 49 | 50 | $(NuGetToolsPath)\NuGet.exe 51 | @(PackageSource) 52 | 53 | "$(NuGetExePath)" 54 | mono --runtime=v4.0.30319 "$(NuGetExePath)" 55 | 56 | $(TargetDir.Trim('\\')) 57 | 58 | -RequireConsent 59 | -NonInteractive 60 | 61 | "$(SolutionDir) " 62 | "$(SolutionDir)" 63 | 64 | 65 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir) 66 | $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols 67 | 68 | 69 | 70 | RestorePackages; 71 | $(BuildDependsOn); 72 | 73 | 74 | 75 | 76 | $(BuildDependsOn); 77 | BuildPackage; 78 | 79 | 80 | 81 | 82 | 83 | 84 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 99 | 100 | 103 | 104 | 105 | 106 | 108 | 109 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 141 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /QuickBootstrap/Scripts/respond.js: -------------------------------------------------------------------------------- 1 | /*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */ 2 | /*! NOTE: If you're already including a window.matchMedia polyfill via Modernizr or otherwise, you don't need this part */ 3 | (function(w) { 4 | "use strict"; 5 | w.matchMedia = w.matchMedia || function(doc, undefined) { 6 | var bool, docElem = doc.documentElement, refNode = docElem.firstElementChild || docElem.firstChild, fakeBody = doc.createElement("body"), div = doc.createElement("div"); 7 | div.id = "mq-test-1"; 8 | div.style.cssText = "position:absolute;top:-100em"; 9 | fakeBody.style.background = "none"; 10 | fakeBody.appendChild(div); 11 | return function(q) { 12 | div.innerHTML = '­'; 13 | docElem.insertBefore(fakeBody, refNode); 14 | bool = div.offsetWidth === 42; 15 | docElem.removeChild(fakeBody); 16 | return { 17 | matches: bool, 18 | media: q 19 | }; 20 | }; 21 | }(w.document); 22 | })(this); 23 | 24 | /*! Respond.js v1.4.0: min/max-width media query polyfill. (c) Scott Jehl. MIT Lic. j.mp/respondjs */ 25 | (function(w) { 26 | "use strict"; 27 | var respond = {}; 28 | w.respond = respond; 29 | respond.update = function() {}; 30 | var requestQueue = [], xmlHttp = function() { 31 | var xmlhttpmethod = false; 32 | try { 33 | xmlhttpmethod = new w.XMLHttpRequest(); 34 | } catch (e) { 35 | xmlhttpmethod = new w.ActiveXObject("Microsoft.XMLHTTP"); 36 | } 37 | return function() { 38 | return xmlhttpmethod; 39 | }; 40 | }(), ajax = function(url, callback) { 41 | var req = xmlHttp(); 42 | if (!req) { 43 | return; 44 | } 45 | req.open("GET", url, true); 46 | req.onreadystatechange = function() { 47 | if (req.readyState !== 4 || req.status !== 200 && req.status !== 304) { 48 | return; 49 | } 50 | callback(req.responseText); 51 | }; 52 | if (req.readyState === 4) { 53 | return; 54 | } 55 | req.send(null); 56 | }; 57 | respond.ajax = ajax; 58 | respond.queue = requestQueue; 59 | respond.regex = { 60 | media: /@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi, 61 | keyframes: /@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi, 62 | urls: /(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g, 63 | findStyles: /@media *([^\{]+)\{([\S\s]+?)$/, 64 | only: /(only\s+)?([a-zA-Z]+)\s?/, 65 | minw: /\([\s]*min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/, 66 | maxw: /\([\s]*max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/ 67 | }; 68 | respond.mediaQueriesSupported = w.matchMedia && w.matchMedia("only all") !== null && w.matchMedia("only all").matches; 69 | if (respond.mediaQueriesSupported) { 70 | return; 71 | } 72 | var doc = w.document, docElem = doc.documentElement, mediastyles = [], rules = [], appendedEls = [], parsedSheets = {}, resizeThrottle = 30, head = doc.getElementsByTagName("head")[0] || docElem, base = doc.getElementsByTagName("base")[0], links = head.getElementsByTagName("link"), lastCall, resizeDefer, eminpx, getEmValue = function() { 73 | var ret, div = doc.createElement("div"), body = doc.body, originalHTMLFontSize = docElem.style.fontSize, originalBodyFontSize = body && body.style.fontSize, fakeUsed = false; 74 | div.style.cssText = "position:absolute;font-size:1em;width:1em"; 75 | if (!body) { 76 | body = fakeUsed = doc.createElement("body"); 77 | body.style.background = "none"; 78 | } 79 | docElem.style.fontSize = "100%"; 80 | body.style.fontSize = "100%"; 81 | body.appendChild(div); 82 | if (fakeUsed) { 83 | docElem.insertBefore(body, docElem.firstChild); 84 | } 85 | ret = div.offsetWidth; 86 | if (fakeUsed) { 87 | docElem.removeChild(body); 88 | } else { 89 | body.removeChild(div); 90 | } 91 | docElem.style.fontSize = originalHTMLFontSize; 92 | if (originalBodyFontSize) { 93 | body.style.fontSize = originalBodyFontSize; 94 | } 95 | ret = eminpx = parseFloat(ret); 96 | return ret; 97 | }, applyMedia = function(fromResize) { 98 | var name = "clientWidth", docElemProp = docElem[name], currWidth = doc.compatMode === "CSS1Compat" && docElemProp || doc.body[name] || docElemProp, styleBlocks = {}, lastLink = links[links.length - 1], now = new Date().getTime(); 99 | if (fromResize && lastCall && now - lastCall < resizeThrottle) { 100 | w.clearTimeout(resizeDefer); 101 | resizeDefer = w.setTimeout(applyMedia, resizeThrottle); 102 | return; 103 | } else { 104 | lastCall = now; 105 | } 106 | for (var i in mediastyles) { 107 | if (mediastyles.hasOwnProperty(i)) { 108 | var thisstyle = mediastyles[i], min = thisstyle.minw, max = thisstyle.maxw, minnull = min === null, maxnull = max === null, em = "em"; 109 | if (!!min) { 110 | min = parseFloat(min) * (min.indexOf(em) > -1 ? eminpx || getEmValue() : 1); 111 | } 112 | if (!!max) { 113 | max = parseFloat(max) * (max.indexOf(em) > -1 ? eminpx || getEmValue() : 1); 114 | } 115 | if (!thisstyle.hasquery || (!minnull || !maxnull) && (minnull || currWidth >= min) && (maxnull || currWidth <= max)) { 116 | if (!styleBlocks[thisstyle.media]) { 117 | styleBlocks[thisstyle.media] = []; 118 | } 119 | styleBlocks[thisstyle.media].push(rules[thisstyle.rules]); 120 | } 121 | } 122 | } 123 | for (var j in appendedEls) { 124 | if (appendedEls.hasOwnProperty(j)) { 125 | if (appendedEls[j] && appendedEls[j].parentNode === head) { 126 | head.removeChild(appendedEls[j]); 127 | } 128 | } 129 | } 130 | appendedEls.length = 0; 131 | for (var k in styleBlocks) { 132 | if (styleBlocks.hasOwnProperty(k)) { 133 | var ss = doc.createElement("style"), css = styleBlocks[k].join("\n"); 134 | ss.type = "text/css"; 135 | ss.media = k; 136 | head.insertBefore(ss, lastLink.nextSibling); 137 | if (ss.styleSheet) { 138 | ss.styleSheet.cssText = css; 139 | } else { 140 | ss.appendChild(doc.createTextNode(css)); 141 | } 142 | appendedEls.push(ss); 143 | } 144 | } 145 | }, translate = function(styles, href, media) { 146 | var qs = styles.replace(respond.regex.keyframes, "").match(respond.regex.media), ql = qs && qs.length || 0; 147 | href = href.substring(0, href.lastIndexOf("/")); 148 | var repUrls = function(css) { 149 | return css.replace(respond.regex.urls, "$1" + href + "$2$3"); 150 | }, useMedia = !ql && media; 151 | if (href.length) { 152 | href += "/"; 153 | } 154 | if (useMedia) { 155 | ql = 1; 156 | } 157 | for (var i = 0; i < ql; i++) { 158 | var fullq, thisq, eachq, eql; 159 | if (useMedia) { 160 | fullq = media; 161 | rules.push(repUrls(styles)); 162 | } else { 163 | fullq = qs[i].match(respond.regex.findStyles) && RegExp.$1; 164 | rules.push(RegExp.$2 && repUrls(RegExp.$2)); 165 | } 166 | eachq = fullq.split(","); 167 | eql = eachq.length; 168 | for (var j = 0; j < eql; j++) { 169 | thisq = eachq[j]; 170 | mediastyles.push({ 171 | media: thisq.split("(")[0].match(respond.regex.only) && RegExp.$2 || "all", 172 | rules: rules.length - 1, 173 | hasquery: thisq.indexOf("(") > -1, 174 | minw: thisq.match(respond.regex.minw) && parseFloat(RegExp.$1) + (RegExp.$2 || ""), 175 | maxw: thisq.match(respond.regex.maxw) && parseFloat(RegExp.$1) + (RegExp.$2 || "") 176 | }); 177 | } 178 | } 179 | applyMedia(); 180 | }, makeRequests = function() { 181 | if (requestQueue.length) { 182 | var thisRequest = requestQueue.shift(); 183 | ajax(thisRequest.href, function(styles) { 184 | translate(styles, thisRequest.href, thisRequest.media); 185 | parsedSheets[thisRequest.href] = true; 186 | w.setTimeout(function() { 187 | makeRequests(); 188 | }, 0); 189 | }); 190 | } 191 | }, ripCSS = function() { 192 | for (var i = 0; i < links.length; i++) { 193 | var sheet = links[i], href = sheet.href, media = sheet.media, isCSS = sheet.rel && sheet.rel.toLowerCase() === "stylesheet"; 194 | if (!!href && isCSS && !parsedSheets[href]) { 195 | if (sheet.styleSheet && sheet.styleSheet.rawCssText) { 196 | translate(sheet.styleSheet.rawCssText, href, media); 197 | parsedSheets[href] = true; 198 | } else { 199 | if (!/^([a-zA-Z:]*\/\/)/.test(href) && !base || href.replace(RegExp.$1, "").split("/")[0] === w.location.host) { 200 | if (href.substring(0, 2) === "//") { 201 | href = w.location.protocol + href; 202 | } 203 | requestQueue.push({ 204 | href: href, 205 | media: media 206 | }); 207 | } 208 | } 209 | } 210 | } 211 | makeRequests(); 212 | }; 213 | ripCSS(); 214 | respond.update = ripCSS; 215 | respond.getEmValue = getEmValue; 216 | function callMedia() { 217 | applyMedia(true); 218 | } 219 | if (w.addEventListener) { 220 | w.addEventListener("resize", callMedia, false); 221 | } else if (w.attachEvent) { 222 | w.attachEvent("onresize", callMedia); 223 | } 224 | })(this); -------------------------------------------------------------------------------- /QuickBootstrap/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
    8 | 9 |
    10 | 11 | 12 |
    13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | -------------------------------------------------------------------------------- /QuickBootstrap/Services/Util/ValidateCodeHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Web; 4 | 5 | namespace QuickBootstrap.Services.Util 6 | { 7 | public sealed class ValidateCodeHelper 8 | { 9 | #region 验证码长度(默认5个验证码的长度) 10 | int length = 5; 11 | /// 12 | /// 验证码长度(默认5个验证码的长度) 13 | /// 14 | public int Length 15 | { 16 | get 17 | { 18 | return length; 19 | } 20 | set 21 | { 22 | length = value; 23 | } 24 | } 25 | #endregion 26 | 27 | #region 验证码字体大小(默认10像素) 28 | int fontSize = 10; 29 | /// 30 | /// 验证码字体大小(默认10像素) 31 | /// 32 | public int FontSize 33 | { 34 | get 35 | { 36 | return fontSize; 37 | } 38 | set 39 | { 40 | fontSize = value; 41 | } 42 | } 43 | #endregion 44 | 45 | #region 边框补(默认1像素) 46 | int padding = 1; 47 | /// 48 | /// 边框补边距(默认1像素) 49 | /// 50 | public int Padding 51 | { 52 | get 53 | { 54 | return padding; 55 | } 56 | set 57 | { 58 | padding = value; 59 | } 60 | } 61 | #endregion 62 | 63 | #region 是否输出燥点(默认不输出) 64 | bool chaos = false; 65 | /// 66 | /// 是否输出燥点(默认不输出) 67 | /// 68 | public bool Chaos 69 | { 70 | get 71 | { 72 | return chaos; 73 | } 74 | set 75 | { 76 | chaos = value; 77 | } 78 | } 79 | #endregion 80 | 81 | #region 输出燥点的颜色(默认灰色) 82 | Color chaosColor = Color.LightGray; 83 | /// 84 | /// 输出燥点的颜色(默认灰色) 85 | /// 86 | public Color ChaosColor 87 | { 88 | get 89 | { 90 | return chaosColor; 91 | } 92 | set 93 | { 94 | chaosColor = value; 95 | } 96 | } 97 | #endregion 98 | 99 | #region 自定义背景色(默认白色) 100 | Color backgroundColor = Color.White; 101 | /// 102 | /// 自定义背景色(默认白色) 103 | /// 104 | public Color BackgroundColor 105 | { 106 | get 107 | { 108 | return backgroundColor; 109 | } 110 | set 111 | { 112 | backgroundColor = value; 113 | } 114 | } 115 | #endregion 116 | 117 | #region 自定义随机颜色数组 118 | Color[] colors = { Color.Black, Color.Red, Color.DarkBlue, Color.Green, Color.Orange, Color.Brown, Color.DarkCyan, Color.Purple }; 119 | /// 120 | /// 自定义随机颜色数组 121 | /// 122 | public Color[] Colors 123 | { 124 | get 125 | { 126 | return colors; 127 | } 128 | set 129 | { 130 | colors = value; 131 | } 132 | } 133 | #endregion 134 | 135 | #region 自定义字体数组 136 | //string[] fonts = { "Arial", "Georgia" }; 137 | string[] fonts = { "Arial", "Verdana", "Comic Sans MS", "Impact", "Haettenschweiler", "Lucida Sans Unicode", "Garamond", "Courier New", "Book Antiqua", "Arial Narrow" }; 138 | /// 139 | /// 自定义字体数组 140 | /// 141 | public string[] Fonts 142 | { 143 | get 144 | { 145 | return fonts; 146 | } 147 | set 148 | { 149 | fonts = value; 150 | } 151 | } 152 | #endregion 153 | 154 | #region 自定义随机码字符串序列(使用逗号分隔) 155 | string codeSerial = "1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,P,Q,R,S,T,U,V,W,X,Y,Z"; 156 | /// 157 | /// 自定义随机码字符串序列(使用逗号分隔) 158 | /// 159 | public string CodeSerial 160 | { 161 | get 162 | { 163 | return codeSerial; 164 | } 165 | set 166 | { 167 | codeSerial = value; 168 | } 169 | } 170 | #endregion 171 | 172 | #region 是否画边框(默认画) 173 | bool border = true; 174 | /// 175 | /// 是否画边框 176 | /// 177 | public bool Border 178 | { 179 | get 180 | { 181 | return border; 182 | } 183 | set 184 | { 185 | border = value; 186 | } 187 | } 188 | #endregion 189 | 190 | #region 边框颜色 默认Color.Gainsboro 191 | Color borderColor = Color.Gainsboro; 192 | /// 193 | /// 边框颜色 默认Color.Gainsboro 194 | /// 195 | public Color BorderColor 196 | { 197 | get 198 | { 199 | return this.borderColor; 200 | } 201 | set 202 | { 203 | this.borderColor = value; 204 | } 205 | } 206 | #endregion 207 | 208 | #region 边框宽度(默认1像素) 209 | int borderWidth = 1; 210 | /// 211 | /// 边框宽度 212 | /// 213 | public int BorderWidth 214 | { 215 | get 216 | { 217 | return this.borderWidth; 218 | } 219 | set 220 | { 221 | this.borderWidth = value; 222 | } 223 | } 224 | #endregion 225 | 226 | #region 生成校验码图片 227 | /// 228 | /// 生成校验码图片 229 | /// 230 | /// 代码 231 | /// 232 | public Bitmap CreateImageCode(string code) 233 | { 234 | int fSize = FontSize; 235 | int fWidth = fSize + Padding; 236 | 237 | int imageWidth = (int)(code.Length * fWidth) + 4 + Padding * 2; 238 | int imageHeight = fSize * 2 + Padding; 239 | 240 | System.Drawing.Bitmap image = new System.Drawing.Bitmap(imageWidth, imageHeight); 241 | 242 | Graphics g = Graphics.FromImage(image); 243 | 244 | g.Clear(BackgroundColor); 245 | 246 | Random rand = new Random(); 247 | 248 | //给背景添加随机生成的燥点 249 | if (this.Chaos) 250 | { 251 | 252 | Pen pen = new Pen(ChaosColor, 0); 253 | int c = Length * 10; 254 | 255 | for (int i = 0; i < c; i++) 256 | { 257 | int x = rand.Next(image.Width); 258 | int y = rand.Next(image.Height); 259 | 260 | g.DrawRectangle(pen, x, y, 1, 1); 261 | } 262 | } 263 | 264 | int left = 0, top = 0, top1 = 1, top2 = 1; 265 | 266 | int n1 = (imageHeight - FontSize - Padding * 2); 267 | int n2 = n1 / 4; 268 | top1 = n2; 269 | top2 = n2 * 2; 270 | 271 | Font f; 272 | Brush b; 273 | 274 | int cindex, findex; 275 | 276 | //随机字体和颜色的验证码字符 277 | for (int i = 0; i < code.Length; i++) 278 | { 279 | cindex = rand.Next(Colors.Length - 1); 280 | findex = rand.Next(Fonts.Length - 1); 281 | 282 | f = new System.Drawing.Font(Fonts[findex], fSize, System.Drawing.FontStyle.Bold); 283 | b = new System.Drawing.SolidBrush(Colors[cindex]); 284 | 285 | if (i % 2 == 1) 286 | { 287 | top = top2; 288 | } 289 | else 290 | { 291 | top = top1; 292 | } 293 | 294 | left = i * fWidth; 295 | 296 | g.DrawString(code.Substring(i, 1), f, b, left, top); 297 | } 298 | 299 | #region 画边框 300 | //画一个边框 边框颜色为Color.Gainsboro 301 | //g.DrawRectangle(new Pen(Color.Gainsboro, 0), 0, 0, image.Width - 1, image.Height - 1); 302 | if (Border) 303 | { 304 | g.DrawRectangle(new Pen(BorderColor, BorderWidth), 0, 0, image.Width - 1, image.Height - 1); 305 | } 306 | #endregion; 307 | g.Dispose(); 308 | return image; 309 | } 310 | #endregion 311 | 312 | #region 将创建好的图片输出到页面 313 | /// 314 | /// 将创建好的图片输出到页面 315 | /// 316 | /// 317 | /// 318 | public void CreateImageOnPage(string code, HttpContext context) 319 | { 320 | System.IO.MemoryStream ms = new System.IO.MemoryStream(); 321 | Bitmap image = this.CreateImageCode(code); 322 | 323 | image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); 324 | 325 | context.Response.ClearContent(); 326 | context.Response.ContentType = "image/Jpeg"; 327 | context.Response.BinaryWrite(ms.GetBuffer()); 328 | 329 | ms.Close(); 330 | ms = null; 331 | image.Dispose(); 332 | image = null; 333 | } 334 | #endregion 335 | 336 | #region 生成随机字符码 337 | /// 338 | /// 生成随机字符码 339 | /// 340 | /// 长度 341 | /// 342 | public string CreateVerifyCode(int codeLen) 343 | { 344 | if (codeLen == 0) 345 | { 346 | codeLen = Length; 347 | } 348 | 349 | string[] arr = CodeSerial.Split(','); 350 | 351 | string code = ""; 352 | 353 | int randValue = -1; 354 | 355 | Random rand = new Random(unchecked((int)DateTime.Now.Ticks)); 356 | 357 | for (int i = 0; i < codeLen; i++) 358 | { 359 | randValue = rand.Next(0, arr.Length - 1); 360 | 361 | code += arr[randValue]; 362 | } 363 | 364 | return code; 365 | } 366 | public string CreateVerifyCode() 367 | { 368 | return CreateVerifyCode(0); 369 | } 370 | #endregion 371 | } 372 | } -------------------------------------------------------------------------------- /QuickBootstrap/QuickBootstrap.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 8 | 9 | 2.0 10 | {C1CB7B0B-5E99-4559-88E5-8BC36BAE472E} 11 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 12 | Library 13 | Properties 14 | QuickBootstrap 15 | QuickBootstrap 16 | v4.5 17 | false 18 | true 19 | 20 | 21 | 22 | 23 | ..\ 24 | true 25 | 26 | 27 | true 28 | full 29 | false 30 | bin\ 31 | DEBUG;TRACE 32 | prompt 33 | 4 34 | 35 | 36 | pdbonly 37 | true 38 | bin\ 39 | TRACE 40 | prompt 41 | 4 42 | 43 | 44 | 45 | False 46 | ..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll 47 | 48 | 49 | False 50 | ..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.dll 51 | 52 | 53 | ..\packages\EntityFramework.Extended.6.1.0.121\lib\net45\EntityFramework.Extended.dll 54 | 55 | 56 | False 57 | ..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.SqlServer.dll 58 | 59 | 60 | ..\packages\EnyimMemcached.2.12\lib\net35\Enyim.Caching.dll 61 | 62 | 63 | ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll 64 | 65 | 66 | False 67 | ..\packages\Microsoft.AspNet.Identity.Core.2.1.0\lib\net45\Microsoft.AspNet.Identity.Core.dll 68 | 69 | 70 | False 71 | ..\packages\Microsoft.AspNet.Identity.EntityFramework.2.1.0\lib\net45\Microsoft.AspNet.Identity.EntityFramework.dll 72 | 73 | 74 | 75 | False 76 | ..\packages\Newtonsoft.Json.6.0.5\lib\net45\Newtonsoft.Json.dll 77 | 78 | 79 | ..\packages\StackExchange.Redis.1.0.394\lib\net45\StackExchange.Redis.dll 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | False 92 | ..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.Helpers.dll 93 | 94 | 95 | False 96 | ..\packages\Microsoft.AspNet.Mvc.5.2.2\lib\net45\System.Web.Mvc.dll 97 | 98 | 99 | False 100 | ..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll 101 | 102 | 103 | False 104 | ..\packages\Microsoft.AspNet.Razor.3.2.2\lib\net45\System.Web.Razor.dll 105 | 106 | 107 | False 108 | ..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.dll 109 | 110 | 111 | False 112 | ..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Deployment.dll 113 | 114 | 115 | False 116 | ..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Razor.dll 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | True 129 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 130 | 131 | 132 | 133 | 134 | 135 | 136 | False 137 | ..\packages\WebGrease.1.6.0\lib\WebGrease.dll 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | Global.asax 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | Designer 227 | 228 | 229 | Web.config 230 | 231 | 232 | Web.config 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 10.0 257 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | True 270 | True 271 | 28387 272 | / 273 | http://localhost:28387/ 274 | False 275 | False 276 | 277 | 278 | False 279 | 280 | 281 | 282 | 283 | 284 | 290 | -------------------------------------------------------------------------------- /QuickBootstrap/Scripts/jquery.validate.unobtrusive.js: -------------------------------------------------------------------------------- 1 | /* NUGET: BEGIN LICENSE TEXT 2 | * 3 | * Microsoft grants you the right to use these script files for the sole 4 | * purpose of either: (i) interacting through your browser with the Microsoft 5 | * website or online service, subject to the applicable licensing or use 6 | * terms; or (ii) using the files as included with a Microsoft product subject 7 | * to that product's license terms. Microsoft reserves all other rights to the 8 | * files not expressly granted by Microsoft, whether by implication, estoppel 9 | * or otherwise. Insofar as a script file is dual licensed under GPL, 10 | * Microsoft neither took the code under GPL nor distributes it thereunder but 11 | * under the terms set out in this paragraph. All notices and licenses 12 | * below are for informational purposes only. 13 | * 14 | * NUGET: END LICENSE TEXT */ 15 | /*! 16 | ** Unobtrusive validation support library for jQuery and jQuery Validate 17 | ** Copyright (C) Microsoft Corporation. All rights reserved. 18 | */ 19 | 20 | /*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: false */ 21 | /*global document: false, jQuery: false */ 22 | 23 | (function ($) { 24 | var $jQval = $.validator, 25 | adapters, 26 | data_validation = "unobtrusiveValidation"; 27 | 28 | function setValidationValues(options, ruleName, value) { 29 | options.rules[ruleName] = value; 30 | if (options.message) { 31 | options.messages[ruleName] = options.message; 32 | } 33 | } 34 | 35 | function splitAndTrim(value) { 36 | return value.replace(/^\s+|\s+$/g, "").split(/\s*,\s*/g); 37 | } 38 | 39 | function escapeAttributeValue(value) { 40 | // As mentioned on http://api.jquery.com/category/selectors/ 41 | return value.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g, "\\$1"); 42 | } 43 | 44 | function getModelPrefix(fieldName) { 45 | return fieldName.substr(0, fieldName.lastIndexOf(".") + 1); 46 | } 47 | 48 | function appendModelPrefix(value, prefix) { 49 | if (value.indexOf("*.") === 0) { 50 | value = value.replace("*.", prefix); 51 | } 52 | return value; 53 | } 54 | 55 | function onError(error, inputElement) { // 'this' is the form element 56 | var container = $(this).find("[data-valmsg-for='" + escapeAttributeValue(inputElement[0].name) + "']"), 57 | replaceAttrValue = container.attr("data-valmsg-replace"), 58 | replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) !== false : null; 59 | 60 | container.removeClass("field-validation-valid").addClass("field-validation-error"); 61 | error.data("unobtrusiveContainer", container); 62 | 63 | if (replace) { 64 | container.empty(); 65 | error.removeClass("input-validation-error").appendTo(container); 66 | } 67 | else { 68 | error.hide(); 69 | } 70 | } 71 | 72 | function onErrors(event, validator) { // 'this' is the form element 73 | var container = $(this).find("[data-valmsg-summary=true]"), 74 | list = container.find("ul"); 75 | 76 | if (list && list.length && validator.errorList.length) { 77 | list.empty(); 78 | container.addClass("validation-summary-errors").removeClass("validation-summary-valid"); 79 | 80 | $.each(validator.errorList, function () { 81 | $("
  • ").html(this.message).appendTo(list); 82 | }); 83 | } 84 | } 85 | 86 | function onSuccess(error) { // 'this' is the form element 87 | var container = error.data("unobtrusiveContainer"), 88 | replaceAttrValue = container.attr("data-valmsg-replace"), 89 | replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) : null; 90 | 91 | if (container) { 92 | container.addClass("field-validation-valid").removeClass("field-validation-error"); 93 | error.removeData("unobtrusiveContainer"); 94 | 95 | if (replace) { 96 | container.empty(); 97 | } 98 | } 99 | } 100 | 101 | function onReset(event) { // 'this' is the form element 102 | var $form = $(this); 103 | $form.data("validator").resetForm(); 104 | $form.find(".validation-summary-errors") 105 | .addClass("validation-summary-valid") 106 | .removeClass("validation-summary-errors"); 107 | $form.find(".field-validation-error") 108 | .addClass("field-validation-valid") 109 | .removeClass("field-validation-error") 110 | .removeData("unobtrusiveContainer") 111 | .find(">*") // If we were using valmsg-replace, get the underlying error 112 | .removeData("unobtrusiveContainer"); 113 | } 114 | 115 | function validationInfo(form) { 116 | var $form = $(form), 117 | result = $form.data(data_validation), 118 | onResetProxy = $.proxy(onReset, form), 119 | defaultOptions = $jQval.unobtrusive.options || {}, 120 | execInContext = function (name, args) { 121 | var func = defaultOptions[name]; 122 | func && $.isFunction(func) && func.apply(form, args); 123 | } 124 | 125 | if (!result) { 126 | result = { 127 | options: { // options structure passed to jQuery Validate's validate() method 128 | errorClass: defaultOptions.errorClass || "input-validation-error", 129 | errorElement: defaultOptions.errorElement || "span", 130 | errorPlacement: function () { 131 | onError.apply(form, arguments); 132 | execInContext("errorPlacement", arguments); 133 | }, 134 | invalidHandler: function () { 135 | onErrors.apply(form, arguments); 136 | execInContext("invalidHandler", arguments); 137 | }, 138 | messages: {}, 139 | rules: {}, 140 | success: function () { 141 | onSuccess.apply(form, arguments); 142 | execInContext("success", arguments); 143 | } 144 | }, 145 | attachValidation: function () { 146 | $form 147 | .off("reset." + data_validation, onResetProxy) 148 | .on("reset." + data_validation, onResetProxy) 149 | .validate(this.options); 150 | }, 151 | validate: function () { // a validation function that is called by unobtrusive Ajax 152 | $form.validate(); 153 | return $form.valid(); 154 | } 155 | }; 156 | $form.data(data_validation, result); 157 | } 158 | 159 | return result; 160 | } 161 | 162 | $jQval.unobtrusive = { 163 | adapters: [], 164 | 165 | parseElement: function (element, skipAttach) { 166 | /// 167 | /// Parses a single HTML element for unobtrusive validation attributes. 168 | /// 169 | /// The HTML element to be parsed. 170 | /// [Optional] true to skip attaching the 171 | /// validation to the form. If parsing just this single element, you should specify true. 172 | /// If parsing several elements, you should specify false, and manually attach the validation 173 | /// to the form when you are finished. The default is false. 174 | var $element = $(element), 175 | form = $element.parents("form")[0], 176 | valInfo, rules, messages; 177 | 178 | if (!form) { // Cannot do client-side validation without a form 179 | return; 180 | } 181 | 182 | valInfo = validationInfo(form); 183 | valInfo.options.rules[element.name] = rules = {}; 184 | valInfo.options.messages[element.name] = messages = {}; 185 | 186 | $.each(this.adapters, function () { 187 | var prefix = "data-val-" + this.name, 188 | message = $element.attr(prefix), 189 | paramValues = {}; 190 | 191 | if (message !== undefined) { // Compare against undefined, because an empty message is legal (and falsy) 192 | prefix += "-"; 193 | 194 | $.each(this.params, function () { 195 | paramValues[this] = $element.attr(prefix + this); 196 | }); 197 | 198 | this.adapt({ 199 | element: element, 200 | form: form, 201 | message: message, 202 | params: paramValues, 203 | rules: rules, 204 | messages: messages 205 | }); 206 | } 207 | }); 208 | 209 | $.extend(rules, { "__dummy__": true }); 210 | 211 | if (!skipAttach) { 212 | valInfo.attachValidation(); 213 | } 214 | }, 215 | 216 | parse: function (selector) { 217 | /// 218 | /// Parses all the HTML elements in the specified selector. It looks for input elements decorated 219 | /// with the [data-val=true] attribute value and enables validation according to the data-val-* 220 | /// attribute values. 221 | /// 222 | /// Any valid jQuery selector. 223 | 224 | // $forms includes all forms in selector's DOM hierarchy (parent, children and self) that have at least one 225 | // element with data-val=true 226 | var $selector = $(selector), 227 | $forms = $selector.parents() 228 | .addBack() 229 | .filter("form") 230 | .add($selector.find("form")) 231 | .has("[data-val=true]"); 232 | 233 | $selector.find("[data-val=true]").each(function () { 234 | $jQval.unobtrusive.parseElement(this, true); 235 | }); 236 | 237 | $forms.each(function () { 238 | var info = validationInfo(this); 239 | if (info) { 240 | info.attachValidation(); 241 | } 242 | }); 243 | } 244 | }; 245 | 246 | adapters = $jQval.unobtrusive.adapters; 247 | 248 | adapters.add = function (adapterName, params, fn) { 249 | /// Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation. 250 | /// The name of the adapter to be added. This matches the name used 251 | /// in the data-val-nnnn HTML attribute (where nnnn is the adapter name). 252 | /// [Optional] An array of parameter names (strings) that will 253 | /// be extracted from the data-val-nnnn-mmmm HTML attributes (where nnnn is the adapter name, and 254 | /// mmmm is the parameter name). 255 | /// The function to call, which adapts the values from the HTML 256 | /// attributes into jQuery Validate rules and/or messages. 257 | /// 258 | if (!fn) { // Called with no params, just a function 259 | fn = params; 260 | params = []; 261 | } 262 | this.push({ name: adapterName, params: params, adapt: fn }); 263 | return this; 264 | }; 265 | 266 | adapters.addBool = function (adapterName, ruleName) { 267 | /// Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where 268 | /// the jQuery Validate validation rule has no parameter values. 269 | /// The name of the adapter to be added. This matches the name used 270 | /// in the data-val-nnnn HTML attribute (where nnnn is the adapter name). 271 | /// [Optional] The name of the jQuery Validate rule. If not provided, the value 272 | /// of adapterName will be used instead. 273 | /// 274 | return this.add(adapterName, function (options) { 275 | setValidationValues(options, ruleName || adapterName, true); 276 | }); 277 | }; 278 | 279 | adapters.addMinMax = function (adapterName, minRuleName, maxRuleName, minMaxRuleName, minAttribute, maxAttribute) { 280 | /// Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where 281 | /// the jQuery Validate validation has three potential rules (one for min-only, one for max-only, and 282 | /// one for min-and-max). The HTML parameters are expected to be named -min and -max. 283 | /// The name of the adapter to be added. This matches the name used 284 | /// in the data-val-nnnn HTML attribute (where nnnn is the adapter name). 285 | /// The name of the jQuery Validate rule to be used when you only 286 | /// have a minimum value. 287 | /// The name of the jQuery Validate rule to be used when you only 288 | /// have a maximum value. 289 | /// The name of the jQuery Validate rule to be used when you 290 | /// have both a minimum and maximum value. 291 | /// [Optional] The name of the HTML attribute that 292 | /// contains the minimum value. The default is "min". 293 | /// [Optional] The name of the HTML attribute that 294 | /// contains the maximum value. The default is "max". 295 | /// 296 | return this.add(adapterName, [minAttribute || "min", maxAttribute || "max"], function (options) { 297 | var min = options.params.min, 298 | max = options.params.max; 299 | 300 | if (min && max) { 301 | setValidationValues(options, minMaxRuleName, [min, max]); 302 | } 303 | else if (min) { 304 | setValidationValues(options, minRuleName, min); 305 | } 306 | else if (max) { 307 | setValidationValues(options, maxRuleName, max); 308 | } 309 | }); 310 | }; 311 | 312 | adapters.addSingleVal = function (adapterName, attribute, ruleName) { 313 | /// Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where 314 | /// the jQuery Validate validation rule has a single value. 315 | /// The name of the adapter to be added. This matches the name used 316 | /// in the data-val-nnnn HTML attribute(where nnnn is the adapter name). 317 | /// [Optional] The name of the HTML attribute that contains the value. 318 | /// The default is "val". 319 | /// [Optional] The name of the jQuery Validate rule. If not provided, the value 320 | /// of adapterName will be used instead. 321 | /// 322 | return this.add(adapterName, [attribute || "val"], function (options) { 323 | setValidationValues(options, ruleName || adapterName, options.params[attribute]); 324 | }); 325 | }; 326 | 327 | $jQval.addMethod("__dummy__", function (value, element, params) { 328 | return true; 329 | }); 330 | 331 | $jQval.addMethod("regex", function (value, element, params) { 332 | var match; 333 | if (this.optional(element)) { 334 | return true; 335 | } 336 | 337 | match = new RegExp(params).exec(value); 338 | return (match && (match.index === 0) && (match[0].length === value.length)); 339 | }); 340 | 341 | $jQval.addMethod("nonalphamin", function (value, element, nonalphamin) { 342 | var match; 343 | if (nonalphamin) { 344 | match = value.match(/\W/g); 345 | match = match && match.length >= nonalphamin; 346 | } 347 | return match; 348 | }); 349 | 350 | if ($jQval.methods.extension) { 351 | adapters.addSingleVal("accept", "mimtype"); 352 | adapters.addSingleVal("extension", "extension"); 353 | } else { 354 | // for backward compatibility, when the 'extension' validation method does not exist, such as with versions 355 | // of JQuery Validation plugin prior to 1.10, we should use the 'accept' method for 356 | // validating the extension, and ignore mime-type validations as they are not supported. 357 | adapters.addSingleVal("extension", "extension", "accept"); 358 | } 359 | 360 | adapters.addSingleVal("regex", "pattern"); 361 | adapters.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url"); 362 | adapters.addMinMax("length", "minlength", "maxlength", "rangelength").addMinMax("range", "min", "max", "range"); 363 | adapters.addMinMax("minlength", "minlength").addMinMax("maxlength", "minlength", "maxlength"); 364 | adapters.add("equalto", ["other"], function (options) { 365 | var prefix = getModelPrefix(options.element.name), 366 | other = options.params.other, 367 | fullOtherName = appendModelPrefix(other, prefix), 368 | element = $(options.form).find(":input").filter("[name='" + escapeAttributeValue(fullOtherName) + "']")[0]; 369 | 370 | setValidationValues(options, "equalTo", element); 371 | }); 372 | adapters.add("required", function (options) { 373 | // jQuery Validate equates "required" with "mandatory" for checkbox elements 374 | if (options.element.tagName.toUpperCase() !== "INPUT" || options.element.type.toUpperCase() !== "CHECKBOX") { 375 | setValidationValues(options, "required", true); 376 | } 377 | }); 378 | adapters.add("remote", ["url", "type", "additionalfields"], function (options) { 379 | var value = { 380 | url: options.params.url, 381 | type: options.params.type || "GET", 382 | data: {} 383 | }, 384 | prefix = getModelPrefix(options.element.name); 385 | 386 | $.each(splitAndTrim(options.params.additionalfields || options.element.name), function (i, fieldName) { 387 | var paramName = appendModelPrefix(fieldName, prefix); 388 | value.data[paramName] = function () { 389 | return $(options.form).find(":input").filter("[name='" + escapeAttributeValue(paramName) + "']").val(); 390 | }; 391 | }); 392 | 393 | setValidationValues(options, "remote", value); 394 | }); 395 | adapters.add("password", ["min", "nonalphamin", "regex"], function (options) { 396 | if (options.params.min) { 397 | setValidationValues(options, "minlength", options.params.min); 398 | } 399 | if (options.params.nonalphamin) { 400 | setValidationValues(options, "nonalphamin", options.params.nonalphamin); 401 | } 402 | if (options.params.regex) { 403 | setValidationValues(options, "regex", options.params.regex); 404 | } 405 | }); 406 | 407 | $(function () { 408 | $jQval.unobtrusive.parse(document); 409 | }); 410 | }(jQuery)); -------------------------------------------------------------------------------- /QuickBootstrap/Scripts/jquery.validate.min.js: -------------------------------------------------------------------------------- 1 | /*! jQuery Validation Plugin - v1.13.0 - 7/1/2014 2 | * http://jqueryvalidation.org/ 3 | * Copyright (c) 2014 Jörn Zaefferer; Licensed MIT */ 4 | !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){a.extend(a.fn,{validate:function(b){if(!this.length)return void(b&&b.debug&&window.console&&console.warn("Nothing selected, can't validate, returning nothing."));var c=a.data(this[0],"validator");return c?c:(this.attr("novalidate","novalidate"),c=new a.validator(b,this[0]),a.data(this[0],"validator",c),c.settings.onsubmit&&(this.validateDelegate(":submit","click",function(b){c.settings.submitHandler&&(c.submitButton=b.target),a(b.target).hasClass("cancel")&&(c.cancelSubmit=!0),void 0!==a(b.target).attr("formnovalidate")&&(c.cancelSubmit=!0)}),this.submit(function(b){function d(){var d;return c.settings.submitHandler?(c.submitButton&&(d=a("").attr("name",c.submitButton.name).val(a(c.submitButton).val()).appendTo(c.currentForm)),c.settings.submitHandler.call(c,c.currentForm,b),c.submitButton&&d.remove(),!1):!0}return c.settings.debug&&b.preventDefault(),c.cancelSubmit?(c.cancelSubmit=!1,d()):c.form()?c.pendingRequest?(c.formSubmitted=!0,!1):d():(c.focusInvalid(),!1)})),c)},valid:function(){var b,c;return a(this[0]).is("form")?b=this.validate().form():(b=!0,c=a(this[0].form).validate(),this.each(function(){b=c.element(this)&&b})),b},removeAttrs:function(b){var c={},d=this;return a.each(b.split(/\s/),function(a,b){c[b]=d.attr(b),d.removeAttr(b)}),c},rules:function(b,c){var d,e,f,g,h,i,j=this[0];if(b)switch(d=a.data(j.form,"validator").settings,e=d.rules,f=a.validator.staticRules(j),b){case"add":a.extend(f,a.validator.normalizeRule(c)),delete f.messages,e[j.name]=f,c.messages&&(d.messages[j.name]=a.extend(d.messages[j.name],c.messages));break;case"remove":return c?(i={},a.each(c.split(/\s/),function(b,c){i[c]=f[c],delete f[c],"required"===c&&a(j).removeAttr("aria-required")}),i):(delete e[j.name],f)}return g=a.validator.normalizeRules(a.extend({},a.validator.classRules(j),a.validator.attributeRules(j),a.validator.dataRules(j),a.validator.staticRules(j)),j),g.required&&(h=g.required,delete g.required,g=a.extend({required:h},g),a(j).attr("aria-required","true")),g.remote&&(h=g.remote,delete g.remote,g=a.extend(g,{remote:h})),g}}),a.extend(a.expr[":"],{blank:function(b){return!a.trim(""+a(b).val())},filled:function(b){return!!a.trim(""+a(b).val())},unchecked:function(b){return!a(b).prop("checked")}}),a.validator=function(b,c){this.settings=a.extend(!0,{},a.validator.defaults,b),this.currentForm=c,this.init()},a.validator.format=function(b,c){return 1===arguments.length?function(){var c=a.makeArray(arguments);return c.unshift(b),a.validator.format.apply(this,c)}:(arguments.length>2&&c.constructor!==Array&&(c=a.makeArray(arguments).slice(1)),c.constructor!==Array&&(c=[c]),a.each(c,function(a,c){b=b.replace(new RegExp("\\{"+a+"\\}","g"),function(){return c})}),b)},a.extend(a.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",validClass:"valid",errorElement:"label",focusInvalid:!0,errorContainer:a([]),errorLabelContainer:a([]),onsubmit:!0,ignore:":hidden",ignoreTitle:!1,onfocusin:function(a){this.lastActive=a,this.settings.focusCleanup&&!this.blockFocusCleanup&&(this.settings.unhighlight&&this.settings.unhighlight.call(this,a,this.settings.errorClass,this.settings.validClass),this.hideThese(this.errorsFor(a)))},onfocusout:function(a){this.checkable(a)||!(a.name in this.submitted)&&this.optional(a)||this.element(a)},onkeyup:function(a,b){(9!==b.which||""!==this.elementValue(a))&&(a.name in this.submitted||a===this.lastElement)&&this.element(a)},onclick:function(a){a.name in this.submitted?this.element(a):a.parentNode.name in this.submitted&&this.element(a.parentNode)},highlight:function(b,c,d){"radio"===b.type?this.findByName(b.name).addClass(c).removeClass(d):a(b).addClass(c).removeClass(d)},unhighlight:function(b,c,d){"radio"===b.type?this.findByName(b.name).removeClass(c).addClass(d):a(b).removeClass(c).addClass(d)}},setDefaults:function(b){a.extend(a.validator.defaults,b)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date ( ISO ).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",maxlength:a.validator.format("Please enter no more than {0} characters."),minlength:a.validator.format("Please enter at least {0} characters."),rangelength:a.validator.format("Please enter a value between {0} and {1} characters long."),range:a.validator.format("Please enter a value between {0} and {1}."),max:a.validator.format("Please enter a value less than or equal to {0}."),min:a.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:!1,prototype:{init:function(){function b(b){var c=a.data(this[0].form,"validator"),d="on"+b.type.replace(/^validate/,""),e=c.settings;e[d]&&!this.is(e.ignore)&&e[d].call(c,this[0],b)}this.labelContainer=a(this.settings.errorLabelContainer),this.errorContext=this.labelContainer.length&&this.labelContainer||a(this.currentForm),this.containers=a(this.settings.errorContainer).add(this.settings.errorLabelContainer),this.submitted={},this.valueCache={},this.pendingRequest=0,this.pending={},this.invalid={},this.reset();var c,d=this.groups={};a.each(this.settings.groups,function(b,c){"string"==typeof c&&(c=c.split(/\s/)),a.each(c,function(a,c){d[c]=b})}),c=this.settings.rules,a.each(c,function(b,d){c[b]=a.validator.normalizeRule(d)}),a(this.currentForm).validateDelegate(":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'] ,[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], [type='radio'], [type='checkbox']","focusin focusout keyup",b).validateDelegate("select, option, [type='radio'], [type='checkbox']","click",b),this.settings.invalidHandler&&a(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler),a(this.currentForm).find("[required], [data-rule-required], .required").attr("aria-required","true")},form:function(){return this.checkForm(),a.extend(this.submitted,this.errorMap),this.invalid=a.extend({},this.errorMap),this.valid()||a(this.currentForm).triggerHandler("invalid-form",[this]),this.showErrors(),this.valid()},checkForm:function(){this.prepareForm();for(var a=0,b=this.currentElements=this.elements();b[a];a++)this.check(b[a]);return this.valid()},element:function(b){var c=this.clean(b),d=this.validationTargetFor(c),e=!0;return this.lastElement=d,void 0===d?delete this.invalid[c.name]:(this.prepareElement(d),this.currentElements=a(d),e=this.check(d)!==!1,e?delete this.invalid[d.name]:this.invalid[d.name]=!0),a(b).attr("aria-invalid",!e),this.numberOfInvalids()||(this.toHide=this.toHide.add(this.containers)),this.showErrors(),e},showErrors:function(b){if(b){a.extend(this.errorMap,b),this.errorList=[];for(var c in b)this.errorList.push({message:b[c],element:this.findByName(c)[0]});this.successList=a.grep(this.successList,function(a){return!(a.name in b)})}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){a.fn.resetForm&&a(this.currentForm).resetForm(),this.submitted={},this.lastElement=null,this.prepareForm(),this.hideErrors(),this.elements().removeClass(this.settings.errorClass).removeData("previousValue").removeAttr("aria-invalid")},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(a){var b,c=0;for(b in a)c++;return c},hideErrors:function(){this.hideThese(this.toHide)},hideThese:function(a){a.not(this.containers).text(""),this.addWrapper(a).hide()},valid:function(){return 0===this.size()},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{a(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(b){}},findLastActive:function(){var b=this.lastActive;return b&&1===a.grep(this.errorList,function(a){return a.element.name===b.name}).length&&b},elements:function(){var b=this,c={};return a(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){return!this.name&&b.settings.debug&&window.console&&console.error("%o has no name assigned",this),this.name in c||!b.objectLength(a(this).rules())?!1:(c[this.name]=!0,!0)})},clean:function(b){return a(b)[0]},errors:function(){var b=this.settings.errorClass.split(" ").join(".");return a(this.settings.errorElement+"."+b,this.errorContext)},reset:function(){this.successList=[],this.errorList=[],this.errorMap={},this.toShow=a([]),this.toHide=a([]),this.currentElements=a([])},prepareForm:function(){this.reset(),this.toHide=this.errors().add(this.containers)},prepareElement:function(a){this.reset(),this.toHide=this.errorsFor(a)},elementValue:function(b){var c,d=a(b),e=b.type;return"radio"===e||"checkbox"===e?a("input[name='"+b.name+"']:checked").val():"number"===e&&"undefined"!=typeof b.validity?b.validity.badInput?!1:d.val():(c=d.val(),"string"==typeof c?c.replace(/\r/g,""):c)},check:function(b){b=this.validationTargetFor(this.clean(b));var c,d,e,f=a(b).rules(),g=a.map(f,function(a,b){return b}).length,h=!1,i=this.elementValue(b);for(d in f){e={method:d,parameters:f[d]};try{if(c=a.validator.methods[d].call(this,i,b,e.parameters),"dependency-mismatch"===c&&1===g){h=!0;continue}if(h=!1,"pending"===c)return void(this.toHide=this.toHide.not(this.errorsFor(b)));if(!c)return this.formatAndAdd(b,e),!1}catch(j){throw this.settings.debug&&window.console&&console.log("Exception occurred when checking element "+b.id+", check the '"+e.method+"' method.",j),j}}if(!h)return this.objectLength(f)&&this.successList.push(b),!0},customDataMessage:function(b,c){return a(b).data("msg"+c.charAt(0).toUpperCase()+c.substring(1).toLowerCase())||a(b).data("msg")},customMessage:function(a,b){var c=this.settings.messages[a];return c&&(c.constructor===String?c:c[b])},findDefined:function(){for(var a=0;aWarning: No message defined for "+b.name+"")},formatAndAdd:function(b,c){var d=this.defaultMessage(b,c.method),e=/\$?\{(\d+)\}/g;"function"==typeof d?d=d.call(this,c.parameters,b):e.test(d)&&(d=a.validator.format(d.replace(e,"{$1}"),c.parameters)),this.errorList.push({message:d,element:b,method:c.method}),this.errorMap[b.name]=d,this.submitted[b.name]=d},addWrapper:function(a){return this.settings.wrapper&&(a=a.add(a.parent(this.settings.wrapper))),a},defaultShowErrors:function(){var a,b,c;for(a=0;this.errorList[a];a++)c=this.errorList[a],this.settings.highlight&&this.settings.highlight.call(this,c.element,this.settings.errorClass,this.settings.validClass),this.showLabel(c.element,c.message);if(this.errorList.length&&(this.toShow=this.toShow.add(this.containers)),this.settings.success)for(a=0;this.successList[a];a++)this.showLabel(this.successList[a]);if(this.settings.unhighlight)for(a=0,b=this.validElements();b[a];a++)this.settings.unhighlight.call(this,b[a],this.settings.errorClass,this.settings.validClass);this.toHide=this.toHide.not(this.toShow),this.hideErrors(),this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return a(this.errorList).map(function(){return this.element})},showLabel:function(b,c){var d,e,f,g=this.errorsFor(b),h=this.idOrName(b),i=a(b).attr("aria-describedby");g.length?(g.removeClass(this.settings.validClass).addClass(this.settings.errorClass),g.html(c)):(g=a("<"+this.settings.errorElement+">").attr("id",h+"-error").addClass(this.settings.errorClass).html(c||""),d=g,this.settings.wrapper&&(d=g.hide().show().wrap("<"+this.settings.wrapper+"/>").parent()),this.labelContainer.length?this.labelContainer.append(d):this.settings.errorPlacement?this.settings.errorPlacement(d,a(b)):d.insertAfter(b),g.is("label")?g.attr("for",h):0===g.parents("label[for='"+h+"']").length&&(f=g.attr("id"),i?i.match(new RegExp("\b"+f+"\b"))||(i+=" "+f):i=f,a(b).attr("aria-describedby",i),e=this.groups[b.name],e&&a.each(this.groups,function(b,c){c===e&&a("[name='"+b+"']",this.currentForm).attr("aria-describedby",g.attr("id"))}))),!c&&this.settings.success&&(g.text(""),"string"==typeof this.settings.success?g.addClass(this.settings.success):this.settings.success(g,b)),this.toShow=this.toShow.add(g)},errorsFor:function(b){var c=this.idOrName(b),d=a(b).attr("aria-describedby"),e="label[for='"+c+"'], label[for='"+c+"'] *";return d&&(e=e+", #"+d.replace(/\s+/g,", #")),this.errors().filter(e)},idOrName:function(a){return this.groups[a.name]||(this.checkable(a)?a.name:a.id||a.name)},validationTargetFor:function(a){return this.checkable(a)&&(a=this.findByName(a.name).not(this.settings.ignore)[0]),a},checkable:function(a){return/radio|checkbox/i.test(a.type)},findByName:function(b){return a(this.currentForm).find("[name='"+b+"']")},getLength:function(b,c){switch(c.nodeName.toLowerCase()){case"select":return a("option:selected",c).length;case"input":if(this.checkable(c))return this.findByName(c.name).filter(":checked").length}return b.length},depend:function(a,b){return this.dependTypes[typeof a]?this.dependTypes[typeof a](a,b):!0},dependTypes:{"boolean":function(a){return a},string:function(b,c){return!!a(b,c.form).length},"function":function(a,b){return a(b)}},optional:function(b){var c=this.elementValue(b);return!a.validator.methods.required.call(this,c,b)&&"dependency-mismatch"},startRequest:function(a){this.pending[a.name]||(this.pendingRequest++,this.pending[a.name]=!0)},stopRequest:function(b,c){this.pendingRequest--,this.pendingRequest<0&&(this.pendingRequest=0),delete this.pending[b.name],c&&0===this.pendingRequest&&this.formSubmitted&&this.form()?(a(this.currentForm).submit(),this.formSubmitted=!1):!c&&0===this.pendingRequest&&this.formSubmitted&&(a(this.currentForm).triggerHandler("invalid-form",[this]),this.formSubmitted=!1)},previousValue:function(b){return a.data(b,"previousValue")||a.data(b,"previousValue",{old:null,valid:!0,message:this.defaultMessage(b,"remote")})}},classRuleSettings:{required:{required:!0},email:{email:!0},url:{url:!0},date:{date:!0},dateISO:{dateISO:!0},number:{number:!0},digits:{digits:!0},creditcard:{creditcard:!0}},addClassRules:function(b,c){b.constructor===String?this.classRuleSettings[b]=c:a.extend(this.classRuleSettings,b)},classRules:function(b){var c={},d=a(b).attr("class");return d&&a.each(d.split(" "),function(){this in a.validator.classRuleSettings&&a.extend(c,a.validator.classRuleSettings[this])}),c},attributeRules:function(b){var c,d,e={},f=a(b),g=b.getAttribute("type");for(c in a.validator.methods)"required"===c?(d=b.getAttribute(c),""===d&&(d=!0),d=!!d):d=f.attr(c),/min|max/.test(c)&&(null===g||/number|range|text/.test(g))&&(d=Number(d)),d||0===d?e[c]=d:g===c&&"range"!==g&&(e[c]=!0);return e.maxlength&&/-1|2147483647|524288/.test(e.maxlength)&&delete e.maxlength,e},dataRules:function(b){var c,d,e={},f=a(b);for(c in a.validator.methods)d=f.data("rule"+c.charAt(0).toUpperCase()+c.substring(1).toLowerCase()),void 0!==d&&(e[c]=d);return e},staticRules:function(b){var c={},d=a.data(b.form,"validator");return d.settings.rules&&(c=a.validator.normalizeRule(d.settings.rules[b.name])||{}),c},normalizeRules:function(b,c){return a.each(b,function(d,e){if(e===!1)return void delete b[d];if(e.param||e.depends){var f=!0;switch(typeof e.depends){case"string":f=!!a(e.depends,c.form).length;break;case"function":f=e.depends.call(c,c)}f?b[d]=void 0!==e.param?e.param:!0:delete b[d]}}),a.each(b,function(d,e){b[d]=a.isFunction(e)?e(c):e}),a.each(["minlength","maxlength"],function(){b[this]&&(b[this]=Number(b[this]))}),a.each(["rangelength","range"],function(){var c;b[this]&&(a.isArray(b[this])?b[this]=[Number(b[this][0]),Number(b[this][1])]:"string"==typeof b[this]&&(c=b[this].replace(/[\[\]]/g,"").split(/[\s,]+/),b[this]=[Number(c[0]),Number(c[1])]))}),a.validator.autoCreateRanges&&(b.min&&b.max&&(b.range=[b.min,b.max],delete b.min,delete b.max),b.minlength&&b.maxlength&&(b.rangelength=[b.minlength,b.maxlength],delete b.minlength,delete b.maxlength)),b},normalizeRule:function(b){if("string"==typeof b){var c={};a.each(b.split(/\s/),function(){c[this]=!0}),b=c}return b},addMethod:function(b,c,d){a.validator.methods[b]=c,a.validator.messages[b]=void 0!==d?d:a.validator.messages[b],c.length<3&&a.validator.addClassRules(b,a.validator.normalizeRule(b))},methods:{required:function(b,c,d){if(!this.depend(d,c))return"dependency-mismatch";if("select"===c.nodeName.toLowerCase()){var e=a(c).val();return e&&e.length>0}return this.checkable(c)?this.getLength(b,c)>0:a.trim(b).length>0},email:function(a,b){return this.optional(b)||/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(a)},url:function(a,b){return this.optional(b)||/^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(a)},date:function(a,b){return this.optional(b)||!/Invalid|NaN/.test(new Date(a).toString())},dateISO:function(a,b){return this.optional(b)||/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(a)},number:function(a,b){return this.optional(b)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(a)},digits:function(a,b){return this.optional(b)||/^\d+$/.test(a)},creditcard:function(a,b){if(this.optional(b))return"dependency-mismatch";if(/[^0-9 \-]+/.test(a))return!1;var c,d,e=0,f=0,g=!1;if(a=a.replace(/\D/g,""),a.length<13||a.length>19)return!1;for(c=a.length-1;c>=0;c--)d=a.charAt(c),f=parseInt(d,10),g&&(f*=2)>9&&(f-=9),e+=f,g=!g;return e%10===0},minlength:function(b,c,d){var e=a.isArray(b)?b.length:this.getLength(a.trim(b),c);return this.optional(c)||e>=d},maxlength:function(b,c,d){var e=a.isArray(b)?b.length:this.getLength(a.trim(b),c);return this.optional(c)||d>=e},rangelength:function(b,c,d){var e=a.isArray(b)?b.length:this.getLength(a.trim(b),c);return this.optional(c)||e>=d[0]&&e<=d[1]},min:function(a,b,c){return this.optional(b)||a>=c},max:function(a,b,c){return this.optional(b)||c>=a},range:function(a,b,c){return this.optional(b)||a>=c[0]&&a<=c[1]},equalTo:function(b,c,d){var e=a(d);return this.settings.onfocusout&&e.unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){a(c).valid()}),b===e.val()},remote:function(b,c,d){if(this.optional(c))return"dependency-mismatch";var e,f,g=this.previousValue(c);return this.settings.messages[c.name]||(this.settings.messages[c.name]={}),g.originalMessage=this.settings.messages[c.name].remote,this.settings.messages[c.name].remote=g.message,d="string"==typeof d&&{url:d}||d,g.old===b?g.valid:(g.old=b,e=this,this.startRequest(c),f={},f[c.name]=b,a.ajax(a.extend(!0,{url:d,mode:"abort",port:"validate"+c.name,dataType:"json",data:f,context:e.currentForm,success:function(d){var f,h,i,j=d===!0||"true"===d;e.settings.messages[c.name].remote=g.originalMessage,j?(i=e.formSubmitted,e.prepareElement(c),e.formSubmitted=i,e.successList.push(c),delete e.invalid[c.name],e.showErrors()):(f={},h=d||e.defaultMessage(c,"remote"),f[c.name]=g.message=a.isFunction(h)?h(b):h,e.invalid[c.name]=!0,e.showErrors(f)),g.valid=j,e.stopRequest(c,j)}},d)),"pending")}}}),a.format=function(){throw"$.format has been deprecated. Please use $.validator.format instead."};var b,c={};a.ajaxPrefilter?a.ajaxPrefilter(function(a,b,d){var e=a.port;"abort"===a.mode&&(c[e]&&c[e].abort(),c[e]=d)}):(b=a.ajax,a.ajax=function(d){var e=("mode"in d?d:a.ajaxSettings).mode,f=("port"in d?d:a.ajaxSettings).port;return"abort"===e?(c[f]&&c[f].abort(),c[f]=b.apply(this,arguments),c[f]):b.apply(this,arguments)}),a.extend(a.fn,{validateDelegate:function(b,c,d){return this.bind(c,function(c){var e=a(c.target);return e.is(b)?d.apply(e,arguments):void 0})}})}); --------------------------------------------------------------------------------