public ActionResult Sync()
        {
            var r           = false;
            var json        = JObject.Parse(new MediaService(WXAPP.AppId, WXAPP.AppSecret).Get("news"));
            int total_count = Convert.ToInt32(json["total_count"].ToString());
            int item_count  = Convert.ToInt32(json["total_count"].ToString());

            if (total_count > item_count)    //如果总数大于单次获取的量,那么循环调用
            {
            }
            else
            {
                WX_MediaManager manager = new WX_MediaManager();
                foreach (var i in json["item"].Children())
                {
                    var           jo   = i["content"]["news_item"][0];
                    WX_Media_News news = new WX_Media_News()
                    {
                        title              = jo["title"].ToString(),
                        thumb_media_id     = jo["thumb_media_id"].ToString(),
                        show_cover_pic     = Convert.ToInt32(jo["show_cover_pic"].ToString()),
                        author             = jo["author"].ToString(),
                        digest             = jo["digest"].ToString(),
                        content            = jo["content"].ToString(),
                        content_source_url = jo["content_source_url"].ToString(),
                        url = jo["url"].ToString(),
                    };

                    WX_Media media = new WX_Media()
                    {
                        AppId        = WXAPP.AppId,
                        MediaId      = i["media_id"].ToString(),
                        MediaName    = jo["title"].ToString(),
                        MediaType    = "news",
                        MediaContent = JsonConvert.SerializeObject(news).Replace("\\", "")
                    };
                    var info = manager.Where(m => m.AppId.Equals(media.AppId) && m.MediaId.Equals(media.MediaId)).FirstOrDefault();
                    if (info != null)
                    {
                        media.MyMediaId = info.MyMediaId;
                        r = manager.Update(media);
                    }
                    else
                    {
                        r = manager.Add(media);
                    }
                }
            }
            return(Json(r, JsonRequestBehavior.AllowGet));
        }
        public ActionResult SyncImage()
        {
            string  json = new MediaService(WXAPP.AppId, WXAPP.AppSecret).Get("image");
            JObject jo   = JObject.Parse(json);

            if (jo["errcode"] != null)
            {
                return(Content("<script> alert('错误:" + jo["errmsg"].ToString() + "');</script>"));
            }
            int total_count = Convert.ToInt32(jo["total_count"]); // 该类型素材总数
            int item_count  = Convert.ToInt32(jo["item_count"]);  // 本次获取的素材数量

            if (total_count > item_count)                         //如果总数大于单次获取的量,那么循环调用
            {
            }
            else
            {
                WX_MediaManager manager = new WX_MediaManager();
                foreach (var i in jo["item"].Children())
                {
                    var media = new WX_Media()
                    {
                        AppId        = WXAPP.AppId,
                        MediaId      = i["media_id"].ToString(),
                        MediaName    = i["name"].ToString(),
                        MediaType    = "image",
                        MediaContent = i["url"].ToString(),
                        //UploadTime = DateTime_EX.GetDateTime(Convert.ToInt32(i["update_Time"].ToString()))
                    };
                    var info = manager.GetByMediaId(media.MediaId, media.AppId);
                    if (info != null)
                    {
                        media.MyMediaId = info.MyMediaId;
                        var r = manager.Update(media);
                    }
                    else
                    {
                        var r = manager.Add(media);
                    }
                }
            }
            return(Json(json, JsonRequestBehavior.AllowGet));
        }