public IHttpActionResult Create()
        {
            try
            {
                var request = new AuthenticatedRequest();

                var siteId        = request.GetPostInt("siteId");
                var channelId     = request.GetPostInt("channelId");
                var contentIdList = TranslateUtils.StringCollectionToIntList(request.GetPostString("contentIds"));

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

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

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

                foreach (var contentId in contentIdList)
                {
                    CreateManager.CreateContent(siteId, channelInfo.Id, contentId);
                }

                return(Ok(new
                {
                    Value = contentIdList
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
Exemple #2
0
        public IHttpActionResult Create()
        {
            try
            {
                var request = new AuthenticatedRequest();

                var siteId            = request.GetPostInt("siteId");
                var channelContentIds = request.GetPostObject <List <MinContentInfo> >("channelContentIds");

                if (!request.IsAdminLoggin)
                {
                    return(Unauthorized());
                }

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

                foreach (var channelContentId in channelContentIds)
                {
                    CreateManager.CreateContent(siteId, channelContentId.ChannelId, channelContentId.Id);
                }

                return(Ok(new
                {
                    Value = true
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
Exemple #3
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var checkedLevel = TranslateUtils.ToIntWithNagetive(DdlCheckType.SelectedValue);

            var isChecked = checkedLevel >= SiteInfo.Additional.CheckContentLevel;

            var contentInfoListToCheck = new List <ContentInfo>();
            var idsDictionaryToCheck   = new Dictionary <int, List <int> >();

            foreach (var channelId in _idsDictionary.Keys)
            {
                var channelInfo          = ChannelManager.GetChannelInfo(SiteInfo.Id, channelId);
                var contentIdList        = _idsDictionary[channelId];
                var contentIdListToCheck = new List <int>();

                int checkedLevelOfUser;
                var isCheckedOfUser = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissionsImpl, SiteInfo, channelId, out checkedLevelOfUser);

                foreach (var contentId in contentIdList)
                {
                    var contentInfo = ContentManager.GetContentInfo(SiteInfo, channelInfo, contentId);
                    if (contentInfo != null)
                    {
                        if (CheckManager.IsCheckable(contentInfo.IsChecked, contentInfo.CheckedLevel, isCheckedOfUser, checkedLevelOfUser))
                        {
                            contentInfoListToCheck.Add(contentInfo);
                            contentIdListToCheck.Add(contentId);
                        }

                        //DataProvider.ContentDao.Update(SiteInfo, channelInfo, contentInfo);

                        //CreateManager.CreateContent(SiteId, contentInfo.ChannelId, contentId);
                        //CreateManager.TriggerContentChangedEvent(SiteId, contentInfo.ChannelId);
                    }
                }
                if (contentIdListToCheck.Count > 0)
                {
                    idsDictionaryToCheck[channelId] = contentIdListToCheck;
                }
            }

            if (contentInfoListToCheck.Count == 0)
            {
                LayerUtils.CloseWithoutRefresh(Page, "alert('您的审核权限不足,无法审核所选内容!');");
                return;
            }

            var translateChannelId = TranslateUtils.ToInt(DdlTranslateChannelId.SelectedValue);

            foreach (var channelId in idsDictionaryToCheck.Keys)
            {
                var tableName     = ChannelManager.GetTableName(SiteInfo, channelId);
                var contentIdList = idsDictionaryToCheck[channelId];
                DataProvider.ContentDao.UpdateIsChecked(tableName, SiteId, channelId, contentIdList, translateChannelId, AuthRequest.AdminName, isChecked, checkedLevel, TbCheckReasons.Text);
            }

            if (translateChannelId > 0)
            {
                var tableName = ChannelManager.GetTableName(SiteInfo, translateChannelId);
                ContentManager.RemoveCache(tableName, translateChannelId);
            }

            AuthRequest.AddSiteLog(SiteId, SiteId, 0, "设置内容状态为" + DdlCheckType.SelectedItem.Text, TbCheckReasons.Text);

            foreach (var channelId in idsDictionaryToCheck.Keys)
            {
                var contentIdList = _idsDictionary[channelId];
                if (contentIdList != null)
                {
                    foreach (var contentId in contentIdList)
                    {
                        CreateManager.CreateContent(SiteId, channelId, contentId);
                        CreateManager.TriggerContentChangedEvent(SiteId, channelId);
                    }
                }
            }

            LayerUtils.CloseAndRedirect(Page, _returnUrl);
        }
Exemple #4
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            var contentId   = AuthRequest.GetQueryInt("id");
            var redirectUrl = string.Empty;

            if (contentId == 0)
            {
                try
                {
                    var tagCollection = TagUtils.ParseTagsString(TbTags.Text);
                    var dict          = BackgroundInputTypeParser.SaveAttributes(SiteInfo, _styleInfoList, Request.Form, ContentAttribute.AllAttributes.Value);

                    var contentInfo = new ContentInfo(dict)
                    {
                        ChannelId           = _channelInfo.Id,
                        SiteId              = SiteId,
                        AddUserName         = AuthRequest.AdminName,
                        LastEditDate        = DateTime.Now,
                        GroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroups.Items),
                        Title = TbTitle.Text
                    };

                    var formatString    = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatStrong"]);
                    var formatEm        = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatEM"]);
                    var formatU         = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatU"]);
                    var formatColor     = Request.Form[ContentAttribute.Title + "_formatColor"];
                    var theFormatString = ContentUtility.GetTitleFormatString(formatString, formatEm, formatU, formatColor);
                    contentInfo.Set(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title), theFormatString);

                    contentInfo.LastEditUserName = contentInfo.AddUserName;

                    foreach (ListItem listItem in CblContentAttributes.Items)
                    {
                        var value         = listItem.Selected.ToString();
                        var attributeName = listItem.Value;
                        contentInfo.Set(attributeName, value);
                    }
                    contentInfo.LinkUrl = TbLinkUrl.Text;
                    contentInfo.AddDate = TbAddDate.DateTime;
                    if (contentInfo.AddDate.Year <= DateUtils.SqlMinValue.Year)
                    {
                        contentInfo.AddDate = DateTime.Now;
                    }

                    contentInfo.CheckedLevel = TranslateUtils.ToIntWithNagetive(DdlContentLevel.SelectedValue);
                    contentInfo.IsChecked    = contentInfo.CheckedLevel >= SiteInfo.Additional.CheckContentLevel;
                    contentInfo.Tags         = TranslateUtils.ObjectCollectionToString(tagCollection, " ");

                    foreach (var service in PluginManager.Services)
                    {
                        try
                        {
                            service.OnContentFormSubmit(new ContentFormSubmitEventArgs(SiteId, _channelInfo.Id,
                                                                                       contentInfo.Id, new AttributesImpl(Request.Form), contentInfo));
                        }
                        catch (Exception ex)
                        {
                            LogUtils.AddErrorLog(service.PluginId, ex, nameof(IService.ContentFormSubmit));
                        }
                    }


                    //判断是不是有审核权限
                    int checkedLevelOfUser;
                    var isCheckedOfUser = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissionsImpl, SiteInfo, contentInfo.ChannelId, out checkedLevelOfUser);
                    if (CheckManager.IsCheckable(contentInfo.IsChecked, contentInfo.CheckedLevel, isCheckedOfUser, checkedLevelOfUser))
                    {
                        if (contentInfo.IsChecked)
                        {
                            contentInfo.CheckedLevel = 0;
                        }

                        contentInfo.Set(ContentAttribute.CheckUserName, AuthRequest.AdminName);
                        contentInfo.Set(ContentAttribute.CheckDate, DateUtils.GetDateAndTimeString(DateTime.Now));
                        contentInfo.Set(ContentAttribute.CheckReasons, string.Empty);
                    }

                    contentInfo.Id = DataProvider.ContentDao.Insert(_tableName, SiteInfo, _channelInfo, contentInfo);

                    TagUtils.AddTags(tagCollection, SiteId, contentInfo.Id);

                    CreateManager.CreateContent(SiteId, _channelInfo.Id, contentInfo.Id);
                    CreateManager.TriggerContentChangedEvent(SiteId, _channelInfo.Id);

                    AuthRequest.AddSiteLog(SiteId, _channelInfo.Id, contentInfo.Id, "添加内容",
                                           $"栏目:{ChannelManager.GetChannelNameNavigation(SiteId, contentInfo.ChannelId)},内容标题:{contentInfo.Title}");

                    ContentUtility.Translate(SiteInfo, _channelInfo.Id, contentInfo.Id, Request.Form["translateCollection"], ETranslateContentTypeUtils.GetEnumType(DdlTranslateType.SelectedValue), AuthRequest.AdminName);

                    redirectUrl = PageContentAddAfter.GetRedirectUrl(SiteId, _channelInfo.Id, contentInfo.Id,
                                                                     ReturnUrl);
                }
                catch (Exception ex)
                {
                    LogUtils.AddErrorLog(ex);
                    FailMessage($"内容添加失败:{ex.Message}");
                }
            }
            else
            {
                var contentInfo = ContentManager.GetContentInfo(SiteInfo, _channelInfo, contentId);
                try
                {
                    var tagsLast = contentInfo.Tags;

                    contentInfo.LastEditUserName = AuthRequest.AdminName;
                    contentInfo.LastEditDate     = DateTime.Now;

                    var dict = BackgroundInputTypeParser.SaveAttributes(SiteInfo, _styleInfoList, Request.Form, ContentAttribute.AllAttributes.Value);
                    contentInfo.Load(dict);

                    contentInfo.GroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroups.Items);
                    var tagCollection = TagUtils.ParseTagsString(TbTags.Text);

                    contentInfo.Title = TbTitle.Text;
                    var formatString    = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatStrong"]);
                    var formatEm        = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatEM"]);
                    var formatU         = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatU"]);
                    var formatColor     = Request.Form[ContentAttribute.Title + "_formatColor"];
                    var theFormatString = ContentUtility.GetTitleFormatString(formatString, formatEm, formatU, formatColor);
                    contentInfo.Set(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title), theFormatString);
                    foreach (ListItem listItem in CblContentAttributes.Items)
                    {
                        var value         = listItem.Selected.ToString();
                        var attributeName = listItem.Value;
                        contentInfo.Set(attributeName, value);
                    }
                    contentInfo.LinkUrl = TbLinkUrl.Text;
                    contentInfo.AddDate = TbAddDate.DateTime;

                    var checkedLevel = TranslateUtils.ToIntWithNagetive(DdlContentLevel.SelectedValue);
                    if (checkedLevel != CheckManager.LevelInt.NotChange)
                    {
                        contentInfo.IsChecked    = checkedLevel >= SiteInfo.Additional.CheckContentLevel;
                        contentInfo.CheckedLevel = checkedLevel;
                    }
                    contentInfo.Tags = TranslateUtils.ObjectCollectionToString(tagCollection, " ");

                    foreach (var service in PluginManager.Services)
                    {
                        try
                        {
                            service.OnContentFormSubmit(new ContentFormSubmitEventArgs(SiteId, _channelInfo.Id,
                                                                                       contentInfo.Id, new AttributesImpl(Request.Form), contentInfo));
                        }
                        catch (Exception ex)
                        {
                            LogUtils.AddErrorLog(service.PluginId, ex, nameof(IService.ContentFormSubmit));
                        }
                    }

                    DataProvider.ContentDao.Update(SiteInfo, _channelInfo, contentInfo);

                    TagUtils.UpdateTags(tagsLast, contentInfo.Tags, tagCollection, SiteId, contentId);

                    ContentUtility.Translate(SiteInfo, _channelInfo.Id, contentInfo.Id, Request.Form["translateCollection"], ETranslateContentTypeUtils.GetEnumType(DdlTranslateType.SelectedValue), AuthRequest.AdminName);

                    CreateManager.CreateContent(SiteId, _channelInfo.Id, contentId);
                    CreateManager.TriggerContentChangedEvent(SiteId, _channelInfo.Id);

                    AuthRequest.AddSiteLog(SiteId, _channelInfo.Id, contentId, "修改内容",
                                           $"栏目:{ChannelManager.GetChannelNameNavigation(SiteId, contentInfo.ChannelId)},内容标题:{contentInfo.Title}");

                    redirectUrl = ReturnUrl;

                    //更新引用该内容的信息
                    //如果不是异步自动保存,那么需要将引用此内容的content修改
                    //var sourceContentIdList = new List<int>
                    //{
                    //    contentInfo.Id
                    //};
                    //var tableList = DataProvider.TableDao.GetTableCollectionInfoListCreatedInDb();
                    //foreach (var table in tableList)
                    //{
                    //    var targetContentIdList = DataProvider.ContentDao.GetReferenceIdList(table.TableName, sourceContentIdList);
                    //    foreach (var targetContentId in targetContentIdList)
                    //    {
                    //        var targetContentInfo = DataProvider.ContentDao.GetContentInfo(table.TableName, targetContentId);
                    //        if (targetContentInfo == null || targetContentInfo.GetString(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString()) continue;

                    //        contentInfo.Id = targetContentId;
                    //        contentInfo.SiteId = targetContentInfo.SiteId;
                    //        contentInfo.ChannelId = targetContentInfo.ChannelId;
                    //        contentInfo.SourceId = targetContentInfo.SourceId;
                    //        contentInfo.ReferenceId = targetContentInfo.ReferenceId;
                    //        contentInfo.Taxis = targetContentInfo.Taxis;
                    //        contentInfo.Set(ContentAttribute.TranslateContentType, targetContentInfo.GetString(ContentAttribute.TranslateContentType));
                    //        DataProvider.ContentDao.Update(table.TableName, contentInfo);

                    //        //资源:图片,文件,视频
                    //        var targetSiteInfo = SiteManager.GetSiteInfo(targetContentInfo.SiteId);
                    //        var bgContentInfo = contentInfo as BackgroundContentInfo;
                    //        var bgTargetContentInfo = targetContentInfo as BackgroundContentInfo;
                    //        if (bgTargetContentInfo != null && bgContentInfo != null)
                    //        {
                    //            if (bgContentInfo.ImageUrl != bgTargetContentInfo.ImageUrl)
                    //            {
                    //                //修改图片
                    //                var sourceImageUrl = PathUtility.MapPath(SiteInfo, bgContentInfo.ImageUrl);
                    //                CopyReferenceFiles(targetSiteInfo, sourceImageUrl);
                    //            }
                    //            else if (bgContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl)) != bgTargetContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl)))
                    //            {
                    //                var sourceImageUrls = TranslateUtils.StringCollectionToStringList(bgContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl)));

                    //                foreach (string imageUrl in sourceImageUrls)
                    //                {
                    //                    var sourceImageUrl = PathUtility.MapPath(SiteInfo, imageUrl);
                    //                    CopyReferenceFiles(targetSiteInfo, sourceImageUrl);
                    //                }
                    //            }
                    //            if (bgContentInfo.FileUrl != bgTargetContentInfo.FileUrl)
                    //            {
                    //                //修改附件
                    //                var sourceFileUrl = PathUtility.MapPath(SiteInfo, bgContentInfo.FileUrl);
                    //                CopyReferenceFiles(targetSiteInfo, sourceFileUrl);

                    //            }
                    //            else if (bgContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl)) != bgTargetContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl)))
                    //            {
                    //                var sourceFileUrls = TranslateUtils.StringCollectionToStringList(bgContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl)));

                    //                foreach (var fileUrl in sourceFileUrls)
                    //                {
                    //                    var sourceFileUrl = PathUtility.MapPath(SiteInfo, fileUrl);
                    //                    CopyReferenceFiles(targetSiteInfo, sourceFileUrl);
                    //                }
                    //            }
                    //        }
                    //    }
                    //}
                }
                catch (Exception ex)
                {
                    LogUtils.AddErrorLog(ex);
                    FailMessage($"内容修改失败:{ex.Message}");
                    return;
                }
            }

            PageUtils.Redirect(redirectUrl);
        }
Exemple #5
0
        public IHttpActionResult Create(int siteId, int channelId)
        {
            try
            {
                var  request  = new RequestImpl();
                var  sourceId = request.GetPostInt(ContentAttribute.SourceId.ToCamelCase());
                bool isAuth;
                if (sourceId == SourceManager.User)
                {
                    isAuth = request.IsUserLoggin && request.UserPermissions.HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ContentAdd);
                }
                else
                {
                    isAuth = request.IsApiAuthenticated &&
                             AccessTokenManager.IsScope(request.ApiToken, AccessTokenManager.ScopeContents) ||
                             request.IsUserLoggin &&
                             request.UserPermissions.HasChannelPermissions(siteId, channelId,
                                                                           ConfigManager.ChannelPermissions.ContentAdd) ||
                             request.IsAdminLoggin &&
                             request.AdminPermissions.HasChannelPermissions(siteId, channelId,
                                                                            ConfigManager.ChannelPermissions.ContentAdd);
                }
                if (!isAuth)
                {
                    return(Unauthorized());
                }

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

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

                if (!channelInfo.Additional.IsContentAddable)
                {
                    return(BadRequest("此栏目不能添加内容"));
                }

                var attributes = request.GetPostObject <Dictionary <string, object> >();
                if (attributes == null)
                {
                    return(BadRequest("无法从body中获取内容实体"));
                }
                var checkedLevel = request.GetPostInt("checkedLevel");

                var tableName = ChannelManager.GetTableName(siteInfo, channelInfo);
                var adminName = request.AdminName;

                var isChecked = checkedLevel >= siteInfo.Additional.CheckContentLevel;
                if (isChecked)
                {
                    if (sourceId == SourceManager.User || request.IsUserLoggin)
                    {
                        isChecked = request.UserPermissionsImpl.HasChannelPermissions(siteId, channelId,
                                                                                      ConfigManager.ChannelPermissions.ContentCheck);
                    }
                    else if (request.IsAdminLoggin)
                    {
                        isChecked = request.AdminPermissionsImpl.HasChannelPermissions(siteId, channelId,
                                                                                       ConfigManager.ChannelPermissions.ContentCheck);
                    }
                }

                var contentInfo = new ContentInfo(attributes)
                {
                    SiteId           = siteId,
                    ChannelId        = channelId,
                    AddUserName      = adminName,
                    LastEditDate     = DateTime.Now,
                    LastEditUserName = adminName,
                    AdminId          = request.AdminId,
                    UserId           = request.UserId,
                    SourceId         = sourceId,
                    IsChecked        = isChecked,
                    CheckedLevel     = checkedLevel
                };

                contentInfo.Id = DataProvider.ContentDao.Insert(tableName, siteInfo, channelInfo, contentInfo);

                foreach (var service in PluginManager.Services)
                {
                    try
                    {
                        service.OnContentFormSubmit(new ContentFormSubmitEventArgs(siteId, channelId, contentInfo.Id, new AttributesImpl(attributes), contentInfo));
                    }
                    catch (Exception ex)
                    {
                        LogUtils.AddErrorLog(service.PluginId, ex, nameof(IService.ContentFormSubmit));
                    }
                }

                if (contentInfo.IsChecked)
                {
                    CreateManager.CreateContent(siteId, channelId, contentInfo.Id);
                    CreateManager.TriggerContentChangedEvent(siteId, channelId);
                }

                request.AddSiteLog(siteId, channelId, contentInfo.Id, "添加内容",
                                   $"栏目:{ChannelManager.GetChannelNameNavigation(siteId, contentInfo.ChannelId)},内容标题:{contentInfo.Title}");

                return(Ok(new
                {
                    Value = contentInfo
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
        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));
            }
        }
        public static void Translate(SiteInfo siteInfo, int channelId, int contentId, int targetSiteId, int targetChannelId, ETranslateContentType translateType)
        {
            if (siteInfo == null || channelId <= 0 || contentId <= 0 || targetSiteId <= 0 || targetChannelId <= 0)
            {
                return;
            }

            var targetSiteInfo    = SiteManager.GetSiteInfo(targetSiteId);
            var targetChannelInfo = ChannelManager.GetChannelInfo(targetSiteId, targetChannelId);
            var targetTableName   = ChannelManager.GetTableName(targetSiteInfo, targetChannelInfo);

            var channelInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId);
            var tableName   = ChannelManager.GetTableName(siteInfo, channelInfo);

            var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId);

            if (contentInfo == null)
            {
                return;
            }

            if (translateType == ETranslateContentType.Copy)
            {
                FileUtility.MoveFileByContentInfo(siteInfo, targetSiteInfo, contentInfo);

                contentInfo.SiteId    = targetSiteId;
                contentInfo.SourceId  = contentInfo.ChannelId;
                contentInfo.ChannelId = targetChannelId;
                contentInfo.Set(ContentAttribute.TranslateContentType, ETranslateContentType.Copy.ToString());
                //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Copy.ToString());
                var theContentId = DataProvider.ContentDao.Insert(targetTableName, targetSiteInfo, targetChannelInfo, contentInfo);

                foreach (var service in PluginManager.Services)
                {
                    try
                    {
                        service.OnContentTranslateCompleted(new ContentTranslateEventArgs(siteInfo.Id, channelInfo.Id, contentId, targetSiteId, targetChannelId, theContentId));
                    }
                    catch (Exception ex)
                    {
                        LogUtils.AddErrorLog(service.PluginId, ex, nameof(service.OnContentTranslateCompleted));
                    }
                }

                CreateManager.CreateContent(targetSiteInfo.Id, contentInfo.ChannelId, theContentId);
                CreateManager.TriggerContentChangedEvent(targetSiteInfo.Id, contentInfo.ChannelId);
            }
            else if (translateType == ETranslateContentType.Cut)
            {
                FileUtility.MoveFileByContentInfo(siteInfo, targetSiteInfo, contentInfo);

                contentInfo.SiteId    = targetSiteId;
                contentInfo.SourceId  = contentInfo.ChannelId;
                contentInfo.ChannelId = targetChannelId;
                contentInfo.Set(ContentAttribute.TranslateContentType, ETranslateContentType.Cut.ToString());
                //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Cut.ToString());

                var newContentId = DataProvider.ContentDao.Insert(targetTableName, targetSiteInfo, targetChannelInfo, contentInfo);
                DataProvider.ContentDao.DeleteContents(siteInfo.Id, tableName, TranslateUtils.ToIntList(contentId), channelId);

                foreach (var service in PluginManager.Services)
                {
                    try
                    {
                        service.OnContentTranslateCompleted(new ContentTranslateEventArgs(siteInfo.Id, channelInfo.Id, contentId, targetSiteId, targetChannelId, newContentId));
                    }
                    catch (Exception ex)
                    {
                        LogUtils.AddErrorLog(service.PluginId, ex, nameof(service.OnContentTranslateCompleted));
                    }

                    try
                    {
                        service.OnContentDeleteCompleted(new ContentEventArgs(siteInfo.Id, channelInfo.Id, contentId));
                    }
                    catch (Exception ex)
                    {
                        LogUtils.AddErrorLog(service.PluginId, ex, nameof(service.OnContentDeleteCompleted));
                    }
                }

                CreateManager.CreateContent(targetSiteInfo.Id, contentInfo.ChannelId, newContentId);
                CreateManager.TriggerContentChangedEvent(targetSiteInfo.Id, contentInfo.ChannelId);
            }
            else if (translateType == ETranslateContentType.Reference)
            {
                if (contentInfo.ReferenceId != 0)
                {
                    return;
                }

                contentInfo.SiteId      = targetSiteId;
                contentInfo.SourceId    = contentInfo.ChannelId;
                contentInfo.ChannelId   = targetChannelId;
                contentInfo.ReferenceId = contentId;
                contentInfo.Set(ContentAttribute.TranslateContentType, ETranslateContentType.Reference.ToString());
                //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Reference.ToString());
                int theContentId = DataProvider.ContentDao.Insert(targetTableName, targetSiteInfo, targetChannelInfo, contentInfo);

                CreateManager.CreateContent(targetSiteInfo.Id, contentInfo.ChannelId, theContentId);
                CreateManager.TriggerContentChangedEvent(targetSiteInfo.Id, contentInfo.ChannelId);
            }
            else if (translateType == ETranslateContentType.ReferenceContent)
            {
                if (contentInfo.ReferenceId != 0)
                {
                    return;
                }

                FileUtility.MoveFileByContentInfo(siteInfo, targetSiteInfo, contentInfo);

                contentInfo.SiteId      = targetSiteId;
                contentInfo.SourceId    = contentInfo.ChannelId;
                contentInfo.ChannelId   = targetChannelId;
                contentInfo.ReferenceId = contentId;
                contentInfo.Set(ContentAttribute.TranslateContentType, ETranslateContentType.ReferenceContent.ToString());
                var theContentId = DataProvider.ContentDao.Insert(targetTableName, targetSiteInfo, targetChannelInfo, contentInfo);

                foreach (var service in PluginManager.Services)
                {
                    try
                    {
                        service.OnContentTranslateCompleted(new ContentTranslateEventArgs(siteInfo.Id, channelInfo.Id, contentId, targetSiteId, targetChannelId, theContentId));
                    }
                    catch (Exception ex)
                    {
                        LogUtils.AddErrorLog(service.PluginId, ex, nameof(service.OnContentTranslateCompleted));
                    }
                }

                CreateManager.CreateContent(targetSiteInfo.Id, contentInfo.ChannelId, theContentId);
                CreateManager.TriggerContentChangedEvent(targetSiteInfo.Id, contentInfo.ChannelId);
            }
        }
