Exemplo n.º 1
0
        /// <summary>
        /// 添加要发送的帖子
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public AjaxResult <Object> AddPostcontent(PostContentReq req)
        {
            Postcontent model_1 = db.Postcontent.Where(w => w.MsgTitle == req.MsgTitle).FirstOrDefault();

            if (model_1 != null)
            {
                return(new AjaxResult <Object>("此帖子已经发送过,请不要重复发送!"));
            }

            Postcontent model = new Postcontent();

            model.MsgTitle        = req.MsgTitle.Trim().Replace(" ", "");
            model.MsgContent      = req.MsgContent.Trim().Replace(" style=\"white-space: nowrap;\"", "");
            model.MsgAuthor       = req.MsgAuthor.Trim();
            model.CreateTime      = DateTime.Now;
            model.CreateManagerId = req.CreateManagerID;
            model.CreateUserId    = req.CreateUserID;
            model.CreateType      = (int)AIDB.Enum.PostContentEnum.CreateType.人工创建;
            model.OpenStatus      = (int)AIDB.Enum.PostContentEnum.OpenStatus.未发布;
            model.CreateUserType  = (int)AIDB.Enum.PostContentEnum.CreateUserType.管理员;
            model.MsgType         = req.MsgType;
            model.PlatformIds     = req.PlatformIDs;
            //model.SubChannelId = req.SubChannelID;
            model.HeadImg       = req.HeadImg;
            model.HeadImgServer = req.HeadImgServer;
            db.Postcontent.Add(model);

            if (db.SaveChanges() > 0)
            {
                return(new AjaxResult <Object>("添加成功!", 0));
            }
            return(new AjaxResult <Object>("添加失败!"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 编辑要发送的帖子
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public AjaxResult <Object> EditPostcontent(PostContentReq req)
        {
            Postcontent model = db.Postcontent.Where(w => w.Id == req.ID).FirstOrDefault();

            if (model == null)
            {
                return(new AjaxResult <Object>("您编辑的帖子信息不存在!"));
            }

            model.MsgTitle      = req.MsgTitle.Trim().Replace(" ", "");
            model.MsgContent    = req.MsgContent.Trim().Replace(" style=\"white-space: nowrap;\"", "");
            model.MsgAuthor     = req.MsgAuthor.Trim();
            model.HeadImg       = req.HeadImg.Trim();
            model.HeadImgServer = req.HeadImgServer.Trim();
            //model.CreateTime = req.CreateTime;
            //model.CreateManagerId = req.CreateManagerID;
            //model.CreateUserId = req.CreateUserID;
            //model.CreateType = req.CreateType;
            model.OpenStatus = req.OpenStatus;
            //model.CreateUserType = req.CreateUserType;
            model.MsgType     = req.MsgType;
            model.PlatformIds = req.PlatformIDs;
            //model.SubChannelId = req.SubChannelID;
            if (db.SaveChanges() > 0)
            {
                return(new AjaxResult <Object>("编辑成功!", 0));
            }
            return(new AjaxResult <Object>("编辑失败!"));
        }
Exemplo n.º 3
0
        public JsonResult Ajax_PostJRTTWenZhang(string PYScript, long id, string HeadImg)
        {
            if (id < 1)
            {
                return(Json(new AjaxResult <Object>("信息错误!")));
            }
            if (string.IsNullOrWhiteSpace(PYScript))
            {
                return(Json(new AjaxResult <Object>("脚本地址错误!")));
            }
            if (string.IsNullOrWhiteSpace(HeadImg))
            {
                return(Json(new AjaxResult <Object>("请上传首页头图!")));
            }

            Postcontent model = pc.SelPostcontent(id);

            if (model == null)
            {
                return(Json(new AjaxResult <Object>("文章不存在!")));
            }

            //循环查询脚本
            var pids = model.PlatformIds.Split(',');

            foreach (var item in pids)
            {
                Subchannel md = sh.SelSubchannel((long)Convert.ToInt32(item));
                if (md != null)
                {
                    if (string.IsNullOrWhiteSpace(md.PyscriptLongEssay))
                    {
                        return(Json(new AjaxResult <Object>("渠道《" + md.SubChannelName + "》,没有填写发布 长文 脚本!")));
                    }
                    if (string.IsNullOrWhiteSpace(md.AnalogPacket))
                    {
                        return(Json(new AjaxResult <Object>("渠道COOKIE错误!")));
                    }

                    //base64加密(COOKIE)
                    string ck = EncodeBase64("utf-8", md.AnalogPacket);

                    //base64加密(内容)
                    string content = jc.EncodeBase64("utf-8", UpdateContent(model.MsgContent));

                    string script = PYScript + " " + model.HeadImg.Replace(" ", "") + " " + model.MsgTitle.Replace(" ", "") + " " + ck + " " + content;


                    //PY执行脚本
                    return(Ajax_PublicPostWTT(script, id));
                }
            }

            return(Json(new AjaxResult <Object>("发布完成!", 0)));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 修改  是否发布状态
        /// </summary>
        /// <param name="id"></param>
        /// <param name="status"></param>
        public int UpOpenStatus(long id, int status)
        {
            Postcontent model = db.Postcontent.Where(w => w.Id == id).FirstOrDefault();

            if (model != null)
            {
                model.OpenStatus = status;
                return(db.SaveChanges());
            }

            return(0);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public AjaxResult <object> DelPostcontent(long id)
        {
            if (id < 1)
            {
                return(new AjaxResult <Object>("请选择您要删除的帖子信息!"));
            }
            Postcontent model = db.Postcontent.Where(w => w.Id == id).FirstOrDefault();

            if (model == null)
            {
                return(new AjaxResult <Object>("帖子信息不存在!"));
            }
            db.Postcontent.Remove(model);
            if (db.SaveChanges() > 0)
            {
                return(new AjaxResult <Object>("删除成功!", 0));
            }
            return(new AjaxResult <Object>("删除失败!"));
        }