Example #1
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            try
            {
                var idsCollection = Request.Form["IDsCollection"];

                if (string.IsNullOrEmpty(idsCollection))
                {
                    FailMessage("操作失败,请选择需要显示的内容");
                    return;
                }

                if (_isKeywordAdd)
                {
                    if (_keywordId > 0)
                    {
                        var idsList    = TranslateUtils.StringCollectionToStringList(idsCollection);
                        var resourceId = 0;
                        foreach (var ids in idsList)
                        {
                            var nodeId     = TranslateUtils.ToInt(ids.Split('_')[0]);
                            var contentId  = TranslateUtils.ToInt(ids.Split('_')[1]);
                            var tableStyle = NodeManager.GetTableStyle(PublishmentSystemInfo, nodeId);
                            var tableName  = NodeManager.GetTableName(PublishmentSystemInfo, nodeId);

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

                            var resourceInfo = new KeywordResourceInfo();

                            resourceInfo.ResourceId          = 0;
                            resourceInfo.PublishmentSystemId = PublishmentSystemId;
                            resourceInfo.KeywordId           = _keywordId;
                            resourceInfo.Title          = contentInfo.Title;
                            resourceInfo.ImageUrl       = contentInfo.GetExtendedAttribute(BackgroundContentAttribute.ImageUrl);
                            resourceInfo.Summary        = MPUtils.GetSummary(contentInfo.GetExtendedAttribute(BackgroundContentAttribute.Summary), contentInfo.GetExtendedAttribute(BackgroundContentAttribute.Content));
                            resourceInfo.ResourceType   = EResourceType.Site;
                            resourceInfo.IsShowCoverPic = false;
                            resourceInfo.Content        = contentInfo.GetExtendedAttribute(BackgroundContentAttribute.Content);
                            resourceInfo.NavigationUrl  = string.Empty;
                            resourceInfo.ChannelId      = contentInfo.NodeId;
                            resourceInfo.ContentId      = contentInfo.Id;
                            resourceInfo.Taxis          = 0;

                            var id = DataProviderWx.KeywordResourceDao.Insert(resourceInfo);
                            if (resourceId == 0)
                            {
                                resourceId = id;
                            }
                        }

                        var redirectUrl = PageKeywordNewsAdd.GetRedirectUrl(PublishmentSystemId, _keywordId, resourceId, !_isMultiple);
                        PageUtils.CloseModalPageAndRedirect(Page, redirectUrl);
                    }
                }
                else
                {
                    var scripts = string.Empty;
                    if (_isMultiple)
                    {
                        var titleBuilder = new StringBuilder();
                        var idsList      = TranslateUtils.StringCollectionToStringList(idsCollection);
                        foreach (var ids in idsList)
                        {
                            var nodeId     = TranslateUtils.ToInt(ids.Split('_')[0]);
                            var contentId  = TranslateUtils.ToInt(ids.Split('_')[1]);
                            var tableStyle = NodeManager.GetTableStyle(PublishmentSystemInfo, nodeId);
                            var tableName  = NodeManager.GetTableName(PublishmentSystemInfo, nodeId);

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

                            titleBuilder.AppendFormat("{0}&nbsp;<a href='{1}' target='blank'>查看</a><br />", contentInfo.Title, PageUtilityWX.GetContentUrl(PublishmentSystemInfo, contentInfo));
                        }
                        scripts = $@"window.parent.{_jsMethod}(""{idsCollection}"", ""{titleBuilder}"");";
                    }
                    else
                    {
                        var nodeId     = TranslateUtils.ToInt(idsCollection.Split('_')[0]);
                        var contentId  = TranslateUtils.ToInt(idsCollection.Split('_')[1]);
                        var tableStyle = NodeManager.GetTableStyle(PublishmentSystemInfo, nodeId);
                        var tableName  = NodeManager.GetTableName(PublishmentSystemInfo, nodeId);

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

                        var imageUrl = contentInfo.GetExtendedAttribute(BackgroundContentAttribute.ImageUrl);
                        var imageSrc = PageUtility.ParseNavigationUrl(PublishmentSystemInfo, imageUrl);
                        var summary  = MPUtils.GetSummary(contentInfo.GetExtendedAttribute(BackgroundContentAttribute.Summary), contentInfo.GetExtendedAttribute(BackgroundContentAttribute.Content));

                        var pageUrl = PageUtilityWX.GetContentUrl(PublishmentSystemInfo, contentInfo);
                        scripts =
                            $@"window.parent.{_jsMethod}(""{contentInfo.Title}"", ""{nodeId}"", ""{contentId}"", ""{pageUrl}"", ""{imageUrl}"", ""{imageSrc}"", ""{summary}"");";

                        if (Request.QueryString["itemIndex"] != null)
                        {
                            scripts =
                                $@"window.parent.{_jsMethod}({_itemIndex}, ""{contentInfo.Title}"", {nodeId}, {contentId});";
                        }
                    }

                    PageUtils.CloseModalPageWithoutRefresh(Page, scripts);
                }
            }
            catch (Exception ex)
            {
                FailMessage(ex, "失败:" + ex.Message);
            }
        }
