Beispiel #1
0
        public void Main(int publishmentSystemId, int inputId)
        {
            var body = new RequestBody();

            var       publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
            InputInfo inputInfo             = null;

            if (inputId > 0)
            {
                inputInfo = DataProvider.InputDao.GetInputInfo(inputId);
            }
            if (inputInfo != null)
            {
                var relatedIdentities = RelatedIdentities.GetRelatedIdentities(ETableStyle.InputContent, publishmentSystemId, inputInfo.InputId);

                var ipAddress = PageUtils.GetIpAddress();

                var contentInfo = new InputContentInfo(0, inputInfo.InputId, 0, inputInfo.IsChecked, body.UserName, ipAddress, DateTime.Now, string.Empty);

                try
                {
                    if (!inputInfo.Additional.IsAnomynous && !body.IsUserLoggin)
                    {
                        throw new Exception("请先登录系统!");
                    }

                    InputTypeParser.AddValuesToAttributes(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, publishmentSystemInfo, relatedIdentities, HttpContext.Current.Request.Form, contentInfo.Attributes, false);

                    if (HttpContext.Current.Request.Files.Count > 0)
                    {
                        foreach (var attributeName in HttpContext.Current.Request.Files.AllKeys)
                        {
                            var myFile = HttpContext.Current.Request.Files[attributeName];
                            if (myFile == null || "" == myFile.FileName)
                            {
                                continue;
                            }

                            var fileUrl = UploadFile(publishmentSystemInfo, myFile);
                            contentInfo.SetExtendedAttribute(attributeName, fileUrl);
                        }
                    }

                    DataProvider.InputContentDao.Insert(contentInfo);

                    string message;
                    if (string.IsNullOrEmpty(HttpContext.Current.Request.Form["successTemplateString"]))
                    {
                        if (string.IsNullOrEmpty(inputInfo.Additional.MessageSuccess))
                        {
                            message = "表单提交成功,正在审核。";
                            if (contentInfo.IsChecked)
                            {
                                message = "表单提交成功。";
                            }
                        }
                        else
                        {
                            message = inputInfo.Additional.MessageSuccess;
                        }
                    }
                    else
                    {
                        message = TranslateUtils.DecryptStringBySecretKey(HttpContext.Current.Request.Form["successTemplateString"]);
                    }

                    HttpContext.Current.Response.Write(InputTemplate.GetInputCallbackScript(publishmentSystemInfo, inputId, true, message));
                    HttpContext.Current.Response.End();

                    //if (contentInfo.IsChecked == EBoolean.True)
                    //{
                    //    FileSystemObject FSO = new FileSystemObject(base.PublishmentSystemID);
                    //    FSO.CreateImmediately(EChangedType.Add, ETemplateTypeUtils.GetEnumType(templateType), channelID, contentID, fileTemplateID);
                    //}
                }
                catch (Exception ex)
                {
                    string message;
                    if (string.IsNullOrEmpty(HttpContext.Current.Request.Form["failureTemplateString"]))
                    {
                        if (string.IsNullOrEmpty(inputInfo.Additional.MessageFailure))
                        {
                            message = "表单提交失败," + ex.Message;
                        }
                        else
                        {
                            message = inputInfo.Additional.MessageFailure;
                        }
                    }
                    else
                    {
                        message = TranslateUtils.DecryptStringBySecretKey(HttpContext.Current.Request.Form["failureTemplateString"]);
                    }

                    HttpContext.Current.Response.Write(InputTemplate.GetInputCallbackScript(publishmentSystemInfo, inputId, false, message));
                    HttpContext.Current.Response.End();
                }
            }
        }
Beispiel #2
0
        public static string ParseDynamicContent(int publishmentSystemId, int channelId, int contentId, int templateId, bool isPageRefresh, string templateContent, string pageUrl, int pageIndex, string ajaxDivId, NameValueCollection queryString, UserInfo userInfo)
        {
            var templateInfo = TemplateManager.GetTemplateInfo(publishmentSystemId, templateId);
            //TemplateManager.GetTemplateInfo(publishmentSystemID, channelID, templateType);
            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
            var pageInfo = new PageInfo(channelId, contentId, publishmentSystemInfo, templateInfo, userInfo);

            pageInfo.SetUniqueId(1000);
            var contextInfo = new ContextInfo(pageInfo);

            templateContent = StlRequestEntities.ParseRequestEntities(queryString, templateContent);
            var contentBuilder = new StringBuilder(templateContent);
            var stlElementList = StlParserUtility.GetStlElementList(contentBuilder.ToString());

            //如果标签中存在<stl:pageContents>
            if (StlParserUtility.IsStlElementExists(StlPageContents.ElementName, stlElementList))
            {
                var stlElement             = StlParserUtility.GetStlElement(StlPageContents.ElementName, stlElementList);
                var stlPageContentsElement = stlElement;
                var stlPageContentsElementReplaceString = stlElement;

                var pageContentsElementParser = new StlPageContents(stlPageContentsElement, pageInfo, contextInfo, true);
                int totalNum;
                var pageCount = pageContentsElementParser.GetPageCount(out totalNum);

                for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                {
                    if (currentPageIndex == pageIndex)
                    {
                        var pageHtml = pageContentsElementParser.Parse(totalNum, currentPageIndex, pageCount, false);
                        contentBuilder.Replace(stlPageContentsElementReplaceString, pageHtml);

                        StlParserManager.ReplacePageElementsInDynamicPage(contentBuilder, pageInfo, stlElementList, pageUrl, pageInfo.PageNodeId, currentPageIndex, pageCount, totalNum, isPageRefresh, ajaxDivId);

                        break;
                    }
                }
            }
            //如果标签中存在<stl:pageChannels>
            else if (StlParserUtility.IsStlElementExists(StlPageChannels.ElementName, stlElementList))
            {
                var stlElement             = StlParserUtility.GetStlElement(StlPageChannels.ElementName, stlElementList);
                var stlPageChannelsElement = stlElement;
                var stlPageChannelsElementReplaceString = stlElement;

                var pageChannelsElementParser = new StlPageChannels(stlPageChannelsElement, pageInfo, contextInfo, true);
                int totalNum;
                var pageCount = pageChannelsElementParser.GetPageCount(out totalNum);

                for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                {
                    if (currentPageIndex == pageIndex)
                    {
                        var pageHtml = pageChannelsElementParser.Parse(currentPageIndex, pageCount);
                        contentBuilder.Replace(stlPageChannelsElementReplaceString, pageHtml);

                        StlParserManager.ReplacePageElementsInDynamicPage(contentBuilder, pageInfo, stlElementList, pageUrl, pageInfo.PageNodeId, currentPageIndex, pageCount, totalNum, isPageRefresh, ajaxDivId);

                        break;
                    }
                }
            }
            //如果标签中存在<stl:pageComments>
            else if (StlParserUtility.IsStlElementExists(StlPageComments.ElementName, stlElementList))
            {
                var stlElement             = StlParserUtility.GetStlElement(StlPageComments.ElementName, stlElementList);
                var stlPageCommentsElement = stlElement;
                var stlPageCommentsElementReplaceString = stlElement;

                var pageCommentsElementParser = new StlPageComments(stlPageCommentsElement, pageInfo, contextInfo, true);
                int totalNum;
                var pageCount = pageCommentsElementParser.GetPageCount(out totalNum);

                for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                {
                    if (currentPageIndex == pageIndex)
                    {
                        var pageHtml = pageCommentsElementParser.Parse(currentPageIndex, pageCount);
                        contentBuilder.Replace(stlPageCommentsElementReplaceString, pageHtml);

                        StlParserManager.ReplacePageElementsInDynamicPage(contentBuilder, pageInfo, stlElementList, pageUrl, pageInfo.PageNodeId, currentPageIndex, pageCount, totalNum, isPageRefresh, ajaxDivId);

                        break;
                    }
                }
            }
            //如果标签中存在<stl:pageinputContents>
            else if (StlParserUtility.IsStlElementExists(StlPageInputContents.ElementName, stlElementList))
            {
                var stlElement = StlParserUtility.GetStlElement(StlPageInputContents.ElementName, stlElementList);
                var stlPageInputContentsElement = stlElement;
                var stlPageInputContentsElementReplaceString = stlElement;

                var pageInputContentsElementParser = new StlPageInputContents(stlPageInputContentsElement, pageInfo, contextInfo, true);
                int totalNum;
                var pageCount = pageInputContentsElementParser.GetPageCount(out totalNum);

                for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                {
                    if (currentPageIndex == pageIndex)
                    {
                        var pageHtml = pageInputContentsElementParser.Parse(currentPageIndex, pageCount);
                        contentBuilder.Replace(stlPageInputContentsElementReplaceString, pageHtml);

                        StlParserManager.ReplacePageElementsInDynamicPage(contentBuilder, pageInfo, stlElementList, pageUrl, pageInfo.PageNodeId, currentPageIndex, pageCount, totalNum, isPageRefresh, ajaxDivId);

                        break;
                    }
                }
            }
            //如果标签中存在<stl:pageSqlContents>
            else if (StlParserUtility.IsStlElementExists(StlPageSqlContents.ElementName, stlElementList))
            {
                var stlElement = StlParserUtility.GetStlElement(StlPageSqlContents.ElementName, stlElementList);
                var stlPageSqlContentsElement = stlElement;
                var stlPageSqlContentsElementReplaceString = stlElement;

                var pageSqlContentsElementParser = new StlPageSqlContents(stlPageSqlContentsElement, pageInfo, contextInfo, true);
                int totalNum;
                var pageCount = pageSqlContentsElementParser.GetPageCount(out totalNum);

                for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                {
                    if (currentPageIndex == pageIndex)
                    {
                        var pageHtml = pageSqlContentsElementParser.Parse(currentPageIndex, pageCount);
                        contentBuilder.Replace(stlPageSqlContentsElementReplaceString, pageHtml);

                        StlParserManager.ReplacePageElementsInDynamicPage(contentBuilder, pageInfo, stlElementList, pageUrl, pageInfo.PageNodeId, currentPageIndex, pageCount, totalNum, isPageRefresh, ajaxDivId);

                        break;
                    }
                }
            }

            else if (StlParserUtility.IsStlElementExists(StlPageItems.ElementName, stlElementList))
            {
                var pageCount             = TranslateUtils.ToInt(queryString["pageCount"]);
                var totalNum              = TranslateUtils.ToInt(queryString["totalNum"]);
                var pageContentsAjaxDivId = queryString["pageContentsAjaxDivID"];

                for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                {
                    if (currentPageIndex == pageIndex)
                    {
                        StlParserManager.ReplacePageElementsInDynamicPage(contentBuilder, pageInfo, stlElementList, pageUrl, pageInfo.PageNodeId, currentPageIndex, pageCount, totalNum, isPageRefresh, pageContentsAjaxDivId);

                        break;
                    }
                }
            }

            StlParserManager.ParseInnerContent(contentBuilder, pageInfo, contextInfo);

            //string afterBodyScript = StlParserManager.GetPageInfoScript(pageInfo, true);
            //string beforBodyScript = StlParserManager.GetPageInfoScript(pageInfo, false);

            //return afterBodyScript + StlParserUtility.GetBackHtml(contentBuilder.ToString(), pageInfo) + beforBodyScript;

            return(StlParserUtility.GetBackHtml(contentBuilder.ToString(), pageInfo));

            //return contentBuilder.ToString();
        }
Beispiel #3
0
        private int SaveContentInfo(bool isAjaxSubmit, bool isPreview, out string errorMessage)
        {
            int savedContentId;

            errorMessage = string.Empty;
            var contentId = 0;

            if (!isPreview)
            {
                contentId = isAjaxSubmit ? TranslateUtils.ToInt(Request.Form["savedContentID"]) : Body.GetQueryInt("ID");
            }

            if (contentId == 0)
            {
                var contentInfo = ContentUtility.GetContentInfo(_tableStyle);
                try
                {
                    int nodeId = 0;
                    //contentInfo.NodeId = _nodeInfo.NodeId;
                    if (PhCategory.Visible == true)
                    {
                        nodeId = Convert.ToInt32(TbCategory.SelectedValue);
                    }
                    else
                    {
                        nodeId = _nodeInfo.NodeId;
                    }
                    contentInfo.NodeId = nodeId;
                    contentInfo.PublishmentSystemId = PublishmentSystemId;
                    contentInfo.AddUserName         = Body.AdministratorName;
                    if (contentInfo.AddDate.Year == DateUtils.SqlMinValue.Year)
                    {
                        errorMessage = $"内容添加失败:系统时间不能为{DateUtils.SqlMinValue.Year}年";
                        return(0);
                    }
                    contentInfo.LastEditUserName = contentInfo.AddUserName;
                    contentInfo.LastEditDate     = DateTime.Now;

                    //自动保存的时候,不保存编辑器的图片
                    InputTypeParser.AddValuesToAttributes(_tableStyle, _tableName, PublishmentSystemInfo, _relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes, !_isAjaxSubmit);

                    StringCollection tagCollection;

                    if (isAjaxSubmit)
                    {
                        contentInfo.ContentGroupNameCollection = Request.Form[ContentAttribute.ContentGroupNameCollection];
                        tagCollection = TagUtils.ParseTagsString(Request.Form[ContentAttribute.Tags]);

                        contentInfo.CheckedLevel = LevelManager.LevelInt.CaoGao;
                        contentInfo.IsChecked    = false;
                    }
                    else
                    {
                        contentInfo.ContentGroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroupNameCollection.Items);
                        tagCollection = TagUtils.ParseTagsString(TbTags.Text);

                        if (PhContentAttributes.Visible)
                        {
                            foreach (ListItem listItem in CblContentAttributes.Items)
                            {
                                var value         = listItem.Selected.ToString();
                                var attributeName = listItem.Value;
                                contentInfo.SetExtendedAttribute(attributeName, value);
                            }
                        }

                        contentInfo.CheckedLevel = TranslateUtils.ToIntWithNagetive(RblContentLevel.SelectedValue);
                        contentInfo.IsChecked    = contentInfo.CheckedLevel >= PublishmentSystemInfo.CheckContentLevel;
                    }
                    contentInfo.Tags = TranslateUtils.ObjectCollectionToString(tagCollection, " ");

                    if (isPreview)
                    {
                        savedContentId = DataProvider.ContentDao.InsertPreview(_tableName, PublishmentSystemInfo, _nodeInfo, contentInfo);
                    }
                    else
                    {
                        savedContentId = DataProvider.ContentDao.Insert(_tableName, PublishmentSystemInfo, contentInfo);
                        //判断是不是有审核权限
                        int checkedLevelOfUser;
                        var isCheckedOfUser = CheckManager.GetUserCheckLevel(Body.AdministratorName, PublishmentSystemInfo, contentInfo.NodeId, out checkedLevelOfUser);
                        if (LevelManager.IsCheckable(PublishmentSystemInfo, contentInfo.NodeId, contentInfo.IsChecked, contentInfo.CheckedLevel, isCheckedOfUser, checkedLevelOfUser))
                        {
                            //添加审核记录
                            BaiRongDataProvider.ContentDao.UpdateIsChecked(_tableName, PublishmentSystemId, contentInfo.NodeId, new List <int> {
                                savedContentId
                            }, 0, true, Body.AdministratorName, contentInfo.IsChecked, contentInfo.CheckedLevel, "");
                        }

                        if (PhTags.Visible)
                        {
                            TagUtils.AddTags(tagCollection, PublishmentSystemId, savedContentId);
                        }
                    }

                    contentInfo.Id = savedContentId;
                }
                catch (Exception ex)
                {
                    LogUtils.AddErrorLog(ex);
                    errorMessage = $"内容添加失败:{ex.Message}";
                    return(0);
                }

                if (!isAjaxSubmit)
                {
                    if (contentInfo.IsChecked)
                    {
                        CreateManager.CreateContentAndTrigger(PublishmentSystemId, _nodeInfo.NodeId, contentInfo.Id);
                    }

                    Body.AddSiteLog(PublishmentSystemId, _nodeInfo.NodeId, contentInfo.Id, "添加内容",
                                    $"栏目:{NodeManager.GetNodeNameNavigation(PublishmentSystemId, contentInfo.NodeId)},内容标题:{contentInfo.Title}");

                    ContentUtility.Translate(PublishmentSystemInfo, _nodeInfo.NodeId, contentInfo.Id, Request.Form["translateCollection"], ETranslateContentTypeUtils.GetEnumType(DdlTranslateType.SelectedValue), Body.AdministratorName);

                    PageUtils.Redirect(EContentModelTypeUtils.Equals(_nodeInfo.ContentModelId, EContentModelType.Photo)
                        ? PageContentPhotoUpload.GetRedirectUrl(PublishmentSystemId, _nodeInfo.NodeId, contentInfo.Id,
                                                                Body.GetQueryString("ReturnUrl"))
                        : PageContentAddAfter.GetRedirectUrl(PublishmentSystemId, _nodeInfo.NodeId, contentInfo.Id,
                                                             ReturnUrl));
                }
            }
            else
            {
                var contentInfo = DataProvider.ContentDao.GetContentInfo(_tableStyle, _tableName, contentId);
                try
                {
                    var tagsLast = contentInfo.Tags;

                    contentInfo.LastEditUserName = Body.AdministratorName;
                    contentInfo.LastEditDate     = DateTime.Now;

                    //自动保存的时候,不保存编辑器的图片
                    InputTypeParser.AddValuesToAttributes(_tableStyle, _tableName, PublishmentSystemInfo, _relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes, !_isAjaxSubmit);

                    StringCollection tagCollection;
                    if (isAjaxSubmit)
                    {
                        contentInfo.ContentGroupNameCollection = Request.Form[ContentAttribute.ContentGroupNameCollection];
                        tagCollection = TagUtils.ParseTagsString(Request.Form[ContentAttribute.Tags]);
                    }
                    else
                    {
                        contentInfo.ContentGroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroupNameCollection.Items);
                        tagCollection = TagUtils.ParseTagsString(TbTags.Text);

                        if (PhContentAttributes.Visible)
                        {
                            foreach (ListItem listItem in CblContentAttributes.Items)
                            {
                                var value         = listItem.Selected.ToString();
                                var attributeName = listItem.Value;
                                contentInfo.SetExtendedAttribute(attributeName, value);
                            }
                        }

                        var checkedLevel = TranslateUtils.ToIntWithNagetive(RblContentLevel.SelectedValue);
                        if (checkedLevel != LevelManager.LevelInt.NotChange)
                        {
                            contentInfo.IsChecked    = checkedLevel >= PublishmentSystemInfo.CheckContentLevel;
                            contentInfo.CheckedLevel = checkedLevel;
                        }
                    }
                    contentInfo.Tags = TranslateUtils.ObjectCollectionToString(tagCollection, " ");

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

                    if (PhTags.Visible)
                    {
                        TagUtils.UpdateTags(tagsLast, contentInfo.Tags, tagCollection, PublishmentSystemId, contentId);
                    }

                    if (!isAjaxSubmit)
                    {
                        ContentUtility.Translate(PublishmentSystemInfo, _nodeInfo.NodeId, contentInfo.Id, Request.Form["translateCollection"], ETranslateContentTypeUtils.GetEnumType(DdlTranslateType.SelectedValue), Body.AdministratorName);

                        if (EContentModelTypeUtils.Equals(_nodeInfo.ContentModelId, EContentModelType.Photo))
                        {
                            PageUtils.Redirect(PageContentPhotoUpload.GetRedirectUrl(PublishmentSystemId, _nodeInfo.NodeId, contentInfo.Id, Body.GetQueryString("ReturnUrl")));
                        }

                        //更新引用该内容的信息
                        //如果不是异步自动保存,那么需要将引用此内容的content修改
                        var sourceContentIdList = new List <int>
                        {
                            contentInfo.Id
                        };
                        var tableList = BaiRongDataProvider.TableCollectionDao.GetAuxiliaryTableListCreatedInDbByAuxiliaryTableType(EAuxiliaryTableType.BackgroundContent, EAuxiliaryTableType.JobContent, EAuxiliaryTableType.VoteContent);
                        foreach (var table in tableList)
                        {
                            var targetContentIdList = BaiRongDataProvider.ContentDao.GetReferenceIdList(table.TableEnName, sourceContentIdList);
                            foreach (int targetContentId in targetContentIdList)
                            {
                                var targetContentInfo = DataProvider.ContentDao.GetContentInfo(ETableStyleUtils.GetEnumType(table.AuxiliaryTableType.ToString()), table.TableEnName, targetContentId);
                                if (targetContentInfo != null && targetContentInfo.GetExtendedAttribute(ContentAttribute.TranslateContentType) == ETranslateContentType.ReferenceContent.ToString())
                                {
                                    contentInfo.Id = targetContentId;
                                    contentInfo.PublishmentSystemId = targetContentInfo.PublishmentSystemId;
                                    contentInfo.NodeId      = targetContentInfo.NodeId;
                                    contentInfo.SourceId    = targetContentInfo.SourceId;
                                    contentInfo.ReferenceId = targetContentInfo.ReferenceId;
                                    contentInfo.Taxis       = targetContentInfo.Taxis;
                                    contentInfo.SetExtendedAttribute(ContentAttribute.TranslateContentType, targetContentInfo.GetExtendedAttribute(ContentAttribute.TranslateContentType));
                                    BaiRongDataProvider.ContentDao.Update(table.TableEnName, contentInfo);

                                    //资源:图片,文件,视频
                                    var targetPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(targetContentInfo.PublishmentSystemId);
                                    var bgContentInfo       = contentInfo as BackgroundContentInfo;
                                    var bgTargetContentInfo = targetContentInfo as BackgroundContentInfo;
                                    if (bgTargetContentInfo != null && bgContentInfo != null)
                                    {
                                        if (bgContentInfo.ImageUrl != bgTargetContentInfo.ImageUrl)
                                        {
                                            //修改图片
                                            var sourceImageUrl = PathUtility.MapPath(PublishmentSystemInfo, bgContentInfo.ImageUrl);
                                            CopyReferenceFiles(targetPublishmentSystemInfo, sourceImageUrl);
                                        }
                                        else if (bgContentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl)) != bgTargetContentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl)))
                                        {
                                            var sourceImageUrls = TranslateUtils.StringCollectionToStringList(bgContentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl)));

                                            foreach (string imageUrl in sourceImageUrls)
                                            {
                                                var sourceImageUrl = PathUtility.MapPath(PublishmentSystemInfo, imageUrl);
                                                CopyReferenceFiles(targetPublishmentSystemInfo, sourceImageUrl);
                                            }
                                        }
                                        if (bgContentInfo.FileUrl != bgTargetContentInfo.FileUrl)
                                        {
                                            //修改附件
                                            var sourceFileUrl = PathUtility.MapPath(PublishmentSystemInfo, bgContentInfo.FileUrl);
                                            CopyReferenceFiles(targetPublishmentSystemInfo, sourceFileUrl);
                                        }
                                        else if (bgContentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl)) != bgTargetContentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl)))
                                        {
                                            var sourceFileUrls = TranslateUtils.StringCollectionToStringList(bgContentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl)));

                                            foreach (string fileUrl in sourceFileUrls)
                                            {
                                                var sourceFileUrl = PathUtility.MapPath(PublishmentSystemInfo, fileUrl);
                                                CopyReferenceFiles(targetPublishmentSystemInfo, sourceFileUrl);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogUtils.AddErrorLog(ex);
                    errorMessage = $"内容修改失败:{ex.Message}";
                    return(0);
                }

                if (!isAjaxSubmit)
                {
                    if (contentInfo.IsChecked)
                    {
                        CreateManager.CreateContentAndTrigger(PublishmentSystemId, _nodeInfo.NodeId, contentId);
                    }

                    Body.AddSiteLog(PublishmentSystemId, _nodeInfo.NodeId, contentId, "修改内容",
                                    $"栏目:{NodeManager.GetNodeNameNavigation(PublishmentSystemId, contentInfo.NodeId)},内容标题:{contentInfo.Title}");
                    PageUtils.Redirect($@"/siteserver/cms/pageContentStudy.aspx?PublishmentSystemID={Body.GetQueryString("PublishmentSystemID")}&NodeID={(string.IsNullOrEmpty(Body.GetQueryString("PNodeID")) ? Body.GetQueryString("NodeId") : Body.GetQueryString("PNodeID"))}");
                    //PageUtils.Redirect(ReturnUrl);
                }
                savedContentId = contentId;
            }

            return(savedContentId);
        }
