public JsonResult SendText(string txt)
        {
            string resultMsg = WXApi.Send(GetToken(), WXApiJson.CreateTextJson(txt, WXApi.GetOpenIDs(GetToken())));

            return(Json("ok", JsonRequestBehavior.AllowGet));
        }
        public JsonResult SendNewGroup(string media_id)
        {
            string resultMsg = WXApi.Send(GetToken(), WXApiJson.CreateNewsJson(media_id, WXApi.GetOpenIDs(GetToken())));

            return(Json("ok", JsonRequestBehavior.AllowGet));
        }
        public JsonResult AsyncMessage()
        {
            Hashtable hash = new Hashtable();
            IEnumerable <WX_Message> Messages = WX_MessageService.instance().GetEnumByCID(UserDateTicket.Company.ID);

            foreach (var item in Messages)
            {
                StringBuilder ArticlesJson = new StringBuilder();

                if (string.IsNullOrEmpty(item.media_id))
                {
                    ArticlesJson.Append(WXApiJson.GetArticlesJsonStr(item.ID));
                    string msg = WXApi.Material_add_news(GetToken(), ArticlesJson.ToString());

                    if (Utils.GetJsonValue(msg, "errcode") != "")
                    {
                        hash["code"]    = 0;
                        hash["errcode"] = Utils.GetJsonValue(msg, "errcode");
                        hash["errmsg"]  = Utils.GetJsonValue(msg, "errmsg");
                        return(Json(hash, JsonRequestBehavior.AllowGet));
                    }
                    string media_id = Utils.GetJsonValue(msg, "media_id");

                    string backInfo = WXApi.Material_get(GetToken(), "{\"media_id\":\"" + media_id + "\"}");
                    if (Utils.GetJsonValue(backInfo, "errcode") != "")
                    {
                        hash["code"]    = 0;
                        hash["errcode"] = Utils.GetJsonValue(msg, "errcode");
                        hash["errmsg"]  = Utils.GetJsonValue(msg, "errmsg");
                        return(Json(hash, JsonRequestBehavior.AllowGet));
                    }

                    var serializer = JsonSerializer.Create();
                    var obj        = serializer.Deserialize(new JsonTextReader(new StringReader(backInfo))) as JObject;
                    var data       = obj["news_item"];
                    for (int i = 0; i < item.Groups.Count(); i++)
                    {
                        if (string.IsNullOrEmpty(item.Groups.ToList()[i].URL))
                        {
                            item.Groups.ToList()[i].URL = JsonHelper.GetJsonValue(data[i].ToString(), "url");
                            WX_MessageGroupService.instance().Update(item.Groups.ToList()[i]);
                        }
                    }
                    item.media_id = media_id;
                    WX_MessageService.instance().Update(item);
                }
            }
            hash["code"] = 1;
            return(Json(hash, JsonRequestBehavior.AllowGet));

            //if (Utils.GetJsonValue(msg, "errcode") == "0")
            //{
            //    return Json(new { code = 1, msg = "" }, JsonRequestBehavior.AllowGet);// "{\"code\":1,\"msg\":\"\"}";
            //}
            //else
            //{
            //    return Json(new
            //    {
            //        code = 0,
            //        msg = "errcode:" +
            //            Utils.GetJsonValue(msg, "errcode") +
            //            ", errmsg:" + Utils.GetJsonValue(msg, "errmsg")
            //    }, JsonRequestBehavior.AllowGet);
            //}
        }