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

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

            if (loginstate == LoginState.NotLogin)
            {
                SetInfo("尚未登录, 不能创建荐购书目记录。<a href='login.aspx?redirect=newrecommend.aspx'>登录</a>");
            }
            if (loginstate == LoginState.Public)
            {
                SetInfo("访客身份, 不能创建荐购书目记录。<a href='login.aspx?redirect=newrecommend.aspx'>登录</a>");
            }

            PlaceHolder edit_holder = (PlaceHolder)this.FindControl("edit_holder");

            if (loginstate == LoginState.Public || loginstate == LoginState.NotLogin)
            {
                edit_holder.Visible = false;
                base.Render(output);
                return;
            }
            else
            {
                edit_holder.Visible = true;
            }
#if NO
            OpacApplication app         = (OpacApplication)this.Page.Application["app"];
            SessionInfo     sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            if (sessioninfo.Account != null)
            {
                TextBox edit_creator = (TextBox)this.FindControl("edit_creator");
                edit_creator.Text = sessioninfo.Account.UserID;
            }
#endif

            base.Render(output);
        }
コード例 #2
0
        protected override void Render(HtmlTextWriter output)
        {
            int    nRet     = 0;
            string strError = "";

            // return:
            //      -1  出错
            //      0   成功
            //      1   尚未登录
            nRet = this.LoadReaderXml(out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }

            if (nRet == 1)
            {
                sessioninfo.LoginCallStack.Push(this.Page.Request.RawUrl);
                this.Page.Response.Redirect("login.aspx", true);
                return;
            }

            LiteralControl text       = null;
            string         strBarcode = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                               "barcode");

            // 显示名
            string strDisplayName = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                           "displayName");
            TextBox edit = (TextBox)this.FindControl("displayName");

            edit.Text = strDisplayName;

#if NO
            OpacApplication app = (OpacApplication)this.Page.Application["app"];

            if (string.IsNullOrEmpty(strBarcode) == false)
            {
                // 读者证号二维码
                string strCode = "";
                // 获得读者证号二维码字符串
                nRet = app.GetPatronTempId(
                    strBarcode,
                    out strCode,
                    out strError);
                if (nRet == -1)
                {
                    strCode = strError;
                }
                text      = (LiteralControl)this.FindControl("qrcode");
                text.Text = strCode;
            }