Beispiel #4
0
        public static List <Article> Trigger(Model.KeywordInfo keywordInfo, string wxOpenID)
        {
            var articleList = new List <Article>();

            DataProviderWX.CountDAO.AddCount(keywordInfo.PublishmentSystemID, ECountType.RequestNews);

            var appointmentInfoList = DataProviderWX.AppointmentDAO.GetAppointmentInfoListByKeywordID(keywordInfo.PublishmentSystemID, keywordInfo.KeywordID);

            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(keywordInfo.PublishmentSystemID);

            foreach (var appointmentInfo in appointmentInfoList)
            {
                Article article = null;

                if (appointmentInfo != null && appointmentInfo.StartDate < DateTime.Now)
                {
                    var isEnd = false;

                    if (appointmentInfo.EndDate < DateTime.Now)
                    {
                        isEnd = true;
                    }

                    if (isEnd)
                    {
                        var endImageUrl = GetEndImageUrl(publishmentSystemInfo, appointmentInfo.EndImageUrl);

                        article = new Article()
                        {
                            Title       = appointmentInfo.EndTitle,
                            Description = appointmentInfo.EndSummary,
                            PicUrl      = endImageUrl
                        };
                    }
                    else
                    {
                        var imageUrl = GetImageUrl(publishmentSystemInfo, appointmentInfo.ImageUrl);
                        var pageUrl  = GetIndexUrl(publishmentSystemInfo, appointmentInfo.ID, wxOpenID);
                        if (appointmentInfo.ContentIsSingle)
                        {
                            var itemID = DataProviderWX.AppointmentItemDAO.GetItemID(publishmentSystemInfo.PublishmentSystemId, appointmentInfo.ID);
                            pageUrl = GetItemUrl(publishmentSystemInfo, appointmentInfo.ID, itemID, wxOpenID);
                        }

                        article = new Article()
                        {
                            Title       = appointmentInfo.Title,
                            Description = appointmentInfo.Summary,
                            PicUrl      = imageUrl,
                            Url         = pageUrl
                        };
                    }
                }

                if (article != null)
                {
                    articleList.Add(article);
                }
            }

            return(articleList);
        }
Beispiel #5
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            LtlUserName.Text = AdminManager.GetDisplayName(Body.AdministratorName, true);

            _menuId      = Body.GetQueryString("menuID");
            _permissions = PermissionsManager.GetPermissions(Body.AdministratorName);

            if (string.IsNullOrEmpty(_menuId))
            {
                var publishmentSystemId = PublishmentSystemId;

                if (publishmentSystemId == 0)
                {
                    publishmentSystemId = Body.AdministratorInfo.PublishmentSystemId;
                }

                var publishmentSystemIdList = ProductPermissionsManager.Current.PublishmentSystemIdList;

                //站点要判断是否存在,是否有权限
                if (publishmentSystemId == 0 || !PublishmentSystemManager.IsExists(publishmentSystemId) || !publishmentSystemIdList.Contains(publishmentSystemId))
                {
                    if (publishmentSystemIdList != null && publishmentSystemIdList.Count > 0)
                    {
                        publishmentSystemId = publishmentSystemIdList[0];
                    }
                }

                _publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);

                if (_publishmentSystemInfo != null && _publishmentSystemInfo.PublishmentSystemId > 0)
                {
                    if (PublishmentSystemId == 0)
                    {
                        PageUtils.Redirect(GetRedirectUrl(_publishmentSystemInfo.PublishmentSystemId, string.Empty));
                        return;
                    }

                    var showPublishmentSystem = false;

                    var permissionList = new List <string>();
                    if (ProductPermissionsManager.Current.WebsitePermissionDict.ContainsKey(_publishmentSystemInfo.PublishmentSystemId))
                    {
                        var websitePermissionList = ProductPermissionsManager.Current.WebsitePermissionDict[_publishmentSystemInfo.PublishmentSystemId];
                        if (websitePermissionList != null)
                        {
                            showPublishmentSystem = true;
                            permissionList.AddRange(websitePermissionList);
                        }
                    }

                    ICollection nodeIdCollection = ProductPermissionsManager.Current.ChannelPermissionDict.Keys;
                    foreach (int nodeId in nodeIdCollection)
                    {
                        if (NodeManager.IsAncestorOrSelf(_publishmentSystemInfo.PublishmentSystemId, _publishmentSystemInfo.PublishmentSystemId, nodeId))
                        {
                            showPublishmentSystem = true;
                            var list = ProductPermissionsManager.Current.ChannelPermissionDict[nodeId];
                            permissionList.AddRange(list);
                        }
                    }

                    var publishmentSystemIdHashtable = new Hashtable();
                    if (publishmentSystemIdList != null)
                    {
                        foreach (var thePublishmentSystemId in publishmentSystemIdList)
                        {
                            publishmentSystemIdHashtable.Add(thePublishmentSystemId, thePublishmentSystemId);
                        }
                    }

                    if (!publishmentSystemIdHashtable.Contains(PublishmentSystemId))
                    {
                        showPublishmentSystem = false;
                    }

                    if (!showPublishmentSystem)
                    {
                        PageUtils.RedirectToErrorPage("您没有此发布系统的操作权限!");
                        return;
                    }

                    NtLeftMenu.TopId = AppManager.IdManagement;
                    NtLeftMenu.PublishmentSystemId = _publishmentSystemInfo.PublishmentSystemId;
                    NtLeftMenu.PermissionList      = permissionList;

                    ClientScriptRegisterClientScriptBlock("NodeTreeScript", NodeNaviTreeItem.GetNavigationBarScript());
                }
                else
                {
                    if (_permissions.IsSystemAdministrator)
                    {
                        PageUtils.Redirect(PagePublishmentSystemAdd.GetRedirectUrl());
                        return;
                    }
                }
            }
            else if (!string.IsNullOrEmpty(_menuId))
            {
                var permissionList = new List <string>();
                if (ProductPermissionsManager.Current.WebsitePermissionDict.ContainsKey(PublishmentSystemId))
                {
                    var websitePermissionList = ProductPermissionsManager.Current.WebsitePermissionDict[PublishmentSystemId];
                    if (websitePermissionList != null)
                    {
                        permissionList.AddRange(websitePermissionList);
                    }
                }

                permissionList.AddRange(_permissions.PermissionList);
                NtLeftMenu.TopId          = _menuId;
                NtLeftMenu.PermissionList = permissionList;

                ClientScriptRegisterClientScriptBlock("NodeTreeScript", NavigationTreeItem.GetNavigationBarScript());
            }

            var topMenuList = new List <int> {
                1, 2
            };

            //cms超管和有权限的管理员
            if (_permissions.IsConsoleAdministrator || _permissions.PermissionList.Count > 0)
            {
                topMenuList.Add(3);
            }
            RptTopMenu.DataSource     = topMenuList;
            RptTopMenu.ItemDataBound += RptTopMenu_ItemDataBound;
            RptTopMenu.DataBind();

            //避免空引用异常
            if (_publishmentSystemInfo != null && _publishmentSystemInfo.PublishmentSystemId > 0)
            {
                BaiRongDataProvider.AdministratorDao.UpdatePublishmentSystemId(Body.AdministratorName, _publishmentSystemInfo.PublishmentSystemId);
            }
        }
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID");

            _isHeadquarters = PublishmentSystemInfo.IsHeadquarters;

            var selectedList = new ArrayList();

            if (!Page.IsPostBack)
            {
                if (_isHeadquarters)
                {
                    HeadquartersExists.Visible   = false;
                    ChangeToSite.Visible         = true;
                    ChangeToHeadquarters.Visible = false;
                    var fileSystems = FileManager.GetFileSystemInfoExtendCollection(WebConfigUtils.PhysicalApplicationPath, true);
                    var publishmentSystemDirList = DataProvider.PublishmentSystemDao.GetLowerPublishmentSystemDirListThatNotIsHeadquarters();
                    foreach (FileSystemInfoExtend fileSystem in fileSystems)
                    {
                        if (fileSystem.IsDirectory)
                        {
                            if (!DirectoryUtils.IsSystemDirectory(fileSystem.Name) && !publishmentSystemDirList.Contains(fileSystem.Name.ToLower()))
                            {
                                FilesToSite.Items.Add(new ListItem(fileSystem.Name, fileSystem.Name));
                            }
                        }
                        else
                        {
                            if (!PathUtility.IsSystemFileForChangePublishmentSystemType(fileSystem.Name))
                            {
                                FilesToSite.Items.Add(new ListItem(fileSystem.Name, fileSystem.Name));
                            }
                        }

                        if (PathUtility.IsWebSiteFile(fileSystem.Name) || DirectoryUtils.IsWebSiteDirectory(fileSystem.Name))
                        {
                            selectedList.Add(fileSystem.Name);
                        }
                    }

                    //主站下的单页模板
                    var fileTemplateInfoList = DataProvider.TemplateDao.GetTemplateInfoArrayListByType(PublishmentSystemId, ETemplateType.FileTemplate);
                    foreach (TemplateInfo fileT in fileTemplateInfoList)
                    {
                        if (fileT.CreatedFileFullName.StartsWith("@/") || fileT.CreatedFileFullName.StartsWith("~/"))
                        {
                            var arr = fileT.CreatedFileFullName.Substring(2).Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                            if (arr.Length > 0)
                            {
                                selectedList.Add(arr[0]);
                            }
                        }
                    }
                }
                else
                {
                    var headquartersExists           = false;
                    var publishmentSystemIDArrayList = PublishmentSystemManager.GetPublishmentSystemIdList();
                    foreach (int psID in publishmentSystemIDArrayList)
                    {
                        var psInfo = PublishmentSystemManager.GetPublishmentSystemInfo(psID);
                        if (psInfo.IsHeadquarters)
                        {
                            headquartersExists = true;
                            break;
                        }
                    }
                    if (headquartersExists)
                    {
                        HeadquartersExists.Visible   = true;
                        ChangeToSite.Visible         = false;
                        ChangeToHeadquarters.Visible = false;
                    }
                    else
                    {
                        HeadquartersExists.Visible   = false;
                        ChangeToSite.Visible         = false;
                        ChangeToHeadquarters.Visible = true;
                    }
                }

                //设置选中的文件以及文件夹
                ControlUtils.SelectListItems(FilesToSite, selectedList);
            }
        }