Exemple #8
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
            });
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            var fileNames = TranslateUtils.StringCollectionToStringList(HihFileNames.Value);

            if (fileNames.Count == 1)
            {
                var fileName = fileNames[0];
                if (!string.IsNullOrEmpty(fileName))
                {
                    var redirectUrl = WebUtils.GetContentAddUploadWordUrl(SiteId, _channelInfo, CbIsFirstLineTitle.Checked, CbIsFirstLineRemove.Checked, CbIsClearFormat.Checked, CbIsFirstLineIndent.Checked, CbIsClearFontSize.Checked, CbIsClearFontFamily.Checked, CbIsClearImages.Checked, TranslateUtils.ToIntWithNagetive(DdlContentLevel.SelectedValue), fileName, _returnUrl);
                    LayerUtils.CloseAndRedirect(Page, redirectUrl);
                }

                return;
            }

            if (fileNames.Count > 1)
            {
                var tableName     = ChannelManager.GetTableName(SiteInfo, _channelInfo);
                var styleInfoList = TableStyleManager.GetContentStyleInfoList(SiteInfo, _channelInfo);

                foreach (var fileName in fileNames)
                {
                    if (!string.IsNullOrEmpty(fileName))
                    {
                        var formCollection = WordUtils.GetWordNameValueCollection(SiteId, CbIsFirstLineTitle.Checked, CbIsFirstLineRemove.Checked, CbIsClearFormat.Checked, CbIsFirstLineIndent.Checked, CbIsClearFontSize.Checked, CbIsClearFontFamily.Checked, CbIsClearImages.Checked, fileName);

                        if (!string.IsNullOrEmpty(formCollection[ContentAttribute.Title]))
                        {
                            var dict = BackgroundInputTypeParser.SaveAttributes(SiteInfo, styleInfoList, formCollection, ContentAttribute.AllAttributes.Value);

                            var contentInfo = new ContentInfo(dict)
                            {
                                ChannelId   = _channelInfo.Id,
                                SiteId      = SiteId,
                                AddUserName = AuthRequest.AdminName,
                                AddDate     = DateTime.Now
                            };

                            contentInfo.LastEditUserName = contentInfo.AddUserName;
                            contentInfo.LastEditDate     = contentInfo.AddDate;

                            contentInfo.CheckedLevel = TranslateUtils.ToIntWithNagetive(DdlContentLevel.SelectedValue);
                            contentInfo.IsChecked    = contentInfo.CheckedLevel >= SiteInfo.Additional.CheckContentLevel;

                            contentInfo.Title = formCollection[ContentAttribute.Title];

                            contentInfo.Id = DataProvider.ContentDao.Insert(tableName, SiteInfo, _channelInfo, contentInfo);

                            CreateManager.CreateContent(SiteId, _channelInfo.Id, contentInfo.Id);
                            CreateManager.TriggerContentChangedEvent(SiteId, _channelInfo.Id);
                        }
                    }
                }
            }

            LayerUtils.Close(Page);
        }