#endif
            text = (LiteralControl)this.FindControl("qrcode");
            if (text != null)
            {
                text.Text = "<img src='./getphoto.aspx?action=pqri&barcode=" + HttpUtility.UrlEncode(strBarcode) + "' alt='QRCode image'></img>";
            }

            // 姓名
            string strName = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                    "name");
            text      = (LiteralControl)this.FindControl("name");
            text.Text = strName;

            // 性别
            string strGender = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                      "gender");
            text      = (LiteralControl)this.FindControl("gender");
            text.Text = strGender;

            // 出生日期
            string strDateOfBirth = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                           "dateOfBirth");
            if (string.IsNullOrEmpty(strDateOfBirth) == true)
            {
                strDateOfBirth = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                        "birthday");
            }

            strDateOfBirth = DateTimeUtil.LocalDate(strDateOfBirth);
            text           = (LiteralControl)this.FindControl("dateOfBirth");
            text.Text      = strDateOfBirth;

            // 证号 2008/11/11
            string strCardNumber = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                          "cardNumber");
            if (String.IsNullOrEmpty(strCardNumber) == true)
            {
                PlaceHolder holder = (PlaceHolder)this.FindControl("cardNumber_holder");
                holder.Visible = false;
            }
            else
            {
                text      = (LiteralControl)this.FindControl("cardNumber");
                text.Text = strCardNumber;
            }

            // 身份证号
            string strIdCardNumber = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                            "idCardNumber");
            text      = (LiteralControl)this.FindControl("idCardNumber");
            text.Text = strIdCardNumber;

            // 单位
            string strDepartment = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                          "department");
            text      = (LiteralControl)this.FindControl("department");
            text.Text = strDepartment;

            // 职务
            string strPost = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                    "post");
            text      = (LiteralControl)this.FindControl("post");
            text.Text = strPost;

            // 地址
            string strAddress = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                       "address");
            text      = (LiteralControl)this.FindControl("address");
            text.Text = strAddress;

            // 电话
            string strTel = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                   "tel");
            text      = (LiteralControl)this.FindControl("tel");
            text.Text = strTel;

            // email
            string strEmail = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                     "email");
            text      = (LiteralControl)this.FindControl("email");
            text.Text = strEmail;

            // 证条码号

            text      = (LiteralControl)this.FindControl("barcode");
            text.Text = strBarcode;

            // 读者类型
            string strReaderType = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                          "readerType");
            text      = (LiteralControl)this.FindControl("readerType");
            text.Text = strReaderType;

            // 证状态
            string strState = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                     "state");
            text      = (LiteralControl)this.FindControl("state");
            text.Text = strState;

            // 发证日期
            string strCreateDate = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                          "createDate");
            strCreateDate = DateTimeUtil.LocalDate(strCreateDate);
            text          = (LiteralControl)this.FindControl("createDate");
            text.Text     = strCreateDate;

            // 证失效期
            string strExpireDate = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                          "expireDate");
            strExpireDate = DateTimeUtil.LocalDate(strExpireDate);
            text          = (LiteralControl)this.FindControl("expireDate");
            text.Text     = strExpireDate;

            // 租金 2008/11/11
            string  strHireExpireDate = "";
            string  strHirePeriod     = "";
            XmlNode nodeHire          = ReaderDom.DocumentElement.SelectSingleNode("hire");
            if (nodeHire != null)
            {
                strHireExpireDate = DomUtil.GetAttr(nodeHire, "expireDate");
                strHirePeriod     = DomUtil.GetAttr(nodeHire, "period");

                strHireExpireDate = DateTimeUtil.LocalDate(strHireExpireDate);
                strHirePeriod     = app.GetDisplayTimePeriodStringEx(strHirePeriod);


                text      = (LiteralControl)this.FindControl("hire");
                text.Text = this.GetString("周期")
                            + ": " + strHirePeriod + "; "
                            + this.GetString("失效期")
                            + ": " + strHireExpireDate;
            }
            else
            {
                PlaceHolder holder = (PlaceHolder)this.FindControl("hire_holder");
                holder.Visible = false;
            }

            // 押金 2008/11/11
            string strForegift = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                        "foregift");
            if (String.IsNullOrEmpty(strForegift) == false)
            {
                text      = (LiteralControl)this.FindControl("foregift");
                text.Text = strForegift;
            }
            else
            {
                PlaceHolder holder = (PlaceHolder)this.FindControl("foregift_holder");
                holder.Visible = false;
            }

            Image photo = (Image)this.FindControl("photo");
            photo.ImageUrl = "./getphoto.aspx?barcode=" + strBarcode;

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

            Button      submit_button       = (Button)this.FindControl("submit");
            PlaceHolder upload_photo_holder = (PlaceHolder)this.FindControl("upload_photo_holder");


            if (loginstate == LoginState.Reader &&
                sessioninfo.ReaderInfo.Barcode == strBarcode)
            {
                submit_button.Visible       = true;
                upload_photo_holder.Visible = true;
            }
            else
            {
                submit_button.Visible       = false;
                upload_photo_holder.Visible = false;
            }

            base.Render(output);
            return;

ERROR1:
            this.SetDebugInfo("errorinfo", strError);
        }