Beispiel #7
0
        public HttpResponseMessage Main()
        {
            var body = new RequestBody();

            var siteId     = TranslateUtils.ToInt(body.GetQueryString("siteId"));
            var uploadType = EInputTypeUtils.GetEnumType(body.GetQueryString("uploadType"));

            var errorMessage          = string.Empty;
            var fileUrls              = new List <string>();
            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(siteId);

            if (body.IsUserLoggin && publishmentSystemInfo != null)
            {
                try
                {
                    if (HttpContext.Current.Request.Files.Count > 0)
                    {
                        for (var i = 0; i < HttpContext.Current.Request.Files.Count; i++)
                        {
                            var postedFile         = HttpContext.Current.Request.Files[i];
                            var filePath           = postedFile.FileName;
                            var fileExtName        = PathUtils.GetExtension(filePath).ToLower();
                            var localDirectoryPath = PathUtility.GetUploadDirectoryPath(publishmentSystemInfo, fileExtName);
                            var localFileName      = PathUtility.GetUploadFileName(publishmentSystemInfo, filePath);
                            var localFilePath      = PathUtils.Combine(localDirectoryPath, localFileName);

                            if (uploadType == EInputType.Image)
                            {
                                if (!PathUtility.IsImageExtenstionAllowed(publishmentSystemInfo, fileExtName))
                                {
                                    errorMessage = "上传图片格式不正确!";
                                    break;
                                }
                                else if (!PathUtility.IsImageSizeAllowed(publishmentSystemInfo, postedFile.ContentLength))
                                {
                                    errorMessage = "上传失败,上传图片超出规定文件大小!";
                                    break;
                                }

                                postedFile.SaveAs(localFilePath);
                                FileUtility.AddWaterMark(publishmentSystemInfo, localFilePath);
                                var imageUrl = PageUtility.GetPublishmentSystemUrlByPhysicalPath(publishmentSystemInfo, localFilePath);
                                fileUrls.Add(imageUrl);
                            }
                            else if (uploadType == EInputType.Video)
                            {
                                if (!PathUtility.IsVideoExtenstionAllowed(publishmentSystemInfo, fileExtName))
                                {
                                    errorMessage = "上传视频格式不正确!";
                                    break;
                                }
                                if (!PathUtility.IsVideoSizeAllowed(publishmentSystemInfo, postedFile.ContentLength))
                                {
                                    errorMessage = "上传失败,上传视频超出规定文件大小!";
                                    break;
                                }
                                postedFile.SaveAs(localFilePath);
                                var videoUrl = PageUtility.GetPublishmentSystemUrlByPhysicalPath(publishmentSystemInfo, localFilePath);
                                fileUrls.Add(videoUrl);
                            }
                            else if (uploadType == EInputType.File)
                            {
                                if (!PathUtility.IsFileExtenstionAllowed(publishmentSystemInfo, fileExtName))
                                {
                                    errorMessage = "此格式不允许上传,请选择有效的文件!";
                                    break;
                                }
                                if (!PathUtility.IsFileSizeAllowed(publishmentSystemInfo, postedFile.ContentLength))
                                {
                                    errorMessage = "上传失败,上传文件超出规定文件大小!";
                                    break;
                                }
                                postedFile.SaveAs(localFilePath);
                                FileUtility.AddWaterMark(publishmentSystemInfo, localFilePath);
                                var fileUrl = PageUtility.GetPublishmentSystemUrlByPhysicalPath(publishmentSystemInfo, localFilePath);
                                fileUrls.Add(fileUrl);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    //errorMessage = ex.Message;
                    errorMessage = "程序错误";
                }
            }

            var builder = new StringBuilder();

            if (fileUrls.Count == 0)
            {
                builder.Append("{\"errorMessage\":\"");
                builder.Append(!string.IsNullOrEmpty(errorMessage) ? errorMessage : "未知错误");
                builder.Append("\"}");
            }
            else
            {
                builder.Append("{\"fileUrls\":[");
                foreach (var fileUrl in fileUrls)
                {
                    builder.Append("\"");
                    builder.Append(fileUrl);
                    builder.Append("\",");
                }
                builder.Length--;
                builder.Append("]}");
            }

            var resp = new HttpResponseMessage();

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.Headers.Get("X-Access-Token")))
            {
                resp.Content = new StringContent(builder.ToString(), Encoding.UTF8, "application/json");
            }
            else
            {
                resp.Content = new StringContent(builder.ToString(), Encoding.UTF8, "text/plain");
            }

            return(resp);
        }
Beispiel #8
0
        private void TranslateChannelAndContent(List <NodeInfo> nodeInfoList, int targetPublishmentSystemID, int parentID, ETranslateType translateType, bool isChecked, int checkedLevel, List <string> nodeIndexNameList, List <string> filePathList)
        {
            if (nodeInfoList == null || nodeInfoList.Count == 0)
            {
                return;
            }

            if (nodeIndexNameList == null)
            {
                nodeIndexNameList = DataProvider.NodeDao.GetNodeIndexNameList(targetPublishmentSystemID);
            }

            if (filePathList == null)
            {
                filePathList = DataProvider.NodeDao.GetAllFilePathByPublishmentSystemId(targetPublishmentSystemID);
            }

            var targetPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(targetPublishmentSystemID);

            foreach (NodeInfo oldNodeInfo in nodeInfoList)
            {
                var nodeInfo = new NodeInfo(oldNodeInfo);
                nodeInfo.PublishmentSystemId = targetPublishmentSystemID;
                nodeInfo.ParentId            = parentID;
                nodeInfo.ContentNum          = 0;
                nodeInfo.ChildrenCount       = 0;

                nodeInfo.AddDate = DateTime.Now;
                if (IsDeleteAfterTranslate.Visible && EBooleanUtils.Equals(IsDeleteAfterTranslate.SelectedValue, EBoolean.True))
                {
                    nodeIndexNameList.Add(nodeInfo.NodeIndexName);
                }

                else if (!string.IsNullOrEmpty(nodeInfo.NodeIndexName) && nodeIndexNameList.IndexOf(nodeInfo.NodeIndexName) == -1)
                {
                    nodeIndexNameList.Add(nodeInfo.NodeIndexName);
                }
                else
                {
                    nodeInfo.NodeIndexName = string.Empty;
                }

                if (!string.IsNullOrEmpty(nodeInfo.FilePath) && filePathList.IndexOf(nodeInfo.FilePath) == -1)
                {
                    filePathList.Add(nodeInfo.FilePath);
                }
                else
                {
                    nodeInfo.FilePath = string.Empty;
                }

                var insertedNodeID = DataProvider.NodeDao.InsertNodeInfo(nodeInfo);

                if (translateType == ETranslateType.All)
                {
                    TranslateContent(targetPublishmentSystemInfo, oldNodeInfo.NodeId, insertedNodeID, isChecked, checkedLevel);
                }

                if (insertedNodeID != 0)
                {
                    var orderByString        = ETaxisTypeUtils.GetChannelOrderByString(ETaxisType.OrderByTaxis);
                    var childrenNodeInfoList = DataProvider.NodeDao.GetNodeInfoList(oldNodeInfo, 0, "", EScopeType.Children, orderByString);
                    if (childrenNodeInfoList != null && childrenNodeInfoList.Count > 0)
                    {
                        TranslateChannelAndContent(childrenNodeInfoList, targetPublishmentSystemID, insertedNodeID, translateType, isChecked, checkedLevel, nodeIndexNameList, filePathList);
                    }

                    if (isChecked)
                    {
                        CreateManager.CreateChannel(targetPublishmentSystemInfo.PublishmentSystemId, insertedNodeID);
                    }
                }
            }
        }
Beispiel #9
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID");
            returnUrl = StringUtils.ValueFromUrl(Body.GetQueryString("ReturnUrl"));

            if (!HasChannelPermissions(PublishmentSystemId, AppManager.Cms.Permission.Channel.ContentDelete))
            {
                IsDeleteAfterTranslate.Visible = false;
            }

            if (!IsPostBack)
            {
                BreadCrumb(AppManager.Cms.LeftMenu.IdContent, "批量转移", string.Empty);

                phReturn.Visible = !string.IsNullOrEmpty(returnUrl);
                ETranslateTypeUtils.AddListItems(TranslateType);
                if (Body.IsQueryExists("ChannelIDCollection"))
                {
                    ControlUtils.SelectListItems(TranslateType, ETranslateTypeUtils.GetValue(ETranslateType.All));
                }
                else
                {
                    ControlUtils.SelectListItems(TranslateType, ETranslateTypeUtils.GetValue(ETranslateType.Content));
                }

                IsDeleteAfterTranslate.Items[0].Value = true.ToString();
                IsDeleteAfterTranslate.Items[1].Value = false.ToString();

                var publishmentSystemIDList = ProductPermissionsManager.Current.PublishmentSystemIdList;
                foreach (var psID in publishmentSystemIDList)
                {
                    var psInfo   = PublishmentSystemManager.GetPublishmentSystemInfo(psID);
                    var listitem = new ListItem(psInfo.PublishmentSystemName, psID.ToString());
                    if (psID == PublishmentSystemId)
                    {
                        listitem.Selected = true;
                    }
                    PublishmentSystemIDDropDownList.Items.Add(listitem);
                }

                var nodeIDStrArrayList = new List <string>();
                if (Body.IsQueryExists("ChannelIDCollection"))
                {
                    nodeIDStrArrayList = TranslateUtils.StringCollectionToStringList(Body.GetQueryString("ChannelIDCollection"));
                }

                var nodeIdList = DataProvider.NodeDao.GetNodeIdListByPublishmentSystemId(PublishmentSystemId);
                var nodeCount  = nodeIdList.Count;
                isLastNodeArray = new bool[nodeCount];
                foreach (int theNodeID in nodeIdList)
                {
                    var enabled = IsOwningNodeId(theNodeID);
                    if (!enabled)
                    {
                        if (!IsHasChildOwningNodeId(theNodeID))
                        {
                            continue;
                        }
                    }
                    var nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, theNodeID);

                    var value = enabled ? nodeInfo.NodeId.ToString() : string.Empty;
                    value = (nodeInfo.Additional.IsContentAddable) ? value : string.Empty;

                    var text     = GetTitle(nodeInfo);
                    var listItem = new ListItem(text, value);
                    if (nodeIDStrArrayList.Contains(value))
                    {
                        listItem.Selected = true;
                    }
                    NodeIDFrom.Items.Add(listItem);
                    listItem = new ListItem(text, value);
                    NodeIDTo.Items.Add(listItem);
                }
            }
        }
Beispiel #10
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID");

            if (!IsPostBack)
            {
                BreadCrumbSys(AppManager.Sys.LeftMenu.Site, "修改站点", AppManager.Sys.Permission.SysSite);

                if (PublishmentSystemInfo.IsHeadquarters)
                {
                    ParentPublishmentSystemIDRow.Visible = false;
                }
                else
                {
                    ParentPublishmentSystemIDRow.Visible = true;

                    ParentPublishmentSystemID.Items.Add(new ListItem("<无上级站点>", "0"));
                    var publishmentSystemIDArrayList = PublishmentSystemManager.GetPublishmentSystemIdList();
                    var mySystemInfoArrayList        = new ArrayList();
                    var parentWithChildren           = new Hashtable();
                    foreach (int publishmentSystemID in publishmentSystemIDArrayList)
                    {
                        if (publishmentSystemID == PublishmentSystemId)
                        {
                            continue;
                        }
                        var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemID);
                        if (publishmentSystemInfo.IsHeadquarters == false)
                        {
                            if (publishmentSystemInfo.ParentPublishmentSystemId == 0)
                            {
                                mySystemInfoArrayList.Add(publishmentSystemInfo);
                            }
                            else
                            {
                                var children = new ArrayList();
                                if (parentWithChildren.Contains(publishmentSystemInfo.ParentPublishmentSystemId))
                                {
                                    children = (ArrayList)parentWithChildren[publishmentSystemInfo.ParentPublishmentSystemId];
                                }
                                children.Add(publishmentSystemInfo);
                                parentWithChildren[publishmentSystemInfo.ParentPublishmentSystemId] = children;
                            }
                        }
                    }
                    foreach (PublishmentSystemInfo publishmentSystemInfo in mySystemInfoArrayList)
                    {
                        AddSite(ParentPublishmentSystemID, publishmentSystemInfo, parentWithChildren, 0);
                    }
                    ControlUtils.SelectListItems(ParentPublishmentSystemID, PublishmentSystemInfo.ParentPublishmentSystemId.ToString());
                }

                var tableList = BaiRongDataProvider.TableCollectionDao.GetAuxiliaryTableListCreatedInDbByAuxiliaryTableType(EAuxiliaryTableType.BackgroundContent);
                foreach (AuxiliaryTableInfo tableInfo in tableList)
                {
                    var li = new ListItem($"{tableInfo.TableCnName}({tableInfo.TableEnName})", tableInfo.TableEnName);
                    AuxiliaryTableForContent.Items.Add(li);
                }

                tableList = BaiRongDataProvider.TableCollectionDao.GetAuxiliaryTableListCreatedInDbByAuxiliaryTableType(EAuxiliaryTableType.VoteContent);
                foreach (AuxiliaryTableInfo tableInfo in tableList)
                {
                    var li = new ListItem($"{tableInfo.TableCnName}({tableInfo.TableEnName})", tableInfo.TableEnName);
                    AuxiliaryTableForVote.Items.Add(li);
                }

                tableList = BaiRongDataProvider.TableCollectionDao.GetAuxiliaryTableListCreatedInDbByAuxiliaryTableType(EAuxiliaryTableType.JobContent);
                foreach (AuxiliaryTableInfo tableInfo in tableList)
                {
                    var li = new ListItem($"{tableInfo.TableCnName}({tableInfo.TableEnName})", tableInfo.TableEnName);
                    AuxiliaryTableForJob.Items.Add(li);
                }

                Taxis.Text = PublishmentSystemInfo.Taxis.ToString();

                IsCheckContentUseLevel.Items.Add(new ListItem("默认审核机制", false.ToString()));
                IsCheckContentUseLevel.Items.Add(new ListItem("多级审核机制", true.ToString()));

                if (PublishmentSystemInfo == null)
                {
                    PageUtils.RedirectToErrorPage("站点不存在,请确认后再试!");
                    return;
                }
                PublishmentSystemName.Text = PublishmentSystemInfo.PublishmentSystemName;
                ControlUtils.SelectListItems(IsCheckContentUseLevel, PublishmentSystemInfo.IsCheckContentUseLevel.ToString());
                if (PublishmentSystemInfo.IsCheckContentUseLevel)
                {
                    ControlUtils.SelectListItems(CheckContentLevel, PublishmentSystemInfo.CheckContentLevel.ToString());
                    CheckContentLevelRow.Visible = true;
                }
                else
                {
                    CheckContentLevelRow.Visible = false;
                }
                if (!string.IsNullOrEmpty(PublishmentSystemInfo.PublishmentSystemDir))
                {
                    PublishmentSystemDir.Text = PathUtils.GetDirectoryName(PublishmentSystemInfo.PublishmentSystemDir);
                }
                if (PublishmentSystemInfo.IsHeadquarters)
                {
                    PublishmentSystemDirRow.Visible = false;
                }
                foreach (ListItem item in AuxiliaryTableForContent.Items)
                {
                    if (item.Value.Equals(PublishmentSystemInfo.AuxiliaryTableForContent))
                    {
                        item.Selected = true;
                    }
                    else
                    {
                        item.Selected = false;
                    }
                }
                foreach (ListItem item in AuxiliaryTableForVote.Items)
                {
                    if (item.Value.Equals(PublishmentSystemInfo.AuxiliaryTableForVote))
                    {
                        item.Selected = true;
                    }
                    else
                    {
                        item.Selected = false;
                    }
                }
                foreach (ListItem item in AuxiliaryTableForJob.Items)
                {
                    if (item.Value.Equals(PublishmentSystemInfo.AuxiliaryTableForJob))
                    {
                        item.Selected = true;
                    }
                    else
                    {
                        item.Selected = false;
                    }
                }

                Submit.Attributes.Add("onclick", GetShowHintScript());
            }
        }
Beispiel #11
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                var targetNodeID = int.Parse(NodeIDTo.SelectedValue);

                var targetPublishmentSystemID   = int.Parse(PublishmentSystemIDDropDownList.SelectedValue);
                var targetPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(targetPublishmentSystemID);
                var isChecked    = false;
                var checkedLevel = 0;
                if (targetPublishmentSystemInfo.CheckContentLevel == 0 || AdminUtility.HasChannelPermissions(Body.AdministratorName, targetPublishmentSystemID, targetNodeID, AppManager.Cms.Permission.Channel.ContentAdd, AppManager.Cms.Permission.Channel.ContentCheck))
                {
                    isChecked    = true;
                    checkedLevel = 0;
                }
                else
                {
                    var UserCheckLevel  = 0;
                    var OwnHighestLevel = false;

                    if (AdminUtility.HasChannelPermissions(Body.AdministratorName, targetPublishmentSystemID, targetNodeID, AppManager.Cms.Permission.Channel.ContentCheckLevel1))
                    {
                        UserCheckLevel = 1;
                        if (AdminUtility.HasChannelPermissions(Body.AdministratorName, targetPublishmentSystemID, targetNodeID, AppManager.Cms.Permission.Channel.ContentCheckLevel2))
                        {
                            UserCheckLevel = 2;
                            if (AdminUtility.HasChannelPermissions(Body.AdministratorName, targetPublishmentSystemID, targetNodeID, AppManager.Cms.Permission.Channel.ContentCheckLevel3))
                            {
                                UserCheckLevel = 3;
                                if (AdminUtility.HasChannelPermissions(Body.AdministratorName, targetPublishmentSystemID, targetNodeID, AppManager.Cms.Permission.Channel.ContentCheckLevel4))
                                {
                                    UserCheckLevel = 4;
                                    if (AdminUtility.HasChannelPermissions(Body.AdministratorName, targetPublishmentSystemID, targetNodeID, AppManager.Cms.Permission.Channel.ContentCheckLevel5))
                                    {
                                        UserCheckLevel = 5;
                                    }
                                }
                            }
                        }
                    }

                    if (UserCheckLevel >= targetPublishmentSystemInfo.CheckContentLevel)
                    {
                        OwnHighestLevel = true;
                    }
                    if (OwnHighestLevel)
                    {
                        isChecked    = true;
                        checkedLevel = 0;
                    }
                    else
                    {
                        isChecked    = false;
                        checkedLevel = UserCheckLevel;
                    }
                }

                try
                {
                    var translateType = ETranslateTypeUtils.GetEnumType(TranslateType.SelectedValue);

                    var nodeIDStrArrayList = ControlUtils.GetSelectedListControlValueArrayList(NodeIDFrom);

                    var nodeIDArrayList = new ArrayList();//需要转移的栏目ID
                    foreach (string nodeIDStr in nodeIDStrArrayList)
                    {
                        var nodeID = int.Parse(nodeIDStr);
                        if (translateType != ETranslateType.Content)//需要转移栏目
                        {
                            if (!NodeManager.IsAncestorOrSelf(PublishmentSystemId, nodeID, targetNodeID))
                            {
                                nodeIDArrayList.Add(nodeID);
                            }
                        }

                        if (translateType == ETranslateType.Content)//转移内容
                        {
                            TranslateContent(targetPublishmentSystemInfo, nodeID, targetNodeID, isChecked, checkedLevel);
                        }
                    }

                    if (translateType != ETranslateType.Content)//需要转移栏目
                    {
                        var nodeIDArrayListToTranslate = new ArrayList(nodeIDArrayList);
                        foreach (int nodeID in nodeIDArrayList)
                        {
                            var subNodeIDArrayList = DataProvider.NodeDao.GetNodeIdListForDescendant(nodeID);
                            if (subNodeIDArrayList != null && subNodeIDArrayList.Count > 0)
                            {
                                foreach (int nodeIDToDelete in subNodeIDArrayList)
                                {
                                    if (nodeIDArrayListToTranslate.Contains(nodeIDToDelete))
                                    {
                                        nodeIDArrayListToTranslate.Remove(nodeIDToDelete);
                                    }
                                }
                            }
                        }

                        var nodeInfoList = new List <NodeInfo>();
                        foreach (int nodeID in nodeIDArrayListToTranslate)
                        {
                            var nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, nodeID);
                            nodeInfoList.Add(nodeInfo);
                        }

                        TranslateChannelAndContent(nodeInfoList, targetPublishmentSystemID, targetNodeID, translateType, isChecked, checkedLevel, null, null);

                        if (IsDeleteAfterTranslate.Visible && EBooleanUtils.Equals(IsDeleteAfterTranslate.SelectedValue, EBoolean.True))
                        {
                            foreach (int nodeID in nodeIDArrayListToTranslate)
                            {
                                try
                                {
                                    DataProvider.NodeDao.Delete(nodeID);
                                }
                                catch { }
                            }
                        }
                    }
                    Submit.Enabled = false;

                    var builder = new StringBuilder();
                    foreach (ListItem listItem in NodeIDFrom.Items)
                    {
                        if (listItem.Selected)
                        {
                            builder.Append(listItem.Text).Append(",");
                        }
                    }
                    if (builder.Length > 0)
                    {
                        builder.Length = builder.Length - 1;
                    }
                    Body.AddSiteLog(PublishmentSystemId, "批量转移", $"栏目:{builder},转移后删除:{IsDeleteAfterTranslate.SelectedValue}");

                    SuccessMessage("批量转移成功!");
                    if (Body.IsQueryExists("ChannelIDCollection"))
                    {
                        PageUtils.Redirect(returnUrl);
                    }
                    else
                    {
                        PageUtils.Redirect(GetRedirectUrl(PublishmentSystemId));
                    }
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "批量转移失败!");
                    LogUtils.AddErrorLog(ex);
                }
            }
        }
