protected void Page_Load(object sender, EventArgs e) { if (WebUtil.PrepareEnvironment(this, ref app, ref sessioninfo) == false) { return; } // 是否登录? if (sessioninfo.UserID == "") { sessioninfo.UserID = "public"; sessioninfo.IsReader = false; } string strError = ""; int nRet = 0; #if NO SessionInfo temp_sessioninfo = new SessionInfo(app); temp_sessioninfo.UserID = app.ManagerUserName; temp_sessioninfo.Password = app.ManagerPassword; temp_sessioninfo.IsReader = false; #endif LibraryChannel channel = app.GetChannel(); try { bool bHintDisplayName = false; // []暗示为显示名 string strDisplayName = this.Request["displayName"]; string strBarcode = this.Request["barcode"]; string strEncyptBarcode = Request.QueryString["encrypt_barcode"]; string strText = ""; // 如果为加密的条码形态 if (String.IsNullOrEmpty(strEncyptBarcode) == false) { strBarcode = OpacApplication.DecryptPassword(strEncyptBarcode); if (strBarcode == null) { strError = "encrypt_barcode参数值格式错误"; goto ERROR1; } bHintDisplayName = true; goto SEARCH_COMMENT; } { if (String.IsNullOrEmpty(strDisplayName) == false) { if (strDisplayName.IndexOfAny(new char[] { '[', ']' }) != -1) { bHintDisplayName = true; } strDisplayName = strDisplayName.Replace("[", "").Trim(); strDisplayName = strDisplayName.Replace("]", "").Trim(); } nRet = 0; string strReaderXml = ""; string strOutputReaderPath = ""; if (String.IsNullOrEmpty(strDisplayName) == false) { byte[] timestamp = null; string[] results = null; long lRet = // temp_sessioninfo.Channel. channel.GetReaderInfo( null, "@displayName:" + strDisplayName, "xml", out results, out strOutputReaderPath, out timestamp, out strError); if (lRet == -1) { goto ERROR1; } if (lRet == 0 && bHintDisplayName == true) { strBarcode = ""; goto SEARCH_COMMENT; } strReaderXml = results[0]; // CONTINUE1: if (nRet == 0) { strBarcode = strDisplayName; } } // SEARCH_BARCODE: if (nRet == 0 && String.IsNullOrEmpty(strBarcode) == false) { strReaderXml = ""; byte[] timestamp = null; string[] results = null; long lRet = // temp_sessioninfo.Channel. channel.GetReaderInfo( null, strBarcode, "xml", out results, out strOutputReaderPath, out timestamp, out strError); if (lRet == -1) { goto ERROR1; } if (lRet == 0) { goto SEARCH_COMMENT; } strReaderXml = results[0]; } if (nRet == 0) { /* * strError = "读者显示名或者证条码号 '" + strDisplayName + "' 不存在"; * goto ERROR1; * */ if (String.IsNullOrEmpty(strBarcode) == true) { strBarcode = strDisplayName; } goto SEARCH_COMMENT; } XmlDocument readerdom = null; nRet = OpacApplication.LoadToDom(strReaderXml, out readerdom, out strError); if (nRet == -1) { strError = "装载读者记录 '" + strOutputReaderPath + "' 进入XML DOM时发生错误: " + strError; goto ERROR1; } strDisplayName = DomUtil.GetElementText(readerdom.DocumentElement, "displayName"); strBarcode = DomUtil.GetElementInnerXml(readerdom.DocumentElement, "barcode"); } SEARCH_COMMENT: strText = strDisplayName; if (String.IsNullOrEmpty(strText) == true) { strText = strBarcode; } this.Label_name.Text = strText; string strRecipient = ""; /* * if (String.IsNullOrEmpty(strDisplayName) == false) * { * if (strDisplayName.IndexOf("[") == -1) * strRecipient = "[" + strDisplayName + "]"; * else * strRecipient = strDisplayName; * if (String.IsNullOrEmpty(strEncyptBarcode) == false) * strRecipient += " encrypt_barcode:" + strEncyptBarcode; * } * else * strRecipient = strBarcode; * */ strRecipient = BoxesInfo.BuildOneAddress(strDisplayName, strBarcode); string strSendMessageUrl = "./message.aspx?recipient=" + HttpUtility.UrlEncode(strRecipient); this.Button_sendMessage.OnClientClick = "window.open('" + strSendMessageUrl + "','_blank'); return cancelClick();"; LoginState loginstate = GlobalUtil.GetLoginState(this.Page); if (loginstate == LoginState.NotLogin || loginstate == LoginState.Public) { this.Button_sendMessage.Enabled = false; } this.BrowseSearchResultControl1.Title = strText + " 所发表的书评"; if (String.IsNullOrEmpty(strEncyptBarcode) == false) { this.Image_photo.ImageUrl = "./getphoto.aspx?encrypt_barcode=" + HttpUtility.UrlEncode(strEncyptBarcode) + "&displayName=" + HttpUtility.UrlEncode(strDisplayName); } else { this.Image_photo.ImageUrl = "./getphoto.aspx?barcode=" + HttpUtility.UrlEncode(strBarcode); } this.Image_photo.Width = 128; this.Image_photo.Height = 128; if (this.IsPostBack == false) { string strXml = ""; if (String.IsNullOrEmpty(strDisplayName) == false && String.IsNullOrEmpty(strBarcode) == false) { // 创建评注记录XML检索式 // 用作者和作者显示名共同限定检索 nRet = ItemSearchControl.BuildCommentQueryXml( app, strDisplayName, strBarcode, "<全部>", 15000, // app.SearchMaxResultCount true, out strXml, out strError); if (nRet == -1) { goto ERROR1; } } else if (String.IsNullOrEmpty(strBarcode) == false) { // 创建XML检索式 nRet = ItemSearchControl.BuildQueryXml( this.app, "comment", strBarcode, "<全部>", "作者", "exact", 15000, // app.SearchMaxResultCount true, out strXml, out strError); if (nRet == -1) { goto ERROR1; } } else if (String.IsNullOrEmpty(strDisplayName) == false) { // 创建XML检索式 nRet = ItemSearchControl.BuildQueryXml( this.app, "comment", strDisplayName, "<全部>", "作者显示名", "exact", 15000, // app.SearchMaxResultCount true, out strXml, out strError); if (nRet == -1) { goto ERROR1; } } else { strError = "strBarcode和strDisplayName均为空,无法进行检索"; goto ERROR1; } string strResultSetName = "opac_userinfo"; // sessioninfo.Channel. channel.Idle += new IdleEventHandler(channel_Idle); try { long lRet = //sessioninfo.Channel. channel.Search( null, strXml, strResultSetName, "", // strOutputStyle out strError); if (lRet == -1) { goto ERROR1; } // not found if (lRet == 0) { this.BrowseSearchResultControl1.Title = strText + " 没有发表过任何书评"; } else { this.BrowseSearchResultControl1.ResultSetName = strResultSetName; this.BrowseSearchResultControl1.ResultCount = (int)lRet; this.BrowseSearchResultControl1.StartIndex = 0; } return; } finally { //sessioninfo.Channel. channel.Idle -= new IdleEventHandler(channel_Idle); } } return; ERROR1: Response.Write(HttpUtility.HtmlEncode(strError)); Response.End(); } finally { #if NO temp_sessioninfo.CloseSession(); #endif app.ReturnChannel(channel); } }
// 提前获得记录体,然后可以获得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); }