forked from xuxiaowei007/FoxOne
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 43092eb
Showing
2,217 changed files
with
667,447 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace FoxOne.Business | ||
{ | ||
public class AjaxResultModel | ||
{ | ||
public object Data { get; set; } | ||
|
||
public bool Result { get; set; } | ||
|
||
public string ErrorMessage { get; set; } | ||
|
||
public bool NoAuthority { get; set; } | ||
|
||
public bool LoginTimeOut { get; set; } | ||
|
||
public AjaxResultModel() | ||
{ | ||
this.Result = true; | ||
this.ErrorMessage = string.Empty; | ||
this.NoAuthority = false; | ||
this.LoginTimeOut = false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using FoxOne.Business.Security; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Web; | ||
using System.Web.Mvc; | ||
using FoxOne.Core; | ||
namespace FoxOne.Business | ||
{ | ||
public class CustomAuthorizeAttribute : AuthorizeAttribute | ||
{ | ||
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext) | ||
{ | ||
if (filterContext.HttpContext.Request.IsAjaxRequest()) | ||
{ | ||
|
||
var result = new AjaxResultModel() | ||
{ | ||
LoginTimeOut = true, | ||
ErrorMessage = "登录超时" | ||
}; | ||
if (filterContext.HttpContext.Response.StatusCode == 403) | ||
{ | ||
filterContext.HttpContext.Response.StatusCode = 200; | ||
result.NoAuthority = true; | ||
result.ErrorMessage = "您没有访问资源[" + filterContext.RouteData.Values["controller"].ToString() + "/" + filterContext.RouteData.Values["action"].ToString() + "]的权限"; | ||
} | ||
filterContext.Result = new JsonResult() | ||
{ | ||
JsonRequestBehavior = JsonRequestBehavior.AllowGet, | ||
Data = result | ||
}; | ||
} | ||
else | ||
{ | ||
base.HandleUnauthorizedRequest(filterContext); | ||
} | ||
} | ||
|
||
protected override bool AuthorizeCore(HttpContextBase httpContext) | ||
{ | ||
var returnValue = httpContext.User.Identity.IsAuthenticated; | ||
if (returnValue) | ||
{ | ||
var request = httpContext.Request; | ||
if (!Sec.Provider.HasPermissionOfUrl(request.Path, request.Url.Query)) | ||
{ | ||
httpContext.Response.StatusCode = 403; | ||
if (httpContext.Request.IsAjaxRequest()) | ||
{ | ||
returnValue = false; | ||
} | ||
else | ||
{ | ||
string redirect = "~/Home/Error/您没有访问该页面的权限"; | ||
httpContext.Response.Redirect(redirect); | ||
httpContext.Response.End(); | ||
} | ||
} | ||
} | ||
return returnValue; | ||
} | ||
|
||
public override void OnAuthorization(AuthorizationContext filterContext) | ||
{ | ||
var attr = filterContext.ActionDescriptor.GetCustomAttributes(typeof(CustomUnAuthorizeAttribute), true); | ||
if (attr.IsNullOrEmpty()) | ||
{ | ||
base.OnAuthorization(filterContext); | ||
} | ||
} | ||
} | ||
|
||
public class CustomUnAuthorizeAttribute : Attribute | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using FoxOne.Core; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Web.Mvc; | ||
|
||
namespace FoxOne.Business | ||
{ | ||
public class CustomHandleErrorAttribute : HandleErrorAttribute | ||
{ | ||
public override void OnException(ExceptionContext filterContext) | ||
{ | ||
Logger.Error(filterContext.Exception.Message, filterContext.Exception); | ||
if (!(filterContext.Exception is FoxOneException)) | ||
{ | ||
//预料之外的异常,记录日志 | ||
|
||
} | ||
if (filterContext.HttpContext.Request.IsAjaxRequest()) | ||
{ | ||
filterContext.ExceptionHandled = true; | ||
filterContext.HttpContext.Response.Clear(); | ||
JsonResult json = new JsonResult(); | ||
AjaxResultModel result = new AjaxResultModel() | ||
{ | ||
Result = false, | ||
//ErrorMessage = "出错的地址是:" + filterContext.RouteData.Values["controller"].ToString() + "/" + filterContext.RouteData.Values["action"].ToString() + "\n异常信息为:" + filterContext.Exception.Message | ||
ErrorMessage = filterContext.Exception.Message | ||
}; | ||
json.Data = result; | ||
json.JsonRequestBehavior = JsonRequestBehavior.AllowGet; | ||
filterContext.Result = json; | ||
} | ||
else | ||
{ | ||
filterContext.ExceptionHandled = true; | ||
filterContext.HttpContext.Response.Clear(); | ||
string message = string.Empty; | ||
if (filterContext.Exception is PageNotFoundException) | ||
{ | ||
filterContext.HttpContext.Response.StatusCode = 404; | ||
message = "页面不存在"; | ||
} | ||
else if (filterContext.Exception is UnAuthorizedException) | ||
{ | ||
filterContext.HttpContext.Response.StatusCode = 403; | ||
message = "您没有访问该页面的权限"; | ||
} | ||
else | ||
{ | ||
filterContext.HttpContext.Response.StatusCode = 500; | ||
message = filterContext.Exception.Message; | ||
} | ||
filterContext.Result = new RedirectResult("/Home/Error/" + message); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace FoxOne.Business | ||
{ | ||
public abstract class DataSourceAttribute : Attribute | ||
{ | ||
public abstract IControl GetDataSource(); | ||
} | ||
|
||
public class EnumDataSourceAttribute : DataSourceAttribute | ||
{ | ||
private Type EnumType { get; set; } | ||
public EnumDataSourceAttribute(Type type) | ||
{ | ||
if (!type.IsEnum) | ||
{ | ||
throw new ArgumentOutOfRangeException("type"); | ||
} | ||
EnumType = type; | ||
} | ||
|
||
public override IControl GetDataSource() | ||
{ | ||
var result = new EnumDataSource(); | ||
result.EnumType = EnumType; | ||
result.EnumValueType = EnumValueType.Code; | ||
return result; | ||
} | ||
} | ||
|
||
public class FunctionDataSourceAttribute : DataSourceAttribute | ||
{ | ||
private Type Type { get; set; } | ||
|
||
public FunctionDataSourceAttribute(Type type) | ||
{ | ||
Type = type; | ||
} | ||
public override IControl GetDataSource() | ||
{ | ||
return Activator.CreateInstance(Type) as IControl; | ||
} | ||
} | ||
|
||
public class TypeDataSourceAttribute : DataSourceAttribute | ||
{ | ||
private Type Type { get; set; } | ||
|
||
public TypeDataSourceAttribute(Type type) | ||
{ | ||
Type = type; | ||
} | ||
public override IControl GetDataSource() | ||
{ | ||
return new TypeDataSource() { BaseType = Type } as IKeyValueDataSource; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace FoxOne.Business | ||
{ | ||
[AttributeUsage(AttributeTargets.Property,Inherited=true)] | ||
public class FormFieldAttribute : Attribute | ||
{ | ||
public FormFieldAttribute() | ||
{ | ||
ControlType = ControlType.None; | ||
Editable = true; | ||
} | ||
public string FormDisplayName { get; set; } | ||
|
||
public ControlType ControlType { get; set; } | ||
|
||
public bool Editable { get; set; } | ||
|
||
public object DefaultValue { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace FoxOne.Business | ||
{ | ||
public class HtmlEncodeAttribute:Attribute | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace FoxOne.Business | ||
{ | ||
public class ParentFieldAttribute:Attribute | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace FoxOne.Business | ||
{ | ||
public class ScriptNameAttribute:Attribute | ||
{ | ||
public string Name { get; set; } | ||
|
||
public ScriptNameAttribute(string name) | ||
{ | ||
Name = name; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace FoxOne.Business | ||
{ | ||
public class TableFieldAttribute:Attribute | ||
{ | ||
public TableFieldAttribute() | ||
{ | ||
IsShow = true; | ||
} | ||
public int ShowLength { get; set; } | ||
|
||
public string ColumnWidth { get; set; } | ||
|
||
public string DefaultValue { get; set; } | ||
|
||
public CellTextAlign TextAlign { get; set; } | ||
|
||
public string DataFormatString { get; set; } | ||
|
||
public string DataFormatFields { get; set; } | ||
|
||
public string ReferenceField { get; set; } | ||
|
||
public bool Sortable { get; set; } | ||
|
||
public bool IsShow { get; set; } | ||
|
||
public bool HtmlEncode { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace FoxOne.Business | ||
{ | ||
public class TitleFieldAttribute:Attribute | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace FoxOne.Business | ||
{ | ||
public class ValidatorAttribute:Attribute | ||
{ | ||
public string ValidateString { get; set; } | ||
|
||
public ValidatorAttribute(string validateString) | ||
{ | ||
ValidateString = validateString; | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.