Beispiel #12
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                PublishmentSystemInfo.PublishmentSystemName = PublishmentSystemName.Text;
                PublishmentSystemInfo.Taxis = TranslateUtils.ToInt(Taxis.Text);
                PublishmentSystemInfo.IsCheckContentUseLevel = TranslateUtils.ToBool(IsCheckContentUseLevel.SelectedValue);
                if (PublishmentSystemInfo.IsCheckContentUseLevel)
                {
                    PublishmentSystemInfo.CheckContentLevel = TranslateUtils.ToInt(CheckContentLevel.SelectedValue);
                }

                var isTableChanged = false;

                if (PublishmentSystemInfo.AuxiliaryTableForContent != AuxiliaryTableForContent.SelectedValue)
                {
                    isTableChanged = true;
                    PublishmentSystemInfo.AuxiliaryTableForContent = AuxiliaryTableForContent.SelectedValue;
                }
                if (PublishmentSystemInfo.AuxiliaryTableForVote != AuxiliaryTableForVote.SelectedValue)
                {
                    isTableChanged = true;
                    PublishmentSystemInfo.AuxiliaryTableForVote = AuxiliaryTableForVote.SelectedValue;
                }
                if (PublishmentSystemInfo.AuxiliaryTableForJob != AuxiliaryTableForJob.SelectedValue)
                {
                    isTableChanged = true;
                    PublishmentSystemInfo.AuxiliaryTableForJob = AuxiliaryTableForJob.SelectedValue;
                }

                if (PublishmentSystemInfo.IsHeadquarters == false)
                {
                    if (!StringUtils.EqualsIgnoreCase(PathUtils.GetDirectoryName(PublishmentSystemInfo.PublishmentSystemDir), PublishmentSystemDir.Text))
                    {
                        var list = DataProvider.NodeDao.GetLowerSystemDirList(PublishmentSystemInfo.ParentPublishmentSystemId);
                        if (list.IndexOf(PublishmentSystemDir.Text.ToLower()) != -1)
                        {
                            FailMessage("站点修改失败,已存在相同的发布路径!");
                            return;
                        }

                        try
                        {
                            var parentPSPath = WebConfigUtils.PhysicalApplicationPath;
                            if (PublishmentSystemInfo.ParentPublishmentSystemId > 0)
                            {
                                var parentPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(PublishmentSystemInfo.ParentPublishmentSystemId);
                                parentPSPath = PathUtility.GetPublishmentSystemPath(parentPublishmentSystemInfo);
                            }
                            DirectoryUtility.ChangePublishmentSystemDir(parentPSPath, PublishmentSystemInfo.PublishmentSystemDir, PublishmentSystemDir.Text);
                        }
                        catch (Exception ex)
                        {
                            FailMessage(ex, "站点修改失败,发布路径文件夹已存在!");
                            return;
                        }
                    }

                    if (ParentPublishmentSystemIDRow.Visible && PublishmentSystemInfo.ParentPublishmentSystemId != TranslateUtils.ToInt(ParentPublishmentSystemID.SelectedValue))
                    {
                        var newParentPublishmentSystemID = TranslateUtils.ToInt(ParentPublishmentSystemID.SelectedValue);
                        var list = DataProvider.NodeDao.GetLowerSystemDirList(newParentPublishmentSystemID);
                        if (list.IndexOf(PublishmentSystemDir.Text.ToLower()) != -1)
                        {
                            FailMessage("站点修改失败,已存在相同的发布路径!");
                            return;
                        }

                        try
                        {
                            DirectoryUtility.ChangeParentPublishmentSystem(PublishmentSystemInfo.ParentPublishmentSystemId, TranslateUtils.ToInt(ParentPublishmentSystemID.SelectedValue), PublishmentSystemId, PublishmentSystemDir.Text);
                            PublishmentSystemInfo.ParentPublishmentSystemId = newParentPublishmentSystemID;
                        }
                        catch (Exception ex)
                        {
                            FailMessage(ex, "站点修改失败,发布路径文件夹已存在!");
                            return;
                        }
                    }

                    PublishmentSystemInfo.PublishmentSystemDir = PublishmentSystemDir.Text;
                }

                try
                {
                    DataProvider.PublishmentSystemDao.Update(PublishmentSystemInfo);
                    if (isTableChanged)
                    {
                        DataProvider.NodeDao.UpdateContentNum(PublishmentSystemInfo);
                    }

                    Body.AddAdminLog("修改站点属性", $"站点:{PublishmentSystemInfo.PublishmentSystemName}");

                    SuccessMessage("站点修改成功!");
                    AddWaitAndRedirectScript(PagePublishmentSystem.GetRedirectUrl());
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "站点修改失败!");
                }
            }
        }
        public IHttpActionResult Main(int siteId, int channelId, int contentId)
        {
            try
            {
                var body = new RequestBody();

                var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(siteId);
                if (!publishmentSystemInfo.Additional.IsCommentable)
                {
                    return(Unauthorized());
                }

                var account  = body.GetPostString("account");
                var password = body.GetPostString("password");
                var replyId  = body.GetPostInt("replyId");
                var content  = body.GetPostString("content");

                if (replyId > 0)
                {
                    string replyUserName;
                    string replyContent;
                    DataProvider.CommentDao.GetUserNameAndContent(replyId, out replyUserName, out replyContent);
                    if (!string.IsNullOrEmpty(replyContent))
                    {
                        var displayName = BaiRongDataProvider.UserDao.GetDisplayName(replyUserName);
                        if (!string.IsNullOrEmpty(displayName))
                        {
                            displayName = $"@{displayName}:";
                        }

                        content += $" //{displayName}{replyContent}";
                    }
                }

                UserInfo userInfo;
                if (!string.IsNullOrEmpty(account) && !string.IsNullOrEmpty(password))
                {
                    string userName;
                    string errorMessage;
                    if (!BaiRongDataProvider.UserDao.ValidateAccount(account, password, out userName, out errorMessage))
                    {
                        LogUtils.AddUserLog(userName, EUserActionType.LoginFailed, "用户登录失败");
                        BaiRongDataProvider.UserDao.UpdateLastActivityDateAndCountOfFailedLogin(userName);
                        return(BadRequest(errorMessage));
                    }

                    BaiRongDataProvider.UserDao.UpdateLastActivityDateAndCountOfLogin(userName);
                    userInfo = BaiRongDataProvider.UserDao.GetUserInfoByUserName(userName);

                    body.UserLogin(userName);
                }
                else
                {
                    userInfo = body.UserInfo;
                }

                if (!publishmentSystemInfo.Additional.IsAnonymousComments && !body.IsUserLoggin)
                {
                    return(Unauthorized());
                }

                var commentInfo = new CommentInfo
                {
                    Id = 0,
                    PublishmentSystemId = siteId,
                    NodeId    = channelId,
                    ContentId = contentId,
                    GoodCount = 0,
                    UserName  = userInfo.UserName,
                    IsChecked = !publishmentSystemInfo.Additional.IsCheckComments,
                    AddDate   = DateTime.Now,
                    Content   = content
                };
                commentInfo.Id = DataProvider.CommentDao.Insert(commentInfo);

                return(Ok(new
                {
                    User = new User(userInfo),
                    Comment = new Comment(commentInfo, userInfo)
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
        public void Main()
        {
            var isSuccess = false;

            try
            {
                var body = new RequestBody();

                if (!string.IsNullOrEmpty(body.GetQueryString("publishmentSystemID")) && !string.IsNullOrEmpty(body.GetQueryString("fileUrl")) && string.IsNullOrEmpty(body.GetQueryString("contentID")))
                {
                    var publishmentSystemId = body.GetQueryInt("publishmentSystemID");
                    var fileUrl             = TranslateUtils.DecryptStringBySecretKey(body.GetQueryString("fileUrl"));

                    if (PageUtils.IsProtocolUrl(fileUrl))
                    {
                        isSuccess = true;
                        PageUtils.Redirect(fileUrl);
                    }
                    else
                    {
                        var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
                        var filePath = PathUtility.MapPath(publishmentSystemInfo, fileUrl);
                        var fileType = EFileSystemTypeUtils.GetEnumType(PathUtils.GetExtension(filePath));
                        if (EFileSystemTypeUtils.IsDownload(fileType))
                        {
                            if (FileUtils.IsFileExists(filePath))
                            {
                                isSuccess = true;
                                PageUtils.Download(HttpContext.Current.Response, filePath);
                            }
                        }
                        else
                        {
                            isSuccess = true;
                            PageUtils.Redirect(PageUtility.ParseNavigationUrl(publishmentSystemInfo, fileUrl));
                        }
                    }
                }
                else if (!string.IsNullOrEmpty(body.GetQueryString("filePath")))
                {
                    var filePath = TranslateUtils.DecryptStringBySecretKey(body.GetQueryString("filePath"));
                    var fileType = EFileSystemTypeUtils.GetEnumType(PathUtils.GetExtension(filePath));
                    if (EFileSystemTypeUtils.IsDownload(fileType))
                    {
                        if (FileUtils.IsFileExists(filePath))
                        {
                            isSuccess = true;
                            PageUtils.Download(HttpContext.Current.Response, filePath);
                        }
                    }
                    else
                    {
                        isSuccess = true;
                        var fileUrl = PageUtils.GetRootUrlByPhysicalPath(filePath);
                        PageUtils.Redirect(PageUtils.ParseNavigationUrl(fileUrl));
                    }
                }
                else if (!string.IsNullOrEmpty(body.GetQueryString("publishmentSystemID")) && !string.IsNullOrEmpty(body.GetQueryString("channelID")) && !string.IsNullOrEmpty(body.GetQueryString("contentID")) && !string.IsNullOrEmpty(body.GetQueryString("fileUrl")))
                {
                    var publishmentSystemId   = body.GetQueryInt("publishmentSystemID");
                    var channelId             = body.GetQueryInt("channelID");
                    var contentId             = body.GetQueryInt("contentID");
                    var fileUrl               = TranslateUtils.DecryptStringBySecretKey(body.GetQueryString("fileUrl"));
                    var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
                    var nodeInfo              = NodeManager.GetNodeInfo(publishmentSystemId, channelId);
                    var tableStyle            = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo);
                    var tableName             = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo);
                    var contentInfo           = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentId);

                    if (!string.IsNullOrEmpty(contentInfo?.GetExtendedAttribute(BackgroundContentAttribute.FileUrl)))
                    {
                        //string fileUrl = contentInfo.GetExtendedAttribute(BackgroundContentAttribute.FileUrl);
                        if (publishmentSystemInfo.Additional.IsCountDownload)
                        {
                            CountManager.AddCount(tableName, contentId.ToString(), ECountType.Download);
                        }

                        if (PageUtils.IsProtocolUrl(fileUrl))
                        {
                            isSuccess = true;
                            PageUtils.Redirect(fileUrl);
                        }
                        else
                        {
                            var filePath = PathUtility.MapPath(publishmentSystemInfo, fileUrl, true);
                            var fileType = EFileSystemTypeUtils.GetEnumType(PathUtils.GetExtension(filePath));
                            if (EFileSystemTypeUtils.IsDownload(fileType))
                            {
                                if (FileUtils.IsFileExists(filePath))
                                {
                                    isSuccess = true;
                                    PageUtils.Download(HttpContext.Current.Response, filePath);
                                }
                            }
                            else
                            {
                                isSuccess = true;
                                PageUtils.Redirect(PageUtility.ParseNavigationUrl(publishmentSystemInfo, fileUrl));
                            }
                        }
                    }
                }
            }
            catch
            {
                // ignored
            }
            if (!isSuccess)
            {
                HttpContext.Current.Response.Write("下载失败,不存在此文件!");
            }
        }
Beispiel #15
0
        public void Import()
        {
            if (!FileUtils.IsFileExists(_filePath))
            {
                return;
            }

            var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(_filePath));

            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(_publishmentSystemId);

            //psInfo.IsCheckContentUseLevel = EBooleanUtils.GetEnumType(AtomUtility.GetDcElementContent(feed.AdditionalElements, PublishmentSystemAttribute.IsCheckContentUseLevel, EBooleanUtils.GetValue(psInfo.IsCheckContentUseLevel)));
            //psInfo.CheckContentLevel = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(feed.AdditionalElements, PublishmentSystemAttribute.CheckContentLevel, psInfo.CheckContentLevel.ToString()));
            publishmentSystemInfo.SettingsXml = AtomUtility.GetDcElementContent(feed.AdditionalElements, PublishmentSystemAttribute.SettingsXml, publishmentSystemInfo.SettingsXml);

            publishmentSystemInfo.Additional.ApiUrl              = PublishmentSystemInfoExtend.DefaultApiUrl;
            publishmentSystemInfo.Additional.HomeUrl             = PublishmentSystemInfoExtend.DefaultHomeUrl;
            publishmentSystemInfo.Additional.IsMultiDeployment   = false;
            publishmentSystemInfo.Additional.IsCreateDoubleClick = false;

            DataProvider.PublishmentSystemDao.Update(publishmentSystemInfo);

            var indexTemplateName = AtomUtility.GetDcElementContent(feed.AdditionalElements, DefaultIndexTemplateName);

            if (!string.IsNullOrEmpty(indexTemplateName))
            {
                var indexTemplateId = TemplateManager.GetTemplateIDByTemplateName(publishmentSystemInfo.PublishmentSystemId, ETemplateType.IndexPageTemplate, indexTemplateName);
                if (indexTemplateId != 0)
                {
                    DataProvider.TemplateDao.SetDefault(publishmentSystemInfo.PublishmentSystemId, indexTemplateId);
                }
            }

            var channelTemplateName = AtomUtility.GetDcElementContent(feed.AdditionalElements, DefaultChannelTemplateName);

            if (!string.IsNullOrEmpty(channelTemplateName))
            {
                var channelTemplateId = TemplateManager.GetTemplateIDByTemplateName(publishmentSystemInfo.PublishmentSystemId, ETemplateType.ChannelTemplate, channelTemplateName);
                if (channelTemplateId != 0)
                {
                    DataProvider.TemplateDao.SetDefault(publishmentSystemInfo.PublishmentSystemId, channelTemplateId);
                }
            }

            var contentTemplateName = AtomUtility.GetDcElementContent(feed.AdditionalElements, DefaultContentTemplateName);

            if (!string.IsNullOrEmpty(contentTemplateName))
            {
                var contentTemplateId = TemplateManager.GetTemplateIDByTemplateName(publishmentSystemInfo.PublishmentSystemId, ETemplateType.ContentTemplate, contentTemplateName);
                if (contentTemplateId != 0)
                {
                    DataProvider.TemplateDao.SetDefault(publishmentSystemInfo.PublishmentSystemId, contentTemplateId);
                }
            }

            var fileTemplateName = AtomUtility.GetDcElementContent(feed.AdditionalElements, DefaultFileTemplateName);

            if (!string.IsNullOrEmpty(fileTemplateName))
            {
                var fileTemplateId = TemplateManager.GetTemplateIDByTemplateName(publishmentSystemInfo.PublishmentSystemId, ETemplateType.FileTemplate, fileTemplateName);
                if (fileTemplateId != 0)
                {
                    DataProvider.TemplateDao.SetDefault(publishmentSystemInfo.PublishmentSystemId, fileTemplateId);
                }
            }

            foreach (AtomEntry entry in feed.Entries)
            {
                var isNodeGroup    = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, "IsNodeGroup"));
                var isContentGroup = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, "IsContentGroup"));
                if (isNodeGroup)
                {
                    var nodeGroupName = AtomUtility.GetDcElementContent(entry.AdditionalElements, "NodeGroupName");
                    if (DataProvider.NodeGroupDao.IsExists(publishmentSystemInfo.PublishmentSystemId, nodeGroupName))
                    {
                        continue;
                    }

                    var taxis       = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "Taxis"));
                    var description = AtomUtility.GetDcElementContent(entry.AdditionalElements, "Description");
                    DataProvider.NodeGroupDao.Insert(new NodeGroupInfo(nodeGroupName, publishmentSystemInfo.PublishmentSystemId, taxis, description));
                }
                else if (isContentGroup)
                {
                    var contentGroupName = AtomUtility.GetDcElementContent(entry.AdditionalElements, "ContentGroupName");
                    if (DataProvider.ContentGroupDao.IsExists(contentGroupName, publishmentSystemInfo.PublishmentSystemId))
                    {
                        continue;
                    }

                    var taxis       = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "Taxis"));
                    var description = AtomUtility.GetDcElementContent(entry.AdditionalElements, "Description");
                    DataProvider.ContentGroupDao.Insert(new ContentGroupInfo(contentGroupName, publishmentSystemInfo.PublishmentSystemId, taxis, description));
                }
            }
        }