Example #2
0
        void rptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var keywordId  = SqlUtils.EvalInt(e.Item.DataItem, "KeywordId");
                var keywords   = SqlUtils.EvalString(e.Item.DataItem, "Keywords");
                var isDisabled = TranslateUtils.ToBool(SqlUtils.EvalString(e.Item.DataItem, "IsDisabled"));
                var reply      = SqlUtils.EvalString(e.Item.DataItem, "Reply");
                var matchType  = EMatchTypeUtils.GetEnumType(SqlUtils.EvalString(e.Item.DataItem, "MatchType"));
                var addDate    = SqlUtils.EvalDateTime(e.Item.DataItem, "AddDate");

                var phSingle   = e.Item.FindControl("phSingle") as PlaceHolder;
                var phMultiple = e.Item.FindControl("phMultiple") as PlaceHolder;

                var resourceInfoList = DataProviderWx.KeywordResourceDao.GetResourceInfoList(keywordId);

                phMultiple.Visible = resourceInfoList.Count > 1;
                phSingle.Visible   = !phMultiple.Visible;

                if (phSingle.Visible)
                {
                    var resourceInfo = new KeywordResourceInfo();
                    if (resourceInfoList.Count > 0)
                    {
                        resourceInfo = resourceInfoList[0];
                    }

                    var ltlSingleTitle     = e.Item.FindControl("ltlSingleTitle") as Literal;
                    var ltlSingleKeywords  = e.Item.FindControl("ltlSingleKeywords") as Literal;
                    var ltlSingleAddDate   = e.Item.FindControl("ltlSingleAddDate") as Literal;
                    var ltlSingleImageUrl  = e.Item.FindControl("ltlSingleImageUrl") as Literal;
                    var ltlSingleSummary   = e.Item.FindControl("ltlSingleSummary") as Literal;
                    var ltlSingleEditUrl   = e.Item.FindControl("ltlSingleEditUrl") as Literal;
                    var ltlSingleDeleteUrl = e.Item.FindControl("ltlSingleDeleteUrl") as Literal;

                    ltlSingleTitle.Text    = $@"<a href=""{"javascript:;"}"" target=""_blank"">{resourceInfo.Title}</a>";
                    ltlSingleKeywords.Text =
                        $@"{keywords + (isDisabled ? "(禁用)" : string.Empty)}&nbsp;<a href=""javascript:;"" onclick=""{ModalKeywordAddNews.GetOpenWindowStringToEdit(PublishmentSystemId, keywordId)}"">修改</a>";
                    ltlSingleAddDate.Text = addDate.ToShortDateString();
                    if (!string.IsNullOrEmpty(resourceInfo.ImageUrl))
                    {
                        ltlSingleImageUrl.Text =
                            $@"<img src=""{PageUtility.ParseNavigationUrl(PublishmentSystemInfo, resourceInfo.ImageUrl)}"" class=""appmsg_thumb"">";
                    }
                    ltlSingleSummary.Text = MPUtils.GetSummary(resourceInfo.Summary, resourceInfo.Content);
                    ltlSingleEditUrl.Text =
                        $@"<a class=""js_edit"" href=""{PageKeywordNewsAdd.GetRedirectUrl(PublishmentSystemId,
                            keywordId, resourceInfo.ResourceId, phSingle.Visible)}""><i class=""icon18_common edit_gray"">编辑</i></a>";
                    ltlSingleDeleteUrl.Text =
                        $@"<a class=""js_del no_extra"" href=""{GetRedirectUrl(
                            PublishmentSystemId)}&delete=true&keywordID={keywordId}"" onclick=""javascript:return confirm('此操作将删除图文回复“{keywords}”,确认吗?');""><i class=""icon18_common del_gray"">删除</i></a>";
                }
                else
                {
                    var resourceInfo = resourceInfoList[0];
                    resourceInfoList.Remove(resourceInfo);

                    var ltlMultipleKeywords  = e.Item.FindControl("ltlMultipleKeywords") as Literal;
                    var ltlMultipleAddDate   = e.Item.FindControl("ltlMultipleAddDate") as Literal;
                    var ltlMultipleTitle     = e.Item.FindControl("ltlMultipleTitle") as Literal;
                    var ltlMultipleImageUrl  = e.Item.FindControl("ltlMultipleImageUrl") as Literal;
                    var rptMultipleContents  = e.Item.FindControl("rptMultipleContents") as Repeater;
                    var ltlMultipleEditUrl   = e.Item.FindControl("ltlMultipleEditUrl") as Literal;
                    var ltlMultipleDeleteUrl = e.Item.FindControl("ltlMultipleDeleteUrl") as Literal;

                    ltlMultipleKeywords.Text =
                        $@"{keywords + (isDisabled ? "(禁用)" : string.Empty)}&nbsp;<a href=""javascript:;"" onclick=""{ModalKeywordAddNews.GetOpenWindowStringToEdit(PublishmentSystemId, keywordId)}"">修改</a>";

                    ltlMultipleAddDate.Text = addDate.ToShortDateString();
                    ltlMultipleTitle.Text   = $@"<a href=""{"javascript:;"}"" target=""_blank"">{resourceInfo.Title}</a>";
                    if (!string.IsNullOrEmpty(resourceInfo.ImageUrl))
                    {
                        ltlMultipleImageUrl.Text =
                            $@"<img src=""{PageUtility.ParseNavigationUrl(PublishmentSystemInfo, resourceInfo.ImageUrl)}"" class=""appmsg_thumb"">";
                    }

                    rptMultipleContents.DataSource     = resourceInfoList;
                    rptMultipleContents.ItemDataBound += rptMultipleContents_ItemDataBound;
                    rptMultipleContents.DataBind();

                    ltlMultipleEditUrl.Text =
                        $@"<a class=""js_edit"" href=""{PageKeywordNewsAdd.GetRedirectUrl(PublishmentSystemId,
                            keywordId, resourceInfo.ResourceId, phSingle.Visible)}""><i class=""icon18_common edit_gray"">编辑</i></a>";
                    ltlMultipleDeleteUrl.Text =
                        $@"<a class=""js_del no_extra"" href=""{GetRedirectUrl(
                            PublishmentSystemId)}&delete=true&keywordID={keywordId}"" onclick=""javascript:return confirm('此操作将删除图文回复“{keywords}”,确认吗?');""><i class=""icon18_common del_gray"">删除</i></a>";
                }
            }
        }
