Esempio n. 1
0
        public ActionResult PublishHtml(string itemID, string toUserName, string genHtml)
        {
            var mdb   = Sitecore.Configuration.Factory.GetDatabase("master");
            var mItem = mdb.GetItem(new Sitecore.Data.ID(itemID));

            if (mItem == null)
            {
                return(Content("Item is not existing!"));
            }
            WCArticles articles   = new WCArticles();
            NewsParams newsParams = new NewsParams();

            newsParams.show_cover_pic        = 1;
            newsParams.need_open_comment     = 1;
            newsParams.only_fans_can_comment = 1;
            newsParams.title              = mItem.Fields["Title"].ToString();
            newsParams.author             = mItem.Fields["Author"].ToString();
            newsParams.digest             = mItem.Fields["Summary"].ToString();
            newsParams.thumb_media_id     = mItem.Fields["thumbnailID"].ToString();
            newsParams.content_source_url = Sitecore.Links.LinkManager.GetItemUrl(mItem);
            newsParams.content            = MsgService.Base64Decode(Request.Params["genHtml"]);

            articles.Add(newsParams);

            NewsResponse newsResponse = (NewsResponse)JsonConvert.DeserializeObject(MsgService.AddNews(articles), typeof(NewsResponse));

            using (new Sitecore.SecurityModel.SecurityDisabler())
            {
                mItem.Editing.BeginEdit();
                mItem["NewsID"] = newsResponse.Media_ID;

                mItem.Editing.EndEdit();
            }

            RTMsgID rtMsgID = new RTMsgID();

            rtMsgID.media_id = newsResponse.Media_ID;

            RTMessageInt rtMessageInt = new RTMessageInt();

            rtMessageInt.touser  = toUserName;
            rtMessageInt.msgtype = "mpnews";
            rtMessageInt.mpnews  = rtMsgID;
            string r = MsgService.SendRTMsg(rtMessageInt);

            return(Content(r));
        }