ASP.NET MVC ApiControllerフィルタ処理返却結果

1152 ワード

    public class OpenIdAutoDecryptAttr : ActionFilterAttribute
    {
        public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
        {
            base.OnActionExecuted(actionExecutedContext);
            var objectContent = actionExecutedContext.Response.Content as ObjectContent;
            if (objectContent != null && objectContent.Value != null && (objectContent.Value.GetType().BaseType == typeof(Parm) || objectContent.Value.GetType() == typeof(Parm)))
            {
                Parm parm = (Parm)objectContent.Value;
                if (!String.IsNullOrEmpty(parm.ErrMsg))
                {
                    LogUtil.DoLog("ErrMsg Before", parm.ErrMsg);
                    Regex regex = new Regex(@"(ORA-[0-9]{1,}:)(.*)\r
(.*)"); if (regex.IsMatch(parm.ErrMsg)) { parm.ErrMsg = regex.Match(parm.ErrMsg).Result("$2").Trim(); } LogUtil.DoLog("ErrMsg After", parm.ErrMsg); } } } }