Ejemplo n.º 1
0
        void rptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var albumInfo = new AlbumInfo(e.Item.DataItem);

                var ltlItemIndex       = e.Item.FindControl("ltlItemIndex") as Literal;
                var ltlTitle           = e.Item.FindControl("ltlTitle") as Literal;
                var ltlKeywords        = e.Item.FindControl("ltlKeywords") as Literal;
                var ltlPVCount         = e.Item.FindControl("ltlPVCount") as Literal;
                var ltlIsEnabled       = e.Item.FindControl("ltlIsEnabled") as Literal;
                var ltlAlbumContentUrl = e.Item.FindControl("ltlAlbumContentUrl") as Literal;
                var ltlPreviewUrl      = e.Item.FindControl("ltlPreviewUrl") as Literal;
                var ltlEditUrl         = e.Item.FindControl("ltlEditUrl") as Literal;

                ltlItemIndex.Text = (e.Item.ItemIndex + 1).ToString();
                ltlTitle.Text     = albumInfo.Title;
                ltlKeywords.Text  = DataProviderWX.KeywordDAO.GetKeywords(albumInfo.KeywordID);
                ltlPVCount.Text   = albumInfo.PVCount.ToString();

                ltlIsEnabled.Text = StringUtils.GetTrueOrFalseImageHtml(!albumInfo.IsDisabled);

                var urlAlbumContent = PageAlbumContent.GetRedirectUrl(PublishmentSystemId, albumInfo.ID);

                ltlAlbumContentUrl.Text = $@"<a href=""{urlAlbumContent}"">微相册</a>";

                var urlPreview = AlbumManager.GetAlbumUrl(PublishmentSystemInfo, albumInfo, string.Empty);
                //urlPreview = BackgroundPreview.GetRedirectUrlToMobile(urlPreview);
                ltlPreviewUrl.Text = $@"<a href=""{urlPreview}"" target=""_blank"">预览</a>";

                var urlEdit = PageAlbumAdd.GetRedirectUrl(PublishmentSystemId, albumInfo.ID);
                ltlEditUrl.Text = $@"<a href=""{urlEdit}"">编辑</a>";
            }
        }
Ejemplo n.º 2
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                var isConflict       = false;
                var conflictKeywords = string.Empty;
                if (!string.IsNullOrEmpty(TbKeywords.Text))
                {
                    if (_albumId > 0)
                    {
                        var albumInfo = DataProviderWx.AlbumDao.GetAlbumInfo(_albumId);
                        isConflict = KeywordManager.IsKeywordUpdateConflict(PublishmentSystemId, albumInfo.KeywordId, PageUtils.FilterXss(TbKeywords.Text), out conflictKeywords);
                    }
                    else
                    {
                        isConflict = KeywordManager.IsKeywordInsertConflict(PublishmentSystemId, PageUtils.FilterXss(TbKeywords.Text), out conflictKeywords);
                    }
                }

                if (isConflict)
                {
                    FailMessage($"触发关键词“{conflictKeywords}”已存在,请设置其他关键词");
                }
                else
                {
                    var albumInfo = new AlbumInfo();
                    if (_albumId > 0)
                    {
                        albumInfo = DataProviderWx.AlbumDao.GetAlbumInfo(_albumId);
                    }
                    albumInfo.PublishmentSystemId = PublishmentSystemId;

                    albumInfo.KeywordId  = DataProviderWx.KeywordDao.GetKeywordId(PublishmentSystemId, _albumId > 0, TbKeywords.Text, EKeywordType.Album, albumInfo.KeywordId);
                    albumInfo.IsDisabled = !CbIsEnabled.Checked;

                    albumInfo.Title    = PageUtils.FilterXss(TbTitle.Text);
                    albumInfo.ImageUrl = ImageUrl.Value;;
                    albumInfo.Summary  = TbSummary.Text;

                    try
                    {
                        if (_albumId > 0)
                        {
                            DataProviderWx.AlbumDao.Update(albumInfo);

                            Body.AddSiteLog(PublishmentSystemId, "修改微相册", $"微相册:{TbTitle.Text}");
                            SuccessMessage("修改微相册成功!");
                        }
                        else
                        {
                            _albumId = DataProviderWx.AlbumDao.Insert(albumInfo);

                            Body.AddSiteLog(PublishmentSystemId, "添加微相册", $"微相册:{TbTitle.Text}");
                            SuccessMessage("添加微相册成功!");
                        }

                        var redirectUrl = PageAlbumContent.GetRedirectUrl(PublishmentSystemId, _albumId);
                        AddWaitAndRedirectScript(redirectUrl);
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "微相册设置失败!");
                    }
                }
            }
        }