Esempio n. 1
0
        public int Insert(KeywordResourceInfo resourceInfo)
        {
            var resourceID = 0;

            var sqlString = "INSERT INTO wx_KeywordResource (PublishmentSystemID, KeywordID, Title, ImageUrl, Summary, ResourceType, IsShowCoverPic, Content, NavigationUrl, ChannelID, ContentID, Taxis) VALUES (@PublishmentSystemID, @KeywordID, @Title, @ImageUrl, @Summary, @ResourceType, @IsShowCoverPic, @Content, @NavigationUrl, @ChannelID, @ContentID, @Taxis)";

            var taxis = GetMaxTaxis(resourceInfo.KeywordID) + 1;
            var parms = new IDataParameter[]
            {
                GetParameter(PARM_PUBLISHMENT_SYSTEM_ID, EDataType.Integer, resourceInfo.PublishmentSystemID),
                GetParameter(PARM_KEYWORD_ID, EDataType.Integer, resourceInfo.KeywordID),
                GetParameter(PARM_TITLE, EDataType.NVarChar, 255, resourceInfo.Title),
                GetParameter(PARM_IMAGE_URL, EDataType.VarChar, 200, resourceInfo.ImageUrl),
                GetParameter(PARM_SUMMARY, EDataType.NVarChar, 255, resourceInfo.Summary),
                GetParameter(PARM_RESOURCE_TYPE, EDataType.VarChar, 50, EResourceTypeUtils.GetValue(resourceInfo.ResourceType)),
                GetParameter(PARM_IS_SHOW_COVER_PIC, EDataType.VarChar, 18, resourceInfo.IsShowCoverPic.ToString()),
                GetParameter(PARM_CONTENT, EDataType.NText, resourceInfo.Content),
                GetParameter(PARM_NAVIGATION_URL, EDataType.VarChar, 200, resourceInfo.NavigationUrl),
                GetParameter(PARM_CHANNEL_ID, EDataType.Integer, resourceInfo.ChannelID),
                GetParameter(PARM_CONTENT_ID, EDataType.Integer, resourceInfo.ContentID),
                GetParameter(PARM_TAXIS, EDataType.Integer, taxis)
            };

            using (var conn = GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        ExecuteNonQuery(trans, sqlString, parms);
                        resourceID = BaiRongDataProvider.DatabaseDao.GetSequence(trans, "wx_KeywordResource");
                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }

            return(resourceID);
        }
Esempio n. 2
0
        public int Insert(KeywordResourceInfo resourceInfo)
        {
            var resourceId = 0;

            var sqlString = "INSERT INTO wx_KeywordResource (PublishmentSystemID, KeywordID, Title, ImageUrl, Summary, ResourceType, IsShowCoverPic, Content, NavigationUrl, ChannelID, ContentID, Taxis) VALUES (@PublishmentSystemID, @KeywordID, @Title, @ImageUrl, @Summary, @ResourceType, @IsShowCoverPic, @Content, @NavigationUrl, @ChannelID, @ContentID, @Taxis)";

            var taxis = GetMaxTaxis(resourceInfo.KeywordId) + 1;
            var parms = new IDataParameter[]
            {
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, resourceInfo.PublishmentSystemId),
                GetParameter(ParmKeywordId, EDataType.Integer, resourceInfo.KeywordId),
                GetParameter(ParmTitle, EDataType.NVarChar, 255, resourceInfo.Title),
                GetParameter(ParmImageUrl, EDataType.VarChar, 200, resourceInfo.ImageUrl),
                GetParameter(ParmSummary, EDataType.NVarChar, 255, resourceInfo.Summary),
                GetParameter(ParmResourceType, EDataType.VarChar, 50, EResourceTypeUtils.GetValue(resourceInfo.ResourceType)),
                GetParameter(ParmIsShowCoverPic, EDataType.VarChar, 18, resourceInfo.IsShowCoverPic.ToString()),
                GetParameter(ParmContent, EDataType.NText, resourceInfo.Content),
                GetParameter(ParmNavigationUrl, EDataType.VarChar, 200, resourceInfo.NavigationUrl),
                GetParameter(ParmChannelId, EDataType.Integer, resourceInfo.ChannelId),
                GetParameter(ParmContentId, EDataType.Integer, resourceInfo.ContentId),
                GetParameter(ParmTaxis, EDataType.Integer, taxis)
            };

            using (var conn = GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        resourceId = ExecuteNonQueryAndReturnId(trans, sqlString, parms);
                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }

            return(resourceId);
        }
