Esempio n. 1
0
        private string RefreshAccessToken()
        {
            string text  = "AccessToken-" + Appid;
            string text2 = Cache.ReadCache(text).ToMyString();
            string result;

            if (text2 != "")
            {
                result = text2;
            }
            else
            {
                HttpHelper httpHelper = new HttpHelper();
                HttpResult html       = httpHelper.GetHtml(new HttpItem
                {
                    URL = SystemExtends.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}", new object[]
                    {
                        this.Appid,
                        this.AppSecret
                    }),
                    Method = "GET"
                });
                string            html2             = html.Html;
                accessTokenResult accessTokenResult = SystemExtends.ToObject <accessTokenResult>(html2);
                Cache.AddCache(text, accessTokenResult.access_token, DateTime.Now.AddMilliseconds((double)(accessTokenResult.expires_in - 600)));
                result = accessTokenResult.access_token;
            }
            return(result);
        }
Esempio n. 2
0
 /// <summary>
 /// 请求执行前
 /// </summary>
 /// <param name="filterContext"></param>
 void IActionFilter.OnActionExecuting(ActionExecutingContext filterContext)
 {
     if (HttpLogEnabled)
     {
         SystemExtends.LogWrite("IP:{0}-Controller:{1}-Action:{2}"
                                .format(Text.NetworkIp, filterContext.ActionDescriptor.ControllerDescriptor.ControllerName, filterContext.ActionDescriptor.ActionName), "HttpLog");
     }
 }
Esempio n. 3
0
 /// <summary>
 /// 输出日志
 /// </summary>
 /// <param name="sql"></param>
 /// <param name="msg"></param>
 /// <param name="_entity"></param>
 private void LogWrite(string sql, string msg, object _entity)
 {
     //SQLLog is true
     if (this.SqlLogEnabled)
     {
         string text = " sql: {0} \r\n msg:{1} \r\n entity: {2}";
         try
         {
             SystemExtends.LogWrite(text.format(sql, msg, _entity.ToJson()), "SqlLog");
         }
         catch (Exception)
         {
         }
     }
 }
Esempio n. 4
0
        public WX_Response sendMessage(JsonResponse model)
        {
            string     text       = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}";
            HttpHelper httpHelper = new HttpHelper();
            HttpItem   item       = new HttpItem();

            item.URL = SystemExtends.format(text, new object[]
            {
                this._accesstoken
            });
            item.Encoding     = Encoding.UTF8;
            item.PostEncoding = Encoding.UTF8;
            item.Method       = "POST";
            item.Postdata     = model.ToJson().Replace("\\\\", "\\");
            HttpResult html  = httpHelper.GetHtml(item);
            string     html2 = html.Html;

            return(SystemExtends.ToObject <WX_Response>(html2));
        }