Exemple #10
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);

            if (Body.IsQueryExists("Gather") && Body.IsQueryExists("GatherRuleNameCollection"))
            {
                var userKeyPrefix = StringUtils.Guid();
                var parameters    = AjaxGatherService.GetGatherParameters(PublishmentSystemId, Body.GetQueryString("GatherRuleNameCollection"), userKeyPrefix);
                RegisterScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxGatherService.GetGatherUrl(), parameters, userKeyPrefix, AjaxGatherService.GetCountArrayUrl());
            }
            else if (Body.IsQueryExists("GatherDatabase") && Body.IsQueryExists("GatherRuleNameCollection"))
            {
                var userKeyPrefix = StringUtils.Guid();
                var parameters    = AjaxGatherService.GetGatherDatabaseParameters(PublishmentSystemId,
                                                                                  Body.GetQueryString("GatherRuleNameCollection"), userKeyPrefix);
                RegisterScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxGatherService.GetGatherDatabaseUrl(), parameters, userKeyPrefix, AjaxGatherService.GetCountArrayUrl());
            }
            else if (Body.IsQueryExists("GatherFile") && Body.IsQueryExists("GatherRuleNameCollection"))
            {
                var userKeyPrefix = StringUtils.Guid();
                var parameters    = AjaxGatherService.GetGatherFileParameters(PublishmentSystemId,
                                                                              Body.GetQueryString("GatherRuleNameCollection"), userKeyPrefix);
                RegisterScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxGatherService.GetGatherFileUrl(), parameters,
                                                           userKeyPrefix, AjaxGatherService.GetCountArrayUrl());
            }
            //----------------------------------------------------------------------------------------//
            else if (Body.IsQueryExists("CreateChannelsOneByOne") && Body.IsQueryExists("ChannelIDCollection"))
            {
                foreach (var channelId in TranslateUtils.StringCollectionToIntList(Body.GetQueryString("ChannelIDCollection")))
                {
                    CreateManager.CreateChannel(PublishmentSystemId, channelId);
                }

                PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString("已成功将栏目放入生成队列"));
            }
            else if (Body.IsQueryExists("CreateContentsOneByOne") && Body.IsQueryExists("NodeID") &&
                     Body.IsQueryExists("ContentIDCollection"))
            {
                foreach (var contentId in TranslateUtils.StringCollectionToIntList(Body.GetQueryString("ContentIDCollection")))
                {
                    CreateManager.CreateContent(PublishmentSystemId, Body.GetQueryInt("NodeID"),
                                                contentId);
                }

                PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString("已成功将内容放入生成队列"));
            }
            else if (Body.IsQueryExists("CreateByTemplate") && Body.IsQueryExists("templateID"))
            {
                CreateManager.CreateFile(PublishmentSystemId, Body.GetQueryInt("templateID"));

                PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString("已成功将文件放入生成队列"));
            }
            else if (Body.IsQueryExists("CreateByIDsCollection") && Body.IsQueryExists("IDsCollection"))
            {
                foreach (var nodeIdContentId in
                         TranslateUtils.StringCollectionToStringCollection(Body.GetQueryString("IDsCollection")))
                {
                    var pair = nodeIdContentId.Split('_');
                    CreateManager.CreateContent(PublishmentSystemId, TranslateUtils.ToInt(pair[0]),
                                                TranslateUtils.ToInt(pair[1]));
                }

                PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString("已成功将文件放入生成队列"));
            }
            //---------------------------------------------------------------------------------------//
            else if (Body.IsQueryExists("SiteTemplateDownload"))
            {
                var userKeyPrefix = StringUtils.Guid();

                var parameters = AjaxOtherService.GetSiteTemplateDownloadParameters(Body.GetQueryString("DownloadUrl"),
                                                                                    Body.GetQueryString("DirectoryName"), userKeyPrefix);
                RegisterScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxOtherService.GetSiteTemplateDownloadUrl(), parameters, userKeyPrefix, AjaxOtherService.GetCountArrayUrl());
            }
            else if (Body.IsQueryExists("SiteTemplateZip"))
            {
                var userKeyPrefix = StringUtils.Guid();

                var parameters = AjaxOtherService.GetSiteTemplateZipParameters(Body.GetQueryString("DirectoryName"), userKeyPrefix);
                RegisterScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxOtherService.GetSiteTemplateZipUrl(), parameters, userKeyPrefix, AjaxOtherService.GetCountArrayUrl());
            }
        }
        public IHttpActionResult Submit()
        {
            try
            {
                var request = new AuthenticatedRequest();

                var siteId            = request.GetPostInt("siteId");
                var channelId         = request.GetPostInt("channelId");
                var isFirstLineTitle  = request.GetPostBool("isFirstLineTitle");
                var isFirstLineRemove = request.GetPostBool("isFirstLineRemove");
                var isClearFormat     = request.GetPostBool("isClearFormat");
                var isFirstLineIndent = request.GetPostBool("isFirstLineIndent");
                var isClearFontSize   = request.GetPostBool("isClearFontSize");
                var isClearFontFamily = request.GetPostBool("isClearFontFamily");
                var isClearImages     = request.GetPostBool("isClearImages");
                var checkedLevel      = request.GetPostInt("checkedLevel");
                var fileNames         = TranslateUtils.StringCollectionToStringList(request.GetPostString("fileNames"));

                if (!request.IsUserLoggin ||
                    !request.UserPermissionsImpl.HasChannelPermissions(siteId, channelId,
                                                                       ConfigManager.ChannelPermissions.ContentAdd))
                {
                    return(Unauthorized());
                }

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

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

                var tableName     = ChannelManager.GetTableName(siteInfo, channelInfo);
                var styleInfoList = TableStyleManager.GetContentStyleInfoList(siteInfo, channelInfo);
                var isChecked     = checkedLevel >= siteInfo.Additional.CheckContentLevel;

                var contentIdList = new List <int>();

                foreach (var fileName in fileNames)
                {
                    if (string.IsNullOrEmpty(fileName))
                    {
                        continue;
                    }

                    var formCollection = WordUtils.GetWordNameValueCollection(siteId, isFirstLineTitle, isFirstLineRemove, isClearFormat, isFirstLineIndent, isClearFontSize, isClearFontFamily, isClearImages, fileName);

                    if (string.IsNullOrEmpty(formCollection[ContentAttribute.Title]))
                    {
                        continue;
                    }

                    var dict = BackgroundInputTypeParser.SaveAttributes(siteInfo, styleInfoList, formCollection, ContentAttribute.AllAttributes.Value);

                    var contentInfo = new ContentInfo(dict)
                    {
                        ChannelId    = channelInfo.Id,
                        SiteId       = siteId,
                        AddUserName  = request.AdminName,
                        AddDate      = DateTime.Now,
                        SourceId     = SourceManager.User,
                        AdminId      = request.AdminId,
                        UserId       = request.UserId,
                        IsChecked    = isChecked,
                        CheckedLevel = checkedLevel
                    };

                    contentInfo.LastEditUserName = contentInfo.AddUserName;
                    contentInfo.LastEditDate     = contentInfo.AddDate;

                    contentInfo.Title = formCollection[ContentAttribute.Title];

                    contentInfo.Id = DataProvider.ContentDao.Insert(tableName, siteInfo, channelInfo, contentInfo);

                    contentIdList.Add(contentInfo.Id);
                }

                if (isChecked)
                {
                    foreach (var contentId in contentIdList)
                    {
                        CreateManager.CreateContent(siteId, channelInfo.Id, contentId);
                    }
                    CreateManager.TriggerContentChangedEvent(siteId, channelInfo.Id);
                }

                return(Ok(new
                {
                    Value = contentIdList
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var checkedLevel = TranslateUtils.ToIntWithNagetive(DdlCheckType.SelectedValue);

            var isChecked = checkedLevel >= SiteInfo.Additional.CheckContentLevel;

            var contentInfoArrayListToCheck = new List <ContentInfo>();
            var idsDictionaryToCheck        = new Dictionary <int, List <int> >();

            foreach (var channelId in _idsDictionary.Keys)
            {
                var tableName            = ChannelManager.GetTableName(SiteInfo, channelId);
                var contentIdList        = _idsDictionary[channelId];
                var contentIdListToCheck = new List <int>();

                int checkedLevelOfUser;
                var isCheckedOfUser = CheckManager.GetUserCheckLevel(Body.AdminName, SiteInfo, channelId, out checkedLevelOfUser);

                foreach (var contentId in contentIdList)
                {
                    var contentInfo = DataProvider.ContentDao.GetContentInfo(tableName, contentId);
                    if (contentInfo != null)
                    {
                        if (CheckManager.IsCheckable(SiteInfo, contentInfo.ChannelId, contentInfo.IsChecked, contentInfo.CheckedLevel, isCheckedOfUser, checkedLevelOfUser))
                        {
                            contentInfoArrayListToCheck.Add(contentInfo);
                            contentIdListToCheck.Add(contentId);
                        }

                        DataProvider.ContentDao.Update(tableName, SiteInfo, contentInfo);

                        if (contentInfo.IsChecked)
                        {
                            CreateManager.CreateContentAndTrigger(SiteId, contentInfo.ChannelId, contentId);
                        }
                    }
                }
                if (contentIdListToCheck.Count > 0)
                {
                    idsDictionaryToCheck[channelId] = contentIdListToCheck;
                }
            }

            if (contentInfoArrayListToCheck.Count == 0)
            {
                LayerUtils.CloseWithoutRefresh(Page, "alert('您的审核权限不足,无法审核所选内容!');");
            }
            else
            {
                try
                {
                    var translateChannelId = TranslateUtils.ToInt(DdlTranslateChannelId.SelectedValue);

                    foreach (var channelId in idsDictionaryToCheck.Keys)
                    {
                        var tableName     = ChannelManager.GetTableName(SiteInfo, channelId);
                        var contentIdList = idsDictionaryToCheck[channelId];
                        DataProvider.ContentDao.UpdateIsChecked(tableName, SiteId, channelId, contentIdList, translateChannelId, true, Body.AdminName, isChecked, checkedLevel, TbCheckReasons.Text);

                        DataProvider.ChannelDao.UpdateContentNum(SiteInfo, channelId, true);
                    }

                    if (translateChannelId > 0)
                    {
                        DataProvider.ChannelDao.UpdateContentNum(SiteInfo, translateChannelId, true);
                    }

                    Body.AddSiteLog(SiteId, SiteId, 0, "设置内容状态为" + DdlCheckType.SelectedItem.Text, TbCheckReasons.Text);

                    if (isChecked)
                    {
                        foreach (var channelId in idsDictionaryToCheck.Keys)
                        {
                            var contentIdList = _idsDictionary[channelId];
                            if (contentIdList != null)
                            {
                                foreach (var contentId in contentIdList)
                                {
                                    CreateManager.CreateContent(SiteId, channelId, contentId);
                                }
                            }
                        }
                    }

                    LayerUtils.CloseAndRedirect(Page, _returnUrl);
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "操作失败!");
                }
            }
        }
Exemple #13
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);

            if (AuthRequest.IsQueryExists("CreateChannelsOneByOne") && AuthRequest.IsQueryExists("ChannelIDCollection"))
            {
                foreach (var channelId in TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("ChannelIDCollection")))
                {
                    CreateManager.CreateChannel(SiteId, channelId);
                }

                LayerUtils.CloseAndOpenPageCreateStatus(Page);
                //PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString(SiteId, "已成功将栏目放入生成队列"));
            }
            else if (AuthRequest.IsQueryExists("CreateContentsOneByOne") && AuthRequest.IsQueryExists("channelId") &&
                     AuthRequest.IsQueryExists("contentIdCollection"))
            {
                foreach (var contentId in TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("contentIdCollection")))
                {
                    CreateManager.CreateContent(SiteId, AuthRequest.GetQueryInt("channelId"),
                                                contentId);
                }

                LayerUtils.CloseAndOpenPageCreateStatus(Page);
                //PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString(SiteId, "已成功将内容放入生成队列"));
            }
            else if (AuthRequest.IsQueryExists("CreateByTemplate") && AuthRequest.IsQueryExists("templateID"))
            {
                CreateManager.CreateFile(SiteId, AuthRequest.GetQueryInt("templateID"));

                LayerUtils.CloseAndOpenPageCreateStatus(Page);
                //PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString(SiteId, "已成功将文件放入生成队列"));
            }
            else if (AuthRequest.IsQueryExists("CreateByIDsCollection") && AuthRequest.IsQueryExists("IDsCollection"))
            {
                foreach (var channelIdContentId in
                         TranslateUtils.StringCollectionToStringCollection(AuthRequest.GetQueryString("IDsCollection")))
                {
                    var pair = channelIdContentId.Split('_');
                    CreateManager.CreateContent(SiteId, TranslateUtils.ToInt(pair[0]),
                                                TranslateUtils.ToInt(pair[1]));
                }

                LayerUtils.CloseAndOpenPageCreateStatus(Page);
                //PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString(SiteId, "已成功将文件放入生成队列"));
            }
            //---------------------------------------------------------------------------------------//
            else if (AuthRequest.IsQueryExists("SiteTemplateDownload"))
            {
                var userKeyPrefix = StringUtils.Guid();

                var downloadUrl   = TranslateUtils.DecryptStringBySecretKey(AuthRequest.GetQueryString("DownloadUrl"));
                var directoryName = PathUtils.GetFileNameWithoutExtension(downloadUrl);

                var parameters = AjaxOtherService.GetSiteTemplateDownloadParameters(downloadUrl, directoryName, userKeyPrefix);
                LtlScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxOtherService.GetSiteTemplateDownloadUrl(), parameters, userKeyPrefix, AjaxOtherService.GetCountArrayUrl());
            }
            else if (AuthRequest.IsQueryExists("SiteTemplateZip"))
            {
                var userKeyPrefix = StringUtils.Guid();

                var parameters = AjaxOtherService.GetSiteTemplateZipParameters(AuthRequest.GetQueryString("DirectoryName"), userKeyPrefix);
                LtlScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxOtherService.GetSiteTemplateZipUrl(), parameters, userKeyPrefix, AjaxOtherService.GetCountArrayUrl());
            }
            else if (AuthRequest.IsQueryExists("SiteTemplateUnZip"))
            {
                var userKeyPrefix = StringUtils.Guid();

                var parameters = AjaxOtherService.GetSiteTemplateUnZipParameters(AuthRequest.GetQueryString("FileName"), userKeyPrefix);
                LtlScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxOtherService.GetSiteTemplateUnZipUrl(), parameters, userKeyPrefix, AjaxOtherService.GetCountArrayUrl());
            }
            //---------------------------------------------------------------------------------------//
            else if (AuthRequest.IsQueryExists("PluginDownload"))
            {
                var userKeyPrefix = StringUtils.Guid();

                var parameters = AjaxOtherService.GetPluginDownloadParameters(AuthRequest.GetQueryString("DownloadUrl"), userKeyPrefix);
                LtlScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxOtherService.GetPluginDownloadUrl(), parameters, userKeyPrefix, AjaxOtherService.GetCountArrayUrl());
            }
        }
        public IHttpActionResult Submit()
        {
            try
            {
                var request = new AuthenticatedRequest();

                var siteId       = request.GetPostInt("siteId");
                var channelId    = request.GetPostInt("channelId");
                var importType   = request.GetPostString("importType");
                var checkedLevel = request.GetPostInt("checkedLevel");
                var isOverride   = request.GetPostBool("isOverride");
                var fileNames    = request.GetPostObject <List <string> >("fileNames");

                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasChannelPermissions(siteId, channelId,
                                                                        ConfigManager.ChannelPermissions.ContentAdd))
                {
                    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;

                var contentIdList = new List <int>();

                if (importType == "zip")
                {
                    foreach (var fileName in fileNames)
                    {
                        var localFilePath = PathUtils.GetTemporaryFilesPath(fileName);

                        if (!EFileSystemTypeUtils.Equals(EFileSystemType.Zip, PathUtils.GetExtension(localFilePath)))
                        {
                            continue;
                        }

                        var importObject = new ImportObject(siteId, request.AdminName);
                        contentIdList.AddRange(importObject.ImportContentsByZipFile(channelInfo, localFilePath, isOverride, isChecked, checkedLevel, request.AdminId, 0, SourceManager.Default));
                    }
                }
                else if (importType == "csv")
                {
                    foreach (var fileName in fileNames)
                    {
                        var localFilePath = PathUtils.GetTemporaryFilesPath(fileName);

                        if (!EFileSystemTypeUtils.Equals(EFileSystemType.Csv, PathUtils.GetExtension(localFilePath)))
                        {
                            continue;
                        }

                        var importObject = new ImportObject(siteId, request.AdminName);
                        contentIdList.AddRange(importObject.ImportContentsByCsvFile(channelInfo, localFilePath, isOverride, isChecked, checkedLevel, request.AdminId, 0, SourceManager.Default));
                    }
                }
                else if (importType == "txt")
                {
                    foreach (var fileName in fileNames)
                    {
                        var localFilePath = PathUtils.GetTemporaryFilesPath(fileName);
                        if (!EFileSystemTypeUtils.Equals(EFileSystemType.Txt, PathUtils.GetExtension(localFilePath)))
                        {
                            continue;
                        }

                        var importObject = new ImportObject(siteId, request.AdminName);
                        contentIdList.AddRange(importObject.ImportContentsByTxtFile(channelInfo, localFilePath, isOverride, isChecked, checkedLevel, request.AdminId, 0, SourceManager.Default));
                    }
                }

                foreach (var contentId in contentIdList)
                {
                    CreateManager.CreateContent(siteId, channelInfo.Id, contentId);
                }
                CreateManager.CreateChannel(siteId, channelInfo.Id);

                request.AddSiteLog(siteId, channelId, 0, "导入内容", string.Empty);

                return(Ok(new
                {
                    Value = true
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
Exemple #15
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var taskID       = 0;
            var checkedLevel = TranslateUtils.ToIntWithNagetive(rblCheckType.SelectedValue);
            var isChecked    = false;
            var isTask       = false;

            if (checkedLevel >= PublishmentSystemInfo.CheckContentLevel)
            {
                isChecked = true;
            }
            else
            {
                isChecked = false;
            }

            var contentInfoArrayListToCheck = new List <ContentInfo>();
            var idsDictionaryToCheck        = new Dictionary <int, List <int> >();

            foreach (var nodeID in _idsDictionary.Keys)
            {
                var tableStyle                = NodeManager.GetTableStyle(PublishmentSystemInfo, nodeID);
                var tableName                 = NodeManager.GetTableName(PublishmentSystemInfo, nodeID);
                var contentIDArrayList        = _idsDictionary[nodeID];
                var contentIDArrayListToCheck = new List <int>();

                var checkedLevelOfUser = 0;
                var isCheckedOfUser    = CheckManager.GetUserCheckLevel(Body.AdministratorName, PublishmentSystemInfo, nodeID, out checkedLevelOfUser);

                foreach (int contentID in contentIDArrayList)
                {
                    var contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentID);
                    if (contentInfo != null)
                    {
                        if (LevelManager.IsCheckable(PublishmentSystemInfo, contentInfo.NodeId, contentInfo.IsChecked, contentInfo.CheckedLevel, isCheckedOfUser, checkedLevelOfUser))
                        {
                            contentInfoArrayListToCheck.Add(contentInfo);
                            contentIDArrayListToCheck.Add(contentID);
                        }

                        DataProvider.ContentDao.Update(tableName, PublishmentSystemInfo, contentInfo);

                        if (contentInfo.IsChecked)
                        {
                            CreateManager.CreateContentAndTrigger(PublishmentSystemId, contentInfo.NodeId, contentID);
                        }
                    }
                }
                if (contentIDArrayListToCheck.Count > 0)
                {
                    idsDictionaryToCheck[nodeID] = contentIDArrayListToCheck;
                }
            }

            if (contentInfoArrayListToCheck.Count == 0)
            {
                PageUtils.CloseModalPageWithoutRefresh(Page, "alert('您的审核权限不足,无法审核所选内容!');");
            }
            else
            {
                try
                {
                    var translateNodeID = TranslateUtils.ToInt(ddlTranslateNodeID.SelectedValue);

                    foreach (int nodeID in idsDictionaryToCheck.Keys)
                    {
                        var tableName          = NodeManager.GetTableName(PublishmentSystemInfo, nodeID);
                        var contentIDArrayList = idsDictionaryToCheck[nodeID];
                        BaiRongDataProvider.ContentDao.UpdateIsChecked(tableName, PublishmentSystemId, nodeID, contentIDArrayList, translateNodeID, true, Body.AdministratorName, isChecked, checkedLevel, tbCheckReasons.Text);

                        DataProvider.NodeDao.UpdateContentNum(PublishmentSystemInfo, nodeID, true);
                    }

                    if (translateNodeID > 0)
                    {
                        DataProvider.NodeDao.UpdateContentNum(PublishmentSystemInfo, translateNodeID, true);
                    }

                    Body.AddSiteLog(PublishmentSystemId, PublishmentSystemId, 0, "设置内容状态为" + rblCheckType.SelectedItem.Text, tbCheckReasons.Text);

                    if (isChecked)
                    {
                        foreach (int nodeID in idsDictionaryToCheck.Keys)
                        {
                            var contentIDArrayList = _idsDictionary[nodeID];
                            if (contentIDArrayList != null)
                            {
                                foreach (int contentID in contentIDArrayList)
                                {
                                    CreateManager.CreateContent(PublishmentSystemId, nodeID, contentID);
                                }
                            }
                        }
                    }

                    PageUtils.CloseModalPageAndRedirect(Page, _returnUrl);
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "操作失败!");
                }
            }
        }