コード例 #3
0
        string GetStyleDirName()
        {
            string strError = "";

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

            if (app == null)
            {
                strError = "app == null";
                goto ERROR1;
            }

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

            if (sessioninfo == null)
            {
                strError = "sessioninfo == null";
                goto ERROR1;
            }

            string strLibraryCodeList = ""; // 当前用户管辖的馆代码列表

#if NO
            if (sessioninfo.Channel != null)
            {
                strLibraryCodeList = sessioninfo.Channel.LibraryCodeList;
            }
#endif
            strLibraryCodeList = sessioninfo.LibraryCodeList;

            // 面板上选择的馆代码
            string strSelectedLibraryCode = (string)this.Page.Session["librarycode"];

            string strLibraryStyleDir = ""; // 分馆的风格目录

            if (string.IsNullOrEmpty(strSelectedLibraryCode) == false)
            {
                XmlNode nodeLibrary = app.WebUiDom.DocumentElement.SelectSingleNode("libraries/library[@code='" + strSelectedLibraryCode + "']");
                if (nodeLibrary != null)
                {
                    strLibraryStyleDir = DomUtil.GetAttr(nodeLibrary, "style");
                    if (string.IsNullOrEmpty(strLibraryStyleDir) == true)
                    {
                        strLibraryStyleDir = DomUtil.GetAttr(nodeLibrary, "code");
                    }
                }
            }

            // 2007/7/11
            LoginState loginstate = GlobalUtil.GetLoginState(this.Page);

            XmlNode nodeUserType = null;
            if (loginstate == LoginState.NotLogin)
            {
                nodeUserType = app.WebUiDom.DocumentElement.SelectSingleNode(
                    "titleBarControl/userType[@type='notlogin']");
            }
            else if (loginstate == LoginState.Public)
            {
                nodeUserType = app.WebUiDom.DocumentElement.SelectSingleNode(
                    "titleBarControl/userType[@type='public']");
            }
            else if (loginstate == LoginState.Librarian)
            {
                nodeUserType = app.WebUiDom.DocumentElement.SelectSingleNode(
                    "titleBarControl/userType[@type='librarian']");
            }

            if (nodeUserType != null)
            {
                string strStyleDirName = DomUtil.GetAttr(nodeUserType, "style");
                return(MakeDir(strLibraryStyleDir, strStyleDirName));

#if NO
                if (String.IsNullOrEmpty(strStyleDirName) == true)
                {
                    return("0"); // 缺省值
                }
                return(strStyleDirName);
#endif
            }


            XmlDocument readerdom = null;
            // 获得当前session中已经登录的读者记录DOM
            // return:
            //      -2  当前登录的用户不是reader类型
            //      -1  出错
            //      0   尚未登录
            //      1   成功
            int nRet = sessioninfo.GetLoginReaderDom(
                out readerdom,
                out strError);
            if (nRet == -1 || nRet == -2)
            {
                goto ERROR1;
            }

            if (nRet == 0)
            {
                goto ERROR1;
            }

            // return PreferenceControl.GetReaderSelectedStyleDir(readerdom);
            return(MakeDir(strLibraryStyleDir, PreferenceControl.GetReaderSelectedStyleDir(readerdom)));

ERROR1:
            return("0");
        }
