コード例 #1
0
        protected override void Render(HtmlTextWriter writer)
        {
            int    nRet     = 0;
            string strError = "";

            OpacApplication app         = (OpacApplication)this.Page.Application["app"];
            SessionInfo     sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            bool bManager = false;

            if (String.IsNullOrEmpty(sessioninfo.UserID) == true ||
                StringUtil.IsInList("managecomment", sessioninfo.RightsOrigin) == false)
            {
                bManager = false;
            }
            else
            {
                bManager = true;
            }

            LoginState loginstate = GlobalUtil.GetLoginState(this.Page);

            bool bReader = false;

            if (sessioninfo.ReaderInfo != null &&
                sessioninfo.IsReader == true && loginstate != LoginState.Public)
            {
                bReader = true;
            }

            if (bManager == false)
            {
                Button delete_button = (Button)this.FindControl("delete_button");
                delete_button.Visible = false;

                Button open_modify_state_button = (Button)this.FindControl("open_modify_state_button");
                open_modify_state_button.Visible = false;

                Button selectall_button = (Button)this.FindControl("selectall_button");
                selectall_button.Visible = false;

                Button unselectall_button = (Button)this.FindControl("unselectall_button");
                unselectall_button.Visible = false;
            }

            /*
             * if (sessioninfo.Account == null)
             * {
             *  // 临时的SessionInfo对象
             *  SessionInfo temp_sessioninfo = new SessionInfo(app);
             *
             *  // 模拟一个账户
             *  Account account = new Account();
             *  account.LoginName = "opac_column";
             *  account.Password = "";
             *  account.Rights = "getbibliosummary";
             *
             *  account.Type = "";
             *  account.Barcode = "";
             *  account.Name = "opac_column";
             *  account.UserID = "opac_column";
             *  account.RmsUserName = app.ManagerUserName;
             *  account.RmsPassword = app.ManagerPassword;
             *
             *  temp_sessioninfo.Account = account;
             *  sessioninfo = temp_sessioninfo;
             * }
             * */

            bool    bUseBiblioSummary = false; // 使用书目摘要(否则就是详细书目格式)
            bool    bDitto            = true;  // 书目 同上...
            XmlNode nodeBookReview    = app.WebUiDom.DocumentElement.SelectSingleNode("bookReview");

            if (nodeBookReview != null)
            {
                DomUtil.GetBooleanParam(nodeBookReview,
                                        "ditto",
                                        true,
                                        out bDitto,
                                        out strError);
                DomUtil.GetBooleanParam(nodeBookReview,
                                        "useBiblioSummary",
                                        false,
                                        out bUseBiblioSummary,
                                        out strError);
            }

            int nPageNo = this.StartIndex / this.PageMaxLines;

            SetTitle(String.IsNullOrEmpty(this.Title) == true ? this.GetString("栏目") : this.Title);

            SetResultInfo();

            if (this.CommentColumn == null ||
                this.CommentColumn.Opened == false)
            {
                this.SetDebugInfo("errorinfo", "尚未创建栏目缓存...");
            }

            if (this.CommentColumn != null)
            {
                LibraryChannel channel = sessioninfo.GetChannel(true);
                app.m_lockCommentColumn.AcquireReaderLock(app.m_nCommentColumnLockTimeout);
                try
                {
                    string strPrevBiblioRecPath = "";

                    for (int i = 0; i < this.PageMaxLines; i++)
                    {
                        PlaceHolder line = (PlaceHolder)this.FindControl("line" + Convert.ToString(i));
                        if (line == null)
                        {
                            PlaceHolder insertpoint = (PlaceHolder)this.FindControl("insertpoint");
                            PlaceHolder content     = (PlaceHolder)this.FindControl("content");

                            line = this.NewContentLine(content, i, insertpoint);
                        }

                        LiteralControl no          = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_no");
                        HyperLink      pathcontrol = (HyperLink)this.FindControl("line" + Convert.ToString(i) + "_path");
                        // LiteralControl contentcontrol = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_content");
                        CommentControl commentcontrol = (CommentControl)this.FindControl("line" + Convert.ToString(i) + "_comment");

                        LiteralControl bibliosummarycontrol = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_bibliosummary");
                        HyperLink      bibliorecpathcontrol = (HyperLink)this.FindControl("line" + Convert.ToString(i) + "_bibliorecpath");
                        Button         newreview            = (Button)this.FindControl("line" + Convert.ToString(i) + "_newreview");
                        PlaceHolder    biblioinfo_holder    = (PlaceHolder)this.FindControl("line" + Convert.ToString(i) + "_biblioinfo_holder");
                        BiblioControl  bibliocontrol        = (BiblioControl)this.FindControl("line_" + i.ToString() + "_bibliocontrol");

                        CheckBox checkbox = (CheckBox)this.FindControl("line" + Convert.ToString(i) + "_checkbox");
                        if (bManager == false)
                        {
                            checkbox.Visible = false;
                        }

                        int index = this.StartIndex + i;
                        if (index >= this.CommentColumn.Count)
                        {
                            checkbox.Visible       = false;
                            commentcontrol.Visible = false;
                            bibliocontrol.Visible  = false;
                            continue;
                        }
                        TopArticleItem record = (TopArticleItem)this.CommentColumn[index];

                        // 序号
                        string strNo = "&nbsp;";
                        strNo = Convert.ToString(i + this.StartIndex + 1);

                        no.Text = "<div>" + strNo + "</div>";

                        // 路径
                        string strPath = record.Line.m_strRecPath;

                        // 2012/7/11
                        commentcontrol.RecPath = app.GetLangItemRecPath(
                            "comment",
                            this.Lang,
                            strPath);

                        byte[] timestamp = null;
                        string strXml    = "";
                        // return:
                        //      -1  出错
                        //      0   没有找到
                        //      1   找到
                        nRet = commentcontrol.GetRecord(
                            app,
                            null,   // sessioninfo,
                            channel,
                            strPath,
                            out strXml,
                            out timestamp,
                            out strError);
                        if (nRet == -1)
                        {
                            goto ERROR1;
                        }
                        if (nRet == 0)
                        {
                        }

                        string strBiblioRecPath = "";
                        if (string.IsNullOrEmpty(strXml) == false)
                        {
                            string strParentID = "";
                            nRet = CommentControl.GetParentID(strXml,
                                                              out strParentID,
                                                              out strError);
                            if (nRet == -1)
                            {
                                goto ERROR1;
                            }

                            strBiblioRecPath = CommentControl.GetBiblioRecPath(
                                app,
                                strPath,
                                strParentID);
                        }
                        else
                        {
                            strBiblioRecPath = "";
                        }

                        //
                        if (bManager == true || bReader == true)
                        {
                            string strUrl = "./book.aspx?BiblioRecPath="
                                            + HttpUtility.UrlEncode(strBiblioRecPath)
                                            + "&CommentRecPath="
                                            + HttpUtility.UrlEncode(strPath)
                                            + "#newreview";
                            newreview.OnClientClick = "window.open('" + strUrl + "','_blank'); return cancelClick();";
                            // newreview.ToolTip = this.GetString("创建新的评注, 属于书目记录") + ":" + strBiblioRecPath;
                            // newreview.Attributes.Add("target", "_blank");
                            newreview.Visible = true;
                        }
                        else
                        {
                            newreview.Visible = false;
                        }

                        if (string.IsNullOrEmpty(strBiblioRecPath) == true)
                        {
                            biblioinfo_holder.Controls.Add(new LiteralControl("<div class='ditto'>" + this.GetString("无法定位书目记录") + "</div>"));
                            bibliocontrol.Visible = false;
                        }
                        else if (bDitto == true &&
                                 strBiblioRecPath == strPrevBiblioRecPath)
                        {
                            biblioinfo_holder.Controls.Add(new LiteralControl("<div class='ditto'>" + this.GetString("同上") + "</div>"));
                            bibliocontrol.Visible = false;
                        }
                        else
                        {
                            if (bUseBiblioSummary == true)
                            {
                                // 获得摘要
                                string strBarcode             = "@bibliorecpath:" + strBiblioRecPath;
                                string strSummary             = "";
                                string strOutputBiblioRecPath = "";
                                long   lRet = //sessioninfo.Channel.
                                              channel.GetBiblioSummary(
                                    null,
                                    strBarcode,
                                    null,
                                    null,
                                    out strOutputBiblioRecPath,
                                    out strSummary,
                                    out strError);
                                if (lRet == -1 || lRet == 0)
                                {
                                    strSummary = strError;
                                }

                                bibliosummarycontrol.Text = strSummary;
                                bibliocontrol.Visible     = false;
                            }
                            else
                            {
                                bibliocontrol.RecPath = strBiblioRecPath;
                                bibliocontrol.Visible = true;
                            }
                        }

                        strPrevBiblioRecPath = strBiblioRecPath;
                    }
                }
                finally
                {
                    app.m_lockCommentColumn.ReleaseReaderLock();
                    sessioninfo.ReturnChannel(channel);
                }
            }
            else
            {
                // 显示空行
                for (int i = 0; i < this.PageMaxLines; i++)
                {
                    PlaceHolder line = (PlaceHolder)this.FindControl("line" + Convert.ToString(i));
                    if (line == null)
                    {
                        continue;
                    }

                    CheckBox checkbox = (CheckBox)this.FindControl("line" + Convert.ToString(i) + "_checkbox");
                    checkbox.Visible = false;

                    CommentControl commentcontrol = (CommentControl)this.FindControl("line" + Convert.ToString(i) + "_comment");
                    commentcontrol.Visible = false;

                    BiblioControl bibliocontrol = (BiblioControl)this.FindControl("line_" + i.ToString() + "_bibliocontrol");
                    bibliocontrol.Visible = false;
                }
            }

            this.SetLineClassAndControlActive();
            base.Render(writer);
            return;

ERROR1:
            this.SetDebugInfo("errorinfo", strError);
            base.Render(writer);
        }