Beispiel #16
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID", "NodeID", "ID", "ReturnUrl");

            _nodeId = Body.GetQueryInt("NodeID");
            var nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, _nodeId);

            _tableStyle = NodeManager.GetTableStyle(PublishmentSystemInfo, nodeInfo);
            _tableName  = NodeManager.GetTableName(PublishmentSystemInfo, nodeInfo);
            _contentId  = Body.GetQueryInt("ID");
            _returnUrl  = StringUtils.ValueFromUrl(Body.GetQueryString("ReturnUrl"));

            _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, _nodeId);

            _contentInfo = DataProvider.ContentDao.GetContentInfo(_tableStyle, _tableName, _contentId);

            if (!IsPostBack)
            {
                BreadCrumb(AppManager.Cms.LeftMenu.IdContent, "查看内容", string.Empty);

                var styleInfoList        = TableStyleManager.GetTableStyleInfoList(_tableStyle, _tableName, _relatedIdentities);
                var myStyleInfoArrayList = new ArrayList();
                if (styleInfoList != null)
                {
                    foreach (var styleInfo in styleInfoList)
                    {
                        if (styleInfo.IsVisible)
                        {
                            myStyleInfoArrayList.Add(styleInfo);
                        }
                    }
                }

                MyRepeater.DataSource     = myStyleInfoArrayList;
                MyRepeater.ItemDataBound += MyRepeater_ItemDataBound;
                MyRepeater.DataBind();

                ltlNodeName.Text  = NodeManager.GetNodeName(PublishmentSystemId, _nodeId);
                ltlNodeName.Text += $@"
<script>
function submitPreview(){{
    window.open(""{PagePreview.GetRedirectUrl(PublishmentSystemId, _nodeId, _contentId, 0, 0)}"");
}}
</script>
";

                if (PublishmentSystemInfo.Additional.IsRelatedByTags)
                {
                    ltlTags.Text = _contentInfo.Tags;
                }
                if (string.IsNullOrEmpty(ltlTags.Text))
                {
                    RowTags.Visible = false;
                }

                ltlContentGroup.Text = _contentInfo.ContentGroupNameCollection;
                if (string.IsNullOrEmpty(ltlContentGroup.Text))
                {
                    RowContentGroup.Visible = false;
                }

                ltlLastEditDate.Text     = DateUtils.GetDateAndTimeString(_contentInfo.LastEditDate);
                ltlAddUserName.Text      = AdminManager.GetDisplayName(_contentInfo.AddUserName, true);
                ltlLastEditUserName.Text = AdminManager.GetDisplayName(_contentInfo.LastEditUserName, true);

                ltlContentLevel.Text = LevelManager.GetCheckState(PublishmentSystemInfo, _contentInfo.IsChecked, _contentInfo.CheckedLevel);

                if (_contentInfo.ReferenceId > 0 && _contentInfo.GetExtendedAttribute(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString())
                {
                    var referencePublishmentSystemID   = DataProvider.NodeDao.GetPublishmentSystemId(_contentInfo.SourceId);
                    var referencePublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(referencePublishmentSystemID);
                    var referenceTableStyle            = NodeManager.GetTableStyle(referencePublishmentSystemInfo, _contentInfo.SourceId);
                    var referenceTableName             = NodeManager.GetTableName(referencePublishmentSystemInfo, _contentInfo.SourceId);
                    var referenceContentInfo           = DataProvider.ContentDao.GetContentInfo(referenceTableStyle, referenceTableName, _contentInfo.ReferenceId);

                    if (referenceContentInfo != null)
                    {
                        var pageUrl           = PageUtility.GetContentUrl(referencePublishmentSystemInfo, referenceContentInfo);
                        var referenceNodeInfo = NodeManager.GetNodeInfo(referenceContentInfo.PublishmentSystemId, referenceContentInfo.NodeId);
                        var addEditUrl        =
                            WebUtils.GetContentAddEditUrl(referencePublishmentSystemInfo.PublishmentSystemId,
                                                          referenceNodeInfo, _contentInfo.ReferenceId, Body.GetQueryString("ReturnUrl"));

                        ltlScripts.Text += $@"
<div class=""tips"">此内容为对内容 (站点:{referencePublishmentSystemInfo.PublishmentSystemName},栏目:{referenceNodeInfo.NodeName})“<a href=""{pageUrl}"" target=""_blank"">{_contentInfo.Title}</a>”(<a href=""{addEditUrl}"">编辑</a>) 的引用,内容链接将和原始内容链接一致</div>";
                    }
                }

                Submit.Attributes.Add("onclick", ModalContentCheck.GetOpenWindowString(PublishmentSystemInfo.PublishmentSystemId, _nodeId, _contentId, _returnUrl));
            }
        }
Beispiel #17
0
        public void Export()
        {
            var psInfo = PublishmentSystemManager.GetPublishmentSystemInfo(_publishmentSystemId);

            var feed = AtomUtility.GetEmptyFeed();

            AtomUtility.AddDcElement(feed.AdditionalElements, PublishmentSystemAttribute.PublishmentSystemId, psInfo.PublishmentSystemId.ToString());
            AtomUtility.AddDcElement(feed.AdditionalElements, PublishmentSystemAttribute.PublishmentSystemName, psInfo.PublishmentSystemName);
            AtomUtility.AddDcElement(feed.AdditionalElements, PublishmentSystemAttribute.AuxiliaryTableForContent, psInfo.AuxiliaryTableForContent);
            AtomUtility.AddDcElement(feed.AdditionalElements, PublishmentSystemAttribute.AuxiliaryTableForGovPublic, psInfo.AuxiliaryTableForGovPublic);
            AtomUtility.AddDcElement(feed.AdditionalElements, PublishmentSystemAttribute.AuxiliaryTableForGovInteract, psInfo.AuxiliaryTableForGovInteract);
            AtomUtility.AddDcElement(feed.AdditionalElements, PublishmentSystemAttribute.AuxiliaryTableForJob, psInfo.AuxiliaryTableForJob);
            AtomUtility.AddDcElement(feed.AdditionalElements, PublishmentSystemAttribute.AuxiliaryTableForVote, psInfo.AuxiliaryTableForVote);
            AtomUtility.AddDcElement(feed.AdditionalElements, PublishmentSystemAttribute.IsCheckContentUseLevel, psInfo.IsCheckContentUseLevel.ToString());
            AtomUtility.AddDcElement(feed.AdditionalElements, PublishmentSystemAttribute.CheckContentLevel, psInfo.CheckContentLevel.ToString());
            AtomUtility.AddDcElement(feed.AdditionalElements, PublishmentSystemAttribute.PublishmentSystemDir, psInfo.PublishmentSystemDir);
            AtomUtility.AddDcElement(feed.AdditionalElements, PublishmentSystemAttribute.PublishmentSystemUrl, psInfo.PublishmentSystemUrl);
            AtomUtility.AddDcElement(feed.AdditionalElements, PublishmentSystemAttribute.IsHeadquarters, psInfo.IsHeadquarters.ToString());
            AtomUtility.AddDcElement(feed.AdditionalElements, PublishmentSystemAttribute.ParentPublishmentSystemId, psInfo.ParentPublishmentSystemId.ToString());
            AtomUtility.AddDcElement(feed.AdditionalElements, PublishmentSystemAttribute.Taxis, psInfo.Taxis.ToString());
            AtomUtility.AddDcElement(feed.AdditionalElements, PublishmentSystemAttribute.SettingsXml, psInfo.Additional.ToString());

            var indexTemplateId = TemplateManager.GetDefaultTemplateID(psInfo.PublishmentSystemId, ETemplateType.IndexPageTemplate);

            if (indexTemplateId != 0)
            {
                var indexTemplateName = TemplateManager.GetTemplateName(_publishmentSystemId, indexTemplateId);
                AtomUtility.AddDcElement(feed.AdditionalElements, DefaultIndexTemplateName, indexTemplateName);
            }

            var channelTemplateId = TemplateManager.GetDefaultTemplateID(psInfo.PublishmentSystemId, ETemplateType.ChannelTemplate);

            if (channelTemplateId != 0)
            {
                var channelTemplateName = TemplateManager.GetTemplateName(_publishmentSystemId, channelTemplateId);
                AtomUtility.AddDcElement(feed.AdditionalElements, DefaultChannelTemplateName, channelTemplateName);
            }

            var contentTemplateId = TemplateManager.GetDefaultTemplateID(psInfo.PublishmentSystemId, ETemplateType.ContentTemplate);

            if (contentTemplateId != 0)
            {
                var contentTemplateName = TemplateManager.GetTemplateName(_publishmentSystemId, contentTemplateId);
                AtomUtility.AddDcElement(feed.AdditionalElements, DefaultContentTemplateName, contentTemplateName);
            }

            var fileTemplateId = TemplateManager.GetDefaultTemplateID(psInfo.PublishmentSystemId, ETemplateType.FileTemplate);

            if (fileTemplateId != 0)
            {
                var fileTemplateName = TemplateManager.GetTemplateName(psInfo.PublishmentSystemId, fileTemplateId);
                AtomUtility.AddDcElement(feed.AdditionalElements, DefaultFileTemplateName, fileTemplateName);
            }

            var nodeGroupInfoList = DataProvider.NodeGroupDao.GetNodeGroupInfoList(psInfo.PublishmentSystemId);

            nodeGroupInfoList.Reverse();

            foreach (var nodeGroupInfo in nodeGroupInfoList)
            {
                var entry = ExportNodeGroupInfo(nodeGroupInfo);
                feed.Entries.Add(entry);
            }

            var contentGroupInfoList = DataProvider.ContentGroupDao.GetContentGroupInfoList(psInfo.PublishmentSystemId);

            contentGroupInfoList.Reverse();

            foreach (var contentGroupInfo in contentGroupInfoList)
            {
                var entry = ExportContentGroupInfo(contentGroupInfo);
                feed.Entries.Add(entry);
            }

            feed.Save(_filePath);
        }
Beispiel #18
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _type = Request.QueryString["type"];

            if (!IsPostBack)
            {
                if (StringUtils.EqualsIgnoreCase(_type, TypePreviewImage))
                {
                    var publishmentSystemId   = Body.GetQueryInt("publishmentSystemID");
                    var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
                    var textBoxClientId       = Body.GetQueryString("textBoxClientID");
                    ltlHtml.Text = $@"
<span id=""previewImage""></span>
<script>
var rootUrl = '{PageUtils.GetRootUrl(string.Empty)}';
var publishmentSystemUrl = '{PageUtility.GetPublishmentSystemUrl(publishmentSystemInfo, string.Empty, true)}';
var imageUrl = window.parent.document.getElementById('{textBoxClientId}').value;
if(imageUrl && imageUrl.search(/\.bmp|\.jpg|\.jpeg|\.gif|\.png$/i) != -1){{
	if (imageUrl.charAt(0) == '~'){{
		imageUrl = imageUrl.replace('~', rootUrl);
	}}else if (imageUrl.charAt(0) == '@'){{
		imageUrl = imageUrl.replace('@', publishmentSystemUrl);
	}}
	if(imageUrl.substr(0,2)=='//'){{
		imageUrl = imageUrl.replace('//', '/');
	}}
    $('#previewImage').html('<img src=""' + imageUrl + '"" class=""img-polaroid"" />');
}}
</script>
";
                }
                else if (StringUtils.EqualsIgnoreCase(_type, TypePreviewVideo))
                {
                    var publishmentSystemId   = Body.GetQueryInt("publishmentSystemID");
                    var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
                    var textBoxClientId       = Body.GetQueryString("textBoxClientID");

                    ltlHtml.Text = $@"
<span id=""previewVideo""></span>
<script>
var rootUrl = '{PageUtils.GetRootUrl(string.Empty)}';
var publishmentSystemUrl = '{PageUtility.GetPublishmentSystemUrl(publishmentSystemInfo, string.Empty, true)}';
var videoUrl = window.parent.document.getElementById('{textBoxClientId}').value;
if (videoUrl.charAt(0) == '~'){{
	videoUrl = videoUrl.replace('~', rootUrl);
}}else if (videoUrl.charAt(0) == '@'){{
	videoUrl = videoUrl.replace('@', publishmentSystemUrl);
}}
if(videoUrl.substr(0,2)=='//'){{
	videoUrl = videoUrl.replace('//', '/');
}}
if (videoUrl){{
    $('#previewVideo').html('<embed src=""../assets/player.swf"" allowfullscreen=""true"" flashvars=""controlbar=over&autostart=true&file='+videoUrl+'"" width=""{450}"" height=""{350}""/>');
}}
</script>
";
                }
                else if (StringUtils.EqualsIgnoreCase(_type, TypePreviewVideoByUrl))
                {
                    var publishmentSystemId   = Body.GetQueryInt("publishmentSystemID");
                    var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
                    var videoUrl = Body.GetQueryString("videoUrl");

                    ltlHtml.Text = $@"
<embed src=""../assets/player.swf"" allowfullscreen=""true"" flashvars=""controlbar=over&autostart=true&file={PageUtility
                        .ParseNavigationUrl(publishmentSystemInfo, videoUrl)}"" width=""{450}"" height=""{350}""/>
";
                }
                else
                {
                    ltlHtml.Text = TranslateUtils.DecryptStringBySecretKey(Request.QueryString["html"]);
                }
            }
        }
Beispiel #19
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            var permissions = PermissionsManager.GetPermissions(Body.AdministratorName);
            var mainPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(1);

            PageUtils.CheckRequestParameter("PublishmentSystemID", "NodeID");
            var nodeID      = Body.GetQueryInt("NodeID");
            var articleId   = Body.GetQueryInt("ArticleId");
            var childNodeId = Body.GetQueryInt("ChildNodeId");

            relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, nodeID);
            nodeInfo          = NodeManager.GetNodeInfo(1, nodeID);
            tableName         = NodeManager.GetTableName(mainPublishmentSystemInfo, nodeInfo);
            tableStyle        = NodeManager.GetTableStyle(mainPublishmentSystemInfo, nodeInfo);
            styleInfoList     = TableStyleManager.GetTableStyleInfoList(tableStyle, tableName, relatedIdentities);
            var styleInfoList2 = TableStyleManager.GetTableStyleInfoList(tableStyle, "siteserver_Node", relatedIdentities);
            Dictionary <string, string> category = DataProvider.NodeDao.GetNodeIdListLevel(2, nodeID);
            int contentNum = 0;

            if (nodeInfo.Additional.IsPreviewContents)
            {
                new Action(() =>
                {
                    DataProvider.ContentDao.DeletePreviewContents(PublishmentSystemId, tableName, nodeInfo);
                }).BeginInvoke(null, null);
            }

            if (!HasChannelPermissions(nodeID, AppManager.Cms.Permission.Channel.ContentView, AppManager.Cms.Permission.Channel.ContentAdd, AppManager.Cms.Permission.Channel.ContentEdit, AppManager.Cms.Permission.Channel.ContentDelete, AppManager.Cms.Permission.Channel.ContentTranslate))
            {
                if (!Body.IsAdministratorLoggin)
                {
                    PageUtils.RedirectToLoginPage();
                    return;
                }
                PageUtils.RedirectToErrorPage("您无此栏目的操作权限!");
                return;
            }

            attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(NodeManager.GetContentAttributesOfDisplay(PublishmentSystemId, nodeID));

            //this.attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(this.nodeInfo.Additional.ContentAttributesOfDisplay);

            spContents.ControlToPaginate = rptContents;
            rptContents.ItemDataBound   += rptContents_ItemDataBound;
            spContents.ItemsPerPage      = PublishmentSystemInfo.Additional.PageSize;

            var administratorName = AdminUtility.IsViewContentOnlySelf(Body.AdministratorName, PublishmentSystemId, nodeID)
                    ? Body.AdministratorName
                    : string.Empty;

            if (Body.IsQueryExists("SearchType") && Body.IsQueryExists("ChildNodeId"))
            {
                List <int> owningNodeIdList = new List <int>
                {
                    nodeID, 3, 4, 6, 9
                };
                List <int> nodeList = new List <int>();
                nodeList.Add(nodeID);
                var firstChildList = DataProvider.NodeDao.GetNodeIdListByParentId(1, nodeID);
                if (firstChildList != null && firstChildList.Count > 0)
                {
                    nodeList.AddRange(firstChildList);
                    foreach (var firstchild in firstChildList)
                    {
                        var secondList = DataProvider.NodeDao.GetNodeIdListByParentId(1, firstchild);
                        if (secondList != null && secondList.Count > 0)
                        {
                            nodeList.AddRange(secondList);
                        }
                    }
                }
                var nodeCollectionIdStr = string.Empty;
                foreach (int nodeId in nodeList)
                {
                    nodeCollectionIdStr = nodeCollectionIdStr + nodeId + ',';
                    contentNum          = contentNum + DataProvider.NodeDao.GetNodeInfo(nodeId).ContentNum;
                }
                //spContents.SelectCommand = DataProvider.ContentDao.GetSelectCommend(tableStyle, tableName, PublishmentSystemId, nodeID, permissions.IsSystemAdministrator, owningNodeIdList, Body.GetQueryString("SearchType"), Body.GetQueryString("Keyword"), Body.GetQueryString("DateFrom"), string.Empty, false, ETriState.All, false, false, false, administratorName);
                spContents.SelectCommand = $@"select * from model_Study where NodeId in({Body.GetQueryString("ChildNodeId")}) AND PublishmentSystemID={PublishmentSystemInfo.PublishmentSystemId}";
            }
            else
            {
                var        test     = tableName;
                List <int> nodeList = new List <int>();
                nodeList.Add(nodeID);
                var firstChildList = DataProvider.NodeDao.GetNodeIdListByParentId(1, nodeID);
                if (firstChildList != null && firstChildList.Count > 0)
                {
                    nodeList.AddRange(firstChildList);
                    foreach (var firstchild in firstChildList)
                    {
                        var secondList = DataProvider.NodeDao.GetNodeIdListByParentId(1, firstchild);
                        if (secondList != null && secondList.Count > 0)
                        {
                            nodeList.AddRange(secondList);
                        }
                    }
                }
                var nodeCollectionIdStr = string.Empty;
                foreach (int nodeId in nodeList)
                {
                    nodeCollectionIdStr = nodeCollectionIdStr + nodeId + ',';
                    contentNum          = contentNum + DataProvider.NodeDao.GetNodeInfo(nodeId).ContentNum;
                }
                nodeCollectionIdStr      = nodeCollectionIdStr.TrimEnd(',');
                spContents.SelectCommand = $@"select * from model_Study where NodeId in({nodeCollectionIdStr}) AND PublishmentSystemID={PublishmentSystemInfo.PublishmentSystemId}";
            }

            spContents.SortField     = BaiRongDataProvider.ContentDao.GetSortFieldName();
            spContents.SortMode      = SortMode.DESC;
            spContents.OrderByString = "ORDER BY Taxis Desc";

            //分页的时候,不去查询总条数,直接使用栏目的属性:ContentNum
            spContents.IsQueryTotalCount = false;
            spContents.TotalCount        = contentNum;//nodeInfo.ContentNum;

            if (!IsPostBack)
            {
                var nodeName = NodeManager.GetNodeNameNavigation(PublishmentSystemId, nodeID);
                //BreadCrumbWithItemTitle(AppManager.Cms.LeftMenu.IdContent, "内容管理", nodeName, string.Empty);

                ltlContentButtons.Text = WebUtils.GetContentCommandsStandard(Body.AdministratorName, PublishmentSystemInfo, nodeInfo, PageUrlReturn, GetRedirectUrl(base.PublishmentSystemId, nodeInfo.NodeId), false);
                spContents.DataBind();

                if (styleInfoList != null)
                {
                    foreach (var styleInfo in styleInfoList)
                    {
                        if (styleInfo.IsVisible)
                        {
                            var listitem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName);
                            SearchType.Items.Add(listitem);
                        }
                    }
                }
                var listitemAll = new ListItem("全部", nodeID.ToString());
                ChannelCategory.Items.Add(listitemAll);
                if (category != null)
                {
                    foreach (var chanelCategory in category)
                    {
                        var listitem = new ListItem(chanelCategory.Key, chanelCategory.Value);
                        ChannelCategory.Items.Add(listitem);
                    }
                }
                //添加隐藏属性
                SearchType.Items.Add(new ListItem("内容ID", ContentAttribute.Id));
                SearchType.Items.Add(new ListItem("添加者", ContentAttribute.AddUserName));
                SearchType.Items.Add(new ListItem("最后修改者", ContentAttribute.LastEditUserName));
                SearchType.Items.Add(new ListItem("内容组", ContentAttribute.ContentGroupNameCollection));

                if (Body.IsQueryExists("SearchType"))
                {
                    DateFrom.Text = Body.GetQueryString("DateFrom");
                    ControlUtils.SelectListItems(SearchType, Body.GetQueryString("SearchType"));
                    Keyword.Text            = Body.GetQueryString("Keyword");
                    ltlContentButtons.Text += @"
<script>
$(document).ready(function() {
	$('#contentSearch').show();
});
</script>
";
                }

                ltlColumnHeadRows.Text  = ContentUtility.GetColumnHeadRowsHtml(styleInfoList, attributesOfDisplay, tableStyle, PublishmentSystemInfo);
                ltlCommandHeadRows.Text = ContentUtility.GetCommandHeadRowsHtml(Body.AdministratorName, tableStyle, PublishmentSystemInfo, nodeInfo);
            }
        }
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _isPublishmentSystemSelect = Body.GetQueryBool("isPublishmentSystemSelect");
            _jsMethod = Body.GetQueryString("jsMethod");

            _targetPublishmentSystemId = Body.GetQueryInt("TargetPublishmentSystemID");
            if (_targetPublishmentSystemId == 0)
            {
                _targetPublishmentSystemId = PublishmentSystemId;
            }

            if (!IsPostBack)
            {
                PhPublishmentSystemId.Visible = _isPublishmentSystemSelect;

                var publishmentSystemIdList = ProductPermissionsManager.Current.PublishmentSystemIdList;

                var mySystemInfoArrayList = new ArrayList();
                var parentWithChildren    = new Hashtable();
                foreach (var publishmentSystemId in publishmentSystemIdList)
                {
                    var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
                    if (publishmentSystemInfo.ParentPublishmentSystemId == 0)
                    {
                        mySystemInfoArrayList.Add(publishmentSystemInfo);
                    }
                    else
                    {
                        var children = new ArrayList();
                        if (parentWithChildren.Contains(publishmentSystemInfo.ParentPublishmentSystemId))
                        {
                            children = (ArrayList)parentWithChildren[publishmentSystemInfo.ParentPublishmentSystemId];
                        }
                        children.Add(publishmentSystemInfo);
                        parentWithChildren[publishmentSystemInfo.ParentPublishmentSystemId] = children;
                    }
                }
                foreach (PublishmentSystemInfo publishmentSystemInfo in mySystemInfoArrayList)
                {
                    AddSite(DdlPublishmentSystemId, publishmentSystemInfo, parentWithChildren, 0);
                }
                ControlUtils.SelectListItems(DdlPublishmentSystemId, _targetPublishmentSystemId.ToString());

                var targetNodeId = Body.GetQueryInt("TargetNodeID");
                if (targetNodeId > 0)
                {
                    var siteName  = PublishmentSystemManager.GetPublishmentSystemInfo(_targetPublishmentSystemId).PublishmentSystemName;
                    var nodeNames = NodeManager.GetNodeNameNavigation(_targetPublishmentSystemId, targetNodeId);
                    if (_targetPublishmentSystemId != PublishmentSystemId)
                    {
                        nodeNames = siteName + ":" + nodeNames;
                    }
                    string value = $"{_targetPublishmentSystemId}_{targetNodeId}";
                    if (!_isPublishmentSystemSelect)
                    {
                        value = targetNodeId.ToString();
                    }
                    string scripts = $"window.parent.{_jsMethod}('{nodeNames}', '{value}');";
                    PageUtils.CloseModalPageWithoutRefresh(Page, scripts);
                }
                else
                {
                    var nodeInfo = NodeManager.GetNodeInfo(_targetPublishmentSystemId, _targetPublishmentSystemId);
                    var linkUrl  = GetRedirectUrl(_targetPublishmentSystemId.ToString(), _targetPublishmentSystemId.ToString());
                    LtlChannelName.Text = $"<a href='{linkUrl}'>{nodeInfo.NodeName}</a>";

                    var additional = new NameValueCollection
                    {
                        ["linkUrl"] = GetRedirectUrl(_targetPublishmentSystemId.ToString(), string.Empty)
                    };
                    ClientScriptRegisterClientScriptBlock("NodeTreeScript", ChannelLoading.GetScript(PublishmentSystemManager.GetPublishmentSystemInfo(_targetPublishmentSystemId), ELoadingType.ChannelSelect, additional));

                    RptChannel.DataSource     = DataProvider.NodeDao.GetNodeIdListByParentId(_targetPublishmentSystemId, _targetPublishmentSystemId);
                    RptChannel.ItemDataBound += RptChannel_ItemDataBound;
                    RptChannel.DataBind();
                }
            }
        }
