Ejemplo n.º 1
0
        public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            // do something before the action executes
            TokenResult = JsonConvert.DeserializeObject <OAuthAccessTokenResult>(context.HttpContext.Session.GetString("OAuthAccessTokenResult"));
            var controller = context.RouteData.Values["controller"]?.ToString();
            var actionName = context.RouteData.Values["action"]?.ToString();

            if (controller?.ToUpper() == "SCHOOLBUS" && actionName?.ToUpper() != "REGISTER" && actionName?.ToUpper() != "SENDSMSCODE")
            {
                var result = await _schoolBusBusines.GetCardInfoByCodeAsync(TokenResult?.openid);

                if (result == null || string.IsNullOrEmpty(result.fcode) || string.IsNullOrEmpty(result.wxpkid))
                {
                    context.Result = new RedirectToActionResult("Register", "SchoolBus", null);
                    return;
                }
            }
            await next();

            // do something after the action executes
            if (!(ViewData.Model is Base_JSSDKVD vd))
            {
                return;
            }
            var model = vd;

            model.TokenResult    = TokenResult;
            model.PageRenderTime = DateTime.Now;
            model.JsSdkUiPackage = JSSDKHelper.GetJsSdkUiPackage(Config.SenparcWeixinSetting.WeixinAppId,
                                                                 Config.SenparcWeixinSetting.WeixinAppSecret,
                                                                 Request.AbsoluteUri());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GoCardInfo()
        {
#if DEBUG
            const string wxid = Openid;
#else
            var wxid = TokenResult.openid;
#endif
            var result = await _schoolBusBusines.GetCardInfoByCodeAsync(wxid);

            return(View(result));
        }
Ejemplo n.º 3
0
        public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            var controller = context.RouteData.Values["controller"]?.ToString();
            var actionName = context.RouteData.Values["action"]?.ToString();

            if (controller?.ToUpper() == "SCHOOLBUS" && actionName?.ToUpper() != "REGISTER" && actionName?.ToUpper() != "SENDSMSCODE")
            {
                var result = await _schoolBusBusines.GetCardInfoByCodeAsync(_openid);

                if (result == null || string.IsNullOrEmpty(result.fcode) || string.IsNullOrEmpty(result.wxpkid))
                {
                    context.Result = new RedirectToActionResult("Register", "SchoolBus", null);// RedirectResult("~/Home/Index")
                    return;
                }
            }
            await next();
        }