/// <summary> /// 方法执行前,如果没有登录就调整到Passport登录页面,没有权限就抛出信息 /// </summary> /// <param name="filterContext"></param> protected override void OnActionExecuting(ActionExecutingContext filterContext) { #region [1、验证是否在服务时间内] var startTimeStr = AppConfigurationHelper.GetString("SystemRunStartTime"); var endTimeStr = AppConfigurationHelper.GetString("SystemRunEndTime"); //没有配置时间 if (!string.IsNullOrEmpty(startTimeStr) && !string.IsNullOrEmpty(endTimeStr)) { var startTime = DataTypeConvertHelper.ToDateTime(startTimeStr); var endTime = DataTypeConvertHelper.ToDateTime(endTimeStr); if (startTime <= new DateTime(1900, 1, 1) || endTime <= new DateTime(1900, 1, 1)) { filterContext.Result = Request.UrlReferrer != null?Stop("系统运行时间配置错误!", Request.UrlReferrer.AbsoluteUri) : Content("系统运行时间配置错误!"); return; } startTime = new DateTime(1900, 1, 1, startTime.Hour, startTime.Minute, startTime.Second); endTime = new DateTime(1900, 1, 1, endTime.Hour, endTime.Minute, endTime.Second); var newTime = DateTime.Now; newTime = new DateTime(1900, 1, 1, newTime.Hour, newTime.Minute, newTime.Second); if (newTime < startTime || newTime > endTime) { filterContext.Result = Request.UrlReferrer != null?Stop("系统处于维护期!", Request.UrlReferrer.AbsoluteUri) : Content("系统处于维护期!"); } } #endregion }
public ActionResult GetStatisticalData(string startTime = null, string endTime = null, long costChannel = 0) { var resultMode = new ResponseBaseModel <dynamic> { ResultCode = ResponceCodeEnum.Fail, Message = "" }; var userId = CurrentModel.UserId; if (userId < 1) { resultMode.Message = "登录失效,请重新登录"; } else { var beginTime = DataTypeConvertHelper.ToDateTime(startTime); var closeTime = DataTypeConvertHelper.ToDateTime(endTime); var server = new CostContentService(); var data = server.GetStatisticsCanPay(userId, beginTime, closeTime, costChannel); resultMode.Data = data; resultMode.ResultCode = ResponceCodeEnum.Success; } return(Json(resultMode, JsonRequestBehavior.AllowGet)); }
public ActionResult CustomerCommentListPage(FlagEnum hasDeal, string beginTime, string endTime, int pageIndex = 1, int pageSize = 10) { if (pageIndex < 1) { pageIndex = 1; } pageSize = pageSize < 1 ? PageSize : pageSize; var beginDateTime = DataTypeConvertHelper.ToDateTime(beginTime, new DateTime(1900, 1, 1)); var endDateTime = DataTypeConvertHelper.ToDateTime(endTime, new DateTime(1900, 1, 1)); var server = new CustomerCommentService(); var dataList = server.GetList(beginDateTime, endDateTime, hasDeal, pageIndex, pageSize, out var count); var resultMode = new ResponseBaseModel <dynamic> { ResultCode = ResponceCodeEnum.Success, Message = "响应成功", Data = new { count, dataList } }; return(Json(resultMode, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 方法执行前,如果没有登录就调整到Passport登录页面,没有权限就抛出信息 /// </summary> /// <param name="filterContext"></param> protected override void OnActionExecuting(ActionExecutingContext filterContext) { #region [1、验证是否在服务时间内] var startTimeStr = AppConfigurationHelper.GetString("SystemRunStartTime"); var endTimeStr = AppConfigurationHelper.GetString("SystemRunEndTime"); //没有配置时间 if (!string.IsNullOrEmpty(startTimeStr) && !string.IsNullOrEmpty(endTimeStr)) { var startTime = DataTypeConvertHelper.ToDateTime(startTimeStr); var endTime = DataTypeConvertHelper.ToDateTime(endTimeStr); if (startTime <= new DateTime(1900, 1, 1) || endTime <= new DateTime(1900, 1, 1)) { filterContext.Result = Request.UrlReferrer != null?Stop("系统运行时间配置错误!", Request.UrlReferrer.AbsoluteUri) : Content("系统运行时间配置错误!"); return; } startTime = new DateTime(1900, 1, 1, startTime.Hour, startTime.Minute, startTime.Second); endTime = new DateTime(1900, 1, 1, endTime.Hour, endTime.Minute, endTime.Second); var newTime = DateTime.Now; newTime = new DateTime(1900, 1, 1, newTime.Hour, newTime.Minute, newTime.Second); if (newTime < startTime || newTime > endTime) { filterContext.Result = Request.UrlReferrer != null?Stop("系统处于维护期!", Request.UrlReferrer.AbsoluteUri) : Content("系统处于维护期!"); return; } } #endregion var noAuthorizeAttributes = filterContext.ActionDescriptor.GetCustomAttributes(typeof(AuthorizeIgnoreAttribute), false); if (noAuthorizeAttributes.Length > 0) { return; } base.OnActionExecuting(filterContext); if (CurrentModel == null) { filterContext.Result = RedirectToAction("Login", "Auth"); return; } var permissionAttributes = filterContext.ActionDescriptor.ControllerDescriptor.GetCustomAttributes(typeof(PermissionAttribute), false).Cast <PermissionAttribute>(); permissionAttributes = filterContext.ActionDescriptor.GetCustomAttributes(typeof(PermissionAttribute), false).Cast <PermissionAttribute>().Union(permissionAttributes); var attributes = permissionAttributes as IList <PermissionAttribute> ?? permissionAttributes.ToList(); var showBanner = string.Empty; if (attributes.Any()) { var hasPermission = true; foreach (var attr in attributes) { foreach (var permission in attr.Permissions) { if (!CurrentModel.BusinessPermissionList.Contains(permission)) { hasPermission = false; break; } } } if (!hasPermission) { if (Request.UrlReferrer != null) { filterContext.Result = Stop("没有权限!", Request.UrlReferrer.AbsoluteUri); } else { filterContext.Result = Content("没有权限!"); } } if (attributes.Count > 1) { MenuId = attributes[0].Permissions.FirstOrDefault().GetHashCode(); ManagerId = attributes[1].Permissions.FirstOrDefault().GetHashCode(); showBanner = EnumHelper.GetDescriptionByEnum(attributes[1].Permissions.FirstOrDefault()); showBanner += "/" + EnumHelper.GetDescriptionByEnum(attributes[0].Permissions.FirstOrDefault()); } else { ManagerId = attributes[0].Permissions.FirstOrDefault().GetHashCode(); showBanner = EnumHelper.GetDescriptionByEnum(attributes[0].Permissions.FirstOrDefault()); } } ViewBag.ShowBanner = showBanner; ViewBag.ManagerId = ManagerId; ViewBag.MenuId = MenuId; }