Exemplo n.º 1
0
        public GridPage <DingClassify> addNews([FromBody] DingNew newsDetail, int classifyId)
        {
            var ress = new GridPage <DingClassify>()
            {
                code = ResCode.Success
            };

            //using (var mdReader = new StringReader(newsDetail.OriginalContent))
            //{
            //    using (var html = new StringWriter())
            //    {
            //        CommonMark.CommonMarkConverter.Convert(mdReader, html);
            //        newsDetail.HtmlContent = html.ToString();
            //    }
            //}
            ress = DataBaseHelper <DingClassify> .Get(_uowProvider, ress, classifyId, x => x.Include(a => a.DingNews));

            ress.data.DingNews.Add(newsDetail);
            ress = DataBaseHelper <DingClassify> .Create(_uowProvider, ress.data, ress, true);

            if (newsDetail.Status == 1)
            {
                OapiMessageCorpconversationAsyncsendV2Request.MsgDomain obj1 = new OapiMessageCorpconversationAsyncsendV2Request.MsgDomain();
                obj1.Msgtype = "link";
                OapiMessageCorpconversationAsyncsendV2Request.LinkDomain obj2 = new OapiMessageCorpconversationAsyncsendV2Request.LinkDomain();
                obj2.PicUrl     = newsDetail.Image;
                obj2.MessageUrl = "eapp://pages/detail/index?id=" + ress.data.Id;
                obj2.Text       = newsDetail.SubTitle;
                obj2.Title      = newsDetail.Title;
                obj1.Link       = obj2;
                var res = DingTalkHelper.PushMessage("1814645351680963", null, "", obj1);
            }
            return(ress);
        }
Exemplo n.º 2
0
        public GridPage <DingNew> editNew([FromBody] DingNew newsDetail, int classifyId)
        {
            var res = new GridPage <DingClassify>()
            {
                code = ResCode.Success
            };
            var ress = new GridPage <DingNew>()
            {
                code = ResCode.Success
            };

            res = DataBaseHelper <DingClassify> .Get(_uowProvider, res, classifyId, x => x.Include(a => a.DingNews));

            var model = res.data.DingNews.Where(a => a.Id == newsDetail.Id).FirstOrDefault();

            if (model != null)
            {
                //model.Image = newsDetail.Image;
                //model.OriginalContent = newsDetail.OriginalContent;
                //model.Status = newsDetail.Status;
                //model.Title = newsDetail.Title;
                //model.UpdateTime = DateTime.Now;
                //model.HtmlContent = newsDetail.HtmlContent;
                //model.Editer = newsDetail.Editer;
                //model.SubTitle = newsDetail.SubTitle;
                newsDetail.DingClassify = res.data;
                newsDetail.CreateTime   = model.CreateTime;
                newsDetail.UpdateTime   = DateTime.Now;
                if (newsDetail.Status == 1)
                {
                    OapiMessageCorpconversationAsyncsendV2Request.MsgDomain obj1 = new OapiMessageCorpconversationAsyncsendV2Request.MsgDomain();
                    obj1.Msgtype = "link";
                    OapiMessageCorpconversationAsyncsendV2Request.LinkDomain obj2 = new OapiMessageCorpconversationAsyncsendV2Request.LinkDomain();
                    obj2.PicUrl     = newsDetail.Image;
                    obj2.MessageUrl = "eapp://pages/detail/index?id=" + res.data.Id;
                    obj2.Text       = newsDetail.SubTitle;
                    obj2.Title      = newsDetail.Title;
                    obj1.Link       = obj2;
                    var result = DingTalkHelper.PushMessage("1814645351680963", null, "", obj1);
                }
                ress = DataBaseHelper <DingNew> .Edit(_uowProvider, newsDetail, ress);
            }
            else
            {
                ress.code = ResCode.Error;
                ress.msg  = "记录不存在";
            }

            return(ress);
        }