Beispiel #21
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _userId    = Body.GetQueryInt("userID");
            _returnUrl = StringUtils.ValueFromUrl(Body.GetQueryString("returnUrl"));

            if (IsPostBack)
            {
                return;
            }

            var pageTitle = _userId == 0 ? "添加用户" : "编辑用户";

            BreadCrumbUser(AppManager.User.LeftMenu.UserConfiguration, pageTitle, AppManager.User.Permission.UserConfiguration);

            LtlPageTitle.Text = pageTitle;
            if (_userId > 0)
            {
                var userInfo = BaiRongDataProvider.UserDao.GetUserInfoAll(_userId);
                if (userInfo != null)
                {
                    TbUserName.Text              = userInfo.UserName;
                    TbUserName.Enabled           = false;
                    TbDisplayName.Text           = userInfo.DisplayName;
                    PhPassword.Visible           = false;
                    TbEmail.Text                 = userInfo.Email;
                    TbMobile.Text                = userInfo.Mobile;
                    TbGender.Text                = userInfo.Gender;
                    TbIdCode.Text                = userInfo.IdCode;
                    TbPublishmentSystemName.Text = PublishmentSystemManager.GetPublishmentSystemInfo(userInfo.PublishmentSystemId).PublishmentSystemName;
                    TbPosition.Text              = userInfo.Position;
                    TbFlowPartyMember.Text       = userInfo.FlowPartyMember.ToString();
                    TbNation.Text                = userInfo.Nation;
                    TbNativePlace.Text           = userInfo.NativePlace;
                    TbTelePhone.Text             = userInfo.Additional.TelePhone;
                    TbEmergencyName.Text         = userInfo.Additional.EmergencyName;
                    TbEmergencyMobile.Text       = userInfo.Additional.EmergencyMobile;
                    TbEmergencyRalationship.Text = userInfo.Additional.EmergencyRalationShip;
                    TbAddress.Text               = userInfo.Additional.PostalAddress;
                }
            }

            if (ConfigManager.UserConfigInfo.RegisterPasswordRestriction != EUserPasswordRestriction.None)
            {
                LtlPasswordTips.Text =
                    $"(请包含{EUserPasswordRestrictionUtils.GetText(ConfigManager.UserConfigInfo.RegisterPasswordRestriction)})";
            }

            if (!string.IsNullOrEmpty(_returnUrl))
            {
                BtnReturn.Attributes.Add("onclick", $"window.location.href='{_returnUrl}';return false;");
            }
            else
            {
                BtnReturn.Visible = false;
            }
        }
Beispiel #22
0
        public static TabCollection GetTabCollection(Tab parent, int publishmentSystemId)
        {
            TabCollection tabCollection;

            if (StringUtils.EqualsIgnoreCase(parent.Id, AppManager.Cms.LeftMenu.Function.IdInput))
            {
                Tab[] tabs;
                var   inputNameList = DataProvider.InputDao.GetInputNameList(publishmentSystemId);
                if (inputNameList.Count > 0)
                {
                    var tabList = new List <Tab>();
                    foreach (var inputName in inputNameList)
                    {
                        var tab = new Tab
                        {
                            Text            = inputName,
                            Id              = AppManager.Cms.LeftMenu.Function.IdInput + "_" + inputName,
                            Href            = PageInputContent.GetRedirectUrl(publishmentSystemId, inputName),
                            KeepQueryString = false,
                            Target          = "right"
                        };

                        tabList.Add(tab);
                    }

                    var k = 0;
                    tabs = new Tab[tabList.Count];
                    for (; k < tabList.Count; k++)
                    {
                        tabs[k] = tabList[k];
                    }

                    parent.Children = tabs;
                }
                else
                {
                    tabs = parent.Children;
                }

                tabCollection = new TabCollection(tabs);
            }
            else if (StringUtils.EqualsIgnoreCase(parent.Id, AppManager.Wcm.LeftMenu.IdGovInteract))
            {
                Tab[] tabs;
                var   publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
                var   nodeInfoList          = GovInteractManager.GetNodeInfoList(publishmentSystemInfo);
                if (nodeInfoList.Count > 0 && ProductPermissionsManager.Current.GovInteractPermissionDict.ContainsKey(publishmentSystemId))
                {
                    var govInteractPermissionListOfPublishmentSystemId = ProductPermissionsManager.Current.GovInteractPermissionDict[publishmentSystemId];
                    var govInteractPermissionList = govInteractPermissionListOfPublishmentSystemId;
                    var tabList = new List <Tab>();
                    foreach (var nodeInfo in nodeInfoList)
                    {
                        if (govInteractPermissionListOfPublishmentSystemId == null || govInteractPermissionListOfPublishmentSystemId.Count == 0)
                        {
                            if (ProductPermissionsManager.Current.GovInteractPermissionDict.ContainsKey(nodeInfo.NodeId))
                            {
                                govInteractPermissionList = ProductPermissionsManager.Current.GovInteractPermissionDict[nodeInfo.NodeId];
                            }
                        }

                        if (govInteractPermissionList != null && govInteractPermissionList.Count > 0)
                        {
                            var tab = new Tab
                            {
                                Text = nodeInfo.NodeName,
                                Id   = AppManager.Wcm.LeftMenu.IdGovInteract + "_" + nodeInfo.NodeId
                            };

                            var childList = new List <Tab>();

                            if (govInteractPermissionList.Contains(AppManager.Wcm.Permission.GovInteract.GovInteractAccept))
                            {
                                childList.Add(new Tab
                                {
                                    Text            = "待受理办件",
                                    Href            = PageGovInteractListAccept.GetRedirectUrl(nodeInfo.PublishmentSystemId, nodeInfo.NodeId),
                                    KeepQueryString = false,
                                    Target          = "right"
                                });
                            }
                            if (govInteractPermissionList.Contains(AppManager.Wcm.Permission.GovInteract.GovInteractReply))
                            {
                                childList.Add(new Tab
                                {
                                    Text            = "待办理办件",
                                    Href            = PageGovInteractListReply.GetRedirectUrl(nodeInfo.PublishmentSystemId, nodeInfo.NodeId),
                                    KeepQueryString = false,
                                    Target          = "right"
                                });
                            }
                            if (govInteractPermissionList.Contains(AppManager.Wcm.Permission.GovInteract.GovInteractCheck))
                            {
                                childList.Add(new Tab
                                {
                                    Text            = "待审核办件",
                                    Href            = PageGovInteractListCheck.GetRedirectUrl(nodeInfo.PublishmentSystemId, nodeInfo.NodeId),
                                    KeepQueryString = false,
                                    Target          = "right"
                                });
                            }
                            if (govInteractPermissionList.Contains(AppManager.Wcm.Permission.GovInteract.GovInteractView) || govInteractPermissionList.Contains(AppManager.Wcm.Permission.GovInteract.GovInteractDelete))
                            {
                                childList.Add(new Tab
                                {
                                    Text            = "所有办件",
                                    Href            = PageGovInteractListAll.GetRedirectUrl(nodeInfo.PublishmentSystemId, nodeInfo.NodeId),
                                    KeepQueryString = false,
                                    Target          = "right"
                                });
                            }
                            if (govInteractPermissionList.Contains(AppManager.Wcm.Permission.GovInteract.GovInteractAdd))
                            {
                                var redirectUrl = PageGovInteractListAccept.GetRedirectUrl(nodeInfo.PublishmentSystemId, nodeInfo.NodeId);
                                var child       = new Tab
                                {
                                    Text            = "新增办件",
                                    Href            = WebUtils.GetContentAddAddUrl(publishmentSystemId, nodeInfo, redirectUrl),
                                    KeepQueryString = false,
                                    Target          = "right"
                                };
                                childList.Add(child);
                            }

                            tab.Children = new Tab[childList.Count];
                            for (var i = 0; i < childList.Count; i++)
                            {
                                tab.Children[i] = childList[i];
                            }

                            tabList.Add(tab);
                        }
                    }

                    var k = 0;
                    tabs = new Tab[parent.Children.Length + tabList.Count];
                    for (; k < tabList.Count; k++)
                    {
                        tabs[k] = tabList[k];
                    }

                    for (var j = 0; j < parent.Children.Length; j++)
                    {
                        tabs[j + k] = parent.Children[j];
                    }
                }
                else
                {
                    tabs = parent.Children;
                }

                tabCollection = new TabCollection(tabs);
            }
            else
            {
                tabCollection = new TabCollection(parent.Children);
            }
            return(tabCollection);
        }
        public IHttpActionResult Main()
        {
            try
            {
                var body = new RequestBody();
                var form = HttpContext.Current.Request.Form;

                var publishmentSystemId   = body.GetPostInt("publishmentSystemId");
                var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
                var ajaxDivId             = PageUtils.FilterSqlAndXss(body.GetPostString("ajaxDivId"));
                var pageNum          = body.GetPostInt("pageNum");
                var isHighlight      = body.GetPostBool("isHighlight");
                var isRedirectSingle = body.GetPostBool("isRedirectSingle");
                var isDefaultDisplay = body.GetPostBool("isDefaultDisplay");
                var dateAttribute    = PageUtils.FilterSqlAndXss(body.GetPostString("dateAttribute"));
                if (string.IsNullOrEmpty(dateAttribute))
                {
                    dateAttribute = ContentAttribute.AddDate;
                }
                var pageIndex = body.GetPostInt("page", 1) - 1;

                var template = TranslateUtils.DecryptStringBySecretKey(body.GetPostString("template"));
                template = StlRequestEntities.ParseRequestEntities(form, template);
                var word           = PageUtils.FilterSql(body.GetPostString("word"));
                var channelId      = body.GetPostString("channelID");
                var dateFrom       = PageUtils.FilterSqlAndXss(body.GetPostString("dateFrom"));
                var dateTo         = PageUtils.FilterSqlAndXss(body.GetPostString("dateTo"));
                var date           = PageUtils.FilterSqlAndXss(body.GetPostString("date"));
                var typeCollection = TranslateUtils.StringCollectionToStringCollection(PageUtils.UrlDecode(PageUtils.FilterSqlAndXss(body.GetPostString("type"))));

                var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemId, TranslateUtils.ToInt(channelId, publishmentSystemId));
                if (nodeInfo == null)
                {
                    nodeInfo = NodeManager.GetNodeInfo(publishmentSystemId, publishmentSystemId);
                }
                var tableStyle = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo);

                var excludeAttributes = "ajaxdivid,pagenum,pageindex,iscrosssite,ishighlight,isredirectsingle,isdefaultdisplay,charset,template,word,click,channelid,datefrom,dateto,date,type,dateattribute";

                var templateInfo = new TemplateInfo(0, publishmentSystemId, string.Empty, ETemplateType.FileTemplate, string.Empty, string.Empty, string.Empty, ECharsetUtils.GetEnumType(publishmentSystemInfo.Additional.Charset), false);

                var pageInfo    = new PageInfo(nodeInfo.NodeId, 0, publishmentSystemInfo, templateInfo, body.UserInfo);
                var contextInfo = new ContextInfo(pageInfo);

                var contentBuilder = new StringBuilder(template);

                var stlLabelList = StlParserUtility.GetStlLabelList(contentBuilder.ToString());

                if (StlParserUtility.IsStlElementExists(StlPageContents.ElementName, stlLabelList))
                {
                    var stlElement             = StlParserUtility.GetStlElement(StlPageContents.ElementName, stlLabelList);
                    var stlPageContentsElement = stlElement;
                    var stlPageContentsElementReplaceString = stlElement;

                    var whereString = DataProvider.ContentDao.GetWhereStringBySearchOutput(publishmentSystemInfo, nodeInfo.NodeId, tableStyle, word, typeCollection, channelId, dateFrom, dateTo, date, dateAttribute, excludeAttributes, form);

                    //没搜索条件时不显示搜索结果
                    if (string.IsNullOrEmpty(whereString) && !isDefaultDisplay)
                    {
                        return(Ok(string.Empty));
                    }

                    var stlPageContents = new StlPageContents(stlPageContentsElement, pageInfo, contextInfo, pageNum, whereString);

                    int totalNum;
                    var pageCount = stlPageContents.GetPageCount(out totalNum);

                    if (totalNum == 0)
                    {
                        return(NotFound());
                    }
                    var isRedirect = false;
                    if (isRedirectSingle && totalNum == 1)
                    {
                        var contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, stlPageContents.SqlString);
                        if (contentInfo != null)
                        {
                            isRedirect     = true;
                            contentBuilder = new StringBuilder($@"
<script>
location.href = '{PageUtility.GetContentUrl(publishmentSystemInfo, contentInfo)}';
</script>
");
                        }
                    }
                    if (!isRedirect)
                    {
                        for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                        {
                            if (currentPageIndex == pageIndex)
                            {
                                var pageHtml     = stlPageContents.Parse(totalNum, currentPageIndex, pageCount, false);
                                var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlPageContentsElementReplaceString, pageHtml));

                                StlParserManager.ReplacePageElementsInSearchPage(pagedBuilder, pageInfo, stlLabelList, ajaxDivId, pageInfo.PageNodeId, currentPageIndex, pageCount, totalNum);

                                if (isHighlight && !string.IsNullOrEmpty(word))
                                {
                                    var pagedContents = pagedBuilder.ToString();
                                    pagedBuilder = new StringBuilder();
                                    pagedBuilder.Append(RegexUtils.Replace(
                                                            $"({word.Replace(" ", "\\s")})(?!</a>)(?![^><]*>)", pagedContents,
                                                            $"<span style='color:#cc0000'>{word}</span>"));
                                }

                                StlUtility.ParseStl(publishmentSystemInfo, pageInfo, contextInfo, pagedBuilder, string.Empty, false);
                                return(Ok(pagedBuilder.ToString()));
                            }
                        }
                    }
                }
                else if (StlParserUtility.IsStlElementExists(StlPageSqlContents.ElementName, stlLabelList))
                {
                    var siteId     = TranslateUtils.ToInt(body.GetPostString("siteID"), 0);
                    var stlElement = StlParserUtility.GetStlElement(StlPageSqlContents.ElementName, stlLabelList);
                    var stlPageSqlContentsElement = stlElement;
                    var stlPageSqlContentsElementReplaceString = stlElement;

                    var whereBuilder = new StringBuilder();
                    if (!string.IsNullOrEmpty(word))
                    {
                        whereBuilder.Append("(");
                        foreach (var type in typeCollection)
                        {
                            whereBuilder.Append($"[{type}] like '%{word}%' OR ");
                        }
                        whereBuilder.Length = whereBuilder.Length - 3;
                        whereBuilder.Append(")");
                    }
                    if (!string.IsNullOrEmpty(dateFrom))
                    {
                        if (whereBuilder.Length > 0)
                        {
                            whereBuilder.Append(" AND ");
                        }
                        whereBuilder.Append($" AddDate >= '{dateFrom}' ");
                    }
                    if (!string.IsNullOrEmpty(dateTo))
                    {
                        if (whereBuilder.Length > 0)
                        {
                            whereBuilder.Append(" AND ");
                        }
                        whereBuilder.Append($" AddDate <= '{dateTo}' ");
                    }
                    if (!string.IsNullOrEmpty(date))
                    {
                        var days = TranslateUtils.ToInt(date);
                        if (days > 0)
                        {
                            if (whereBuilder.Length > 0)
                            {
                                whereBuilder.Append(" AND ");
                            }
                            whereBuilder.Append(SqlUtils.GetDateDiffLessThanDays("AddDate", days.ToString()));
                        }
                    }
                    if (siteId > 0)
                    {
                        if (whereBuilder.Length > 0)
                        {
                            whereBuilder.Append(" AND ");
                        }
                        whereBuilder.Append($"(PublishmentSystemID = {siteId})");
                    }

                    if (whereBuilder.Length > 0)
                    {
                        whereBuilder.Append(" AND ");
                    }
                    whereBuilder.Append("(NodeID > 0) ");

                    var tableName = BaiRongDataProvider.TableCollectionDao.GetFirstTableNameByTableType(EAuxiliaryTableType.BackgroundContent);
                    var arraylist = TranslateUtils.StringCollectionToStringList("ajaxdivid,pagenum,pageindex,iscrosssite,ishighlight,isredirectsingle,isdefaultdisplay,charset,successtemplatestring,failuretemplatestring,word,click,channelid,datefrom,dateto,date,type,siteid");
                    foreach (string key in form.Keys)
                    {
                        if (arraylist.Contains(key.ToLower()))
                        {
                            continue;
                        }
                        if (!string.IsNullOrEmpty(form[key]))
                        {
                            var value = StringUtils.Trim(form[key]);
                            if (!string.IsNullOrEmpty(value))
                            {
                                if (TableManager.IsAttributeNameExists(tableStyle, tableName, key))
                                {
                                    if (whereBuilder.Length > 0)
                                    {
                                        whereBuilder.Append(" AND ");
                                    }
                                    whereBuilder.Append($"([{key}] like '%{value}%')");
                                }
                                else
                                {
                                    if (whereBuilder.Length > 0)
                                    {
                                        whereBuilder.Append(" AND ");
                                    }
                                    whereBuilder.Append($"({ContentAttribute.SettingsXml} like '%{key}={value}%')");
                                }
                            }
                        }
                    }

                    //没搜索条件时不显示搜索结果
                    if (whereBuilder.Length == 0 && isDefaultDisplay == false)
                    {
                        return(Ok(string.Empty));
                    }

                    var stlPageSqlContents = new StlPageSqlContents(stlPageSqlContentsElement, pageInfo, contextInfo, false, false);
                    if (string.IsNullOrEmpty(stlPageSqlContents.DisplayInfo.QueryString))
                    {
                        stlPageSqlContents.DisplayInfo.QueryString =
                            $"SELECT * FROM {tableName} WHERE {whereBuilder}";
                    }
                    stlPageSqlContents.LoadData();

                    int totalNum;
                    var pageCount = stlPageSqlContents.GetPageCount(out totalNum);

                    if (totalNum == 0)
                    {
                        return(NotFound());
                    }
                    for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                    {
                        if (currentPageIndex == pageIndex)
                        {
                            var pageHtml     = stlPageSqlContents.Parse(currentPageIndex, pageCount);
                            var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlPageSqlContentsElementReplaceString, pageHtml));

                            StlParserManager.ReplacePageElementsInSearchPage(pagedBuilder, pageInfo, stlLabelList, ajaxDivId, pageInfo.PageNodeId, currentPageIndex, pageCount, totalNum);

                            if (isHighlight && !string.IsNullOrEmpty(word))
                            {
                                var pagedContents = pagedBuilder.ToString();
                                pagedBuilder = new StringBuilder();
                                pagedBuilder.Append(RegexUtils.Replace(
                                                        $"({word.Replace(" ", "\\s")})(?!</a>)(?![^><]*>)", pagedContents,
                                                        $"<span style='color:#cc0000'>{word}</span>"));
                            }

                            StlUtility.ParseStl(publishmentSystemInfo, pageInfo, contextInfo, pagedBuilder, string.Empty, false);
                            return(Ok(pagedBuilder.ToString()));
                        }
                    }
                }

                StlUtility.ParseStl(publishmentSystemInfo, pageInfo, contextInfo, contentBuilder, string.Empty, false);
                return(Ok(contentBuilder.ToString()));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
        private int Validate_PublishmentSystemInfo(out string errorMessage)
        {
            try
            {
                var isHq = TranslateUtils.ToBool(IsHeadquarters.SelectedValue); // 是否主站
                var parentPublishmentSystemId = 0;
                var publishmentSystemDir      = string.Empty;

                if (isHq == false)
                {
                    if (DirectoryUtils.IsSystemDirectory(PublishmentSystemDir.Text))
                    {
                        errorMessage = "文件夹名称不能为系统文件夹名称!";
                        return(0);
                    }

                    parentPublishmentSystemId = TranslateUtils.ToInt(ParentPublishmentSystemID.SelectedValue);
                    publishmentSystemDir      = PublishmentSystemDir.Text;

                    var list = DataProvider.NodeDao.GetLowerSystemDirList(parentPublishmentSystemId);
                    if (list.IndexOf(publishmentSystemDir.ToLower()) != -1)
                    {
                        errorMessage = "已存在相同的发布路径!";
                        return(0);
                    }

                    if (!DirectoryUtils.IsDirectoryNameCompliant(publishmentSystemDir))
                    {
                        errorMessage = "文件夹名称不符合系统要求!";
                        return(0);
                    }
                }

                var nodeInfo = new NodeInfo();

                nodeInfo.NodeName       = nodeInfo.NodeIndexName = "首页";
                nodeInfo.NodeType       = ENodeType.BackgroundPublishNode;
                nodeInfo.ContentModelId = EContentModelTypeUtils.GetValue(EContentModelType.Content);

                var publishmentSystemUrl = PageUtils.Combine(WebConfigUtils.ApplicationPath, publishmentSystemDir);

                var psInfo = BaseTable.GetDefaultPublishmentSystemInfo(PageUtils.FilterXss(PublishmentSystemName.Text), AuxiliaryTableForContent.SelectedValue, string.Empty, string.Empty, AuxiliaryTableForVote.SelectedValue, AuxiliaryTableForJob.SelectedValue, publishmentSystemDir, publishmentSystemUrl, parentPublishmentSystemId);

                if (psInfo.ParentPublishmentSystemId > 0)
                {
                    var parentPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(psInfo.ParentPublishmentSystemId);
                    psInfo.PublishmentSystemUrl = PageUtils.Combine(parentPublishmentSystemInfo.PublishmentSystemUrl, psInfo.PublishmentSystemDir);
                }

                psInfo.IsHeadquarters = isHq;

                psInfo.Additional.Charset     = Charset.SelectedValue;
                psInfo.IsCheckContentUseLevel = TranslateUtils.ToBool(IsCheckContentUseLevel.SelectedValue);
                if (psInfo.IsCheckContentUseLevel)
                {
                    psInfo.CheckContentLevel = TranslateUtils.ToInt(CheckContentLevel.SelectedValue);
                }

                var thePublishmentSystemId = DataProvider.NodeDao.InsertPublishmentSystemInfo(nodeInfo, psInfo, Body.AdministratorName);

                if (_permissions.IsSystemAdministrator && !_permissions.IsConsoleAdministrator)
                {
                    var publishmentSystemIdList = ProductPermissionsManager.Current.PublishmentSystemIdList ?? new List <int>();
                    publishmentSystemIdList.Add(thePublishmentSystemId);
                    BaiRongDataProvider.AdministratorDao.UpdatePublishmentSystemIdCollection(Body.AdministratorName, TranslateUtils.ObjectCollectionToString(publishmentSystemIdList));
                }

                Body.AddAdminLog("新建站点", $"站点名称:{PageUtils.FilterXss(PublishmentSystemName.Text)}");

                //if (isHQ == EBoolean.False)
                //{
                //    string configFilePath = PathUtility.MapPath(psInfo, "@/web.config");
                //    if (FileUtils.IsFileExists(configFilePath))
                //    {
                //        FileUtility.UpdateWebConfig(configFilePath, psInfo.Additional.Charset);
                //    }
                //    else
                //    {
                //        FileUtility.CreateWebConfig(configFilePath, psInfo.Additional.Charset);
                //    }
                //}
                errorMessage = string.Empty;
                return(thePublishmentSystemId);
            }
            catch (Exception e)
            {
                errorMessage = e.Message;
                return(0);
            }
        }
