protected override void Render(HtmlTextWriter output) { int nRet = 0; string strError = ""; if (String.IsNullOrEmpty(this.RefID) == true && String.IsNullOrEmpty(this.BiblioRecPath) == true) { strError = "RefID 和 BiblioRecPath 均为空, 无法显示"; this.SetDebugInfo("errorinfo", strError); base.Render(output); return; // goto ERROR1; } OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; string strCommentDbName = ""; if (String.IsNullOrEmpty(this.BiblioRecPath) == false) { string strBiblioDbName = StringUtil.GetDbName(this.BiblioRecPath); // return: // -1 出错 // 0 没有找到(书目库) // 1 找到 nRet = app.GetCommentDbName(strBiblioDbName, out strCommentDbName, out strError); if (nRet == -1) goto ERROR1; if (String.IsNullOrEmpty(strCommentDbName) == true) { this.Visible = false; // base.Render(output); return; } } HiddenField biblio_recpath = (HiddenField)this.FindControl("biblio_recpath"); biblio_recpath.Value = this.BiblioRecPath; LoginState loginstate = GlobalUtil.GetLoginState(this.Page); PlaceHolder inputline = (PlaceHolder)this.FindControl("inputline"); string strOutputCommentPath = ""; string strCommentXml = ""; string strBiblioRecPath = this.BiblioRecPath; byte[] comment_timestamp = null; LibraryChannel channel = sessioninfo.GetChannel(true); try { // 如果this.BiblioRecPath为空, 并且要求显示同种全部评注 // 那只能通过this.Barcode取出一个评注记录, 从中才能得知种记录的路径 if (String.IsNullOrEmpty(strBiblioRecPath) == true) { bool bGetItemXml = true; if ((this.CommentDispStyle & CommentDispStyle.Comments) == CommentDispStyle.Comments) bGetItemXml = false; string strBiblio = ""; long lRet = // sessioninfo.Channel. channel.GetCommentInfo( null, "@refid:" + this.RefID, // null, (bGetItemXml == true) ? "xml" : "", // strResultType out strCommentXml, out strOutputCommentPath, out comment_timestamp, "recpath", // strBiblioType out strBiblio, out strBiblioRecPath, out strError); if (lRet == -1) goto ERROR1; if (lRet > 1) { strError = "参考ID '" + this.RefID + "' 命中 " + nRet.ToString() + " 条记录"; goto ERROR1; } this.BiblioRecPath = strBiblioRecPath; } long nHitCount = 0; if ((this.CommentDispStyle & CommentDispStyle.Comments) == CommentDispStyle.Comments) { // 检索出该种的所有评注 #if NO sessioninfo.ItemLoad += new ItemLoadEventHandler(SessionInfo_CommentLoad); sessioninfo.SetStart += new SetStartEventHandler(sessioninfo_SetStart); #endif // tempItemBarcodes = new List<string>(); try { long lRet = SearchComments( app, channel, strBiblioRecPath, out strError); if (lRet == -1) goto ERROR1; nHitCount = lRet; if (nHitCount > 0) { if (String.IsNullOrEmpty(this.FocusRecPath) == true) { nRet = GetCommentsSearchResult( app, channel, SessionInfo_CommentLoad, this.StartIndex, this.PageMaxLines, false, this.Lang, out strError); if (nRet == -1) goto ERROR1; } else { int nFoundStart = -1; // return: // -1 出错 // 0 没有找到 // 1 找到 nRet = GetCommentsSearchResult( app, channel, SessionInfo_CommentLoad, sessioninfo_SetStart, this.PageMaxLines, this.FocusRecPath, false, this.Lang, out nFoundStart, out strError); if (nRet == -1 || nRet == 0) goto ERROR1; } } } finally { #if NO sessioninfo.SetStart -= new SetStartEventHandler(sessioninfo_SetStart); sessioninfo.ItemLoad -= new ItemLoadEventHandler(SessionInfo_CommentLoad); #endif //tempOutput = null; // this.ItemConverter = null; } // this.ItemBarcodes = this.tempItemBarcodes; this.ResultCount = (int)nHitCount; SetResultInfo((int)nHitCount); bool bHasCommandButton = false; if (nHitCount == 0) { // 如果一个评注也没有, 则不出现命令按钮 PlaceHolder cmdline = (PlaceHolder)this.FindControl("cmdline"); if (cmdline != null) cmdline.Visible = false; // 也可用SetInfo() // this.SetDebugInfo("none", this.GetString("无评注")); // "(无评注)" this.SetInfo(this.GetString("无评注")); // "(无评注)" // 不显示空的表格 if (this.DisplayBlankTable == false) { this.Visible = false; return; } } else if (bHasCommandButton == false && this.ResultCount <= this.PageMaxLines) { // 如果没有命令按钮,并且没有分页器, 则不出现命令按钮区域 PlaceHolder cmdline = (PlaceHolder)this.FindControl("cmdline"); if (cmdline != null) cmdline.Visible = false; } } else if ((this.CommentDispStyle & CommentDispStyle.Comment) == CommentDispStyle.Comment) { if (strCommentXml == "") throw new Exception("评注记录尚未准备好"); // this.tempItemBarcodes = new List<string>(); ItemLoadEventArgs e = new ItemLoadEventArgs(); e.Index = 0; e.Path = strOutputCommentPath; e.Count = 1; e.Xml = strCommentXml; SessionInfo_CommentLoad(this, e); //m_recpathlist.Add(e.Path + "|" + ByteArray.GetHexTimeStampString(e.Timestamp)); } //this.RecPathList = StringUtil.MakePathList(this.m_recpathlist); if (String.IsNullOrEmpty(this.WarningText) == false) SetDebugInfo(this.WarningText); // 根据登录身份决定是否能发表新评注 if (loginstate == LoginState.Public || loginstate == LoginState.NotLogin) { inputline.Visible = false; } else { inputline.Visible = true; string strBiblioState = ""; { string strBiblioXml = ""; long lRet = // sessioninfo.Channel. channel.GetBiblioInfo( null, this.BiblioRecPath, "", "xml", out strBiblioXml, out strError); if (lRet == -1) { /* strError = "获得种记录 '" + this.RecPath + "' 时出错: " + strError; goto ERROR1; * */ } else { string strOutMarcSyntax = ""; string strMarc = ""; // 将MARCXML格式的xml记录转换为marc机内格式字符串 // parameters: // bWarning ==true, 警告后继续转换,不严格对待错误; = false, 非常严格对待错误,遇到错误后不继续转换 // strMarcSyntax 指示marc语法,如果=="",则自动识别 // strOutMarcSyntax out参数,返回marc,如果strMarcSyntax == "",返回找到marc语法,否则返回与输入参数strMarcSyntax相同的值 nRet = MarcUtil.Xml2Marc(strBiblioXml, true, "", // this.CurMarcSyntax, out strOutMarcSyntax, out strMarc, out strError); if (nRet == -1) goto ERROR1; strBiblioState = MarcDocument.GetFirstSubfield(strMarc, "998", "s"); // 状态 } } bool bOrderComment = false; if (StringUtil.IsInList("订购征询", strBiblioState) == true) bOrderComment = true; CommentControl editor = (CommentControl)this.FindControl("editor"); editor.BiblioRecPath = strBiblioRecPath; if (bOrderComment == true) { editor.EditType = "订购征询"; } else { editor.EditType = "书评"; } editor.EditAction = "new"; editor.RecPath = ""; } /* if (this.Active == false) { inputline.Visible = false; } * */ SetControlActive(); /* LiteralControl newreview_editor_style = (LiteralControl)this.FindControl("newreview_editor_style"); if (this.HideNewReviewEdtior == true) newreview_editor_style.Text = " style='DISPLAY:none'"; * */ base.Render(output); return; } finally { sessioninfo.ReturnChannel(channel); } ERROR1: this.SetDebugInfo("errorinfo", strError); }
// TODO: 结果集是和 channel 在一起的。如果 channel 不确定,就需要用全局结果集 // 获得一定范围的检索命中结果 // return: public static int GetCommentsSearchResult( OpacApplication app, LibraryChannel channel, ItemLoadEventHandler itemLoadProc, int nStart, int nMaxCount, bool bGetRecord, string strLang, // 2012/7/9 out string strError) { strError = ""; List<string> aPath = null; long lRet = // this.Channel. channel.GetSearchResult( null, "default", nStart, // 0, nMaxCount, // -1, strLang, out aPath, out strError); if (lRet == -1) goto ERROR1; long lHitCount = lRet; if (aPath.Count == 0) { strError = "GetSearchResult aPath error"; goto ERROR1; } for (int i = 0; i < aPath.Count; i++) { if (bGetRecord == true) { string strXml = ""; string strMetaData = ""; byte[] timestamp = null; string strOutputPath = ""; string strStyle = LibraryChannel.GETRES_ALL_STYLE; lRet = // this.Channel. channel.GetRes( null, aPath[i], strStyle, out strXml, out strMetaData, out timestamp, out strOutputPath, out strError); if (lRet == -1) goto ERROR1; if (// this.ItemLoad != null itemLoadProc != null ) { ItemLoadEventArgs e = new ItemLoadEventArgs(); e.Path = aPath[i]; e.Index = i; e.Count = aPath.Count; e.Xml = strXml; e.Timestamp = timestamp; e.TotalCount = (int)lHitCount; // this.ItemLoad(this, e); e.Channel = channel; itemLoadProc(null, e); } } else { if (// this.ItemLoad != null itemLoadProc != null) { ItemLoadEventArgs e = new ItemLoadEventArgs(); e.Path = aPath[i]; e.Index = i; e.Count = aPath.Count; e.Xml = ""; e.Timestamp = null; e.TotalCount = (int)lHitCount; // this.ItemLoad(this, e); e.Channel = channel; itemLoadProc(null, e); } } } return 0; ERROR1: return -1; }
void SessionInfo_CommentLoad(object sender, ItemLoadEventArgs e) { int nRet = 0; string strError = ""; // this.m_recpathlist.Add(e.Path + "|" + ByteArray.GetHexTimeStampString(e.Timestamp)); OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; /* bool bManager = false; if (sessioninfo.Account == null || StringUtil.IsInList("managecomment", sessioninfo.RightsOrigin) == false) bManager = false; else bManager = true; * */ CommentControl commentcontrol = (CommentControl)this.FindControl("line_" + Convert.ToString(e.Index) + "_comment"); if (this.Active == false) commentcontrol.Active = false; string strXml = ""; byte[] timestamp = null; // return: // -1 出错 // 0 没有找到 // 1 找到 nRet = commentcontrol.GetRecord(app, sessioninfo, e.Channel, e.Path, out strXml, out timestamp, out strError); if (nRet == -1) goto ERROR1; e.Xml = strXml; e.Timestamp = timestamp; XmlDocument dom = new XmlDocument(); try { if (string.IsNullOrEmpty(e.Xml) == false) dom.LoadXml(e.Xml); else dom.LoadXml("<root />"); } catch (Exception ex) { strError = ExceptionUtil.GetAutoText(ex); goto ERROR1; } PlaceHolder line = (PlaceHolder)this.FindControl("line" + Convert.ToString(e.Index)); if (line == null) { PlaceHolder cmdline = (PlaceHolder)this.FindControl("cmdline"); line = NewLine(e.Index, cmdline); // this.LineCount++; } line.Visible = true; LiteralControl left = (LiteralControl)line.FindControl("line" + Convert.ToString(e.Index) + "left"); CheckBox checkbox = (CheckBox)line.FindControl("line" + Convert.ToString(e.Index) + "checkbox"); LiteralControl no = (LiteralControl)this.FindControl("line" + Convert.ToString(e.Index) + "_no"); LiteralControl middle = (LiteralControl)line.FindControl("line" + Convert.ToString(e.Index) + "middle"); LiteralControl right = (LiteralControl)line.FindControl("line" + Convert.ToString(e.Index) + "right"); // PlaceHolder editor = (PlaceHolder)this.FindControl("line_editarea_" + Convert.ToString(e.Index)); checkbox.Visible = false; // 暂时不用,因为没有cmdline string strOriginCreator = DomUtil.GetElementText(dom.DocumentElement, "creator"); string strResult = ""; string strRefID = DomUtil.GetElementText(dom.DocumentElement, "refID"); string strClass = "content"; if (strRefID == this.RefID && String.IsNullOrEmpty(strRefID) == false) { strClass = "content active"; } string strAnchor = ""; if (e.Path == this.FocusRecPath) { strClass = "content active"; strAnchor = "<a name='active'></a>"; } strResult += "<tr class='" + strClass + "' >" + "<td class='no'>" + strAnchor; // 左 left.Text = strResult; // checkbox.Text = Convert.ToString(e.TotalCount - (e.Index + this.StartIndex)); string strNo = Convert.ToString(e.TotalCount - (e.Index + this.StartIndex)); no.Text = "<div>" + strNo + "</div>"; // 右开始 strResult = "</td>"; strResult += "<td class='content'>"; middle.Text = strResult; commentcontrol.RecPath = e.Path; return; ERROR1: this.Page.Response.Write(strError); }
// 根据特性的评注记录路径,获得一定范围的检索命中结果 // return: // -1 出错 // 0 没有找到 // 1 找到 public int GetCommentsSearchResult( OpacApplication app, int nPerCount, string strCommentRecPath, bool bGetRecord, string strLang, // 2012/7/9 out int nStart, out string strError) { strError = ""; nStart = -1; long lHitCount = 0; bool bFound = false; List <string> aPath = null; for (int j = 0; ; j++) { nStart = j * nPerCount; // 只获得路径。确保所要的lStart lCount范围全部获得 long lRet = this.Channel.GetSearchResult( null, "default", nStart, // 0, nPerCount, // -1, strLang, out aPath, out strError); if (lRet == -1) { goto ERROR1; } lHitCount = lRet; if (lHitCount == 0) { return(0); } if (aPath.Count == 0) { break; } for (int i = 0; i < aPath.Count; i++) { if (aPath[i] == strCommentRecPath) { bFound = true; break; } } if (bFound == true) { break; } if (nStart >= lHitCount) { break; } } if (bFound == true) { if (this.SetStart != null) { SetStartEventArgs e = new SetStartEventArgs(); e.StartIndex = nStart; this.SetStart(this, e); } for (int i = 0; i < aPath.Count; i++) { if (bGetRecord == true) { string strXml = ""; string strMetaData = ""; byte[] timestamp = null; string strOutputPath = ""; string strStyle = LibraryChannel.GETRES_ALL_STYLE; long lRet = this.Channel.GetRes( null, aPath[i], strStyle, out strXml, out strMetaData, out timestamp, out strOutputPath, out strError); if (lRet == -1) { goto ERROR1; } if (this.ItemLoad != null) { ItemLoadEventArgs e = new ItemLoadEventArgs(); e.Path = aPath[i]; e.Index = i; e.Count = aPath.Count; e.Xml = strXml; e.Timestamp = timestamp; e.TotalCount = (int)lHitCount; this.ItemLoad(this, e); } } else { if (this.ItemLoad != null) { ItemLoadEventArgs e = new ItemLoadEventArgs(); e.Path = aPath[i]; e.Index = i; e.Count = aPath.Count; e.Xml = ""; e.Timestamp = null; e.TotalCount = (int)lHitCount; this.ItemLoad(this, e); } } } return(1); // 找到 } nStart = -1; strError = "路径为 '" + strCommentRecPath + "' 的记录在结果集中没有找到"; return(0); // 没有找到 ERROR1: return(-1); }
// 根据特性的评注记录路径,获得一定范围的检索命中结果 // return: // -1 出错 // 0 没有找到 // 1 找到 public static int GetCommentsSearchResult( OpacApplication app, LibraryChannel channel, ItemLoadEventHandler itemLoadProc, SetStartEventHandler setStartProc, int nPerCount, string strCommentRecPath, bool bGetRecord, string strLang, // 2012/7/9 out int nStart, out string strError) { strError = ""; nStart = -1; long lHitCount = 0; bool bFound = false; List<string> aPath = null; for (int j = 0; ; j++) { nStart = j * nPerCount; // 只获得路径。确保所要的lStart lCount范围全部获得 long lRet = // this.Channel. channel.GetSearchResult( null, "default", nStart, // 0, nPerCount, // -1, strLang, out aPath, out strError); if (lRet == -1) goto ERROR1; lHitCount = lRet; if (lHitCount == 0) return 0; if (aPath.Count == 0) break; for (int i = 0; i < aPath.Count; i++) { if (aPath[i] == strCommentRecPath) { bFound = true; break; } } if (bFound == true) break; if (nStart >= lHitCount) break; } if (bFound == true) { if (// this.SetStart != null setStartProc != null) { SetStartEventArgs e = new SetStartEventArgs(); e.StartIndex = nStart; // this.SetStart(this, e); setStartProc(null, e); } for (int i = 0; i < aPath.Count; i++) { if (bGetRecord == true) { string strXml = ""; string strMetaData = ""; byte[] timestamp = null; string strOutputPath = ""; string strStyle = LibraryChannel.GETRES_ALL_STYLE; long lRet = // this.Channel. channel.GetRes( null, aPath[i], strStyle, out strXml, out strMetaData, out timestamp, out strOutputPath, out strError); if (lRet == -1) goto ERROR1; if (//this.ItemLoad != null itemLoadProc != null) { ItemLoadEventArgs e = new ItemLoadEventArgs(); e.Path = aPath[i]; e.Index = i; e.Count = aPath.Count; e.Xml = strXml; e.Timestamp = timestamp; e.TotalCount = (int)lHitCount; // this.ItemLoad(this, e); e.Channel = channel; itemLoadProc(null, e); } } else { if (//this.ItemLoad != null itemLoadProc != null) { ItemLoadEventArgs e = new ItemLoadEventArgs(); e.Path = aPath[i]; e.Index = i; e.Count = aPath.Count; e.Xml = ""; e.Timestamp = null; e.TotalCount = (int)lHitCount; // this.ItemLoad(this, e); e.Channel = channel; itemLoadProc(null, e); } } } return 1; // 找到 } nStart = -1; strError = "路径为 '" + strCommentRecPath + "' 的记录在结果集中没有找到"; return 0; // 没有找到 ERROR1: return -1; }
// TODO: 结果集是和 channel 在一起的。如果 channel 不确定,就需要用全局结果集 // 获得一定范围的检索命中结果 // return: public int GetCommentsSearchResult( OpacApplication app, int nStart, int nMaxCount, bool bGetRecord, string strLang, // 2012/7/9 out string strError) { strError = ""; List <string> aPath = null; long lRet = this.Channel.GetSearchResult( null, "default", nStart, // 0, nMaxCount, // -1, strLang, out aPath, out strError); if (lRet == -1) { goto ERROR1; } long lHitCount = lRet; if (aPath.Count == 0) { strError = "GetSearchResult aPath error"; goto ERROR1; } for (int i = 0; i < aPath.Count; i++) { if (bGetRecord == true) { string strXml = ""; string strMetaData = ""; byte[] timestamp = null; string strOutputPath = ""; string strStyle = LibraryChannel.GETRES_ALL_STYLE; lRet = this.Channel.GetRes( null, aPath[i], strStyle, out strXml, out strMetaData, out timestamp, out strOutputPath, out strError); if (lRet == -1) { goto ERROR1; } if (this.ItemLoad != null) { ItemLoadEventArgs e = new ItemLoadEventArgs(); e.Path = aPath[i]; e.Index = i; e.Count = aPath.Count; e.Xml = strXml; e.Timestamp = timestamp; e.TotalCount = (int)lHitCount; this.ItemLoad(this, e); } } else { if (this.ItemLoad != null) { ItemLoadEventArgs e = new ItemLoadEventArgs(); e.Path = aPath[i]; e.Index = i; e.Count = aPath.Count; e.Xml = ""; e.Timestamp = null; e.TotalCount = (int)lHitCount; this.ItemLoad(this, e); } } } return(0); ERROR1: return(-1); }
/* * Barcode和BiblioRecPath是否具有值, 分为3种情况 * 1)Barcode和BiblioRecPath都有值。 * 这通常表示需要通过种记录路径获得全部册显示出来,把特定的barcode对应行加亮显示 * 如果此时ItemDispStyle为Item,则不好理解,这时只需指定Barcode,而Biblio不需要有值 * 2)Barcode有值 * 这需要先获得册记录,然后从册记录<parent>中获得种记录的id * 3)BiblioRecPath有值 * 这表示需要显示同种的全部册 */ protected override void Render(HtmlTextWriter output) { int nRet = 0; string strError = ""; if (String.IsNullOrEmpty(this.Barcode) == true && String.IsNullOrEmpty(this.BiblioRecPath) == true) { strError = "Barcode和BiblioRecPath均为空, 无法显示"; goto ERROR1; } LoginState loginstate = GlobalUtil.GetLoginState(this.Page); OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; /* if (sessioninfo.Account == null) { //strError = "尚未登录"; //goto ERROR1; this.Page.Response.Redirect("login.aspx"); this.Page.Response.End(); return; } * */ // 设置 预约按钮文字和状态 Button reservationbutton = (Button)this.FindControl("reservationbutton"); /* if (sessioninfo.Account == null || (sessioninfo.Account != null && sessioninfo.Account.UserID == "public")) // 2006/12/24 * */ if (loginstate == LoginState.NotLogin || loginstate == LoginState.Public) // 2007/7/10 { reservationbutton.Text = this.GetString("加入预约列表"); reservationbutton.Enabled = false; } else { // Debug.Assert(sessioninfo.ReaderInfo != null); if (sessioninfo.ReaderInfo == null || String.IsNullOrEmpty(sessioninfo.ReaderInfo.Name) == true) { // 没有姓名 reservationbutton.Text = this.GetString("加入预约列表"); } else { // 有姓名 reservationbutton.Text = string.Format( this.GetString("加入someone的预约列表"), // "加入 {0} 的预约列表" sessioninfo.ReaderInfo.Name); // "加入 " + sessioninfo.Account.Name + " 的预约列表"; } reservationbutton.Enabled = true; } PlaceHolder reservationreaderbarcode_holder = (PlaceHolder)this.FindControl("reservationreaderbarcode_holder"); /* if (sessioninfo.Account == null // 2007/7/10 || sessioninfo.Account.Barcode != "" || sessioninfo.Account.UserID == "public") // 2006/12/24 * */ if (loginstate == LoginState.Librarian) { // 图书馆员才能动态指定读者证条码号 reservationreaderbarcode_holder.Visible = true; // 放入可能的内容 2008/9/27 if (sessioninfo.ReaderInfo != null && String.IsNullOrEmpty(sessioninfo.ReaderInfo.ReaderDomBarcode) == false) { TextBox reservationreaderbarcode = (TextBox)this.FindControl("reservationreaderbarcode"); Debug.Assert(reservationreaderbarcode != null, ""); reservationreaderbarcode.Text = sessioninfo.ReaderInfo.ReaderDomBarcode; } } else { reservationreaderbarcode_holder.Visible = false; } string strBiblioRecPath = this.BiblioRecPath; string strOutputItemPath = ""; string strItemXml = ""; byte[] item_timestamp = null; // 如果this.BiblioRecPath为空, 并且要求显示同种全部册 // 那只能通过this.Barcode取出一个册记录, 从中才能得知种记录的路径 if (String.IsNullOrEmpty(strBiblioRecPath) == true) { #if NO // 获得册记录 // return: // -1 error // 0 not found // 1 命中1条 // >1 命中多于1条 nRet = app.GetItemRecXml( sessioninfo.Channels, this.Barcode, out strItemXml, out strOutputItemPath, out strError); if (nRet == 0) { strError = "册条码号为 '" + this.Barcode + "' 的册记录没有找到"; goto ERROR1; } if (nRet == -1) goto ERROR1; #endif bool bGetItemXml = true; if ((this.ItemDispStyle & ItemDispStyle.Items) == ItemDispStyle.Items) bGetItemXml = false; string strBiblio = ""; long lRet = sessioninfo.Channel.GetItemInfo( null, this.Barcode, (bGetItemXml == true) ? "xml" : "", // strResultType out strItemXml, out strOutputItemPath, out item_timestamp, "recpath", // strBiblioType out strBiblio, out strBiblioRecPath, out strError); if (lRet == -1) goto ERROR1; if (lRet == 0) { strError = "册条码号 '" + this.Barcode + "' 没有找到"; goto ERROR1; } if (lRet > 1) { strError = "册条码号 '" + this.Barcode + "' 命中 " + nRet.ToString() + " 条记录"; goto ERROR1; } Debug.Assert(string.IsNullOrEmpty(strBiblioRecPath) == false, ""); this.BiblioRecPath = strBiblioRecPath; } if ((this.ItemDispStyle & ItemDispStyle.Items) == ItemDispStyle.Items) { string strLibraryCode = (string)this.Page.Session["librarycode"]; // 检索出该种的所有册 sessioninfo.ItemLoad += new ItemLoadEventHandler(SessionInfo_ItemLoad); tempItemBarcodes = new List<string>(); // tempOutput = ""; // tempOutput = output; try { // return: // -2 实体库没有定义 // -1 出错 // 其他 命中的全部结果数量。 nRet = sessioninfo.OpacSearchItems( app, strBiblioRecPath, this.StartIndex, this.PageMaxLines, this.Lang, strLibraryCode, out strError); if (nRet == -1) { strError = "sessioninfo.SearchItems() error :" + strError; goto ERROR1; } if (nRet == -2) { this.Visible = false; return; } } finally { sessioninfo.ItemLoad -= new ItemLoadEventHandler(SessionInfo_ItemLoad); //tempOutput = null; // // this.ItemConverter = null; } this.ItemBarcodes = this.tempItemBarcodes; this.ResultCount = nRet; // 2009/6/9 add SetResultInfo(nRet); if (nRet == 0) { // 如果一册也没有, 则不出现命令按钮 /* Button button = (Button)this.FindControl("reservationbutton"); if (button != null) button.Visible = false; */ PlaceHolder cmdline = (PlaceHolder)this.FindControl("cmdline"); if (cmdline != null) cmdline.Visible = false; this.SetDebugInfo("none", this.GetString("无馆藏")); // "(无馆藏)" // 不显示空的表格 if (this.DisplayBlankTable == false) { this.Visible = false; return; } } } else if ((this.ItemDispStyle & ItemDispStyle.Item) == ItemDispStyle.Item) { if (strItemXml == "") throw new Exception("册记录尚未准备好"); this.tempItemBarcodes = new List<string>(); ItemLoadEventArgs e = new ItemLoadEventArgs(); e.Index = 0; e.Path = strOutputItemPath; e.Count = 1; e.Xml = strItemXml; e.Timestamp = item_timestamp; SessionInfo_ItemLoad(this, e); this.ItemBarcodes = this.tempItemBarcodes; } if (String.IsNullOrEmpty(this.WarningText) == false) SetDebugInfo(this.WarningText); if (this.Active == false) reservationbutton.Enabled = false; base.Render(output); return; ERROR1: // output.Write(strError); // 2011/4/21 this.SetDebugInfo("errorinfo", strError); base.Render(output); }
void SessionInfo_ItemLoad(object sender, ItemLoadEventArgs e) { int nRet = 0; string strError = ""; OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; LoginState loginstate = GlobalUtil.GetLoginState(this.Page); bool bAllowReservation = true; // 尚未登录、访客身份等原因导致的允许和不允许使用预约checkbox状态 string strAllowReservationReason = ""; // 原因字符串,用于tooltips提示 if (loginstate == LoginState.NotLogin) { bAllowReservation = false; strAllowReservationReason = "当前尚未登录"; } else if (loginstate == LoginState.Public) { bAllowReservation = false; strAllowReservationReason = "当前为访客身份"; } // 返回前被过滤掉的记录 if (string.IsNullOrEmpty(e.Xml) == true) return; XmlDocument dom = new XmlDocument(); try { dom.LoadXml(e.Xml); } catch (Exception ex) { strError = ex.Message; goto ERROR1; } PlaceHolder line = (PlaceHolder)this.FindControl("line" + Convert.ToString(e.Index)); if (line == null) { PlaceHolder cmdline = (PlaceHolder)this.FindControl("cmdline"); line = NewLine(e.Index, cmdline); this.LineCount++; } line.Visible = true; LiteralControl left = (LiteralControl)line.FindControl("line" + Convert.ToString(e.Index) + "left"); CheckBox checkbox = (CheckBox)line.FindControl("line" + Convert.ToString(e.Index) + "checkbox"); LiteralControl right = (LiteralControl)line.FindControl("line" + Convert.ToString(e.Index) + "right"); string strResult = ""; string strBarcode = DomUtil.GetElementText(dom.DocumentElement, "barcode"); // string strBorrower = DomUtil.GetElementText(dom.DocumentElement, "borrower"); // 2015/4/3 string strRefID = DomUtil.GetElementText(dom.DocumentElement, "refID"); if (string.IsNullOrEmpty(strBarcode) == true) strBarcode = "@refID:" + strRefID; this.tempItemBarcodes.Add(strBarcode); if (this.m_hidecolumns == null) { string strItemDbName = ResPath.GetDbName(e.Path); string strBiblioDbName = ""; // 根据实体库名, 找到对应的书目库名 // return: // -1 出错 // 0 没有找到 // 1 找到 nRet = app.GetBiblioDbNameByItemDbName(strItemDbName, out strBiblioDbName, out strError); if (string.IsNullOrEmpty(strBiblioDbName) == false) { this.m_hidecolumns = GetHideColumns(app, strBiblioDbName); // 重新设置栏目标题行 if (this.m_hidecolumns != null && this.m_hidecolumns.Count > 0) { PlaceHolder titleline = (PlaceHolder)this.FindControl("titleline"); CreateTitleLine(titleline, this.m_hidecolumns); } } else this.m_hidecolumns = new List<string>(); } /* string strColor = "bgcolor=#ffffff"; if (strBarcode == this.Barcode) { strColor = "bgcolor=#bbbbff"; // 当前正在借阅的册 } */ string strClass = "content"; string strAnchor = ""; if ((strBarcode == this.Barcode && String.IsNullOrEmpty(strBarcode) == false// 排除空的条码号 2009/8/4 changed ) || e.Path == this.FocusRecPath) { strClass = "content active"; // 2009/8/4 changed strAnchor = "<a name='active'></a>"; } // 是否和合订成员册? bool bMember = false; XmlNode nodeBindingParent = dom.DocumentElement.SelectSingleNode("binding/bindingParent"); if (nodeBindingParent != null) { bMember = true; strClass += " bindingmember"; } // 状态 string strState = DomUtil.GetElementText(dom.DocumentElement, "state"); // 2015/1/9 if (StringUtil.IsInList("注销", strState) == true) strClass += " absolute"; if (StringUtil.IsInList("加工中", strState) == true) strClass += " repairing"; strResult += "\r\n<tr class='" + strClass + "' ><td class='no'>" + strAnchor; // 左 left.Text = strResult; // checkbox checkbox.Text = Convert.ToString(e.Index + this.StartIndex + 1); // 馆藏地点 string strLocation = DomUtil.GetElementText(dom.DocumentElement, "location"); #if NO bool bResultValue = false; string strMessageText = ""; // 执行脚本函数ItemCanBorrow // parameters: // return: // -2 not found script // -1 出错 // 0 成功 nRet = app.DoItemCanBorrowScriptFunction( false, sessioninfo.Account, dom, out bResultValue, out strMessageText, out strError); if (nRet == -1) { strMessageText = strError; } if (nRet == -2) { // 根据馆藏地点是否允许借阅, 设置checkbox状态 List<string> locations = app.GetLocationTypes(true); if (locations.IndexOf(strLocation) == -1) { checkbox.Enabled = false; checkbox.ToolTip = "此册因属馆藏地点 " + strLocation + " 而不能外借。"; } else { checkbox.Enabled = bAllowReservation; if (bAllowReservation == false) { checkbox.ToolTip = "此册因" + strAllowReservationReason + "而无法进行预约勾选操作。"; } } } else { // 根据脚本加以设置 checkbox.Enabled = bAllowReservation == true ? bResultValue : false; if (bAllowReservation == false) { checkbox.ToolTip = "此册因" + strAllowReservationReason + "而无法进行预约勾选操作。"; } } #endif XmlNode nodeCanBorrow = dom.DocumentElement.SelectSingleNode("canBorrow"); string strCanBorrowText = ""; bool bCanBorrow = true; if (nodeCanBorrow != null) { strCanBorrowText = nodeCanBorrow.InnerText; DomUtil.GetBooleanParam(nodeCanBorrow, "canBorrow", true, out bCanBorrow, out strError); } // 根据馆藏地点是否允许借阅, 设置checkbox状态 if (bCanBorrow == false) { checkbox.Enabled = false; checkbox.ToolTip = strCanBorrowText; } else { checkbox.Enabled = bAllowReservation; if (bAllowReservation == false) { checkbox.ToolTip = "此册因" + strAllowReservationReason + "而无法进行预约勾选操作。"; } } // 右开始 strResult = "</td>"; // 条码号 if (this.m_hidecolumns.IndexOf("barcode") == -1) strResult += "<td class='barcode'>" + strBarcode + "</td>"; // 状态 // string strState = DomUtil.GetElementText(dom.DocumentElement, "state"); // strState = strMessageText + strState; string strStateMessage = DomUtil.GetElementText(dom.DocumentElement, "stateMessage"); if (String.IsNullOrEmpty(strStateMessage) == false) strState = strStateMessage; if (bMember == true) StringUtil.SetInList(ref strState, "已装入合订册", true); if (this.m_hidecolumns.IndexOf("state") == -1) strResult += "<td class='state'>" + (strState == "" ? " " : strState) + "</td>"; // 馆藏地 string strLocationCaption = ""; string strLocationUrl = ""; string strDisplayText = ""; // 获得馆藏地点的显示字符串 // return: // -1 error // 0 not found // 1 found nRet = GetLocationDisplayString( this.Lang, // "zh", strLocation, out strLocationCaption, out strLocationUrl, out strError); if (nRet == -1) strDisplayText = strError; else { if (String.IsNullOrEmpty(strLocationUrl) == false) { strDisplayText = "<a href='" + strLocationUrl + "'>" + strLocationCaption + "</a>"; } else { strDisplayText = strLocationCaption; } } if (this.m_hidecolumns.IndexOf("location") == -1) strResult += "<td class='location'>" + (strDisplayText == "" ? " " : strDisplayText) + "</td>"; // 索取号 // 2009/4/7 string strAccessNo = DomUtil.GetElementText(dom.DocumentElement, "accessNo"); if (this.m_hidecolumns.IndexOf("accessNo") == -1) { string strAccessNoText = ""; string strAccessNoUrl = "./location.aspx?location=" + HttpUtility.UrlEncode(strLocation) + "&accessNo=" + HttpUtility.UrlEncode(strAccessNo); if (String.IsNullOrEmpty(strAccessNoUrl) == false) { strAccessNoText = "<a href='" + strAccessNoUrl + "'>" + HttpUtility.HtmlEncode(StringUtil.GetPlainTextCallNumber(strAccessNo)) + "</a>"; } else { strAccessNoText = HttpUtility.HtmlEncode(StringUtil.GetPlainTextCallNumber(strAccessNo)); } strResult += "<td class='accessNo'>" + (strAccessNoText == "" ? " " : strAccessNoText) + "</td>"; } // 出版日期 // 2009/4/7 string strPublishTime = DomUtil.GetElementText(dom.DocumentElement, "publishTime"); if (this.m_hidecolumns.IndexOf("publishTime") == -1) strResult += "<td class='publishTime'>" + (strPublishTime == "" ? " " : GetDisplayPublishTime(strPublishTime)) + "</td>"; // 卷期信息 // 2009/4/7 string strVolume = DomUtil.GetElementText(dom.DocumentElement, "volume"); if (this.m_hidecolumns.IndexOf("volume") == -1) strResult += "<td class='volume'>" + (strVolume == "" ? " " : strVolume) + "</td>"; // 价格 string strPrice = DomUtil.GetElementText(dom.DocumentElement, "price"); if (this.m_hidecolumns.IndexOf("price") == -1) strResult += "<td class='price'>" + (strPrice == "" ? " " : strPrice) + "</td>"; // 注释 string strComment = DomUtil.GetElementText(dom.DocumentElement, "comment"); if (this.m_hidecolumns.IndexOf("comment") == -1) strResult += "<td class='comment'>" + (strComment == "" ? " " : strComment) + "</td>"; // 借者条码 string strBorrower = DomUtil.GetElementText(dom.DocumentElement, "borrower"); bool bMyselfBorrower = false; /* bool bLibrarian = false; if (sessioninfo.Account != null && sessioninfo.Account.Type != "reader") bLibrarian = true; else bLibrarian = false; * */ // 看看是否自己已经借阅的 if (String.IsNullOrEmpty(strBorrower) == false && loginstate != LoginState.NotLogin /*sessioninfo.Account != null*/) { if (loginstate == LoginState.Reader /*sessioninfo.Account.Type == "reader"*/ && sessioninfo.ReaderInfo.Barcode == strBorrower && String.IsNullOrEmpty(strBorrower) == false) { Debug.Assert(sessioninfo.ReaderInfo != null); bMyselfBorrower = true; checkbox.Enabled = false; checkbox.ToolTip = "此册已经被本人借阅, 在还回前,不能预约。"; } } // 如果不允许预约在架的图书 if (checkbox.Enabled == true && app.CanReserveOnshelf == false && String.IsNullOrEmpty(strBorrower) == true) { checkbox.Enabled = false; checkbox.ToolTip = "在架(未被借阅的)册,不能预约。"; } // 对于读者,隐去除自己以外的其他人的证条码号 // 对于访客登录或者没有登录,也是隐去证条码号 2007/9/4 if (loginstate == LoginState.Public || loginstate == LoginState.NotLogin || (loginstate == LoginState.Reader && bMyselfBorrower == false)) { int nLength = strBorrower.Length; strBorrower = ""; strBorrower = strBorrower.PadLeft(nLength, '*'); } // strResult += "<td class='borrower'>"; string strBorrowString = ""; if (loginstate == LoginState.Librarian && strBorrower != "") { // TODO: 要改造readerinfo.aspx string strBorrowerUrl = "./readerinfo.aspx?barcode=" + strBorrower; // strResult += "<a href='"+strBorrowerUrl+"'>" + strBorrower + "</a>"; strBorrowString = "<a href='" + strBorrowerUrl + "'>" + strBorrower + "</a>"; } else { /* strResult += (strBorrower == "" ? " " : strBorrower); if (bMyself == true) strResult += "(我自己)"; * */ strBorrowString = strBorrower; if (bMyselfBorrower == true) strBorrowString += this.GetString("我自己"); // "(我自己)" } // strResult += "</td>"; // 续借次 string strNo = DomUtil.GetElementText(dom.DocumentElement, "no"); // strResult += "<td class='renewno'>" + (strNo == "" ? " " : strNo) + "</td>"; // 借阅日期 string strBorrowDate = DomUtil.GetElementText(dom.DocumentElement, "borrowDate"); string strTime = strBorrowDate; if (String.IsNullOrEmpty(strTime) == false) { try { strTime = DateTimeUtil.LocalTime(strTime); } catch { strTime = "时间格式错误 -- " + strTime; } } // <borrowerReaderType>是2009/9/18以后为实体记录新增的一个元素,是从读者记录中<readerType>中复制过来的 string strBorrowerReaderType = DomUtil.GetElementText(dom.DocumentElement, "borrowerReaderType"); // strTime = strTime.Replace(" ", "<br/>"); // 插入一个回车,以便占据的宽度更小一点 // strResult += "<td class='borrowdate' nowrap>" + (strTime == "" ? " " : strTime) + "</td>"; // 借阅期限 string strPeriod = DomUtil.GetElementText(dom.DocumentElement, "borrowPeriod"); // strResult += "<td class='borrowperiod'>" + (strPeriod == "" ? " " : strPeriod) + "</td>"; // string strError = ""; string strOverDue = ""; // 超期情况字符串。已经被规范过,不超期的时候这个字符串为空值 string strOriginOverdue = ""; // 超期情况字符串,没有加工过,如果是不超期的时候,则会说还有多少天到期 long lOver = 0; string strPeriodUnit = ""; strClass = "borrows"; #if NO if (String.IsNullOrEmpty(strBorrowDate) == false) { // 获得日历 Calendar calendar = null; if (String.IsNullOrEmpty(strBorrowerReaderType) == false) { nRet = app.GetReaderCalendar(strBorrowerReaderType, out calendar, out strError); if (nRet == -1) { calendar = null; } } // 检查超期情况。 // return: // -1 数据格式错误 // 0 没有发现超期 // 1 发现超期 strError中有提示信息 // 2 已经在宽限期内,很容易超期 2009/3/13 nRet = app.CheckPeriod( calendar, // 2009/9/18 changed strBorrowDate, strPeriod, out lOver, out strPeriodUnit, out strError); strOriginOverdue = strError; if (nRet == -1) strOverDue = strError; // 错误信息 if (nRet == 1) strOverDue = this.GetString("已超期"); else if (nRet == 2) // 2009/9/18 strOverDue = this.GetString("已在宽限期内,即将超期"); /* if (nRet == 1 || nRet == 0) strOverDue = strError; // "已超期"; * */ if (nRet == 1) strClass = "borrows over"; else if (nRet == 2) // 2009/9/18 strClass = "borrows warning"; else if (nRet == 0 && lOver >= -5) strClass = "borrows warning"; strPeriod = app.GetDisplayTimePeriodStringEx(strPeriod); } #endif string strType = ""; XmlNode nodeOverdueInfo = dom.DocumentElement.SelectSingleNode( "overdueInfo"); if (nodeOverdueInfo != null) { strOverDue = nodeOverdueInfo.InnerText; strType = DomUtil.GetAttr(nodeOverdueInfo, "type"); } if (String.IsNullOrEmpty(strType) == false) strClass += "" + strType; XmlNode nodeOriginOverdueInfo = dom.DocumentElement.SelectSingleNode( "originOverdueInfo"); if (nodeOriginOverdueInfo != null) { strOriginOverdue = nodeOriginOverdueInfo.InnerText; strPeriodUnit = DomUtil.GetAttr(nodeOriginOverdueInfo, "unit"); string strOver = DomUtil.GetAttr(nodeOriginOverdueInfo, "over"); string strCalendarName = DomUtil.GetAttr(nodeOriginOverdueInfo, "calendar"); } // 超期情况 // strResult += "<td class='"+strClass+"'>" + (strOverDue == "" ? " " : strOverDue) + "</td>"; // TODO: 颜色最好根据是否超期而加以变化? string strText = ""; if (String.IsNullOrEmpty(strBorrowString) == false) { strText += this.GetString("借阅者") + ": " + strBorrowString; if (string.IsNullOrEmpty(strNo) == false && strNo != "0") { strText += "<br/>" + this.GetString("续借次") + ": " + strNo; } strPeriod = app.GetDisplayTimePeriodStringEx(strPeriod); strText += "<br/>" + this.GetString("借阅日期") + ": " + strTime + "<br/>" + this.GetString("借阅期限") + ": " + strPeriod; // + " (" + lOver.ToString() + ")"; if (String.IsNullOrEmpty(strOverDue) == false) { strText += "<br/>" + this.GetString("是否超期") + ": " + strOverDue; } } // 2009/8/5 // tips text if (String.IsNullOrEmpty(strOriginOverdue) == false && String.IsNullOrEmpty(strText) == false) { strText = "<a title=\"" + strOriginOverdue.Replace("\"", "'") + "\">" + strText + "</a>"; } if (this.m_hidecolumns.IndexOf("borrows") == -1) strResult += "<td class='" + strClass + "' nowrap>" + strText + "</td>"; // 预约情况 if (this.m_hidecolumns.IndexOf("reservations") == -1) { string strReservations = ""; XmlNodeList nodes = dom.DocumentElement.SelectNodes("reservations/request"); for (int i = 0; i < nodes.Count; i++) { XmlNode node = nodes[i]; string strReader = DomUtil.GetAttr(node, "reader"); string strRequestDate = DateTimeUtil.LocalDate(DomUtil.GetAttr(node, "requestDate")); bool bMyselfReserver = false; if (/*sessioninfo.Account != null && sessioninfo.Account.Type == "reader"*/ loginstate == LoginState.Reader && sessioninfo.ReaderInfo.Barcode == strReader && String.IsNullOrEmpty(strReader) == false) { bMyselfReserver = true; } // 对于读者,隐去除自己以外的其他人的证条码号 if (loginstate == LoginState.NotLogin || loginstate == LoginState.Public // 2009/4/10 /*sessioninfo.Account == null*/ || (loginstate == LoginState.Reader /*sessioninfo.Account != null && sessioninfo.Account.Type == "reader"*/ && bMyselfReserver == false)) { int nLength = strReader.Length; strReader = ""; strReader = strReader.PadLeft(nLength, '*'); } // TODO: 要改造readerinfo.aspx string strReaderUrl = "./readerinfo.aspx?barcode=" + strReader; if (loginstate == LoginState.Librarian) { strReservations += this.GetString("读者证条码号") + ": " + "<a href='" + strReaderUrl + "'>" + strReader + "</a>" + "; " + this.GetString("请求日期") + ": " + strRequestDate + "<br/>"; } else { string strReaderString = strReader; if (bMyselfReserver == true) strBorrowString += this.GetString("我自己"); // "(我自己)" strReservations += this.GetString("读者证条码号") + ": " + strReaderString + "; " + this.GetString("请求日期") + ": " + strRequestDate + "<br/>"; } } strResult += "<td class='reservations'>" + (strReservations == "" ? " " : strReservations) + "</td>"; } // 流通次 if (this.m_hidecolumns.IndexOf("borrowcount") == -1) { string strCirculationCount = ""; XmlNode nodeCount = dom.DocumentElement.SelectSingleNode("borrowHistory/@count"); if (nodeCount != null) strCirculationCount = nodeCount.Value; strResult += "<td class='borrowcount'>" + (string.IsNullOrEmpty(strCirculationCount) == true ? " " : strCirculationCount) + "</td>"; } /* // 从属种记录id strResult += "<td class='parent'>" + DomUtil.GetElementText(dom.DocumentElement, "parent") + "</td>"; * */ strResult += "</tr>"; right.Text = strResult; return; ERROR1: // tempOutput += strError; this.Page.Response.Write(strError); }
// 检索出册数据 // 带有偏移量的版本 // 2009/6/9 // return: // -2 实体库没有定义 // -1 出错 // 其他 命中的全部结果数量。 // public static int OpacSearchItems( OpacApplication app, LibraryChannel channel, ItemLoadEventHandler itemLoadProc, string strBiblioRecPath, int nStart, int nMaxCount, string strLang, string strLibraryCode, out string strError) { strError = ""; // string strXml = ""; // LibraryChannel channel = this.GetChannel(true, this.m_strParameters); try { string strStyle = "opac"; if (string.IsNullOrEmpty(strLibraryCode) == true) strStyle += ",getotherlibraryitem"; else strStyle += ",librarycode:" + strLibraryCode; long lStart = nStart; long lCount = nMaxCount; long lTotalCount = 0; for (; ; ) { EntityInfo[] iteminfos = null; long lRet = // this.Channel. channel.GetEntities( null, strBiblioRecPath, lStart, lCount, strStyle, strLang, out iteminfos, out strError); if (lRet == -1) { if (//this.Channel. channel.ErrorCode == ErrorCode.ItemDbNotDef) return -2; return -1; } if (lRet == 0) { strError = "没有找到"; return 0; } lTotalCount = lRet; if (lCount < 0) lCount = lTotalCount - lStart; if (lStart + lCount > lTotalCount) lCount = lTotalCount - lStart; // 处理 for (int i = 0; i < iteminfos.Length; i++) { EntityInfo info = iteminfos[i]; if (//this.ItemLoad != null itemLoadProc != null) { ItemLoadEventArgs e = new ItemLoadEventArgs(); e.Path = info.OldRecPath; e.Index = i; // +nStart; e.Count = nMaxCount; // (int)lTotalCount - nStart; e.Timestamp = info.OldTimestamp; e.Xml = info.OldRecord; //this.ItemLoad(this, e); itemLoadProc(null, e); } } lStart += iteminfos.Length; lCount -= iteminfos.Length; if (lStart >= lTotalCount) break; if (lCount <= 0) break; } return (int)lTotalCount; } finally { // this.ReturnChannel(channel); } }
protected override void Render(HtmlTextWriter output) { int nRet = 0; string strError = ""; if (String.IsNullOrEmpty(this.RefID) == true && String.IsNullOrEmpty(this.BiblioRecPath) == true) { strError = "RefID和BiblioRecPath均为空, 无法显示"; this.SetDebugInfo("errorinfo", strError); base.Render(output); return; // goto ERROR1; } OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; string strCommentDbName = ""; if (String.IsNullOrEmpty(this.BiblioRecPath) == false) { string strBiblioDbName = ResPath.GetDbName(this.BiblioRecPath); // return: // -1 出错 // 0 没有找到(书目库) // 1 找到 nRet = app.GetCommentDbName(strBiblioDbName, out strCommentDbName, out strError); if (nRet == -1) goto ERROR1; if (String.IsNullOrEmpty(strCommentDbName) == true) { this.Visible = false; // base.Render(output); return; } } HiddenField biblio_recpath = (HiddenField)this.FindControl("biblio_recpath"); biblio_recpath.Value = this.BiblioRecPath; LoginState loginstate = GlobalUtil.GetLoginState(this.Page); PlaceHolder inputline = (PlaceHolder)this.FindControl("inputline"); #if NO // PlaceHolder edit_holder = (PlaceHolder)this.FindControl("edit_holder"); if (loginstate == LoginState.Public || loginstate == LoginState.NotLogin) { inputline.Visible = false; } else { inputline.Visible = true; if (String.IsNullOrEmpty(this.EditLineNumbers) == true) { string strBiblioState = ""; { string strOutputPath = ""; string strBiblioXml = ""; string strMetaData = ""; byte[] timestamp = null; long lRet = channel.GetRes(this.BiblioRecPath, out strBiblioXml, out strMetaData, out timestamp, out strOutputPath, out strError); if (lRet == -1) { /* strError = "获得种记录 '" + this.RecPath + "' 时出错: " + strError; goto ERROR1; * */ } else { string strOutMarcSyntax = ""; string strMarc = ""; // 将MARCXML格式的xml记录转换为marc机内格式字符串 // parameters: // bWarning ==true, 警告后继续转换,不严格对待错误; = false, 非常严格对待错误,遇到错误后不继续转换 // strMarcSyntax 指示marc语法,如果=="",则自动识别 // strOutMarcSyntax out参数,返回marc,如果strMarcSyntax == "",返回找到marc语法,否则返回与输入参数strMarcSyntax相同的值 nRet = MarcUtil.Xml2Marc(strBiblioXml, true, "", // this.CurMarcSyntax, out strOutMarcSyntax, out strMarc, out strError); if (nRet == -1) goto ERROR1; strBiblioState = MarcDocument.GetFirstSubfield(strMarc, "998", "s"); // 状态 } } bool bOrderComment = false; if (StringUtil.IsInList("订购征询", strBiblioState) == true) bOrderComment = true; HiddenField type = (HiddenField)this.FindControl("edit_type"); LiteralControl description = (LiteralControl)this.FindControl("edit_description"); PlaceHolder ordercomment_description_holder = (PlaceHolder)this.FindControl("ordercomment_description_holder"); // PlaceHolder recpath_holder = (PlaceHolder)this.FindControl("recpath_holder"); if (bOrderComment == true) { ordercomment_description_holder.Visible = true; description.Text = this.GetString("本书正在征求订购意见") + ":"; type.Value = "订购征询"; } else { ordercomment_description_holder.Visible = false; description.Text = this.GetString("在此贡献您的书评")+":"; type.Value = "书评"; } if (sessioninfo.Account != null) { /* TextBox edit_creator = (TextBox)this.FindControl("edit_creator"); edit_creator.Text = sessioninfo.Account.UserID; * */ LiteralControl recordinfo = (LiteralControl)this.FindControl("recordinfo"); recordinfo.Text = this.GetString("创建者") + ": " + GetCurrentAccountDisplayName(); if (IsReaderHasnotDisplayName() == true) { recordinfo.Text += "<div class='comment'>" + this.GetString("若想以个性化的作者名字发表评注") + ",<a href='./personalinfo.aspx' target='_blank'>" + this.GetString("点这里立即添加我的显示名") + "</a></div>"; } } // recpath_holder.Visible = false; } } #endif string strOutputCommentPath = ""; string strCommentXml = ""; string strBiblioRecPath = this.BiblioRecPath; byte[] comment_timestamp = null; // 如果this.BiblioRecPath为空, 并且要求显示同种全部评注 // 那只能通过this.Barcode取出一个评注记录, 从中才能得知种记录的路径 if (String.IsNullOrEmpty(strBiblioRecPath) == true) { /* // 获得评注记录 // return: // -1 error // 0 not found // 1 命中1条 // >1 命中多于1条 nRet = app.GetCommentRecXml( sessioninfo.Channels, this.RefID, out strCommentXml, out strOutputCommentPath, out strError); if (nRet == 0) { strError = "参考ID为 '" + this.RefID + "' 的评注记录没有找到"; goto ERROR1; } if (nRet == -1) goto ERROR1; * */ bool bGetItemXml = true; if ((this.CommentDispStyle & CommentDispStyle.Comments) == CommentDispStyle.Comments) bGetItemXml = false; string strBiblio = ""; long lRet = sessioninfo.Channel.GetCommentInfo( null, "@refid:" + this.RefID, // null, (bGetItemXml == true) ? "xml" : "", // strResultType out strCommentXml, out strOutputCommentPath, out comment_timestamp, "recpath", // strBiblioType out strBiblio, out strBiblioRecPath, out strError); if (lRet == -1) goto ERROR1; if (lRet > 1) { strError = "参考ID '" + this.RefID + "' 命中 " + nRet.ToString() + " 条记录"; goto ERROR1; } this.BiblioRecPath = strBiblioRecPath; } // string strCommentDbName = ""; // 评注库名 // string strBiblioRecID = ""; // 种记录id // 若需要取得种记录路径和id #if NO // 如果需要从评注记录中获得种记录路径 if (String.IsNullOrEmpty(this.BiblioRecPath) == true && strCommentXml != "") { strCommentDbName = ResPath.GetDbName(strOutputCommentPath); string strBiblioDbName = ""; // 根据评注库名, 找到对应的书目库名 // return: // -1 出错 // 0 没有找到 // 1 找到 nRet = app.GetBiblioDbNameByCommentDbName(strCommentDbName, out strBiblioDbName, out strError); if (nRet == -1) goto ERROR1; if (nRet == 0) { strError = "评注库 '" + strCommentDbName + "' 名在cfgs/global配置文件中没有找到对应的书目库名"; goto ERROR1; } // 获得评注记录中的<parent>字段 XmlDocument dom = new XmlDocument(); try { dom.LoadXml(strCommentXml); } catch (Exception ex) { strError = "评注记录XML装载到DOM出错:" + ex.Message; goto ERROR1; } strBiblioRecID = DomUtil.GetElementText(dom.DocumentElement, "//parent"); if (String.IsNullOrEmpty(strBiblioRecID) == true) { strError = "评注记录XML中<parent>元素缺乏或者值为空, 因此无法定位种记录"; goto ERROR1; } strBiblioRecPath = strBiblioDbName + "/" + strBiblioRecID; } #endif #if NO // 若需要知道评注库名 if (String.IsNullOrEmpty(strCommentDbName) == true && String.IsNullOrEmpty(this.BiblioRecPath) == false) { // 根据书目库名, 找到对应的评注库名 // return: // -1 出错 // 0 没有找到 // 1 找到 nRet = app.GetCommentDbName(ResPath.GetDbName(this.BiblioRecPath), out strCommentDbName, out strError); if (nRet == -1) goto ERROR1; } if ((this.CommentDispStyle & CommentDispStyle.Comments) == CommentDispStyle.Comments) { // 已知种路径, 但不知评注库名 strBiblioRecPath = this.BiblioRecPath; strBiblioRecID = ResPath.GetRecordId(this.BiblioRecPath); } #endif // // //m_recpathlist.Clear(); //this.RecPathList = ""; long nHitCount = 0; if ((this.CommentDispStyle & CommentDispStyle.Comments) == CommentDispStyle.Comments) { // 检索出该种的所有评注 sessioninfo.ItemLoad += new ItemLoadEventHandler(SessionInfo_CommentLoad); sessioninfo.SetStart += new SetStartEventHandler(sessioninfo_SetStart); // tempItemBarcodes = new List<string>(); try { long lRet = sessioninfo.SearchComments( app, strBiblioRecPath, out strError); if (lRet == -1) goto ERROR1; nHitCount = lRet; if (nHitCount > 0) { if (String.IsNullOrEmpty(this.FocusRecPath) == true) { nRet = sessioninfo.GetCommentsSearchResult( app, this.StartIndex, this.PageMaxLines, false, this.Lang, out strError); if (nRet == -1) goto ERROR1; } else { int nFoundStart = -1; // return: // -1 出错 // 0 没有找到 // 1 找到 nRet = sessioninfo.GetCommentsSearchResult( app, this.PageMaxLines, this.FocusRecPath, false, this.Lang, out nFoundStart, out strError); if (nRet == -1 || nRet == 0) goto ERROR1; } } } finally { sessioninfo.SetStart -= new SetStartEventHandler(sessioninfo_SetStart); sessioninfo.ItemLoad -= new ItemLoadEventHandler(SessionInfo_CommentLoad); //tempOutput = null; // this.ItemConverter = null; } // this.ItemBarcodes = this.tempItemBarcodes; this.ResultCount = (int)nHitCount; SetResultInfo((int)nHitCount); bool bHasCommandButton = false; if (nHitCount == 0) { // 如果一个评注也没有, 则不出现命令按钮 PlaceHolder cmdline = (PlaceHolder)this.FindControl("cmdline"); if (cmdline != null) cmdline.Visible = false; // 也可用SetInfo() // this.SetDebugInfo("none", this.GetString("无评注")); // "(无评注)" this.SetInfo(this.GetString("无评注")); // "(无评注)" // 不显示空的表格 if (this.DisplayBlankTable == false) { this.Visible = false; return; } } else if (bHasCommandButton == false && this.ResultCount <= this.PageMaxLines) { // 如果没有命令按钮,并且没有分页器, 则不出现命令按钮区域 PlaceHolder cmdline = (PlaceHolder)this.FindControl("cmdline"); if (cmdline != null) cmdline.Visible = false; } } else if ((this.CommentDispStyle & CommentDispStyle.Comment) == CommentDispStyle.Comment) { if (strCommentXml == "") throw new Exception("评注记录尚未准备好"); // this.tempItemBarcodes = new List<string>(); ItemLoadEventArgs e = new ItemLoadEventArgs(); e.Index = 0; e.Path = strOutputCommentPath; e.Count = 1; e.Xml = strCommentXml; SessionInfo_CommentLoad(this, e); //m_recpathlist.Add(e.Path + "|" + ByteArray.GetHexTimeStampString(e.Timestamp)); } //this.RecPathList = StringUtil.MakePathList(this.m_recpathlist); if (String.IsNullOrEmpty(this.WarningText) == false) SetDebugInfo(this.WarningText); // 根据登录身份决定是否能发表新评注 if (loginstate == LoginState.Public || loginstate == LoginState.NotLogin) { inputline.Visible = false; } else { inputline.Visible = true; string strBiblioState = ""; { string strBiblioXml = ""; /* string strOutputPath = ""; string strMetaData = ""; byte[] timestamp = null; string strStyle = LibraryChannel.GETRES_ALL_STYLE; // TODO: 可以优化为从前面一次性获得 long lRet = sessioninfo.Channel.GetRes( null, this.BiblioRecPath, strStyle, out strBiblioXml, out strMetaData, out timestamp, out strOutputPath, out strError); * */ long lRet = sessioninfo.Channel.GetBiblioInfo( null, this.BiblioRecPath, "", "xml", out strBiblioXml, out strError); if (lRet == -1) { /* strError = "获得种记录 '" + this.RecPath + "' 时出错: " + strError; goto ERROR1; * */ } else { string strOutMarcSyntax = ""; string strMarc = ""; // 将MARCXML格式的xml记录转换为marc机内格式字符串 // parameters: // bWarning ==true, 警告后继续转换,不严格对待错误; = false, 非常严格对待错误,遇到错误后不继续转换 // strMarcSyntax 指示marc语法,如果=="",则自动识别 // strOutMarcSyntax out参数,返回marc,如果strMarcSyntax == "",返回找到marc语法,否则返回与输入参数strMarcSyntax相同的值 nRet = MarcUtil.Xml2Marc(strBiblioXml, true, "", // this.CurMarcSyntax, out strOutMarcSyntax, out strMarc, out strError); if (nRet == -1) goto ERROR1; strBiblioState = MarcDocument.GetFirstSubfield(strMarc, "998", "s"); // 状态 } } bool bOrderComment = false; if (StringUtil.IsInList("订购征询", strBiblioState) == true) bOrderComment = true; CommentControl editor = (CommentControl)this.FindControl("editor"); editor.BiblioRecPath = strBiblioRecPath; if (bOrderComment == true) { editor.EditType = "订购征询"; } else { editor.EditType = "书评"; } editor.EditAction = "new"; editor.RecPath = ""; } /* if (this.Active == false) { inputline.Visible = false; } * */ SetControlActive(); /* LiteralControl newreview_editor_style = (LiteralControl)this.FindControl("newreview_editor_style"); if (this.HideNewReviewEdtior == true) newreview_editor_style.Text = " style='DISPLAY:none'"; * */ base.Render(output); return; ERROR1: this.SetDebugInfo("errorinfo", strError); }