/// <summary> /// 更新永久图文素材 /// </summary> /// <param name="keyValue"></param> public void UpdateForeverNews(string keyValue) { long id = Convert.ToInt64(keyValue); string appId = WxOperatorProvider.Provider.GetCurrent().AppId; var specification = new Specification <WxNews>().FetchStrategy.Include(p => p.WxNewsItems.Select(e => e.Thumb)); WxNews wxNews = wxNewsRepository.Get(id, specification); NewsModel[] newsModel = new NewsModel[wxNews.WxNewsItems.Count()]; var index = 0; foreach (WxNewsItem wxNewsItem in wxNews.WxNewsItems) { newsModel[index] = new NewsModel(); newsModel[index].title = wxNewsItem.Title; newsModel[index].author = wxNewsItem.Author; newsModel[index].content = wxNewsItem.Content; newsModel[index].content_source_url = wxNewsItem.ContentSourceUrl; newsModel[index].digest = wxNewsItem.Digest; newsModel[index].need_open_comment = wxNewsItem.NeedOpenComment; newsModel[index].only_fans_can_comment = wxNewsItem.OnlyFansCanComment; newsModel[index].show_cover_pic = wxNewsItem.ShowCoverPic.ToString(); newsModel[index].thumb_media_id = wxNewsItem.Thumb.MediaId; newsModel[index].thumb_url = wxNewsItem.Thumb.MediaUrl; index++; } if (!string.IsNullOrEmpty(wxNews.MediaId)) { for (var i = 0; i < newsModel.Length; i++) { var wxJsonResult = MediaApi.UpdateForeverNews(appId, wxNews.MediaId, i, newsModel[i], 10000); } } }