Beispiel #25
0
        public static void Translate(PublishmentSystemInfo publishmentSystemInfo, int nodeID, int contentID, int targetPublishmentSystemID, int targetNodeID, ETranslateContentType translateType, string administratorName)
        {
            if (publishmentSystemInfo == null || nodeID <= 0 || contentID <= 0 || targetPublishmentSystemID <= 0 || targetNodeID <= 0)
            {
                return;
            }

            var targetPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(targetPublishmentSystemID);

            var targetTableName = NodeManager.GetTableName(targetPublishmentSystemInfo, targetNodeID);

            var nodeInfo   = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeID);
            var tableStyle = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo);
            var tableName  = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo);

            var contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentID);

            if (contentInfo != null)
            {
                if (translateType == ETranslateContentType.Copy)
                {
                    FileUtility.MoveFileByContentInfo(publishmentSystemInfo, targetPublishmentSystemInfo, contentInfo);

                    contentInfo.PublishmentSystemId = targetPublishmentSystemID;
                    contentInfo.SourceId            = contentInfo.NodeId;
                    contentInfo.NodeId = targetNodeID;
                    contentInfo.Attributes[ContentAttribute.TranslateContentType] = ETranslateContentType.Copy.ToString();
                    //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Copy.ToString());
                    var theContentID = DataProvider.ContentDao.Insert(targetTableName, targetPublishmentSystemInfo, contentInfo);
                    if (EContentModelTypeUtils.IsPhoto(nodeInfo.ContentModelId))
                    {
                        var photoInfoList = DataProvider.PhotoDao.GetPhotoInfoList(publishmentSystemInfo.PublishmentSystemId, contentID);
                        if (photoInfoList.Count > 0)
                        {
                            foreach (var photoInfo in photoInfoList)
                            {
                                photoInfo.PublishmentSystemID = targetPublishmentSystemID;
                                photoInfo.ContentID           = theContentID;

                                FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.SmallUrl);
                                FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.MiddleUrl);
                                FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.LargeUrl);

                                DataProvider.PhotoDao.Insert(photoInfo);
                            }
                        }
                    }
                    if (contentInfo.IsChecked)
                    {
                        CreateManager.CreateContentAndTrigger(targetPublishmentSystemInfo.PublishmentSystemId, contentInfo.NodeId, theContentID);
                    }
                }
                else if (translateType == ETranslateContentType.Cut)
                {
                    FileUtility.MoveFileByContentInfo(publishmentSystemInfo, targetPublishmentSystemInfo, contentInfo);
                    contentInfo.PublishmentSystemId = targetPublishmentSystemID;
                    contentInfo.SourceId            = contentInfo.NodeId;
                    contentInfo.NodeId = targetNodeID;
                    contentInfo.Attributes[ContentAttribute.TranslateContentType] = ETranslateContentType.Cut.ToString();
                    //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Cut.ToString());
                    if (StringUtils.EqualsIgnoreCase(tableName, targetTableName))
                    {
                        contentInfo.Taxis = DataProvider.ContentDao.GetTaxisToInsert(targetTableName, targetNodeID, contentInfo.IsTop);
                        DataProvider.ContentDao.Update(targetTableName, targetPublishmentSystemInfo, contentInfo);
                    }
                    else
                    {
                        DataProvider.ContentDao.Insert(targetTableName, targetPublishmentSystemInfo, contentInfo);
                        DataProvider.ContentDao.DeleteContents(publishmentSystemInfo.PublishmentSystemId, tableName, TranslateUtils.ToIntList(contentID), nodeID);
                    }

                    DataProvider.NodeDao.UpdateContentNum(publishmentSystemInfo, nodeID, true);
                    DataProvider.NodeDao.UpdateContentNum(targetPublishmentSystemInfo, targetNodeID, true);

                    if (EContentModelTypeUtils.IsPhoto(nodeInfo.ContentModelId))
                    {
                        var photoInfoList = DataProvider.PhotoDao.GetPhotoInfoList(publishmentSystemInfo.PublishmentSystemId, contentID);
                        if (photoInfoList.Count > 0)
                        {
                            foreach (var photoInfo in photoInfoList)
                            {
                                photoInfo.PublishmentSystemID = targetPublishmentSystemID;

                                FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.SmallUrl);
                                FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.MiddleUrl);
                                FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.LargeUrl);

                                DataProvider.PhotoDao.Update(photoInfo);
                            }
                        }
                    }
                    if (contentInfo.IsChecked)
                    {
                        CreateManager.CreateContentAndTrigger(targetPublishmentSystemInfo.PublishmentSystemId, contentInfo.NodeId, contentInfo.Id);
                    }
                }
                else if (translateType == ETranslateContentType.Reference)
                {
                    if (contentInfo.ReferenceId == 0)
                    {
                        contentInfo.PublishmentSystemId = targetPublishmentSystemID;
                        contentInfo.SourceId            = contentInfo.NodeId;
                        contentInfo.NodeId      = targetNodeID;
                        contentInfo.ReferenceId = contentID;
                        contentInfo.Attributes[ContentAttribute.TranslateContentType] = ETranslateContentType.Reference.ToString();
                        //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Reference.ToString());
                        DataProvider.ContentDao.Insert(targetTableName, targetPublishmentSystemInfo, contentInfo);
                    }
                }
                else if (translateType == ETranslateContentType.ReferenceContent)
                {
                    if (contentInfo.ReferenceId == 0)
                    {
                        contentInfo.PublishmentSystemId = targetPublishmentSystemID;
                        contentInfo.SourceId            = contentInfo.NodeId;
                        contentInfo.NodeId      = targetNodeID;
                        contentInfo.ReferenceId = contentID;
                        contentInfo.Attributes[ContentAttribute.TranslateContentType] = ETranslateContentType.ReferenceContent.ToString();
                        var theContentID = DataProvider.ContentDao.Insert(targetTableName, targetPublishmentSystemInfo, contentInfo);
                        if (EContentModelTypeUtils.IsPhoto(nodeInfo.ContentModelId))
                        {
                            var photoInfoList = DataProvider.PhotoDao.GetPhotoInfoList(publishmentSystemInfo.PublishmentSystemId, contentID);
                            if (photoInfoList.Count > 0)
                            {
                                foreach (var photoInfo in photoInfoList)
                                {
                                    photoInfo.PublishmentSystemID = targetPublishmentSystemID;
                                    photoInfo.ContentID           = theContentID;

                                    FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.SmallUrl);
                                    FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.MiddleUrl);
                                    FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.LargeUrl);

                                    DataProvider.PhotoDao.Insert(photoInfo);
                                }
                            }
                        }

                        FileUtility.MoveFileByContentInfo(publishmentSystemInfo, targetPublishmentSystemInfo, contentInfo);

                        if (contentInfo.IsChecked)
                        {
                            CreateManager.CreateContentAndTrigger(targetPublishmentSystemInfo.PublishmentSystemId, contentInfo.NodeId, theContentID);
                        }
                    }
                }
            }
        }
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _sortedlist  = SiteTemplateManager.Instance.GetSiteTemplateSortedList();
            _permissions = PermissionsManager.GetPermissions(Body.AdministratorName);

            if (!IsPostBack)
            {
                BaiRongDataProvider.TableCollectionDao.CreateAllAuxiliaryTableIfNotExists();

                SiteTemplateDir.Value = Body.GetQueryString("siteTemplate");

                BreadCrumbSys(AppManager.Sys.LeftMenu.Site, "创建站点", AppManager.Sys.Permission.SysSite);

                var hqSiteId = DataProvider.PublishmentSystemDao.GetPublishmentSystemIdByIsHeadquarters();
                if (hqSiteId == 0)
                {
                    IsHeadquarters.SelectedValue = "True";
                    phNotIsHeadquarters.Visible  = false;
                }
                else
                {
                    IsHeadquarters.Enabled = false;
                }

                ParentPublishmentSystemID.Items.Add(new ListItem("<无上级站点>", "0"));
                var publishmentSystemIdArrayList = PublishmentSystemManager.GetPublishmentSystemIdList();
                var mySystemInfoArrayList        = new ArrayList();
                var parentWithChildren           = new Hashtable();
                foreach (int publishmentSystemId in publishmentSystemIdArrayList)
                {
                    var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
                    if (publishmentSystemInfo.IsHeadquarters == false)
                    {
                        if (publishmentSystemInfo.ParentPublishmentSystemId == 0)
                        {
                            mySystemInfoArrayList.Add(publishmentSystemInfo);
                        }
                        else
                        {
                            var children = new ArrayList();
                            if (parentWithChildren.Contains(publishmentSystemInfo.ParentPublishmentSystemId))
                            {
                                children = (ArrayList)parentWithChildren[publishmentSystemInfo.ParentPublishmentSystemId];
                            }
                            children.Add(publishmentSystemInfo);
                            parentWithChildren[publishmentSystemInfo.ParentPublishmentSystemId] = children;
                        }
                    }
                }
                foreach (PublishmentSystemInfo publishmentSystemInfo in mySystemInfoArrayList)
                {
                    AddSite(ParentPublishmentSystemID, publishmentSystemInfo, parentWithChildren, 0);
                }
                ControlUtils.SelectListItems(ParentPublishmentSystemID, "0");

                ECharsetUtils.AddListItems(Charset);
                ControlUtils.SelectListItems(Charset, ECharsetUtils.GetValue(ECharset.utf_8));

                var tableList = BaiRongDataProvider.TableCollectionDao.GetAuxiliaryTableListCreatedInDbByAuxiliaryTableType(EAuxiliaryTableType.BackgroundContent);
                foreach (var tableInfo in tableList)
                {
                    var li = new ListItem($"{tableInfo.TableCnName}({tableInfo.TableEnName})", tableInfo.TableEnName);
                    AuxiliaryTableForContent.Items.Add(li);
                }

                tableList = BaiRongDataProvider.TableCollectionDao.GetAuxiliaryTableListCreatedInDbByAuxiliaryTableType(EAuxiliaryTableType.VoteContent);
                foreach (var tableInfo in tableList)
                {
                    var li = new ListItem($"{tableInfo.TableCnName}({tableInfo.TableEnName})", tableInfo.TableEnName);
                    AuxiliaryTableForVote.Items.Add(li);
                }

                tableList = BaiRongDataProvider.TableCollectionDao.GetAuxiliaryTableListCreatedInDbByAuxiliaryTableType(EAuxiliaryTableType.JobContent);
                foreach (var tableInfo in tableList)
                {
                    var li = new ListItem($"{tableInfo.TableCnName}({tableInfo.TableEnName})", tableInfo.TableEnName);
                    AuxiliaryTableForJob.Items.Add(li);
                }

                IsCheckContentUseLevel.Items.Add(new ListItem("默认审核机制", false.ToString()));
                IsCheckContentUseLevel.Items.Add(new ListItem("多级审核机制", true.ToString()));
                ControlUtils.SelectListItems(IsCheckContentUseLevel, false.ToString());

                UseSiteTemplate.Attributes.Add("onclick", "displaySiteTemplateDiv(this)");

                BindGrid();

                if (_sortedlist.Count > 0)
                {
                    SetActivePlaceHolder(WizardPlaceHolder.ChooseSiteTemplate, ChooseSiteTemplate);
                }
                else
                {
                    ChooseSiteTemplate.Visible = false;
                    UseSiteTemplate.Checked    = false;
                    SetActivePlaceHolder(WizardPlaceHolder.CreateSiteParameters, CreateSiteParameters);
                    RowSiteTemplateName.Visible = RowIsImportContents.Visible = RowIsImportTableStyles.Visible = RowIsUserSiteTemplateAuxiliaryTables.Visible = false;
                    phAuxiliaryTable.Visible    = true;
                }
            }
        }
