Ejemplo n.º 1
0
    private void DisplayArticleData()
    {
        if (c.qsAct == ConfigFormAction.edit)
        {
            ArticleForBackend article = artPub.GetArticleDataForBackend(c.qsArtId);

            if (article != null)
            {
                hidArticleLevelNo.Text    = article.ArticleLevelNo.ToString();
                txtSortNo.Text            = article.SortNo.ToString();
                txtStartDate.Text         = string.Format("{0:yyyy-MM-dd}", article.StartDate);
                txtEndDate.Text           = string.Format("{0:yyyy-MM-dd}", article.EndDate);
                txtBannerPicFileName.Text = article.BannerPicFileName;

                txtArticleAlias.Text   = article.ArticleAlias;
                btnAliasLink.HRef      = string.Format("{0}/Article.aspx?alias={1}", ConfigurationManager.AppSettings["WebsiteUrl"], txtArticleAlias.Text);
                btnAliasLink.InnerHtml = Server.HtmlEncode(btnAliasLink.HRef);
                AliasLinkArea.Visible  = true;

                rdolLayoutMode.SelectedValue = article.LayoutModeId.ToString();
                rdolShowType.SelectedValue   = article.ShowTypeId.ToString();
                txtLinkUrl.Text = article.LinkUrl;
                string linkTarget = article.LinkTarget;
                chkIsNewWindow.Checked     = (linkTarget == "_blank");
                txtControlName.Text        = article.ControlName;
                txtSubItemControlName.Text = article.SubItemControlName;
                chkIsHideSelf.Checked      = article.IsHideSelf;
                chkIsHideChild.Checked     = article.IsHideChild;
                chkDontDelete.Checked      = article.DontDelete;
                ltrPostAccount.Text        = article.PostAccount;
                ltrPostDate.Text           = string.Format("{0:yyyy-MM-dd HH:mm:ss}", article.PostDate);
                string   mdfAccount = article.MdfAccount;
                DateTime mdfDate    = DateTime.MinValue;

                if (article.MdfDate.HasValue)
                {
                    mdfDate = article.MdfDate.Value;
                }

                chkSubjectAtBannerArea.Checked      = article.SubjectAtBannerArea;
                txtPublishDate.Text                 = string.Format("{0:yyyy-MM-dd}", article.PublishDate);
                chkIsShowInUnitArea.Checked         = article.IsShowInUnitArea;
                chkIsShowInSitemap.Checked          = article.IsShowInSitemap;
                hidSortFieldOfFrontStage.Text       = article.SortFieldOfFrontStage;
                hidIsSortDescOfFrontStage.Text      = article.IsSortDescOfFrontStage.ToString();
                hidIsListAreaShowInFrontStage.Text  = article.IsListAreaShowInFrontStage.ToString();
                hidIsAttAreaShowInFrontStage.Text   = article.IsAttAreaShowInFrontStage.ToString();
                hidIsPicAreaShowInFrontStage.Text   = article.IsPicAreaShowInFrontStage.ToString();
                hidIsVideoAreaShowInFrontStage.Text = article.IsVideoAreaShowInFrontStage.ToString();
                txtSubItemLinkUrl.Text              = article.SubItemLinkUrl;

                //zh-TW
                if (LangManager.IsEnableEditLangZHTW())
                {
                    ArticleMultiLang articleZhTw = artPub.GetArticleMultiLangDataForBackend(c.qsArtId, LangManager.CultureNameZHTW);

                    if (articleZhTw != null)
                    {
                        txtArticleSubjectZhTw.Text  = articleZhTw.ArticleSubject;
                        chkIsShowInLangZhTw.Checked = articleZhTw.IsShowInLang;
                        txtCkeContextZhTw.Text      = articleZhTw.ArticleContext;
                        txtSubtitleZhTw.Text        = articleZhTw.Subtitle;
                        txtPublisherNameZhTw.Text   = articleZhTw.PublisherName;

                        if (articleZhTw.MdfDate.HasValue && articleZhTw.MdfDate.Value > mdfDate)
                        {
                            mdfAccount = articleZhTw.MdfAccount;
                            mdfDate    = articleZhTw.MdfDate.Value;
                        }
                    }
                }

                //en
                if (LangManager.IsEnableEditLangEN())
                {
                    ArticleMultiLang articleEn = artPub.GetArticleMultiLangDataForBackend(c.qsArtId, LangManager.CultureNameEN);

                    if (articleEn != null)
                    {
                        txtArticleSubjectEn.Text  = articleEn.ArticleSubject;
                        chkIsShowInLangEn.Checked = articleEn.IsShowInLang;
                        txtCkeContextEn.Text      = articleEn.ArticleContext;
                        txtSubtitleEn.Text        = articleEn.Subtitle;
                        txtPublisherNameEn.Text   = articleEn.PublisherName;

                        if (articleEn.MdfDate.HasValue && articleEn.MdfDate.Value > mdfDate)
                        {
                            mdfAccount = articleEn.MdfAccount;
                            mdfDate    = articleEn.MdfDate.Value;
                        }
                    }
                }

                if (mdfDate != DateTime.MinValue)
                {
                    ltrMdfAccount.Text = mdfAccount;
                    ltrMdfDate.Text    = string.Format("{0:yyyy-MM-dd HH:mm:ss}", mdfDate);
                }

                btnSave.Visible = true;
            }
        }
        else if (c.qsAct == ConfigFormAction.add)
        {
            // get parent data
            ArticleForBackend parent = artPub.GetArticleDataForBackend(c.qsArtId);

            if (parent != null)
            {
                int parentArticleLevelNo = parent.ArticleLevelNo.Value;
                hidArticleLevelNo.Text = (parentArticleLevelNo + 1).ToString();
                int parentShowTypeId   = parent.ShowTypeId.Value;
                int parentLayoutModeId = parent.LayoutModeId.Value;

                if (parentShowTypeId == 3)
                {
                    // setting Sub-item default URL
                    string parentSubItemLinkUrl = parent.SubItemLinkUrl ?? "";

                    if (!string.IsNullOrEmpty(parentSubItemLinkUrl))
                    {
                        rdolShowType.SelectedValue = parentShowTypeId.ToString();
                        txtLinkUrl.Text            = parentSubItemLinkUrl;
                    }
                }
                else if (parentShowTypeId == 4)
                {
                    // setting Sub-item default control
                    string parentSubItemControlName = parent.SubItemControlName ?? "";

                    if (!string.IsNullOrEmpty(parentSubItemControlName))
                    {
                        rdolShowType.SelectedValue = parentShowTypeId.ToString();
                        txtControlName.Text        = parentSubItemControlName;
                    }
                }

                int newSortNo = artPub.GetArticleMaxSortNo(c.qsArtId) + 10;
                txtSortNo.Text = newSortNo.ToString();
                DateTime startDate = DateTime.Today.AddDays(3);
                DateTime endDate   = startDate.AddYears(10);
                txtStartDate.Text            = string.Format("{0:yyyy-MM-dd}", startDate);
                txtEndDate.Text              = string.Format("{0:yyyy-MM-dd}", endDate);
                StartTodayArea.Visible       = true;
                txtPublisherNameZhTw.Text    = c.seLoginEmpData.EmpName;
                txtPublisherNameEn.Text      = c.seLoginEmpData.EmpName;
                txtPublishDate.Text          = txtStartDate.Text;
                rdolLayoutMode.SelectedValue = parentLayoutModeId.ToString();

                btnSave.Visible = true;
            }
        }

        if (Convert.ToInt32(hidArticleLevelNo.Text) == 1)
        {
            IsShowInUnitArea.Visible    = true;
            IsShowInSitemapArea.Visible = true;
        }
    }
