public JsonResult update(Entity.DetailInfo info, string contents, string gallery)
        {
            using (var manage = new Data.CMSManage())
            {
                string shows = this.getFormString("shows");
                if (string.IsNullOrEmpty(shows))
                {
                    info.Show = 0;
                }
                else
                {
                    var show = 0;
                    if (shows.IndexOf(',') > 0)
                    {
                        var _shows = shows.Split(',');
                        foreach (var _s in _shows)
                        {
                            show += Utils.strToInt(_s);
                        }
                    }
                    else
                    {
                        show = Utils.strToInt(shows);
                    }

                    info.Show = show;
                }
                if (info.UserId <= 0 && this.userOnlineInfo.AdminOnline)
                {
                    info.UserId = this.userOnlineInfo.AdminUserInfo.UserId;
                }

                manage.updateDetail(info);

                //更新详情
                if (!string.IsNullOrEmpty(contents))
                {
                    JavaScriptSerializer jsHelper = new JavaScriptSerializer();
                    var contentlist = jsHelper.Deserialize <List <Entity.DetailContentInfo> >(contents);
                    if (contentlist != null)
                    {
                        manage.updateDetailContent(contentlist, info.DetailId, info.ItemId, info.ChannelCode);
                    }
                }

                if (!string.IsNullOrEmpty(gallery))
                {
                    //更新图库
                    JavaScriptSerializer jsHelper = new JavaScriptSerializer();
                    var gallerylist = jsHelper.Deserialize <List <Entity.DetailGalleryInfo> >(gallery);
                    if (gallerylist != null)
                    {
                        manage.updateDetailGallery(gallerylist, info.DetailId);
                    }
                }

                return(this.getResult(manage.Error, manage.Message));
            }
        }
Beispiel #2
0
        public JsonResult updateDetail(Entity.DetailInfo info, string pics, int cid, string content, string key, string verifykey)
        {
            if (this.config.EnabledDetailVerifykey)
            {
                if (string.IsNullOrEmpty(key))
                {
                    key = "verifycode";
                }
                var code = Config.UserConfig.getVerifyCode(key);
                if (string.IsNullOrEmpty(verifykey) || code == null || !code.Code.Equals(verifykey.ToLower()))
                {
                    return(this.getResult(Entity.Error.错误, "验证码错误!"));
                }
            }
            if (info == null || string.IsNullOrEmpty(info.ChannelCode))
            {
                return(this.getResult(Entity.Error.错误, "频道错误!"));
            }
            if (string.IsNullOrEmpty(pics) && string.IsNullOrEmpty(content))
            {
                return(this.getResult(Entity.Error.错误, "内容为空!"));
            }
            using (var manage = new bitcms.Data.CMSManage())
            {
                if (this.config.VerifyUserDetail)
                {
                    info.Display = 0;
                }

                if (info.ItemId > 0)
                {
                    info.Items = info.ItemId.ToString();
                }
                info.UserId = this.userOnlineInfo.UserId;
                info.Author = this.userOnlineInfo.UserName;
                if (string.IsNullOrEmpty(info.Source))
                {
                    info.Source = this.config.SiteName;
                }
                manage.updateDetail(info);
                if (info.DetailId > 0)
                {
                    if (!string.IsNullOrEmpty(content))
                    {
                        var contentInfo = new Entity.DetailContentInfo()
                        {
                            Title       = info.Title,
                            Content     = content,
                            OrderNo     = 0,
                            DetailId    = info.DetailId,
                            ContentId   = cid,
                            ItemId      = info.ItemId,
                            ChannelCode = info.ChannelCode,
                            InDate      = Config.SiteConfig.getLocalTime()
                        };
                        manage.updateDetailContent(contentInfo);
                    }
                    if (!string.IsNullOrEmpty(pics))
                    {
                        //更新图库
                        JavaScriptSerializer jsHelper = new JavaScriptSerializer();
                        var gallerylist = jsHelper.Deserialize <List <Entity.DetailGalleryInfo> >(pics);
                        if (gallerylist != null)
                        {
                            manage.updateDetailGallery(gallerylist, info.DetailId);
                        }
                    }
                }
                if (info.Display != 1 && this.config.VerifyUserDetail)
                {
                    manage.Message = "发表成功,系统审核后将进行展示!";
                }
                else
                {
                    manage.Message = "发表成功";
                }

                return(this.getResult(manage.Error, manage.Message));
            }
        }
Beispiel #3
0
        /// <summary>
        /// 更新资讯
        /// </summary>
        /// <returns></returns>
        public bool updateDetail(Entity.DetailInfo info)
        {
            if (string.IsNullOrEmpty(info.DetailCode))
            {
                do
                {
                    info.DetailCode = Guid.NewGuid().ToString("N");
                } while (checkItemCode(info.DetailCode, info.ItemId) > 0);
            }

            var key = Utils.removeUnSafeString(info.Title);

            if (info.ItemId > 0)
            {
                var itemInfo = this.getItemInfo(info.ItemId);
                if (itemInfo != null)
                {
                    key += "," + Utils.removeUnSafeString(itemInfo.ItemName);
                }
                info.Items = getItems(info.ItemId);
            }
            if (!string.IsNullOrEmpty(info.Keyword))
            {
                info.Keyword = Utils.removeUnSafeString(info.Keyword);
            }
            if (string.IsNullOrEmpty(info.SearchKey))
            {
                info.SearchKey = string.Format("{0}|-_-|{1}", key, info.Keyword);
            }
            else
            {
                info.SearchKey = string.Format("{0},{2}|-_-|{1}", key, info.Keyword, info.SearchKey);
            }

            if (info.DetailId > 0)
            {
                var detailinfo = this.getDetailInfo(info.DetailId);
                if (info.InDate <= DateTime.MinValue)
                {
                    info.InDate = detailinfo.InDate;
                }
                if (info.DisplayTime <= DateTime.MinValue)
                {
                    info.DisplayTime = detailinfo.DisplayTime;
                }
                info.HitsNum    = detailinfo.HitsNum;
                info.ReviewNum  = detailinfo.ReviewNum;
                info.FollowNum  = detailinfo.FollowNum;
                info.AgainstNum = detailinfo.AgainstNum;
                info.AgreeNum   = detailinfo.AgreeNum;

                this.dbContext.Entry(detailinfo).CurrentValues.SetValues(info);
            }
            else
            {
                if (info.InDate <= DateTime.MinValue)
                {
                    info.InDate = Config.SiteConfig.getLocalTime();
                }
                if (info.DisplayTime <= DateTime.MinValue)
                {
                    info.DisplayTime = Config.SiteConfig.getLocalTime();
                }

                this.dbContext.Detail.Add(info);
            }
            return(this.dbContext.SaveChanges() > 0);
        }