public virtual AppResult GetToken(string appcode) { var app = _appService.GetApp(appcode); var accessToken = AccessTokenManager.GetToken(CorpID, app.SecretValue); return(new AppResult { AccessToken = accessToken, AgentId = app.WeChatAppID }); }
public void GetTicket_AppCode_NotNull() { IWeChatAppService appService = container.Resolve <IWeChatAppService>(); var app = appService.GetApp(Constants.MOBILE_APPROVAL); var ticket = JsApiTicketManager.TryGetTicket("wx2e8cc6975a5fa1ce", app.SecretValue); Assert.IsNotNull(ticket); Console.WriteLine(ticket); }
public void AutoFac_Test() { var connstr = "server=.;database=dev;uid=sa;pwd=123456"; ContainerBuilder builder = new ContainerBuilder(); builder.RegisterType <WeChatAppService>().As <IWeChatAppService>(); builder.RegisterType <WeChatAppRepository>().As <IWeChatAppRepository>(); builder.RegisterInstance(EFContext.CreateForEFDesignTools(connstr)); //builder.RegisterModule(new ConfigurationSettingsReader("autofac")); //using (IContainer container = builder.Build()) //{ // AutoFacManager manager = container.Resolve<AutoFacManager>(); // manager.Say(); //} using (IContainer container = builder.Build()) { IWeChatAppService service = container.Resolve <IWeChatAppService>(); var app = service.GetApp(Constants.MOBILE_APPROVAL); Console.WriteLine(app.WeChatAppID); } }
// GET: WeChat public ActionResult Index() { var app = _currentService.GetApp(Constants.MOBILE_APPROVAL_TEST); return(View(app)); }