public override void OnActionExecuting(ActionExecutingContext filterContext) { if (!Enabled) { base.OnActionExecuting(filterContext); return; } string token = filterContext.HttpContext.Request["token"]; JwtResult jwt = JwtUtil.Decode(token); if (jwt.Success) { //获取当前登录用户 IUser iUser = lessContext.GetService <IUser>(); lessContext.CurrentUser = iUser.GetCurrentUser(lessContext); if (lessContext.CurrentUser == null) { jwt.Success = false; jwt.Msg = $"获取登录帐号 {lessContext.Jwt.Result[BasicConst.JWT_USER].loginName} 信息失败,请重新登录!"; filterContext.HttpContext.Response.AddHeaderTimeOut(); filterContext.Result = new BaseJsonResult() { Data = jwt }; return; } //获取当前站点 var sysWebSiteDal = lessContext.GetService <SysWebSiteDal>(); lessContext.WebSite = sysWebSiteDal.GetModel(filterContext.HttpContext.Request["SiteID"]); //获取权限 IPermissions iPermissions = lessContext.GetService <IPermissions>(); lessContext.Limit = iPermissions.GetPermissions(lessContext, filterContext.RequestContext.HttpContext.Request); base.OnActionExecuting(filterContext); return; } else { filterContext.HttpContext.Response.AddHeaderTimeOut(); if (string.IsNullOrEmpty(WhenNotPassedRedirectUrl)) { filterContext.Result = new BaseJsonResult() { Data = jwt }; } else { filterContext.Result = new RedirectResult(WhenNotPassedRedirectUrl); } } }
public Boolean RefreshFileAttributes(IPermissions permissions) { Boolean attributesChanged = false; if (fileInfo == null) { attributesChanged = true; fileInfo = new System.IO.FileInfo(localPathAndName); } else { fileInfo.Refresh(); } // // Update file attributes // ModeFlags newPermissions = permissions.GetPermissions(this); if (newPermissions != fileAttributes.protectionMode) { attributesChanged = true; fileAttributes.protectionMode = newPermissions; } fileAttributes.hardLinks = (fileType == FileType.Directory) ? 2U : 1U; fileAttributes.ownerUid = 0; fileAttributes.gid = 0; if (fileType == FileType.Regular) { UInt64 newFileSize = (UInt64)fileInfo.Length; if (fileAttributes.fileSize != newFileSize) { attributesChanged = true; fileAttributes.fileSize = newFileSize; } fileAttributes.diskSize = fileAttributes.fileSize; } fileAttributes.specialData1 = 0; fileAttributes.specialData2 = 0; { DateTime lastAccessDateTime = fileInfo.LastAccessTime; UInt32 newLastAccessTimeSeconds = lastAccessDateTime.ToUniversalTime().ToUnixTime(); if (fileAttributes.lastAccessTime.seconds != newLastAccessTimeSeconds) { attributesChanged = true; fileAttributes.lastAccessTime.seconds = newLastAccessTimeSeconds; } } { DateTime lastModifyTime = fileInfo.LastWriteTime; UInt32 newLastModifyTimeSeconds = lastModifyTime.ToUniversalTime().ToUnixTime(); if (fileAttributes.lastModifyTime.seconds != newLastModifyTimeSeconds) { attributesChanged = true; fileAttributes.lastModifyTime.seconds = newLastModifyTimeSeconds; } } if (attributesChanged) { fileAttributes.lastAttributeModifyTime.seconds = (fileAttributes.lastAccessTime.seconds > fileAttributes.lastModifyTime.seconds) ? fileAttributes.lastAccessTime.seconds : fileAttributes.lastModifyTime.seconds; } return(attributesChanged); }