コード例 #1
0
ファイル: BorrowInfoControl.cs プロジェクト: zhangandding/dp2
        void RenderBorrow(
            OpacApplication app,
            SessionInfo sessioninfo,
            XmlDocument dom)
        {
            string strReaderType = DomUtil.GetElementText(dom.DocumentElement,
                                                          "readerType");

            // 获得日历
            string strError = "";

            /*
             * Calendar calendar = null;
             * int nRet = app.GetReaderCalendar(strReaderType, out calendar, out strError);
             * if (nRet == -1)
             * {
             *  this.SetDebugInfo("warninginfo", strError);
             *  calendar = null;
             * }
             * */

            // return:
            //      null    xml文件不存在,或者<borrowInfoControl>元素不存在
            string strColumnStyle = GetColumnStyle(app);

            if (strColumnStyle == null)
            {
                strColumnStyle = "";    // 2009/11/23 防止ToLower()抛出异常
            }
            // 借阅的册
            PlaceHolder borrowinfo = (PlaceHolder)this.FindControl("borrowinfo");

            // 清空集合
            this.BorrowBarcodes = new List <string>();

            string strReaderBarcode = DomUtil.GetElementText(dom.DocumentElement,
                                                             "barcode");

            XmlNodeList nodes = dom.DocumentElement.SelectNodes("borrows/borrow");

            this.BorrowLineCount = nodes.Count;
            for (int i = 0; i < nodes.Count; i++)
            {
                PlaceHolder line = (PlaceHolder)borrowinfo.FindControl("borrowinfo_line" + Convert.ToString(i));
                if (line == null)
                {
                    Control insertpos = borrowinfo.FindControl("borrowinfo_insertpos");
                    line = NewBorrowLine(insertpos.Parent, i, insertpos);
                    // this.BorrowLineCount++;
                }
                line.Visible = true;

                LiteralControl left     = (LiteralControl)line.FindControl("borrowinfo_line" + Convert.ToString(i) + "left");
                CheckBox       checkbox = (CheckBox)line.FindControl("borrowinfo_line" + Convert.ToString(i) + "checkbox");
                LiteralControl right    = (LiteralControl)line.FindControl("borrowinfo_line" + Convert.ToString(i) + "right");


                XmlNode node = nodes[i];

                string strBarcode = DomUtil.GetAttr(node, "barcode");

                // 添加到集合
                this.BorrowBarcodes.Add(strBarcode);

                string strNo           = DomUtil.GetAttr(node, "no");
                string strBorrowDate   = DomUtil.GetAttr(node, "borrowDate");
                string strPeriod       = DomUtil.GetAttr(node, "borrowPeriod");
                string strOperator     = DomUtil.GetAttr(node, "operator");
                string strRenewComment = DomUtil.GetAttr(node, "renewComment");

                string strOverDue = "";
                bool   bOverdue   = false; // 是否超期

                DateTime timeReturning = DateTime.MinValue;
                string   strTips       = "";
#if NO
                if (strColumnStyle.ToLower() == "style1")
                {
                    DateTime timeNextWorkingDay;
                    long     lOver         = 0;
                    string   strPeriodUnit = "";

                    // 获得还书日期
                    // return:
                    //      -1  数据格式错误
                    //      0   没有发现超期
                    //      1   发现超期   strError中有提示信息
                    //      2   已经在宽限期内,很容易超期
                    nRet = app.GetReturningTime(
                        calendar,
                        strBorrowDate,
                        strPeriod,
                        out timeReturning,
                        out timeNextWorkingDay,
                        out lOver,
                        out strPeriodUnit,
                        out strError);
                    if (nRet == -1)
                    {
                        strOverDue = strError;
                    }
                    else
                    {
                        strTips = strError;
                        if (nRet == 1)
                        {
                            bOverdue   = true;
                            strOverDue = " ("
                                         + string.Format(this.GetString("已超期s"), // 已超期 {0}
                                                         app.GetDisplayTimePeriodStringEx(lOver.ToString() + " " + strPeriodUnit))
                                         + ")";

                            /*
                             * strOverDue = " (已超期 "
                             + lOver.ToString()
                             + " "
                             + app.GetDisplayTimeUnitLang(strPeriodUnit)
                             + ")";
                             * */
                        }
                    }
                }
                else
                {
                    // string strError = "";
                    // 检查超期情况。
                    // return:
                    //      -1  数据格式错误
                    //      0   没有发现超期
                    //      1   发现超期   strError中有提示信息
                    nRet = app.CheckPeriod(
                        calendar,
                        strBorrowDate,
                        strPeriod,
                        out strError);
                    if (nRet == -1)
                    {
                        strOverDue = strError;
                    }
                    else
                    {
                        if (nRet == 1)
                        {
                            bOverdue = true;
                        }
                        strOverDue = strError;  // 其他无论什么情况都显示出来
                    }
                }
#endif

                string strResult = "";

                string strTrClass = " class='dark' ";

                if ((i % 2) == 1)
                {
                    strTrClass = " class='light' ";
                }

                strResult += "<tr " + strTrClass + " nowrap><td class='barcode' nowrap>";
                // 左
                left.Text = strResult;

                // checkbox
                // checkbox.Text = Convert.ToString(i + 1);

                // 右开始
                strResult = "&nbsp;";

                strResult += "<a href='book.aspx?barcode=" + strBarcode + "&borrower=" + strReaderBarcode + "'>"
                             + strBarcode + "</a></td>";

#if NO
                // 获得摘要
                string strSummary       = "";
                string strBiblioRecPath = "";
                long   lRet             = sessioninfo.Channel.GetBiblioSummary(
                    null,
                    strBarcode,
                    null,
                    null,
                    out strBiblioRecPath,
                    out strSummary,
                    out strError);
                if (lRet == -1 || lRet == 0)
                {
                    strSummary = strError;
                }

                /*
                 * LibraryServerResult result = app.GetBiblioSummary(
                 *  sessioninfo,
                 *  strBarcode,
                 *  null,
                 *  null,
                 *  out strBiblioRecPath,
                 *  out strSummary);
                 * if (result.Value == -1 || result.Value == 0)
                 *  strSummary = result.ErrorInfo;
                 * */
#endif

                strResult += "<td class='summary pending' width='50%'>" + strBarcode + "</td>";
                strResult += "<td class='no' nowrap align='right'>" + strNo + "</td>";  // 续借次

                strResult += "<td class='borrowdate' nowrap>" + OpacApplication.LocalDateOrTime(strBorrowDate, strPeriod) + "</td>";
                strResult += "<td class='borrowperiod' nowrap>" + app.GetDisplayTimePeriodStringEx(strPeriod) + "</td>";

                strOverDue = DomUtil.GetAttr(node, "overdueInfo");
                string strOverdue1  = DomUtil.GetAttr(node, "overdueInfo1");
                string strIsOverdue = DomUtil.GetAttr(node, "isOverdue");
                if (strIsOverdue == "yes")
                {
                    bOverdue = true;
                }

                string strTimeReturning = DomUtil.GetAttr(node, "timeReturning");
                if (String.IsNullOrEmpty(strTimeReturning) == false)
                {
                    timeReturning = DateTimeUtil.FromRfc1123DateTimeString(strTimeReturning).ToLocalTime();
                }

                if (strColumnStyle.ToLower() == "style1")
                {
                    strTips    = strOverDue;
                    strOverDue = strOverdue1;

                    if (bOverdue == true)
                    {
                        strResult += "<td class='returningdate overdue'>"
                                     + "<a title=\"" + strTips.Replace("\"", "'") + "\">"
                                     + OpacApplication.LocalDateOrTime(timeReturning, strPeriod)
                                     // + timeReturning.ToString("d")
                                     + strOverDue
                                     + "</a>"
                                     + "</td>";
                    }
                    else
                    {
                        strResult += "<td class='returningdate'>"
                                     + "<a title=\"" + strTips.Replace("\"", "'") + "\">"
                                     + OpacApplication.LocalDateOrTime(timeReturning, strPeriod)
                                     // + timeReturning.ToString("d")
                                     + strOverDue
                                     + "</a>"
                                     + "</td>";
                    }
                }
                else
                {
                    if (bOverdue == true)
                    {
                        strResult += "<td class='overdue'>" + strOverDue + "</td>";
                    }
                    else
                    {
                        strResult += "<td class='notoverdue'>" + strOverDue + "</td>";
                    }
                }
                strResult += "<td class='renewcomment'>" + strRenewComment.Replace(";", "<br/>") +

                             "</td>";
                strResult += "<td class='operator' nowrap>" + strOperator + "</td>";
                strResult += "</tr>";

                right.Text = strResult;
            }

            // 把多余的行隐藏起来
            for (int i = nodes.Count; ; i++)
            {
                PlaceHolder line = (PlaceHolder)borrowinfo.FindControl("borrowinfo_line" + Convert.ToString(i));
                if (line == null)
                {
                    break;
                }

                line.Visible = false;
            }

            if (nodes.Count == 0)
            {
                Control insertpos = borrowinfo.FindControl("borrowinfo_insertpos");
                int     pos       = insertpos.Parent.Controls.IndexOf(insertpos);
                if (pos == -1)
                {
                    // text-level: 内部错误
                    throw new Exception("插入参照对象没有找到");
                }

                LiteralControl literal = new LiteralControl();
                literal.Text = "<tr class='dark'><td colspan='8'>" + this.GetString("(无借阅信息)") + "<td></tr>";

                insertpos.Parent.Controls.AddAt(pos, literal);
            }
        }
コード例 #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
ファイル: 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);
        }