Exemple #1
0
        void rptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var ltlItemTitle    = e.Item.FindControl("ltlItemTitle") as Literal;
                var ltlChannel      = e.Item.FindControl("ltlChannel") as Literal;
                var ltlItemImageUrl = e.Item.FindControl("ltlItemImageUrl") as Literal;
                var ltlItemSummary  = e.Item.FindControl("ltlItemSummary") as Literal;
                var ltlSelect       = e.Item.FindControl("ltlSelect") as Literal;

                var contentInfo = new ContentInfo(e.Item.DataItem);

                ltlItemTitle.Text = WebUtils.GetContentTitle(PublishmentSystemInfo, contentInfo, PageUrl);
                var nodeName = _valueHashtable[contentInfo.NodeId] as string;
                if (nodeName == null)
                {
                    nodeName = NodeManager.GetNodeNameNavigation(PublishmentSystemId, contentInfo.NodeId);
                    _valueHashtable[contentInfo.NodeId] = nodeName;
                }
                ltlChannel.Text = nodeName;

                var imageUrl = contentInfo.GetExtendedAttribute(BackgroundContentAttribute.ImageUrl);
                if (!string.IsNullOrEmpty(imageUrl))
                {
                    ltlItemImageUrl.Text =
                        $@"<img src=""{PageUtility.ParseNavigationUrl(PublishmentSystemInfo, imageUrl)}"" style=""max-width:78px;max-height:78px;"" />";
                }

                ltlItemSummary.Text = MPUtils.GetSummary(contentInfo.GetExtendedAttribute(BackgroundContentAttribute.Summary), contentInfo.GetExtendedAttribute(BackgroundContentAttribute.Content));

                if (_isMultiple)
                {
                    ltlSelect.Text =
                        $@"<input type=""checkbox"" name=""IDsCollection"" value=""{contentInfo.NodeId}_{contentInfo.Id}"" />";
                }
                else
                {
                    ltlSelect.Text =
                        $@"<input type=""radio"" name=""IDsCollection"" value=""{contentInfo.NodeId}_{contentInfo.Id}"" />";
                }
            }
        }
Exemple #2
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);
            }
        }