コード例 #4
0
        protected override void Render(HtmlTextWriter writer)
        {
            string strError = "";
            int    nRet     = 0;

            LiteralControl table = (LiteralControl)this.FindControl("table");

#if NO
            DropDownList list = (DropDownList)this.FindControl("librarycode");
#endif

            if (String.IsNullOrEmpty(this.Xml) == true)
            {
                /*
                 * strError = "<span class='comment'>"
                 + this.GetString("尚未指定日期参数")  // "(尚未指定日期参数)"
                 + "</span>";
                 + goto ERROR1;
                 * */
                strError = this.DateRange + " " + this.GetString("没有统计信息");
                goto ERROR1;
            }

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

            string strTemplateFilename = app.CfgDir + "\\statis_template.xml";
#if NO
            string strLibraryCode = list.Text;
            if (strLibraryCode == "<所有分馆>")
            {
                strLibraryCode = "";
            }
#endif
            string strLibraryCode = (string)this.Page.Session["librarycode"];

            List <string> codes = app.GetAllLibraryCodes();
            bool          bExistsTemplateFile = false;
            if (File.Exists(strTemplateFilename) == true)
            {
                bExistsTemplateFile = true;

                string     strTargetXml = "";
                LoginState loginstate   = GlobalUtil.GetLoginState(this.Page);

                // 利用模板文件过滤统计事项,并将事项按照模板顺序排序
                nRet = StatisViewControl.FilterXmlFile(
                    strLibraryCode,
                    loginstate.ToString().ToLower(), // notlogin public reader librarian
                    this.Xml,
                    strTemplateFilename,
                    false,
                    out strTargetXml,
                    // out exist_codes,
                    out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }

                this.Xml = strTargetXml;
            }

            string strDate = "";
            strDate = this.DateRange;

            try
            {
                dom = new XmlDocument();
                dom.LoadXml(this.Xml);
            }
            catch (Exception ex)
            {
                strError = "XML字符串装入DOM时出错:" + ex.Message;
                goto ERROR1;
            }

#if NO
            // 如果没有过滤,则需要在这里获得馆代码
            if (File.Exists(strTemplateFilename) == false)
            {
                XmlNodeList nodes = dom.DocumentElement.SelectNodes("library");
                foreach (XmlNode node in nodes)
                {
                    string strCode = DomUtil.GetAttr(node, "code");
                    exist_codes.Add(strCode);
                }
            }
#endif
            // 如果没有过滤,则需要在这里把特定馆代码的片段提升到根下
            if (bExistsTemplateFile == false &&
                string.IsNullOrEmpty(strLibraryCode) == false)
            {
                XmlNode node = dom.DocumentElement.SelectSingleNode("library[@code='" + strLibraryCode + "']");
                if (node != null)
                {
                    dom.DocumentElement.InnerXml = node.InnerXml;
                }
                else
                {
                    dom.DocumentElement.InnerXml = "";
                }
            }

            StringBuilder text = new StringBuilder(4096);

            text.Append("<div class='statisframe'><table class='statis' >");// border='1'

            string strLibraryCodeText = "";
            if (String.IsNullOrEmpty(strLibraryCode) == true)
            {
                if (codes.Count == 0)
                {
                    strLibraryCodeText = "";
                }
                else
                {
                    strLibraryCodeText = this.GetString("全部分馆") + " ";
                }
            }
            else
            {
                strLibraryCodeText = strLibraryCode + " ";
            }
            List <string> column_titles = new List <string>();

            DateTime start_date = DateTimeUtil.Long8ToDateTime(this.RangeStatisInfo.StartDate);
            DateTime end_date   = DateTimeUtil.Long8ToDateTime(this.RangeStatisInfo.EndDate);
            DateTime now        = DateTime.Now;
            if (this.IsRange == true)
            {
                DateTime current_date = start_date;
                while (current_date <= end_date &&
                       current_date <= now)
                {
                    column_titles.Add(GetDateString(current_date, current_date == start_date));
                    current_date = current_date.AddDays(1);
                }
            }


            string strColspan = "";
            strColspan = " colspan='" + (column_titles.Count + 2).ToString() + "' ";

            // 标题行
            text.Append("<tr class='tabletitle'><td " + strColspan + ">" + strLibraryCodeText + strDate + " "
                        + this.GetString("实时统计信息")
                        + "</td></tr>");

            // 注释行
            if (this.RangeStatisInfo != null)
            {
                string strComment = GetCommentString(this.RangeStatisInfo);
                text.Append("<tr class='comment'><td " + strColspan + ">" + strComment + "</td></tr>");
            }

            // 栏目标题行
            string strColumnLine = "";
            if (this.IsRange == true)
            {
                StringBuilder line = new StringBuilder(4096);
                foreach (string s in column_titles)
                {
                    line.Append("<td class='day'>" + s + "</td>");
                }
                strColumnLine = "<tr class='column'><td class='rowtitle'>统计指标</td><td class='rowtitle'>合计</td>"
                                + line.ToString()
                                + "</tr>";
            }
            else
            {
                strColumnLine = "<tr class='column'><td class='rowtitle'>统计指标</td><td class='rowtitle'>合计</td>"
                                + "</tr>";
            }
            text.Append(strColumnLine);

            XmlNodeList categorys = this.dom.DocumentElement.SelectNodes("category");
            for (int i = 0; i < categorys.Count; i++)
            {
                XmlNode category = categorys[i];

                string strCategory = DomUtil.GetAttr(category, "name");

                // 2009/7/31
                string strCategoryCaption = this.GetStringEx(strCategory);
                if (String.IsNullOrEmpty(strCategoryCaption) == true)
                {
                    strCategoryCaption = strCategory;
                }

                text.Append("<tr class='category'><td " + strColspan + ">");
                text.Append(strCategoryCaption);
                text.Append("</td></tr>");

                XmlNodeList items = category.SelectNodes("item");

                for (int j = 0; j < items.Count; j++)
                {
                    XmlNode item = items[j];

                    string strItemName  = DomUtil.GetAttr(item, "name");
                    string strItemValue = DomUtil.GetAttr(item, "value");

                    // 2009/7/31
                    string strItemNameCaption = this.GetStringEx(strItemName);
                    if (String.IsNullOrEmpty(strItemNameCaption) == true)
                    {
                        strItemNameCaption = strItemName;
                    }

                    if (this.IsRange == false)
                    {
                        text.Append("<tr class='content'><td class='name'>");
                        text.Append(strItemNameCaption);
                        text.Append("</td><td class='value'>");
                        text.Append(strItemValue);
                        text.Append("</td></tr>");
                    }
                    else
                    {
                        string[] values = strItemValue.Split(new char[] { ',' });
                        text.Append("<tr class='content'><td class='name'>");
                        text.Append(strItemNameCaption);
                        text.Append("</td>");

                        int      k            = 0;
                        DateTime current_date = start_date;
                        foreach (string v in values)
                        {
                            if (current_date <= end_date &&
                                current_date <= now)
                            {
                            }
                            else
                            {
                                break;  // 比今天还要靠后的就不显示了
                            }
                            string strClass = "day";
                            if (k == 0)
                            {
                                strClass = "value";
                            }

                            text.Append("<td class='" + strClass + "'>");
                            text.Append(string.IsNullOrEmpty(v) == false ? v : "&nbsp;");
                            text.Append("</td>");

                            if (k != 0) // 第一次出现是合计值, 不是普通日子的值
                            {
                                current_date = current_date.AddDays(1);
                            }

                            k++;
                        }

                        while (current_date <= end_date &&
                               current_date <= now)
                        {
                            text.Append("<td class='day'>&nbsp;</td>");
                            current_date = current_date.AddDays(1);
                        }
                        text.Append("</tr>");
                    }
                }
            }

            if (this.IsRange == true && column_titles.Count > 3)
            {
                // 底部再来一次栏目标题行
                text.Append(strColumnLine);
            }

            text.Append("</table></div>");

            table.Text = text.ToString();
            base.Render(writer);
            return;

ERROR1:
            table.Text = "<span class='comment'>"
                         + HttpUtility.HtmlEncode(strError)
                         + "</span>";
            base.Render(writer);
        }