Beispiel #27
0
        public string GetWhereStringByStlSearch(bool isAllSites, string siteName, string siteDir, string siteIds, string channelIndex, string channelName, string channelIds, string type, string word, string dateAttribute, string dateFrom, string dateTo, string since, int publishmentSystemId, List <string> excludeAttributes, NameValueCollection form, out bool isDefaultCondition)
        {
            isDefaultCondition = true;
            var whereBuilder = new StringBuilder();

            PublishmentSystemInfo publishmentSystemInfo = null;

            if (!string.IsNullOrEmpty(siteName))
            {
                publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfoBySiteName(siteName);
            }
            else if (!string.IsNullOrEmpty(siteDir))
            {
                publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfoByDirectory(siteDir);
            }
            if (publishmentSystemInfo == null)
            {
                publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
            }

            var channelId = StlCacheManager.NodeId.GetNodeIdByChannelIdOrChannelIndexOrChannelName(publishmentSystemId, publishmentSystemId, channelIndex, channelName);
            var nodeInfo  = NodeManager.GetNodeInfo(publishmentSystemId, channelId);

            if (isAllSites)
            {
                whereBuilder.Append("(PublishmentSystemID > 0) ");
            }
            else if (!string.IsNullOrEmpty(siteIds))
            {
                whereBuilder.Append($"(PublishmentSystemID IN ({TranslateUtils.ToSqlInStringWithoutQuote(TranslateUtils.StringCollectionToIntList(siteIds))})) ");
            }
            else
            {
                whereBuilder.Append($"(PublishmentSystemID = {publishmentSystemInfo.PublishmentSystemId}) ");
            }

            if (!string.IsNullOrEmpty(channelIds))
            {
                whereBuilder.Append(" AND ");
                var nodeIdList = new List <int>();
                foreach (var nodeId in TranslateUtils.StringCollectionToIntList(channelIds))
                {
                    nodeIdList.Add(nodeId);
                    nodeIdList.AddRange(DataProvider.NodeDao.GetNodeIdListForDescendant(nodeId));
                }
                whereBuilder.Append(nodeIdList.Count == 1
                    ? $"(NodeID = {nodeIdList[0]}) "
                    : $"(NodeID IN ({TranslateUtils.ToSqlInStringWithoutQuote(nodeIdList)})) ");
            }
            else if (channelId != publishmentSystemId)
            {
                whereBuilder.Append(" AND ");
                var nodeIdList = DataProvider.NodeDao.GetNodeIdListForDescendant(channelId);
                nodeIdList.Add(channelId);
                whereBuilder.Append(nodeIdList.Count == 1
                    ? $"(NodeID = {nodeIdList[0]}) "
                    : $"(NodeID IN ({TranslateUtils.ToSqlInStringWithoutQuote(nodeIdList)})) ");
            }

            var typeList = new List <string>();

            if (string.IsNullOrEmpty(type))
            {
                typeList.Add(ContentAttribute.Title);
            }
            else
            {
                typeList = TranslateUtils.StringCollectionToStringList(type);
            }

            if (!string.IsNullOrEmpty(word))
            {
                whereBuilder.Append(" AND (");
                foreach (var attributeName in typeList)
                {
                    whereBuilder.Append($"[{attributeName}] LIKE '%{PageUtils.FilterSql(word)}%' OR ");
                }
                whereBuilder.Length = whereBuilder.Length - 3;
                whereBuilder.Append(")");
            }

            if (string.IsNullOrEmpty(dateAttribute))
            {
                dateAttribute = ContentAttribute.AddDate;
            }

            if (!string.IsNullOrEmpty(dateFrom))
            {
                whereBuilder.Append(" AND ");
                whereBuilder.Append($" {dateAttribute} >= '{dateFrom}' ");
            }
            if (!string.IsNullOrEmpty(dateTo))
            {
                whereBuilder.Append(" AND ");
                whereBuilder.Append($" {dateAttribute} <= '{dateTo}' ");
            }
            if (!string.IsNullOrEmpty(since))
            {
                var sinceDate = DateTime.Now.AddHours(-DateUtils.GetSinceHours(since));
                whereBuilder.Append($" AND {dateAttribute} BETWEEN '{DateUtils.GetDateAndTimeString(sinceDate)}' AND {SqlUtils.GetDefaultDateString()} ");
            }

            var tableStyle    = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo);
            var tableName     = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo);
            var styleInfoList = RelatedIdentities.GetTableStyleInfoList(publishmentSystemInfo, tableStyle, nodeInfo.NodeId);

            foreach (string key in form.Keys)
            {
                if (excludeAttributes.Contains(key.ToLower()))
                {
                    continue;
                }
                if (string.IsNullOrEmpty(form[key]))
                {
                    continue;
                }

                var value = StringUtils.Trim(form[key]);
                if (string.IsNullOrEmpty(value))
                {
                    continue;
                }

                if (TableManager.IsAttributeNameExists(tableStyle, tableName, key))
                {
                    whereBuilder.Append(" AND ");
                    whereBuilder.Append($"({key} LIKE '%{value}%')");
                }
                else
                {
                    foreach (var tableStyleInfo in styleInfoList)
                    {
                        if (StringUtils.EqualsIgnoreCase(tableStyleInfo.AttributeName, key))
                        {
                            whereBuilder.Append(" AND ");
                            whereBuilder.Append($"({ContentAttribute.SettingsXml} LIKE '%{key}={value}%')");
                            break;
                        }
                    }
                }

                if (tableStyle == ETableStyle.GovPublicContent)
                {
                    if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.DepartmentId))
                    {
                        whereBuilder.Append(" AND ");
                        whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                    }
                    else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category1Id))
                    {
                        whereBuilder.Append(" AND ");
                        whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                    }
                    else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category2Id))
                    {
                        whereBuilder.Append(" AND ");
                        whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                    }
                    else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category3Id))
                    {
                        whereBuilder.Append(" AND ");
                        whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                    }
                    else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category4Id))
                    {
                        whereBuilder.Append(" AND ");
                        whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                    }
                    else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category5Id))
                    {
                        whereBuilder.Append(" AND ");
                        whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                    }
                    else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category6Id))
                    {
                        whereBuilder.Append(" AND ");
                        whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                    }
                }
            }

            if (whereBuilder.ToString().Contains(" AND "))
            {
                isDefaultCondition = false;
            }

            return(whereBuilder.ToString());
        }
Beispiel #28
0
        public void Main(int publishmentSystemId, int inputId)
        {
            var body = new RequestBody();

            var       publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
            InputInfo inputInfo             = null;

            if (inputId > 0)
            {
                inputInfo = DataProvider.InputDao.GetInputInfo(inputId);
            }
            if (inputInfo != null)
            {
                var relatedIdentities = RelatedIdentities.GetRelatedIdentities(ETableStyle.InputContent, publishmentSystemId, inputInfo.InputId);

                var ipAddress = PageUtils.GetIpAddress();

                var contentInfo = new InputContentInfo(0, inputInfo.InputId, 0, inputInfo.IsChecked, body.UserName, ipAddress, DateTime.Now, string.Empty);

                try
                {
                    if (!inputInfo.Additional.IsAnomynous && !body.IsUserLoggin)
                    {
                        throw new Exception("请先登录系统!");
                    }

                    InputTypeParser.AddValuesToAttributes(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, publishmentSystemInfo, relatedIdentities, HttpContext.Current.Request.Form, contentInfo.Attributes, false);

                    if (HttpContext.Current.Request.Files.Count > 0)
                    {
                        foreach (var attributeName in HttpContext.Current.Request.Files.AllKeys)
                        {
                            var myFile = HttpContext.Current.Request.Files[attributeName];
                            if (myFile == null || "" == myFile.FileName)
                            {
                                continue;
                            }

                            var fileUrl = UploadFile(publishmentSystemInfo, myFile);
                            contentInfo.SetExtendedAttribute(attributeName, fileUrl);
                        }
                    }

                    contentInfo.Id = DataProvider.InputContentDao.Insert(contentInfo);

                    if (inputInfo.Additional.IsAdministratorSmsNotify)
                    {
                        var keys =
                            TranslateUtils.StringCollectionToStringList(inputInfo.Additional.AdministratorSmsNotifyKeys);
                        if (keys.Count > 0)
                        {
                            var parameters = new NameValueCollection();
                            if (keys.Contains(InputContentAttribute.Id))
                            {
                                parameters.Add(InputContentAttribute.Id, contentInfo.Id.ToString());
                            }
                            if (keys.Contains(InputContentAttribute.AddDate))
                            {
                                parameters.Add(InputContentAttribute.AddDate, DateUtils.GetDateAndTimeString(contentInfo.AddDate));
                            }
                            var styleInfoList = TableStyleManager.GetTableStyleInfoList(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, relatedIdentities);
                            foreach (var styleInfo in styleInfoList)
                            {
                                if (keys.Contains(styleInfo.AttributeName))
                                {
                                    var value = contentInfo.GetExtendedAttribute(styleInfo.AttributeName);
                                    parameters.Add(styleInfo.AttributeName, value);
                                }
                            }

                            string errorMessage;
                            SmsManager.SendNotify(inputInfo.Additional.AdministratorSmsNotifyMobile,
                                                  inputInfo.Additional.AdministratorSmsNotifyTplId, parameters, out errorMessage);
                        }
                    }

                    HttpContext.Current.Response.Write(StlInput.GetPostMessageScript(inputId, true));
                    HttpContext.Current.Response.End();
                }
                catch (Exception)
                {
                    HttpContext.Current.Response.Write(StlInput.GetPostMessageScript(inputId, false));
                    HttpContext.Current.Response.End();
                }
            }
        }
Beispiel #29
0
        public void Main()
        {
            var body = new RequestBody();

            var publishmentSystemId   = body.GetQueryInt("publishmentSystemId");
            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);

            try
            {
                var channelId = body.GetQueryInt("channelId");
                if (channelId == 0)
                {
                    channelId = publishmentSystemId;
                }
                var contentId      = body.GetQueryInt("contentId");
                var fileTemplateId = body.GetQueryInt("fileTemplateId");
                var isRedirect     = TranslateUtils.ToBool(body.GetQueryString("isRedirect"));

                var fso        = new FileSystemObject(publishmentSystemId);
                var nodeInfo   = NodeManager.GetNodeInfo(publishmentSystemId, channelId);
                var tableStyle = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo);
                var tableName  = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo);
                if (fileTemplateId != 0)
                {
                    fso.CreateFile(fileTemplateId);
                }
                else if (contentId != 0)
                {
                    fso.CreateContent(tableStyle, tableName, channelId, contentId);
                }
                else if (channelId != 0)
                {
                    fso.CreateChannel(channelId);
                }
                else if (publishmentSystemId != 0)
                {
                    fso.CreateChannel(publishmentSystemId);
                }

                if (isRedirect)
                {
                    var redirectUrl = string.Empty;
                    if (fileTemplateId != 0)
                    {
                        redirectUrl = PageUtility.GetFileUrl(publishmentSystemInfo, fileTemplateId);
                    }
                    else if (contentId != 0)
                    {
                        var contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentId);
                        redirectUrl = PageUtility.GetContentUrl(publishmentSystemInfo, contentInfo);
                    }
                    else if (channelId != 0)
                    {
                        redirectUrl = PageUtility.GetChannelUrl(publishmentSystemInfo, nodeInfo);
                    }
                    else if (publishmentSystemId != 0)
                    {
                        redirectUrl = PageUtility.GetIndexPageUrl(publishmentSystemInfo);
                    }

                    if (!string.IsNullOrEmpty(redirectUrl))
                    {
                        redirectUrl = PageUtils.AddQueryString(redirectUrl, "__r", StringUtils.GetRandomInt(1, 10000).ToString());
                        HttpContext.Current.Response.Redirect(redirectUrl, true);
                        return;
                    }
                }
            }
            catch
            {
                var redirectUrl = PageUtility.GetIndexPageUrl(publishmentSystemInfo);
                HttpContext.Current.Response.Redirect(redirectUrl, true);
                return;
            }

            HttpContext.Current.Response.Write(string.Empty);
            HttpContext.Current.Response.End();
        }
Beispiel #30
0
        public static void RecoverySite(int publishmentSystemId, bool isDeleteChannels, bool isDeleteTemplates, bool isDeleteFiles, bool isZip, string path, bool isOverride, bool isUseTable, string administratorName)
        {
            var importObject = new ImportObject(publishmentSystemId);

            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);

            var siteTemplatePath = path;

            if (isZip)
            {
                //解压文件
                siteTemplatePath = PathUtils.GetTemporaryFilesPath(EBackupTypeUtils.GetValue(EBackupType.Site));
                DirectoryUtils.DeleteDirectoryIfExists(siteTemplatePath);
                DirectoryUtils.CreateDirectoryIfNotExists(siteTemplatePath);

                ZipUtils.UnpackFiles(path, siteTemplatePath);
            }
            var siteTemplateMetadataPath = PathUtils.Combine(siteTemplatePath, DirectoryUtils.SiteTemplates.SiteTemplateMetadata);

            if (isDeleteChannels)
            {
                var nodeIdList = DataProvider.NodeDao.GetNodeIdListByParentId(publishmentSystemId, publishmentSystemId);
                foreach (int nodeId in nodeIdList)
                {
                    DataProvider.NodeDao.Delete(nodeId);
                }
            }
            if (isDeleteTemplates)
            {
                var templateInfoArrayList =
                    DataProvider.TemplateDao.GetTemplateInfoArrayListByPublishmentSystemId(publishmentSystemId);
                foreach (TemplateInfo templateInfo in templateInfoArrayList)
                {
                    if (templateInfo.IsDefault == false)
                    {
                        DataProvider.TemplateDao.Delete(publishmentSystemId, templateInfo.TemplateId);
                    }
                }
            }
            if (isDeleteFiles)
            {
                DirectoryUtility.DeletePublishmentSystemFiles(publishmentSystemInfo);
            }

            //导入文件
            importObject.ImportFiles(siteTemplatePath, isOverride);

            //导入模板
            var templateFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileTemplate);

            importObject.ImportTemplates(templateFilePath, isOverride, administratorName);

            //导入辅助表
            var tableDirectoryPath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.Table);

            importObject.ImportAuxiliaryTables(tableDirectoryPath, isUseTable);

            //导入菜单
            var menuDisplayFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileMenuDisplay);

            importObject.ImportMenuDisplay(menuDisplayFilePath, isOverride);

            //导入标签样式
            var tagStyleFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileTagStyle);

            importObject.ImportTagStyle(tagStyleFilePath, isOverride);

            //导入固定广告
            var adFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileAd);

            importObject.ImportAd(adFilePath, isOverride);

            //导入采集规则
            var gatherRuleFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileGatherRule);

            importObject.ImportGatherRule(gatherRuleFilePath, isOverride);

            //导入提交表单
            var inputDirectoryPath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.Input);

            importObject.ImportInput(inputDirectoryPath, isOverride);

            //导入站点设置
            var configurationFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileConfiguration);

            importObject.ImportConfiguration(configurationFilePath);

            //导入内容模型
            var contentModelFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileContentModel);

            importObject.ImportContentModel(contentModelFilePath, true);

            //导入栏目及内容
            var siteContentDirectoryPath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.SiteContent);

            importObject.ImportChannelsAndContents(0, siteContentDirectoryPath, isOverride);

            DataProvider.NodeDao.UpdateContentNum(publishmentSystemInfo);

            //导入表样式及清除缓存
            if (isUseTable)
            {
                importObject.ImportTableStyles(tableDirectoryPath);
            }
            importObject.RemoveDbCache();

            CacheUtils.Clear();
        }