Exemple #3
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>";
                }
            }
        }
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID");
            keywordID  = TranslateUtils.ToInt(GetQueryString("keywordID"));
            resourceID = TranslateUtils.ToInt(GetQueryString("resourceID"));
            isSingle   = TranslateUtils.ToBool(GetQueryString("isSingle"));

            if (Request.QueryString["deleteResource"] != null)
            {
                var deleteResourceID = TranslateUtils.ToInt(Request.QueryString["deleteResourceID"]);

                try
                {
                    DataProviderWX.KeywordResourceDAO.Delete(deleteResourceID);
                    SuccessDeleteMessage();
                }
                catch (Exception ex)
                {
                    FailDeleteMessage(ex);
                }
            }

            if (!IsPostBack)
            {
                var pageTitle = keywordID == 0 ? "添加关键词图文回复" : "修改关键词图文回复";
                ltlPageTitle.Text = pageTitle;

                BreadCrumb(AppManager.WeiXin.LeftMenu.ID_Accounts, AppManager.WeiXin.LeftMenu.Function.ID_ImageReply, pageTitle, AppManager.WeiXin.Permission.WebSite.ImageReply);
                phSingle.Visible   = isSingle;
                phMultiple.Visible = !isSingle;

                if (isSingle)
                {
                    var resourceInfo = new KeywordResourceInfo();

                    resourceInfo.ResourceID          = 0;
                    resourceInfo.PublishmentSystemID = PublishmentSystemID;
                    resourceInfo.KeywordID           = keywordID;
                    resourceInfo.Title          = "标题";
                    resourceInfo.ImageUrl       = string.Empty;
                    resourceInfo.Summary        = string.Empty;
                    resourceInfo.ResourceType   = EResourceType.Content;
                    resourceInfo.IsShowCoverPic = true;
                    resourceInfo.Content        = string.Empty;
                    resourceInfo.NavigationUrl  = string.Empty;
                    resourceInfo.ChannelID      = 0;
                    resourceInfo.ContentID      = 0;
                    resourceInfo.Taxis          = 0;

                    if (resourceID > 0)
                    {
                        resourceInfo = DataProviderWX.KeywordResourceDAO.GetResourceInfo(resourceID);
                    }
                    ltlSingleTitle.Text = $@"<a href=""javascript:;"">{resourceInfo.Title}</a>";
                    if (string.IsNullOrEmpty(resourceInfo.ImageUrl))
                    {
                        ltlSingleImageUrl.Text = @"<i class=""appmsg_thumb default"">封面图片</i>";
                    }
                    else
                    {
                        ltlSingleImageUrl.Text =
                            $@"<img class=""js_appmsg_thumb"" src=""{PageUtility.ParseNavigationUrl(
                                PublishmentSystemInfo, resourceInfo.ImageUrl)}"">";
                    }
                    ltlSingleSummary.Text = MPUtils.GetSummary(resourceInfo.Summary, resourceInfo.Content);
                }
                else
                {
                    var resourceInfoList = DataProviderWX.KeywordResourceDAO.GetResourceInfoList(keywordID);

                    var resourceInfo = new KeywordResourceInfo();

                    resourceInfo.ResourceID          = 0;
                    resourceInfo.PublishmentSystemID = PublishmentSystemID;
                    resourceInfo.KeywordID           = keywordID;
                    resourceInfo.Title          = "标题";
                    resourceInfo.ImageUrl       = string.Empty;
                    resourceInfo.Summary        = string.Empty;
                    resourceInfo.ResourceType   = EResourceType.Content;
                    resourceInfo.IsShowCoverPic = true;
                    resourceInfo.Content        = string.Empty;
                    resourceInfo.NavigationUrl  = string.Empty;
                    resourceInfo.ChannelID      = 0;
                    resourceInfo.ContentID      = 0;
                    resourceInfo.Taxis          = 0;

                    if (resourceInfoList.Count <= 1)
                    {
                        resourceInfoList.Add(resourceInfo);
                    }

                    if (resourceInfoList.Count > 1)
                    {
                        resourceInfo = resourceInfoList[0];
                        resourceInfoList.Remove(resourceInfo);
                    }

                    ltlMultipleTitle.Text = $@"<a href=""javascript:;"">{resourceInfo.Title}</a>";

                    if (string.IsNullOrEmpty(resourceInfo.ImageUrl))
                    {
                        ltlMultipleImageUrl.Text = @"<i class=""appmsg_thumb default"">封面图片</i>";
                    }
                    else
                    {
                        ltlMultipleImageUrl.Text =
                            $@"<img class=""js_appmsg_thumb"" src=""{PageUtility.ParseNavigationUrl(
                                PublishmentSystemInfo, resourceInfo.ImageUrl)}"">";
                    }
                    ltlMultipleEditUrl.Text =
                        $@"<a class=""icon18_common edit_gray js_edit"" href=""{BackgroundKeywordResourceAdd.GetRedirectUrl(
                            PublishmentSystemID, keywordID, resourceInfo.ResourceID, 1, false)}"" target=""resource"">&nbsp;&nbsp;</a>";

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

                    ltlItemEditUrl.Text =
                        $@"<a class=""icon18_common edit_gray js_edit"" href=""{BackgroundKeywordResourceAdd.GetRedirectUrl(
                            PublishmentSystemID, keywordID, 0, resourceInfoList.Count + 2, false)}"" target=""resource"">&nbsp;&nbsp;</a>";
                }

                ltlIFrame.Text =
                    $@"<iframe frameborder=""0"" id=""resource"" name=""resource"" width=""100%"" height=""1300"" src=""{BackgroundKeywordResourceAdd
                        .GetRedirectUrl(PublishmentSystemID, keywordID, resourceID, 1, isSingle)}"" scrolling=""no""></iframe>";
            }
        }