Esempio n. 3
0
        private string GetNavHtml(EResourceType resourceType)
        {
            var nav = string.Empty;

            var list = new List <EResourceType>();

            list.Add(EResourceType.Site);
            list.Add(EResourceType.Content);
            list.Add(EResourceType.Url);

            foreach (var rType in list)
            {
                nav +=
                    $@"<li class=""{(rType == resourceType ? "active" : string.Empty)}""><a href=""javascript:;"" class=""{EResourceTypeUtils
                        .GetValue(rType)}"" resourceType=""{EResourceTypeUtils.GetValue(rType)}"">显示{EResourceTypeUtils
                        .GetText(rType)}</a></li>";
            }

            return(nav);
        }
Esempio n. 4
0
        public void Update(KeywordResourceInfo resourceInfo)
        {
            var parms = new IDataParameter[]
            {
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, resourceInfo.PublishmentSystemId),
                GetParameter(ParmKeywordId, EDataType.Integer, resourceInfo.KeywordId),
                GetParameter(ParmTitle, EDataType.NVarChar, 255, resourceInfo.Title),
                GetParameter(ParmImageUrl, EDataType.VarChar, 200, resourceInfo.ImageUrl),
                GetParameter(ParmSummary, EDataType.NVarChar, 255, resourceInfo.Summary),
                GetParameter(ParmResourceType, EDataType.VarChar, 50, EResourceTypeUtils.GetValue(resourceInfo.ResourceType)),
                GetParameter(ParmIsShowCoverPic, EDataType.VarChar, 18, resourceInfo.IsShowCoverPic.ToString()),
                GetParameter(ParmContent, EDataType.NText, resourceInfo.Content),
                GetParameter(ParmNavigationUrl, EDataType.VarChar, 200, resourceInfo.NavigationUrl),
                GetParameter(ParmChannelId, EDataType.Integer, resourceInfo.ChannelId),
                GetParameter(ParmContentId, EDataType.Integer, resourceInfo.ContentId),
                GetParameter(ParmTaxis, EDataType.Integer, resourceInfo.Taxis),
                GetParameter(ParmResourceId, EDataType.Integer, resourceInfo.ResourceId)
            };

            ExecuteNonQuery(SqlUpdate, parms);
        }
Esempio n. 5
0
        public void Update(KeywordResourceInfo resourceInfo)
        {
            var parms = new IDataParameter[]
            {
                GetParameter(PARM_PUBLISHMENT_SYSTEM_ID, EDataType.Integer, resourceInfo.PublishmentSystemID),
                GetParameter(PARM_KEYWORD_ID, EDataType.Integer, resourceInfo.KeywordID),
                GetParameter(PARM_TITLE, EDataType.NVarChar, 255, resourceInfo.Title),
                GetParameter(PARM_IMAGE_URL, EDataType.VarChar, 200, resourceInfo.ImageUrl),
                GetParameter(PARM_SUMMARY, EDataType.NVarChar, 255, resourceInfo.Summary),
                GetParameter(PARM_RESOURCE_TYPE, EDataType.VarChar, 50, EResourceTypeUtils.GetValue(resourceInfo.ResourceType)),
                GetParameter(PARM_IS_SHOW_COVER_PIC, EDataType.VarChar, 18, resourceInfo.IsShowCoverPic.ToString()),
                GetParameter(PARM_CONTENT, EDataType.NText, resourceInfo.Content),
                GetParameter(PARM_NAVIGATION_URL, EDataType.VarChar, 200, resourceInfo.NavigationUrl),
                GetParameter(PARM_CHANNEL_ID, EDataType.Integer, resourceInfo.ChannelID),
                GetParameter(PARM_CONTENT_ID, EDataType.Integer, resourceInfo.ContentID),
                GetParameter(PARM_TAXIS, EDataType.Integer, resourceInfo.Taxis),
                GetParameter(PARM_RESOURCE_ID, EDataType.Integer, resourceInfo.ResourceID)
            };

            ExecuteNonQuery(SQL_UPDATE, parms);
        }
