Exemple #1
0
        public ContentCheckInfo GetCheckInfoByLastId(string tableName, int contentId)
        {
            ContentCheckInfo checkInfo = null;

            //var sqlString = "SELECT TOP 1 Id, TableName, SiteId, ChannelId, ContentId, IsAdmin, UserName, IsChecked, CheckedLevel, CheckDate, Reasons FROM siteserver_ContentCheck WHERE TableName = @TableName AND ContentId = @ContentId ORDER BY Id DESC";
            var sqlString = SqlUtils.ToTopSqlString(TableName, "Id, TableName, SiteId, ChannelId, ContentId, IsAdmin, UserName, IsChecked, CheckedLevel, CheckDate, Reasons", "WHERE TableName = @TableName AND ContentId = @ContentId", "ORDER BY Id DESC", 1);

            var parms = new IDataParameter[]
            {
                GetParameter(ParmTableName, DataType.VarChar, 50, tableName),
                GetParameter(ParmContentId, DataType.Integer, contentId)
            };

            using (var rdr = ExecuteReader(sqlString, parms))
            {
                if (rdr.Read())
                {
                    var i = 0;
                    checkInfo = new ContentCheckInfo(GetInt(rdr, i++), GetString(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetBool(rdr, i++), GetString(rdr, i++), GetBool(rdr, i++), GetInt(rdr, i++), GetDateTime(rdr, i++), GetString(rdr, i));
                }
                rdr.Close();
            }

            return(checkInfo);
        }
Exemple #2
0
        public ContentCheckInfo GetCheckInfoByLastId(string tableName, int contentId)
        {
            ContentCheckInfo checkInfo = null;

            //var sqlString = "SELECT TOP 1 CheckID, TableName, PublishmentSystemID, NodeID, ContentID, IsAdmin, UserName, IsChecked, CheckedLevel, CheckDate, Reasons FROM bairong_ContentCheck WHERE TableName = @TableName AND ContentID = @ContentID ORDER BY CheckID DESC";
            var sqlString = SqlUtils.GetTopSqlString(TableName, "CheckID, TableName, PublishmentSystemID, NodeID, ContentID, IsAdmin, UserName, IsChecked, CheckedLevel, CheckDate, Reasons", "WHERE TableName = @TableName AND ContentID = @ContentID ORDER BY CheckID DESC", 1);

            var parms = new IDataParameter[]
            {
                GetParameter(ParmTableName, EDataType.VarChar, 50, tableName),
                GetParameter(ParmContentid, EDataType.Integer, contentId)
            };

            using (var rdr = ExecuteReader(sqlString, parms))
            {
                if (rdr.Read())
                {
                    var i = 0;
                    checkInfo = new ContentCheckInfo(GetInt(rdr, i++), GetString(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetBool(rdr, i++), GetString(rdr, i++), GetBool(rdr, i++), GetInt(rdr, i++), GetDateTime(rdr, i++), GetString(rdr, i));
                }
                rdr.Close();
            }

            return(checkInfo);
        }
Exemple #3
0
        public void Insert(ContentCheckInfo checkInfo)
        {
            const string sqlString = "INSERT INTO siteserver_ContentCheck (TableName, SiteId, ChannelId, ContentId, UserName, IsChecked, CheckedLevel, CheckDate, Reasons) VALUES (@TableName, @SiteId, @ChannelId, @ContentId, @UserName, @IsChecked, @CheckedLevel, @CheckDate, @Reasons)";

            var parms = new IDataParameter[]
            {
                GetParameter(ParmTableName, DataType.VarChar, 50, checkInfo.TableName),
                GetParameter(ParmSiteId, DataType.Integer, checkInfo.SiteId),
                GetParameter(ParmChannelId, DataType.Integer, checkInfo.ChannelId),
                GetParameter(ParmContentId, DataType.Integer, checkInfo.ContentId),
                GetParameter(ParmUserName, DataType.VarChar, 255, checkInfo.UserName),
                GetParameter(ParmIsChecked, DataType.VarChar, 18, checkInfo.IsChecked.ToString()),
                GetParameter(ParmCheckedLevel, DataType.Integer, checkInfo.CheckedLevel),
                GetParameter(ParmCheckDate, DataType.DateTime, checkInfo.CheckDate),
                GetParameter(ParmReasons, DataType.VarChar, 255, checkInfo.Reasons),
            };

            ExecuteNonQuery(sqlString, parms);
        }
Exemple #4
0
        public void Insert(ContentCheckInfo checkInfo)
        {
            const string sqlString = "INSERT INTO bairong_ContentCheck (TableName, PublishmentSystemID, NodeID, ContentID, IsAdmin, UserName, IsChecked, CheckedLevel, CheckDate, Reasons) VALUES (@TableName, @PublishmentSystemID, @NodeID, @ContentID, @IsAdmin, @UserName, @IsChecked, @CheckedLevel, @CheckDate, @Reasons)";

            var parms = new IDataParameter[]
            {
                GetParameter(ParmTableName, EDataType.VarChar, 50, checkInfo.TableName),
                GetParameter(ParmPublishmentsystemid, EDataType.Integer, checkInfo.PublishmentSystemId),
                GetParameter(ParmNodeid, EDataType.Integer, checkInfo.NodeId),
                GetParameter(ParmContentid, EDataType.Integer, checkInfo.ContentId),
                GetParameter(ParmIsAdmin, EDataType.VarChar, 18, checkInfo.IsAdmin.ToString()),
                GetParameter(ParmUserName, EDataType.NVarChar, 255, checkInfo.UserName),
                GetParameter(ParmIsChecked, EDataType.VarChar, 18, checkInfo.IsChecked.ToString()),
                GetParameter(ParmCheckedLevel, EDataType.Integer, checkInfo.CheckedLevel),
                GetParameter(ParmCheckDate, EDataType.DateTime, checkInfo.CheckDate),
                GetParameter(ParmReasons, EDataType.NVarChar, 255, checkInfo.Reasons),
            };

            ExecuteNonQuery(sqlString, parms);
        }
Exemple #5
0
        public ContentCheckInfo GetCheckInfo(int checkId)
        {
            ContentCheckInfo checkInfo = null;

            var parms = new IDataParameter[]
            {
                GetParameter(ParmId, DataType.Integer, checkId)
            };

            using (var rdr = ExecuteReader(SqlSelect, parms))
            {
                if (rdr.Read())
                {
                    var i = 0;
                    checkInfo = new ContentCheckInfo(GetInt(rdr, i++), GetString(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetBool(rdr, i++), GetString(rdr, i++), GetBool(rdr, i++), GetInt(rdr, i++), GetDateTime(rdr, i++), GetString(rdr, i));
                }
                rdr.Close();
            }

            return(checkInfo);
        }
        public IHttpActionResult Submit()
        {
            try
            {
                var request = new AuthenticatedRequest();

                var siteId             = request.GetPostInt("siteId");
                var channelId          = request.GetPostInt("channelId");
                var contentIdList      = TranslateUtils.StringCollectionToIntList(request.GetPostString("contentIds"));
                var checkedLevel       = request.GetPostInt("checkedLevel");
                var isTranslate        = request.GetPostBool("isTranslate");
                var translateChannelId = request.GetPostInt("translateChannelId");
                var reasons            = request.GetPostString("reasons");

                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasChannelPermissions(siteId, channelId,
                                                                        ConfigManager.ChannelPermissions.ContentCheck))
                {
                    return(Unauthorized());
                }

                var siteInfo = SiteManager.GetSiteInfo(siteId);
                if (siteInfo == null)
                {
                    return(BadRequest("无法确定内容对应的站点"));
                }

                var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId);
                if (channelInfo == null)
                {
                    return(BadRequest("无法确定内容对应的栏目"));
                }

                var isChecked = checkedLevel >= siteInfo.Additional.CheckContentLevel;
                if (isChecked)
                {
                    checkedLevel = 0;
                }
                var tableName = ChannelManager.GetTableName(siteInfo, channelInfo);

                var contentInfoList = new List <ContentInfo>();
                foreach (var contentId in contentIdList)
                {
                    var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId);
                    if (contentInfo == null)
                    {
                        continue;
                    }

                    contentInfo.Set(ContentAttribute.CheckUserName, request.AdminName);
                    contentInfo.Set(ContentAttribute.CheckDate, DateTime.Now);
                    contentInfo.Set(ContentAttribute.CheckReasons, reasons);

                    contentInfo.IsChecked    = isChecked;
                    contentInfo.CheckedLevel = checkedLevel;

                    if (isTranslate && translateChannelId > 0)
                    {
                        var translateChannelInfo = ChannelManager.GetChannelInfo(siteId, translateChannelId);
                        contentInfo.ChannelId = translateChannelInfo.Id;
                        DataProvider.ContentDao.Update(siteInfo, translateChannelInfo, contentInfo);
                    }
                    else
                    {
                        DataProvider.ContentDao.Update(siteInfo, channelInfo, contentInfo);
                    }

                    contentInfoList.Add(contentInfo);

                    var checkInfo = new ContentCheckInfo(0, tableName, siteId, contentInfo.ChannelId, contentInfo.Id, request.AdminName, isChecked, checkedLevel, DateTime.Now, reasons);
                    DataProvider.ContentCheckDao.Insert(checkInfo);
                }

                if (isTranslate && translateChannelId > 0)
                {
                    ContentManager.RemoveCache(tableName, channelId);
                    var translateTableName = ChannelManager.GetTableName(siteInfo, translateChannelId);
                    ContentManager.RemoveCache(translateTableName, translateChannelId);
                }

                request.AddSiteLog(siteId, "批量审核内容");

                foreach (var contentInfo in contentInfoList)
                {
                    CreateManager.CreateContent(siteId, contentInfo.ChannelId, contentInfo.Id);
                }
                CreateManager.TriggerContentChangedEvent(siteId, channelId);
                if (isTranslate && translateChannelId > 0)
                {
                    CreateManager.TriggerContentChangedEvent(siteId, translateChannelId);
                }

                return(Ok(new
                {
                    Value = contentIdList
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
Exemple #7
0
        public CheckResult Check([FromBody] CheckRequest request)
        {
            var req = new AuthenticatedRequest();

            if (!req.IsApiAuthenticated ||
                !AccessTokenManager.IsScope(req.ApiToken, AccessTokenManager.ScopeContents))
            {
                return(Request.Unauthorized <CheckResult>());
            }

            var site = SiteManager.GetSiteInfo(request.SiteId);

            if (site == null)
            {
                return(Request.BadRequest <CheckResult>("无法确定内容对应的站点"));
            }

            var contents = new List <Dictionary <string, object> >();

            foreach (var channelContentId in request.Contents)
            {
                var channel   = ChannelManager.GetChannelInfo(request.SiteId, channelContentId.ChannelId);
                var tableName = ChannelManager.GetTableName(site, channel);
                var content   = ContentManager.GetContentInfo(site, channel, channelContentId.Id);
                if (content == null)
                {
                    continue;
                }

                content.Set(ContentAttribute.CheckUserName, req.AdminName);
                content.Set(ContentAttribute.CheckDate, DateTime.Now);
                content.Set(ContentAttribute.CheckReasons, request.Reasons);
                content.Checked      = true;
                content.CheckedLevel = 0;

                DataProvider.ContentDao.Update(site, channel, content);

                contents.Add(content.ToDictionary());

                var contentCheck = new ContentCheckInfo
                {
                    TableName    = tableName,
                    SiteId       = request.SiteId,
                    ChannelId    = content.ChannelId,
                    ContentId    = content.Id,
                    UserName     = req.AdminName,
                    IsChecked    = true,
                    CheckedLevel = 0,
                    CheckDate    = DateTime.Now,
                    Reasons      = request.Reasons
                };

                DataProvider.ContentCheckDao.Insert(contentCheck);
            }

            req.AddSiteLog(request.SiteId, "批量审核内容");

            foreach (var content in request.Contents)
            {
                CreateManager.CreateContent(request.SiteId, content.ChannelId, content.Id);
            }

            foreach (var distinctChannelId in request.Contents.Select(x => x.ChannelId).Distinct())
            {
                CreateManager.TriggerContentChangedEvent(request.SiteId, distinctChannelId);
            }

            CreateManager.CreateChannel(request.SiteId, request.SiteId);

            return(new CheckResult
            {
                Contents = contents
            });
        }