I have a controller:
我有一个控制器:
private readonly IUserService _userService;
public ReportController ( IOptions<AppSettings> appSettings,
UserManager<ApplicationUser> userManager,
IUserService userService ) : base( appSettings, userManager ) {
_userService = userService;
}
public async Task<ActionResult> Report ( string path ) {
var currentUser = await GetCurrentUserAsync();
var excludedItems = _userService.GetUserExcludedReportsById( currentUser.Id ).Select( er => er.Path );
if ( string.IsNullOrEmpty( path ) || excludedItems.Any( path.Contains ) ) {
return RedirectToAction( nameof(HomeController.Index), "Home" );
}
var customItems = _userService.GetUserCustomReportsById( currentUser.Id ).Select( er => er.Path );
if ( path.Contains( AppSettings.CustomReportsFolderName ) && !customItems.Any( path.Contains ) ) {
return RedirectToAction( nameof(HomeController.Index), "Home" );
}
var model = GetReportViewerModel( Request );
model.Parameters.Clear();
var dbname = _userService.GetDefaultDbName( (await GetCurrentUserAsync()).Id );
model.Parameters.Add( "connectionStr", new[] {
dbname
} );
model.ReportPath = path;
model.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Ntlm;
return View( "Report", model );
}
}
private reado