Esempio n. 6
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID");

            keywordID  = TranslateUtils.ToInt(GetQueryString("keywordID"));
            resourceID = TranslateUtils.ToInt(GetQueryString("resourceID"));
            floor      = TranslateUtils.ToInt(GetQueryString("floor"));
            isSingle   = TranslateUtils.ToBool(GetQueryString("isSingle"));

            if (!IsPostBack)
            {
                ltlPreview.Text = @"
<p class=""js_cover upload_preview"" style=""display:none"">
    <input type=""hidden"" id=""imageUrl"" name=""imageUrl"" value="""" />
    <img src="""" width=""64"">
    <a class=""js_removeCover"" href=""javascript:;"" onclick=""deleteImageUrl();return false;"">删除</a>
</p>";
                ltlNav.Text     = GetNavHtml(EResourceType.Site);

                ltlSite.Text = @"
<div id=""titles"" class=""well well-small"" style=""display:none""></div>
<input id=""channelID"" name=""channelID"" type=""hidden"" value="""" />
<input id=""contentID"" name=""contentID"" type=""hidden"" value="""" />";

                if (resourceID > 0)
                {
                    var resourceInfo = DataProviderWX.KeywordResourceDAO.GetResourceInfo(resourceID);

                    if (resourceInfo.ResourceType == EResourceType.Site)
                    {
                        var siteHtml = MPUtils.GetSitePreivewHtml(PublishmentSystemInfo, resourceInfo.ChannelID, resourceInfo.ContentID);
                        if (!string.IsNullOrEmpty(siteHtml))
                        {
                            ltlSite.Text = $@"
<div id=""titles"" class=""well well-small"">{siteHtml}</div>
<input id=""channelID"" name=""channelID"" type=""hidden"" value=""{resourceInfo.ChannelID}"" />
<input id=""contentID"" name=""contentID"" type=""hidden"" value=""{resourceInfo.ContentID}"" />";
                        }
                    }

                    tbTitle.Text = resourceInfo.Title;
                    tbTaxis.Text = resourceInfo.Taxis.ToString();
                    if (!string.IsNullOrEmpty(resourceInfo.ImageUrl))
                    {
                        ltlPreview.Text = $@"
<p class=""js_cover upload_preview"">
    <input type=""hidden"" id=""imageUrl"" name=""imageUrl"" value=""{resourceInfo.ImageUrl}"" />
    <img src=""{PageUtility.ParseNavigationUrl(PublishmentSystemInfo, resourceInfo.ImageUrl)}"" width=""64"">
    <a class=""js_removeCover"" href=""javascript:;"" onclick=""deleteImageUrl();return false;"">删除</a>
</p>";
                    }
                    tbSummary.Text = resourceInfo.Summary;
                    if (resourceInfo.IsShowCoverPic == false)
                    {
                        ltlScript.Text += "<script>$('.js_show_cover_pic').click();</script>";
                    }
                    breContent.Text      = resourceInfo.Content;
                    tbNavigationUrl.Text = resourceInfo.NavigationUrl;

                    ltlScript.Text +=
                        $@"<script>$('.nav a.{EResourceTypeUtils.GetValue(resourceInfo.ResourceType)}').click();</script>";
                }

                btnContentSelect.Attributes.Add("onclick", "parent." + Modal.ContentSelect.GetOpenWindowString(PublishmentSystemID, false, "contentSelect"));
                btnChannelSelect.Attributes.Add("onclick", "parent." + CMS.BackgroundPages.Modal.ChannelSelect.GetOpenWindowString(PublishmentSystemID));

                var top = 0;
                if (floor > 1)
                {
                    top = 67 + (floor - 1) * 103;
                }
                ltlArrow.Text =
                    $@"<i class=""arrow arrow_out"" style=""margin-top: {top}px;""></i><i class=""arrow arrow_in"" style=""margin-top: {top}px;""></i>";
            }
        }
Esempio n. 7
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);

                            StringUtility.AddLog(PublishmentSystemID, "修改关键词图文回复");
                            SuccessMessage("关键词图文回复修改成功!");
                        }
                        else
                        {
                            resourceID = DataProviderWX.KeywordResourceDAO.Insert(resourceInfo);

                            StringUtility.AddLog(PublishmentSystemID, "新增关键词图文回复");
                            SuccessMessage("关键词图文回复新增成功!");
                        }

                        FileUtilityWX.CreateWeiXinContent(PublishmentSystemInfo, keywordID, resourceID);

                        var redirectUrl = BackgroundKeywordNewsAdd.GetRedirectUrl(PublishmentSystemID, keywordID, resourceID, isSingle);
                        ltlScript.Text +=
                            $@"<script>setTimeout(""parent.redirect('{redirectUrl}')"", 1500);</script>";
                    }
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "关键词图文回复配置失败!");
                }
            }
        }