Example #3
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isChanged    = false;
            var keywordIdNew = 0;

            try
            {
                if (_keywordId == 0)
                {
                    var conflictKeywords = string.Empty;
                    if (KeywordManager.IsKeywordInsertConflict(PublishmentSystemId, TbKeywords.Text, out conflictKeywords))
                    {
                        FailMessage($"触发关键词“{conflictKeywords}”已存在,请设置其他关键词");
                    }
                    else
                    {
                        var keywordInfo = new KeywordInfo();

                        keywordInfo.KeywordId           = 0;
                        keywordInfo.PublishmentSystemId = PublishmentSystemId;
                        keywordInfo.Keywords            = TbKeywords.Text;
                        keywordInfo.IsDisabled          = !CbIsEnabled.Checked;
                        keywordInfo.KeywordType         = EKeywordType.News;
                        keywordInfo.MatchType           = EMatchTypeUtils.GetEnumType(DdlMatchType.SelectedValue);
                        keywordInfo.Reply   = string.Empty;
                        keywordInfo.AddDate = DateTime.Now;
                        keywordInfo.Taxis   = 0;

                        keywordIdNew = DataProviderWx.KeywordDao.Insert(keywordInfo);

                        Body.AddSiteLog(PublishmentSystemId, "添加图文回复关键词", $"关键词:{TbKeywords.Text}");

                        isChanged = true;
                    }
                }
                else
                {
                    var conflictKeywords = string.Empty;
                    if (KeywordManager.IsKeywordUpdateConflict(PublishmentSystemId, _keywordId, TbKeywords.Text, out conflictKeywords))
                    {
                        FailMessage($"触发关键词“{conflictKeywords}”已存在,请设置其他关键词");
                    }
                    else
                    {
                        var keywordInfo = DataProviderWx.KeywordDao.GetKeywordInfo(_keywordId);
                        keywordInfo.Keywords   = TbKeywords.Text;
                        keywordInfo.IsDisabled = !CbIsEnabled.Checked;
                        keywordInfo.MatchType  = EMatchTypeUtils.GetEnumType(DdlMatchType.SelectedValue);

                        DataProviderWx.KeywordDao.Update(keywordInfo);

                        Body.AddSiteLog(PublishmentSystemId, "编辑图文回复关键词", $"关键词:{TbKeywords.Text}");

                        isChanged = true;
                    }
                }
            }
            catch (Exception ex)
            {
                FailMessage(ex, "失败:" + ex.Message);
            }

            if (isChanged)
            {
                if (_keywordId == 0)
                {
                    if (CbIsSelect.Checked)
                    {
                        PageUtils.Redirect(ModalContentSelect.GetRedirectUrlByKeywordAddList(PublishmentSystemId, !_isSingle, keywordIdNew));
                    }
                    else
                    {
                        PageUtils.CloseModalPageAndRedirect(Page, PageKeywordNewsAdd.GetRedirectUrl(PublishmentSystemId, keywordIdNew, 0, _isSingle));
                    }
                }
                else
                {
                    PageUtils.CloseModalPage(Page);
                }
            }
        }
