using APT.Infrastructure.Core;
using log4net;
using Microsoft.AspNetCore.Mvc.Filters;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace APT.Infrastructure.Api
{
public class RootOrgAttribute : Attribute, IAsyncActionFilter
{
///
/// 添加根节点过滤
///
///
///
///
public async Task OnActionExecutionAsync(Microsoft.AspNetCore.Mvc.Filters.ActionExecutingContext context, ActionExecutionDelegate next)
{
try
{
var s = context.HttpContext.Request.Headers["RootOrgId"].ToString();
if (!string.IsNullOrEmpty(s))
{
AppContext.CurrentSession.RootOrgId = new Guid(s);
}
}
catch (Exception ex)
{
LoggerManager.GetLogger().Error(Infrastructure.Core.LogHelper.GetCurSourceFileName() + " - " + LogHelper.GetLineNum() + ":" + ex.Message);
//throw;
}
finally
{
await next.Invoke();
}
}
}
}