本文整理汇总了C#中GenericRepository.SearchFor方法的典型用法代码示例。如果您正苦于以下问题:C# GenericRepository.SearchFor方法的具体用法?C# GenericRepository.SearchFor怎么用?C# GenericRepository.SearchFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GenericRepository
的用法示例。
在下文中一共展示了GenericRepository.SearchFor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnActionExecuting
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (filterContext == null)
{
throw new ArgumentNullException("filterContext");
}
string path = filterContext.HttpContext.Request.Path.ToLower();
if (path == "/" || path == "/Login/Index".ToLower() || path == "/Login/Login".ToLower()
|| path == "/Login/GetValidateCode".ToLower())
{
return; //忽略权限判定
}
if (!CheckLogin(filterContext))
{
string rawUrl = filterContext.HttpContext.Request.RawUrl;
string allUrl = filterContext.HttpContext.Request.Url.ToString();
int index = allUrl.IndexOf(rawUrl);
string url = allUrl.Substring(0, index);
if (filterContext.HttpContext.Request.IsAjaxRequest())
{
filterContext.HttpContext.Response.StatusCode = 499; //尽量不要与现有的Http状态码冲突
}
filterContext.Result = new ContentResult
{
Content =
"<script language =\"javascript\" type =\"text/javascript\" >alert(\"登录超时!\");window.top.location.href = \"" +
url + "/Login/Index\";</script>"
};
}
else
{
string roleCode = filterContext.HttpContext.Session["UiRoles"].ToString();
if (_list.Count == 0)
{
Guid id = Guid.Parse(roleCode);
using (IRoleManager iRoleManager = new RoleManager())
{
Role role = iRoleManager.GetById(id);
if (role != null)
{
using (
IGenericRepository<ResourceRole> iResourceRoleRepository =
new GenericRepository<ResourceRole>())
{
IList<ResourceRole> reRl = iResourceRoleRepository.SearchFor(p => p.RlID.Equals(id));
IGenericRepository<Resource> resRepository = new GenericRepository<Resource>();
IList<Resource> relist = resRepository.GetAll();
foreach (var resourceRole in reRl)
{
Resource res = relist.First(p => p.ResourceID.Equals(resourceRole.ReID));
if (res.ReType.Equals("1") && res.State.Equals("0")&&res.URL!=null)
{
_list.Add(res.URL);
}
}
}
}
else
{
string rawUrl = filterContext.HttpContext.Request.RawUrl;
string allUrl = filterContext.HttpContext.Request.Url.ToString();
int index = allUrl.IndexOf(rawUrl);
string url = allUrl.Substring(0, index);
filterContext.Result = new ContentResult
{
Content =
"<script language =\"javascript\" type =\"text/javascript\" >alert(\"无权访问此页!\");window.top.location.href = \"" +
url + "/Login/Index\";</script>"
};
}
}
}
//if (_list.Where(p => p.ToLower().Equals(path)).Count() == 0)
//{
// string rawUrl = filterContext.HttpContext.Request.RawUrl;
// string allUrl = filterContext.HttpContext.Request.Url.ToString();
// int index = allUrl.IndexOf(rawUrl);
// string url = allUrl.Substring(0, index);
// filterContext.Result = new ContentResult
// {
// Content =
// "<script language =\"javascript\" type =\"text/javascript\" >alert(\"无权访问此页!\");window.top.location.href = \"" +
// url + "/Login/Index\";</script>"
// };
//}
}
}