Example #4
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                try
                {
                    var resourceInfo = new KeywordResourceInfo();
                    resourceInfo.PublishmentSystemId = PublishmentSystemId;
                    resourceInfo.KeywordId           = _keywordId;

                    if (_resourceId > 0)
                    {
                        resourceInfo = DataProviderWx.KeywordResourceDao.GetResourceInfo(_resourceId);
                    }

                    resourceInfo.Title          = TbTitle.Text;
                    resourceInfo.Taxis          = Convert.ToInt32(TbTaxis.Text);
                    resourceInfo.ResourceType   = EResourceTypeUtils.GetEnumType(Request.Form["resourceType"]);
                    resourceInfo.ImageUrl       = Request.Form["imageUrl"];
                    resourceInfo.Summary        = TbSummary.Text;
                    resourceInfo.IsShowCoverPic = TranslateUtils.ToBool(Request.Form["isShowCoverPic"]);
                    resourceInfo.Content        = BreContent.Text;
                    resourceInfo.NavigationUrl  = TbNavigationUrl.Text;
                    resourceInfo.ChannelId      = TranslateUtils.ToInt(Request.Form["channelID"]);
                    resourceInfo.ContentId      = TranslateUtils.ToInt(Request.Form["contentID"]);

                    var isError = false;

                    if (resourceInfo.ResourceType == EResourceType.Site)
                    {
                        if (resourceInfo.ChannelId == 0)
                        {
                            FailMessage("图文回复保存失败,请选择需要显示的微网站页面!");
                            LtlScript.Text +=
                                $@"<script>$('.nav a.{EResourceTypeUtils.GetValue(EResourceType.Site)}').click();</script>";
                            isError = true;
                        }
                    }
                    else if (resourceInfo.ResourceType == EResourceType.Url)
                    {
                        if (string.IsNullOrEmpty(resourceInfo.NavigationUrl))
                        {
                            FailMessage("图文回复保存失败,请填写需要链接的网址!");
                            LtlScript.Text +=
                                $@"<script>$('.nav a.{EResourceTypeUtils.GetValue(EResourceType.Url)}').click();</script>";
                            isError = true;
                        }
                    }

                    if (!isError)
                    {
                        if (_resourceId > 0)
                        {
                            DataProviderWx.KeywordResourceDao.Update(resourceInfo);

                            Body.AddSiteLog(PublishmentSystemId, "修改关键词图文回复");
                            SuccessMessage("关键词图文回复修改成功!");
                        }
                        else
                        {
                            _resourceId = DataProviderWx.KeywordResourceDao.Insert(resourceInfo);

                            Body.AddSiteLog(PublishmentSystemId, "新增关键词图文回复");
                            SuccessMessage("关键词图文回复新增成功!");
                        }

                        FileUtilityWX.CreateWeiXinContent(PublishmentSystemInfo, _keywordId, _resourceId);

                        var redirectUrl = PageKeywordNewsAdd.GetRedirectUrl(PublishmentSystemId, _keywordId, _resourceId, _isSingle);
                        LtlScript.Text +=
                            $@"<script>setTimeout(""parent.redirect('{redirectUrl}')"", 1500);</script>";
                    }
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "关键词图文回复配置失败!");
                }
            }
        }