コード例 #5
0
ファイル: ItemControl.cs プロジェクト: zhangandding/dp2
        // 提前获得记录体,然后可以获得parentid
        public int LoadRecord(string strItemRecPath,
                              out string strParentID,
                              out string strError)
        {
            int nRet = 0;

            strError    = "";
            strParentID = "";

            this.EnsureChildControls();

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

            string strXml = "";
            // LibraryChannel channel = sessioninfo.Channel;
            LibraryChannel channel = sessioninfo.GetChannel(true);

            try
            {
                string strBiblio        = "";
                string strBiblioRecPath = "";

                byte[] timestamp     = null;
                string strOutputPath = "";
                long   lRet          = // sessioninfo.Channel.
                                       channel.GetItemInfo(
                    null,
                    "@path:" + strItemRecPath,
                    "xml", // strResultType
                    out strXml,
                    out strOutputPath,
                    out timestamp,
                    "", // "recpath",  // strBiblioType
                    out strBiblio,
                    out strBiblioRecPath,
                    out strError);
                if (lRet == -1)
                {
                    goto ERROR1;
                }
            }
            finally
            {
                sessioninfo.ReturnChannel(channel);
            }

            XmlDocument itemdom = null;

            nRet = OpacApplication.LoadToDom(strXml,
                                             out itemdom,
                                             out strError);
            if (nRet == -1)
            {
                // text-level: 内部错误
                strError = "装载册记录进入XML DOM时发生错误: " + strError;
                goto ERROR1;
            }

            strParentID = DomUtil.GetElementText(itemdom.DocumentElement,
                                                 "parent");

            // 册条码号
            SetValue(itemdom, "barcode", "itembarcode");

            // 右上角记录路径
            string         strUrl  = "./book.aspx?ItemRecPath=" + HttpUtility.UrlEncode(strItemRecPath) + "#active";
            LiteralControl recpath = (LiteralControl)this.FindControl("recpath");

            recpath.Text = "<div class='recpath'><a href='" + strUrl + "' target='_blank' title='" + this.GetString("记录路径") + "'>" + strItemRecPath + "</a></div>";

            // 状态
            SetValue(itemdom, "state");

            // 馆藏地点
            SetValue(itemdom, "location");

            // 册价格
            SetValue(itemdom, "price");

            // 出版时间
            SetValue(itemdom, "publishTime", "publishtime");

            // 渠道
            SetValue(itemdom, "seller");

            // 经费来源
            SetValue(itemdom, "source");

            // 索取号
            SetValue(itemdom, "accessNo", "callnumber");

            // 卷
            SetValue(itemdom, "volume");

            // 册类型
            SetValue(itemdom, "bookType", "booktype");

            // 登录号
            SetValue(itemdom, "registerNo", "registerno");

            // 注释
            SetValue(itemdom, "comment");

            // 批次号
            SetValue(itemdom, "batchNo", "batchno");

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


            // 借者
            string strBorrower = DomUtil.GetElementText(itemdom.DocumentElement,
                                                        "borrower");

            if (String.IsNullOrEmpty(strBorrower) == false)
            {
                string strBorrowDate = DomUtil.GetElementText(itemdom.DocumentElement,
                                                              "borrowDate");
                strBorrowDate = DateTimeUtil.LocalDate(strBorrowDate);
                string strBorrowPeriod = DomUtil.GetElementText(itemdom.DocumentElement,
                                                                "borrowPeriod");
                strBorrowPeriod = app.GetDisplayTimePeriodStringEx(strBorrowPeriod);

                string strBorrowerText = "";
                if (loginstate == LoginState.Librarian)
                {
                    strBorrowerText = "<a href='./readerinfo.aspx?barcode=" + strBorrower + "' target='_blank'>" + strBorrower + "</a>";
                }
                else if (loginstate == LoginState.Reader && sessioninfo.ReaderInfo.Barcode == strBorrower)
                {
                    strBorrowerText = strBorrower + "(" + this.GetString("我自己") + ")";
                }
                else
                {
                    strBorrowerText = new string('*', strBorrower.Length);
                }

                LiteralControl text = (LiteralControl)this.FindControl("borrower");
                text.Text = this.GetString("借阅者") + ": " + strBorrowerText + "  " + this.GetString("借阅日期") + ":" + strBorrowDate + "  " + this.GetString("借阅期限") + ":" + strBorrowPeriod;
            }

            // 参考ID
            SetValue(itemdom, "refID", "refid");

            this.ItemRecPath = strItemRecPath;
            this.m_bLoaded   = true;
            return(1);

ERROR1:
            return(-1);
        }
コード例 #6
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);
        }