Ejemplo n.º 2
0
        /// <summary>
        /// 取得後台網頁所屬的作業代碼
        /// </summary>
        public int GetOpIdOfPage(Guid articleId)
        {
            if (opIdOfPage < 1)
            {
                bool   gotOpId      = false;
                Guid   curArticleId = articleId;
                Guid   curParentId  = Guid.Empty;
                int    curArticleLevelNo;
                string linkUrl = "";
                bool   isRoot  = false;

                // get article info
                ArticleForBackend article = null;

                using (ArticlePublisherDataAccess artPubDao = new ArticlePublisherDataAccess())
                {
                    article = artPubDao.GetArticleDataForBackend(curArticleId);
                    string dbErrMsg = artPubDao.GetErrMsg();
                }

                if (article != null)
                {
                    if (!article.ParentId.HasValue)
                    {
                        isRoot = true;
                    }
                    else
                    {
                        curParentId = article.ParentId.Value;
                    }

                    curArticleLevelNo = article.ArticleLevelNo.Value;
                }

                if (isRoot)
                {
                    opIdOfPage = base.GetOpIdOfPage();
                    return(opIdOfPage);
                }

                do
                {
                    // get opId by LinkUrl
                    linkUrl = string.Format("Article-Node.aspx?artid={0}", curArticleId);
                    OperationOpInfo opInfo = null;

                    using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
                    {
                        opInfo = empAuthDao.GetOperationOpInfoByLinkUrl(linkUrl);
                        string dbErrMsg = empAuthDao.GetErrMsg();
                    }

                    if (opInfo != null)
                    {
                        opIdOfPage = opInfo.OpId;
                        gotOpId    = true;
                    }
                    else
                    {
                        if (curParentId == Guid.Empty)
                        {
                            // parent is root
                            break;
                        }

                        // get parent info
                        ArticleForBackend parent = null;

                        using (ArticlePublisherDataAccess artPubDao = new ArticlePublisherDataAccess())
                        {
                            parent = artPubDao.GetArticleDataForBackend(curParentId);
                            string dbErrMsg = artPubDao.GetErrMsg();
                        }

                        if (parent == null)
                        {
                            logger.Error(string.Format("can not get article data of {0}", curParentId));
                            break;
                        }

                        // move to parent level
                        curArticleId      = curParentId;
                        curParentId       = parent.ParentId.Value;
                        curArticleLevelNo = parent.ArticleLevelNo.Value;
                    }
                } while (!gotOpId);

                if (!gotOpId)
                {
                    opIdOfPage = base.GetOpIdOfPage();
                }
            }

            return(opIdOfPage);
        }