public static void LoadToken()
 {
     string fileName = GetTokenFileName();
     if (File.Exists(fileName))
     {
         fCurrent = new JsAccessToken();
         fCurrent.ReadFromFile("Json", WeConst.JS_MODE, fileName, ReadSettings.Default, QName.Toolkit);
     }
 }
Exemple #2
0
        public static void LoadToken()
        {
            string fileName = GetTokenFileName();

            if (File.Exists(fileName))
            {
                fCurrent = new JsAccessToken();
                fCurrent.ReadFromFile("Json", WeConst.JS_MODE, fileName, ReadSettings.Default, QName.Toolkit);
            }
        }
Exemple #3
0
        private static JsAccessToken CreateToken()
        {
            string url;

            if (WeixinSettings.Current.Mode == WeixinMode.Normal)
            {
                url = WeUtil.GetUrl(WeConst.JS_TICKET);
            }
            else
            {
                url = WeCorpUtil.GetCorpUrl(WeCorpConst.JS_TICKET, WeixinSettings.Current.CorpUserManagerSecret);
            }
            JsAccessToken token = ReadToken(url, WeConst.JS_MODE, new JsAccessToken());

            SaveToken(token);
            return(token);
        }
        public void AppStarting(object application, BaseAppSetting appsetting,
                                BaseGlobalVariable globalVariable)
        {
            string path = Path.Combine(appsetting.XmlPath, "weixin.xml");

            if (File.Exists(path))
            {
                WeixinXml xml = new WeixinXml();
                xml.ReadXmlFromFile(path);
                WeixinSettings.Current = new WeixinSettings(xml);
                if (WeixinSettings.Current.Mode == WeixinMode.Normal)
                {
                    AccessToken.LoadToken();
                    JsAccessToken.LoadToken();
                }
                else
                {
                    CorpAccessTokenList.LoadToken();
                }
            }
        }
Exemple #5
0
        private static void SaveToken(JsAccessToken fCurrent)
        {
            string fileName = GetTokenFileName();

            FileUtil.VerifySaveFile(fileName, fCurrent.WriteJson(WeConst.JS_MODE), Encoding.UTF8);
        }
 private static void SaveToken(JsAccessToken fCurrent)
 {
     string fileName = GetTokenFileName();
     FileUtil.VerifySaveFile(fileName, fCurrent.WriteJson(WeConst.JS_MODE), Encoding.UTF8);
 }