public static long GetServerResultCount( SessionInfo sessioninfo, string strResultsetName) { LibraryChannel channel = sessioninfo.GetChannel(true); try { string strError = ""; Record[] searchresults = null; long lRet = // sessioninfo.Channel. channel.GetSearchResult( null, strResultsetName, 0, 0, "id", "zh", out searchresults, out strError); return(lRet); } finally { sessioninfo.ReturnChannel(channel); } }
// 删除 int Delete( out string strError) { strError = ""; long nRet = 0; OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; MessageData[] messages = new MessageData[1]; MessageData[] output_messages = null; messages[0] = new MessageData(); messages[0].strRecordID = this.RecordID; messages[0].TimeStamp = this.TimeStamp; LibraryChannel channel = sessioninfo.GetChannel(true); try { if (String.IsNullOrEmpty(this.RecordID) == false) { // 如果是废件箱内的消息, 彻底删除 if (BoxesInfo.IsRecycleBin(this.BoxName) == true) { nRet = // sessioninfo.Channel. channel.SetMessage( "delete", "", messages, out output_messages, out strError); } else { // 否则移动到废件箱 nRet = // sessioninfo.Channel. channel.SetMessage( "delete", "movetorecyclebin", messages, out output_messages, out strError); } if (nRet == -1) { return(-1); } this.BoxName = null; // 现在不属于任何信箱 } return(0); } finally { sessioninfo.ReturnChannel(channel); } }
// TODO: 检查boxtype // 装入一个信箱的信息 public int LoadBox( string strUserID, string strBoxType, out string strError) { strError = ""; OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; // 首先默认控件的当前信箱 if (String.IsNullOrEmpty(strBoxType) == true) { strBoxType = this.CurrentBoxType; } // 若还是空, 则默认INBOX if (String.IsNullOrEmpty(strBoxType) == true) { strBoxType = BoxesInfo.INBOX; } string strResultSetName = "messagelist_" + strBoxType; LibraryChannel channel = sessioninfo.GetChannel(true); try { int nTotalCount = 0; MessageData[] messages = null; long nRet = // sessioninfo.Channel. channel.ListMessage( "search", // true, strResultSetName, strBoxType, MessageLevel.Summary, 0, 0, out nTotalCount, out messages, out strError); if (nRet == -1) { return(-1); } this.ResultSetName = strResultSetName; this.ResultCount = nTotalCount; this.CurrentBoxType = strBoxType; return(0); } finally { sessioninfo.ReturnChannel(channel); } }
// 获得历史信息 // parameters: // nStart 开始位置。如果为 -1,表示仅获得事项总数 // return: // -2 尚未登录 // -1 出错 // 其它 符合条件的事项总数 int GetChargingHistory(int nPageNo, int nItemsPerPage, out List <ChargingItemWrapper> results, out string strError) { strError = ""; results = null; // 获得读者证条码号 string strReaderBarcode = ""; { // return: // -1 出错 // 0 成功 // 1 尚未登录 int nRet = this.LoadReaderXml(out strError); if (nRet == -1) { return(0); } if (nRet == 1) { return(-2); } strReaderBarcode = DomUtil.GetElementText(ReaderDom.DocumentElement, "barcode"); } OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; LibraryChannel channel = sessioninfo.GetChannel(true); try { // 获得借阅历史 // parameters: // nPageNo 页号 // nItemsPerPage 每页的事项个数。如果为 -1,表示希望从头获取全部内容 // return: // -1 出错 // 其它 符合条件的事项总数 return((int)//sessioninfo.Channel. channel.LoadChargingHistory( null, strReaderBarcode, "return,lost,read", nPageNo, nItemsPerPage, out results, out strError)); } finally { sessioninfo.ReturnChannel(channel); } }
// 重新检索结果集 public void RefreshList() { OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; string strError = ""; int nTotalCount = 0; MessageData[] messages = null; if (String.IsNullOrEmpty(this.UserID) == true) { // text-level: 内部错误 throw new Exception("UserID为空"); } LibraryChannel channel = sessioninfo.GetChannel(true); try { // 重新发起检索,但暂不获取 long nRet = // sessioninfo.Channel. channel.ListMessage( "search", // true, this.ResultSetName, this.CurrentBoxType, MessageLevel.Summary, 0, 0, out nTotalCount, out messages, out strError); if (nRet == -1) { // text-level: 内部错误 this.SetDebugInfo("errorinfo", "刷新时检索失败: " + strError); } else { this.ResultCount = nTotalCount; } } finally { sessioninfo.ReturnChannel(channel); } }
protected override void Render(HtmlTextWriter writer) { OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; long nRet = 0; int nPageNo = this.StartIndex / this.PageMaxLines; if (nPageNo >= this.PageCount) // 如果超过最后一页 { lastpage_Click(null, null); } SetResultInfo(); string strError = ""; List <string> tempids = new List <string>(); if (this.ResultCount != 0) { MessageData[] messages = null; LibraryChannel channel = sessioninfo.GetChannel(true); try { int nTotalCount = 0; nRet = // sessioninfo.Channel. channel.ListMessage( "", // false, this.ResultSetName, this.CurrentBoxType, MessageLevel.Summary, this.StartIndex, this.PageMaxLines, out nTotalCount, out messages, out strError); if (nRet == -1) { throw new Exception(strError); } } finally { sessioninfo.ReturnChannel(channel); } // 显示本页中的浏览行 for (int i = 0; i < this.PageMaxLines; i++) { MessageData data = null; if (i < messages.Length) { data = messages[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"); CheckBox checkbox = (CheckBox)this.FindControl("line" + Convert.ToString(i) + "_checkbox"); LiteralControl sender = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_sender"); LiteralControl recipient = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_recipient"); LiteralControl subject = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_subject"); LiteralControl date = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_date"); LiteralControl size = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_size"); LiteralControl classname = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_classname"); if (data == null) { checkbox.Visible = false; subject.Text = " "; continue; } checkbox.Visible = true; tempids.Add(data.strRecordID); // 序号 string strNo = " "; strNo = Convert.ToString(i + this.StartIndex + 1); no.Text = strNo; string strDetailUrl = "./message.aspx?id=" + data.strRecordID; if (data.strSubject == "") { data.strSubject = this.GetString("无"); // "(无)" } sender.Text = data.strSender; recipient.Text = data.strRecipient; subject.Text = "<a href='" + strDetailUrl + "'>" + data.strSubject + "</a>"; date.Text = DateTimeUtil.LocalTime(data.strCreateTime); size.Text = data.strSize; if (data.Touched == true) { classname.Text = "content"; } else { classname.Text = "content new"; } } // end of for this.LineCount = Math.Max(this.LineCount, this.PageMaxLines); } else { // 显示空行 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); } line.Visible = true; CheckBox checkbox = (CheckBox)this.FindControl("line" + Convert.ToString(i) + "_checkbox"); checkbox.Visible = false; LiteralControl subject = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_subject"); subject.Text = " "; } } this.ItemIDs = tempids; // 设置删除按钮文字 Button deletebutton = (Button)this.FindControl("delete"); if (BoxesInfo.IsRecycleBin(this.CurrentBoxType) == true) { deletebutton.Text = this.GetString("永久删除选定的消息"); } else { deletebutton.Text = this.GetString("将选定的消息移至废件箱"); } // 设置删除全部按钮文字 Button deleteallbutton = (Button)this.FindControl("deleteall"); if (BoxesInfo.IsRecycleBin(this.CurrentBoxType) == true) { deleteallbutton.Text = this.GetString("永久删除全部消息"); } else { deleteallbutton.Text = this.GetString("将全部消息移至废件箱"); } base.Render(writer); }
protected void Page_Load(object sender, EventArgs e) { if (WebUtil.PrepareEnvironment(this, ref app, ref sessioninfo) == false) { return; } // 是否登录? if (string.IsNullOrEmpty(sessioninfo.UserID) == true) { sessioninfo.UserID = "public"; sessioninfo.IsReader = false; } string strError = ""; int nRet = 0; string strBarcode = this.Request["barcode"]; if (string.IsNullOrEmpty(strBarcode) == true) { strError = "需要指定barcode参数"; goto ERROR1; } string strLang = this.Request["lang"]; if (string.IsNullOrEmpty(strLang) == false) { //this.UICulture = strLang; //this.Culture = strLang; try { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(strLang); Thread.CurrentThread.CurrentUICulture = new CultureInfo(strLang); } catch { } //this.Session["lang"] = Thread.CurrentThread.CurrentUICulture.Name; } #if NO // test this.Response.Write("test"); this.Response.End(); return; #endif if (StringUtil.HasHead(strBarcode, "biblio_html:") == true) { string strBiblioRecPath = strBarcode.Substring("biblio_html:".Length); // 获得书目记录XML string[] formats = new string[1]; formats[0] = "xml"; byte[] timestamp = null; string[] results = null; // 2016/1/24 if (string.IsNullOrEmpty(sessioninfo.UserID) == true) { strError = "sessioninfo.UserID 为空 (sessioninfo.Parameters='" + sessioninfo.Parameters + "') {F548F93A-3ED7-4F7A-8729-CD65E375D360}"; goto ERROR1; } LibraryChannel channel = null; #if CHANNEL_POOL channel = sessioninfo.GetChannel(true /*, sessioninfo.Parameters*/); #else channel = sessioninfo.GetChannel(false); #endif long lRet = channel.GetBiblioInfos( null, strBiblioRecPath, "", formats, out results, out timestamp, out strError); #if CHANNEL_POOL sessioninfo.ReturnChannel(channel); #endif if (lRet == -1) { strError = "获得书目记录 '" + strBiblioRecPath + "' 时出错: " + strError; goto ERROR1; } if (lRet == 0) { strError = "书目记录 '" + strBiblioRecPath + "' 不存在"; goto ERROR1; } if (results == null || results.Length < 1) { strError = "results error {87C72690-662D-48E3-920D-B0E0C5D53726}"; goto ERROR1; } string strBiblioXml = results[0]; // 创建HTML string strBiblioDbName = StringUtil.GetDbName(strBiblioRecPath); // 需要从内核映射过来文件 string strLocalPath = ""; nRet = app.MapKernelScriptFile( // null, // sessioninfo, strBiblioDbName, "./cfgs/opac_biblio.fltx", // OPAC查询固定认这个角色的配置文件,作为公共查询书目格式创建的脚本。而流通前端,创建书目格式的时候,找的是loan_biblio.fltx配置文件 out strLocalPath, out strError); if (nRet == -1) { goto ERROR1; } // 将种记录数据从XML格式转换为HTML格式 string strResult = ""; KeyValueCollection result_params = null; string strFilterFileName = strLocalPath; // app.CfgDir + "\\biblio.fltx"; nRet = app.ConvertBiblioXmlToHtml( strFilterFileName, strBiblioXml, strBiblioRecPath, out strResult, out result_params, out strError); if (nRet == -1) { goto ERROR1; } this.Response.Write(strResult); this.Response.End(); return; } else if (StringUtil.HasHead(strBarcode, "formated:") == true) { strBarcode = strBarcode.Substring("formated:".Length); string strArrivedItemBarcode = ""; string[] barcodes = strBarcode.Split(new char[] { ',' }); string strTemp = ""; foreach (string barcode in barcodes) { if (string.IsNullOrEmpty(barcode) == true) { continue; } if (string.IsNullOrEmpty(strTemp) == false) { strTemp += ","; } if (barcode[0] == '!') { strArrivedItemBarcode = barcode.Substring(1); strTemp += strArrivedItemBarcode; } else { strTemp += barcode; } } strBarcode = strTemp; string strStyle = "html"; // this.Request["style"]; string strOtherParams = ""; // this.Request["otherparams"]; LibraryChannel channel = null; #if CHANNEL_POOL channel = sessioninfo.GetChannel(true /*, sessioninfo.Parameters*/); // 2016/1/25 增加第二参数 #else channel = sessioninfo.GetChannel(false); #endif // 获得一系列册的摘要字符串 // // paramters: // strStyle 风格。逗号间隔的列表。如果包含html text表示格式。forcelogin // strOtherParams <a>命令中其余的参数。例如" target='_blank' "可以用来打开新窗口 string strResult = ReservationInfoControl.GetBarcodesSummary( app, channel, strBarcode, strArrivedItemBarcode, strStyle, strOtherParams); #if CHANNEL_POOL sessioninfo.ReturnChannel(channel); #endif this.Response.Write(strResult); this.Response.End(); return; } else { // 2016/1/25 if (string.IsNullOrEmpty(sessioninfo.UserID) == true) { strError = "sessioninfo.UserID 为空 (sessioninfo.Parameters='" + sessioninfo.Parameters + "') {9A54CD5B-B1CF-43D2-8AE3-1969B5873055}"; goto ERROR1; } // 获得摘要 string strSummary = ""; string strBiblioRecPath = ""; LibraryChannel channel = null; #if CHANNEL_POOL channel = sessioninfo.GetChannel(true /*, sessioninfo.Parameters*/); // 2016/1/25 增加第二参数 #else channel = sessioninfo.GetChannel(false); #endif long lRet = channel.GetBiblioSummary( null, strBarcode, null, null, out strBiblioRecPath, out strSummary, out strError); #if CHANNEL_POOL sessioninfo.ReturnChannel(channel); #endif if (lRet == -1 || lRet == 0) { strSummary = strError; } this.Response.Write(strSummary); this.Response.End(); } return; ERROR1: this.Response.Write(strError); this.Response.End(); }
void renewButton_Click(object sender, EventArgs e) { List <string> barcodes = this.GetCheckedBorrowBarcodes(); if (barcodes.Count == 0) { // text-level: 用户提示 this.SetDebugInfo("errorinfo", this.GetString("尚未选择要续借的事项")); // "操作失败。尚未选择要续借的事项。" return; } OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; LibraryChannel channel = sessioninfo.GetChannel(true); try { for (int i = 0; i < barcodes.Count; i++) { string strItemBarcode = barcodes[i]; //string strItemRecord = ""; //string strReaderRecord = ""; string strReaderBarcode = ""; if (String.IsNullOrEmpty(this.ReaderBarcode) == false) { strReaderBarcode = this.ReaderBarcode; } else { strReaderBarcode = sessioninfo.ReaderInfo.Barcode; } if (String.IsNullOrEmpty(strReaderBarcode) == true) { // text-level: 用户提示 this.SetDebugInfo("errorinfo", this.GetString("尚未指定读者证条码号")); // "尚未指定读者证条码号。操作失败。" return; } string[] aDupPath = null; string[] item_records = null; string[] reader_records = null; string[] biblio_records = null; BorrowInfo borrow_info = null; string strError = ""; string strOutputReaderBarcode = ""; long lRet = // sessioninfo.Channel. channel.Borrow( null, true, strReaderBarcode, strItemBarcode, null, false, null, "", // style "", out item_records, "", out reader_records, "", out biblio_records, out aDupPath, out strOutputReaderBarcode, out borrow_info, out strError); if (lRet == -1) { this.SetDebugInfo("errorinfo", strError); return; } // 清除读者记录缓存,以便借阅信息得到刷新 sessioninfo.ClearLoginReaderDomCache(); } } finally { sessioninfo.ReturnChannel(channel); } // text-level: 用户提示 this.SetDebugInfo(this.GetString("续借成功")); // "续借成功。" }
// 根据记录数量的多少,少的时候可以立即返回结果,多的时候用线程后台处理,然后可以随时查询状态 // 线程用线程池,避免过多耗用线程数目 // 根据结果集名,提取全部书目 XML 记录,然后批处理经过 MarcFilter 过滤,创建若干个子结果集 // 最基本的功能是返回子结果集的显示名,文件名,包含记录数量,供前端显示在界面上 // 较为深入的功能是,将子结果集按照 key 排序归并,而显示出二级条目和数量。二级结果集是子结果集的子结果集 // TODO: 如何及时清理Task对象,避免内存过度膨胀? 是否仅保存最新10个Task对象? void GetFilterInfo( string strResultsetName, string strSelected, string strLang) { string strError = ""; GetFilterInfo result_info = new GetFilterInfo(); if (string.IsNullOrEmpty(strResultsetName) == true) { strError = "结果集名不应为空"; goto ERROR1; } FilterTask t = app.FindFilterTask(strResultsetName); // Task对象是利用 Session 内结果集名来进行管理的 if (t == null) { // 如果一个结果集还没有被后台任务处理,就立即启动一个后台任务 t = new FilterTask(); app.SetFilterTask(strResultsetName, t); string strGlobalResultSetName = ""; bool bShare = false; if (strResultsetName[0] == '#') { strGlobalResultSetName = strResultsetName.Substring(1); } else { // 构造全局结果集名 strGlobalResultSetName = sessioninfo.GetHashCode() + "_" + strResultsetName; LibraryChannel channel = sessioninfo.GetChannel(true); try { // 先把结果集共享 // 管理结果集 // parameters: // strAction share/remove 分别表示共享为全局结果集对象/删除全局结果集对象 long lRet = // sessioninfo.Channel. channel.ManageSearchResult( null, "share", strResultsetName, strGlobalResultSetName, out strError); if (lRet == -1) { goto ERROR1; } bShare = true; } finally { sessioninfo.ReturnChannel(channel); } } FilterTaskInput i = new FilterTaskInput(); i.App = app; i.FilterFileName = Path.Combine(app.DataDir, "cfgs/facet.fltx"); i.ResultSetName = strGlobalResultSetName; i.ShareResultSet = bShare; // i.SessionInfo = sessioninfo; i.TempDir = app.TempDir; i.TaskName = strResultsetName; // Task对象是利用Session内结果集名来进行管理的 i.MaxCount = 1000; // i.aggregation_names = new List<string>() {"author"}; XmlDocument def_dom = GetFacetDefDom(out strError); if (def_dom == null) { goto ERROR1; } i.DefDom = def_dom; ThreadPool.QueueUserWorkItem(t.ThreadPoolCallBack, i); strError = "#pending"; // 表示正在处理,希望前端稍后重新访问 goto ERROR1; } else { if (t.TaskState == TaskState.Processing) { if (t.ProgressRange != 0) { result_info.ProgressValue = (int)(((double)t.ProgressValue / (double)t.ProgressRange) * 100); } strError = "#pending"; // 表示正在处理,希望前端稍后重新访问 goto ERROR1; } if (string.IsNullOrEmpty(t.ErrorInfo) == false) { strError = t.ErrorInfo; goto ERROR1; } GC.Collect(); // 试着释放 Hashtable 等 long lHitCount = MyWebPage.GetServerResultCount(sessioninfo, strResultsetName); XmlDocument def_dom = GetFacetDefDom(out strError); if (def_dom == null) { goto ERROR1; } this.m_facetDom = def_dom; this.m_strLang = strLang; try { // 创建FilterInfo数组 result_info.Items = ResultsetFilter.BuildFilterInfos( strResultsetName, lHitCount, strSelected, GetKeyNameCaption, t.ResultItems, app.TempDir, // sessioninfo.GetTempDir(), 10); // GC.Collect(); // 担心 DpResultSet 未能回收 } catch (Exception ex) { strError = ExceptionUtil.GetAutoText(ex); goto ERROR1; } if (t.HitCount > 1000) { result_info.Comment = "分面导航只提取了当前结果集的前 1000 条记录"; } } // 返回一级节点的名字和包含记录数量 this.Response.Write(MyWebPage.GetResultString(result_info)); this.Response.End(); return; ERROR1: result_info.ErrorString = strError; this.Response.Write(MyWebPage.GetResultString(result_info)); this.Response.End(); }
// 预约:删除请求 void reservationDeleteButton_Click(object sender, EventArgs e) { string strBarcodeList = GetChekcedReservationBarcodes(); if (String.IsNullOrEmpty(strBarcodeList) == true) { // text-level: 用户提示 this.SetDebugInfo("errorinfo", this.GetString("尚未选择要删除的预约事项")); // "尚未选择要删除的预约事项。" return; } OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; string strReaderBarcode = ""; if (String.IsNullOrEmpty(this.ReaderBarcode) == false) { strReaderBarcode = this.ReaderBarcode; } else { strReaderBarcode = sessioninfo.ReaderInfo.Barcode; } if (String.IsNullOrEmpty(strReaderBarcode) == true) { // text-level: 用户提示 this.SetDebugInfo("errorinfo", this.GetString("尚未指定读者证条码号。操作失败")); // "尚未指定读者证条码号。操作失败。" return; } LibraryChannel channel = sessioninfo.GetChannel(true); try { string strError = ""; long lRet = // sessioninfo.Channel. channel.Reservation( null, "delete", strReaderBarcode, strBarcodeList, out strError); if (lRet == -1) { this.SetDebugInfo("errorinfo", strError); } else { // text-level: 用户提示 string strMessage = this.GetString("删除预约信息成功。请看预约列表"); // "删除预约信息成功。请看预约列表。" // 成功时也可能有提示信息 if (String.IsNullOrEmpty(strError) == false) { strMessage += "<br/><br/>" + strError; } this.SetDebugInfo(strMessage); } } finally { sessioninfo.ReturnChannel(channel); } // 清除读者记录缓存 sessioninfo.ClearLoginReaderDomCache(); }
void CreateBoxListControls(PlaceHolder boxlist) { OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; bool bDetectFullCount = true; // 是否首次就探测所有信箱的未读数字 LiteralControl literal = new LiteralControl(); literal.Text = this.GetPrefixString( this.GetString("信箱"), "boxes_wrapper"); literal.Text += "<table class='boxes'>"; // width='100%' cellspacing='1' cellpadding='4' boxlist.Controls.Add(literal); LinkButton linkbutton = null; int nInboxUntouchedCount = 0; // 收件箱中的未读信件数目 LibraryChannel channel = sessioninfo.GetChannel(true); try { for (int i = 0; i < app.BoxesInfo.Boxes.Count; i++) { Box box = app.BoxesInfo.Boxes[i]; string strClass = "box"; if (/*box.Name == this.CurrentBoxType*/ box.Type == this.CurrentBoxType) { strClass = "box active"; } literal = new LiteralControl(); literal.Text = "<tr class='" + strClass + "'><td class='" + strClass + "' nowrap>"; boxlist.Controls.Add(literal); int nCount = 0; if (bDetectFullCount == true) { nCount = // sessioninfo.Channel. channel.GetUntouchedMessageCount( box.Name); if (nCount != -1) { // untouchedcountlist[box.Name] = (object)nCount; } if (box.Type == BoxesInfo.INBOX) { nInboxUntouchedCount = nCount; } } linkbutton = new LinkButton(); linkbutton.ID = box.Name; string strCaption = app.BoxesInfo.GetString(box.Type); // 获得信箱对于当前语言的名字 2009/7/14 changed if (nCount != 0) { linkbutton.Text = strCaption + "(" + Convert.ToString(nCount) + ")"; } else { linkbutton.Text = strCaption; } linkbutton.Click += new EventHandler(linkbutton_Click); boxlist.Controls.Add(linkbutton); literal = new LiteralControl(); literal.Text = "</td></tr>"; boxlist.Controls.Add(literal); } } finally { sessioninfo.ReturnChannel(channel); } // this.UntouchedCountList = untouchedcountlist; // 更新内容 literal = new LiteralControl(); literal.Text = "<tr class='cmd'><td class='newmessage'>"; boxlist.Controls.Add(literal); Button newmessagebutton = new Button(); newmessagebutton.ID = "newmessage"; newmessagebutton.Text = this.GetString("撰写消息"); newmessagebutton.CssClass = "newmessage"; newmessagebutton.Click += new EventHandler(newmessage_Click); boxlist.Controls.Add(newmessagebutton); literal = new LiteralControl(); literal.Text = "</td></tr>"; boxlist.Controls.Add(literal); literal = new LiteralControl(); literal.Text = "</table>" + this.GetPostfixString(); boxlist.Controls.Add(literal); }
// 删除选择的消息 void deletebutton_Click(object sender, EventArgs e) { OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; List <string> ids = new List <string>(); for (int i = 0; i < this.LineCount; i++) { CheckBox checkbox = (CheckBox)this.FindControl("line" + Convert.ToString(i) + "_checkbox"); if (checkbox.Checked == true) { if (this.ItemIDs.Count <= i) { // text-level: 内部错误 this.SetDebugInfo("errorinfo", "ItemIDs失效..."); return; } ids.Add(this.ItemIDs[i]); checkbox.Checked = false; } } if (ids.Count == 0) { // text-level: 用户提示 this.SetDebugInfo(this.GetString("尚未选择任何消息")); return; } bool bMoveToRecycleBin = true; if (BoxesInfo.IsRecycleBin(this.CurrentBoxType) == true) { bMoveToRecycleBin = false; } else { bMoveToRecycleBin = true; } MessageData[] messages = new MessageData[ids.Count]; for (int i = 0; i < ids.Count; i++) { messages[i] = new MessageData(); messages[i].strRecordID = ids[i]; } LibraryChannel channel = sessioninfo.GetChannel(true); try { MessageData[] output_messages = null; string strError = ""; long nRet = // sessioninfo.Channel. channel.SetMessage("delete", bMoveToRecycleBin == true ? "movetorecyclebin" : "", messages, out output_messages, out strError); if (nRet == -1) { this.SetDebugInfo("errorinfo", strError); } else { if (bMoveToRecycleBin == true) { // text-level: 用户提示 this.SetDebugInfo( string.Format(this.GetString("已将s个消息移动到废件箱"), // "已将 {0} 个消息移动到废件箱。" ids.Count.ToString())); // "已将 " + ids.Count + " 个消息移动到废件箱。"); } else { // text-level: 用户提示 this.SetDebugInfo( string.Format(this.GetString("已将s个消息永久删除"), // "已将 {0} 个消息永久删除。" ids.Count.ToString())); // "已将 " + ids.Count + " 个消息永久删除。"); } this.RefreshList(); // 刷新当前结果集显示 } } finally { sessioninfo.ReturnChannel(channel); } }
// 发送 int Send(out string strError) { OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; strError = ""; TextBox recipient = (TextBox)this.FindControl("recipient"); if (String.IsNullOrEmpty(recipient.Text) == true) { // text-level: 用户提示 strError = this.GetString("尚未填写收件人"); // "尚未填写收件人" return(-1); } TextBox subject = (TextBox)this.FindControl("subject"); if (String.IsNullOrEmpty(subject.Text) == true) { // text-level: 用户提示 strError = this.GetString("尚未填写主题"); // "尚未填写主题" return(-1); } TextBox sender = (TextBox)this.FindControl("sender"); sender.Text = this.UserID; TextBox content = (TextBox)this.FindControl("content"); MessageData[] messages = new MessageData[1]; MessageData[] output_messages = null; messages[0] = new MessageData(); messages[0].strRecipient = recipient.Text; messages[0].strSender = sender.Text; messages[0].strSubject = subject.Text; messages[0].strMime = "text"; messages[0].strBody = content.Text; //messages[0].strRecordID = strOldRecordID; // string strOldRecordID, //messages[0].TimeStamp = baOldTimeStamp; // byte [] baOldTimeStamp, LibraryChannel channel = sessioninfo.GetChannel(true); try { long nRet = // sessioninfo.Channel. channel.SetMessage( "send", "", messages, out output_messages, out strError); if (nRet == -1) { return(-1); } // 如果来自草稿箱, 则需要从中永久删除 if (BoxesInfo.IsTemp(this.BoxName) == true) { messages = new MessageData[1]; output_messages = null; messages[0] = new MessageData(); messages[0].strRecordID = this.RecordID; // string strOldRecordID, messages[0].TimeStamp = this.TimeStamp; // byte [] baOldTimeStamp, nRet = // sessioninfo.Channel. channel.SetMessage( "delete", "", messages, out output_messages, out strError); if (nRet == -1) { return(-1); } this.BoxName = null; // 现在不属于任何信箱 } return(0); } finally { sessioninfo.ReturnChannel(channel); } }
// 保存到草稿箱 int SaveToTemp(out string strError) { OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; strError = ""; string strOldRecordID = ""; byte[] baOldTimeStamp = null; // 如果是来自草稿的记录 if (BoxesInfo.IsTemp(this.BoxName) == true) { strOldRecordID = this.RecordID; baOldTimeStamp = this.TimeStamp; } TextBox recipient = (TextBox)this.FindControl("recipient"); TextBox subject = (TextBox)this.FindControl("subject"); TextBox sender = (TextBox)this.FindControl("sender"); sender.Text = this.UserID; TextBox content = (TextBox)this.FindControl("content"); //byte[] baOutputTimeStamp = null; //string strOutputID = ""; MessageData[] messages = new MessageData[1]; MessageData[] output_messages = null; messages[0] = new MessageData(); messages[0].strRecipient = recipient.Text; messages[0].strSender = sender.Text; messages[0].strSubject = subject.Text; messages[0].strMime = "text"; messages[0].strBody = content.Text; messages[0].strRecordID = strOldRecordID; // string strOldRecordID, messages[0].TimeStamp = baOldTimeStamp; // byte [] baOldTimeStamp, LibraryChannel channel = sessioninfo.GetChannel(true); try { long nRet = // sessioninfo.Channel. channel.SetMessage( "save", "", messages, out output_messages, out strError); if (nRet == -1) { return(-1); } } finally { sessioninfo.ReturnChannel(channel); } if (output_messages == null || output_messages.Length < 1) { strError = "output_messages error"; return(-1); } // 为了便于再次修改后保存 this.RecordID = output_messages[0].strRecordID; this.TimeStamp = output_messages[0].TimeStamp; return(0); }
int PrepareBiblioRecord( out string strError) { strError = ""; int nRet = 0; long lRet = 0; // string strOutputPath = ""; if (string.IsNullOrEmpty(this.RecPath) == true) { return(0); // 此时无法进行初始化 } OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; string strBiblioXml = ""; LibraryChannel channel = sessioninfo.GetChannel(true); try { // string strBiblioState = ""; byte[] timestamp = null; string[] formats = new string[1]; formats[0] = "xml"; string[] results = null; lRet = // sessioninfo.Channel. channel.GetBiblioInfos( null, this.RecPath, "", formats, out results, out timestamp, out strError); if (lRet == -1) { strError = "获得书目记录 '" + this.RecPath + "' 时出错: " + strError; goto ERROR1; } if (lRet == 0) { strError = "书目记录 '" + this.RecPath + "' 不存在"; goto ERROR1; } if (results == null || results.Length < 1) { strError = "results error {A9217775-645E-42F1-8307-22B26C0E1D69}"; goto ERROR1; } strBiblioXml = results[0]; this.m_strXml = strBiblioXml; this.Timestamp = ByteArray.GetHexTimeStampString(timestamp); this.BiblioRecPath = this.RecPath; } finally { sessioninfo.ReturnChannel(channel); } if (app.SearchLog != null) { SearchLogItem log = new SearchLogItem(); log.IP = this.Page.Request.UserHostAddress.ToString(); log.Query = ""; log.Time = DateTime.UtcNow; log.HitCount = 1; log.Format = "biblio"; log.RecPath = this.RecPath; app.SearchLog.AddLogItem(log); } string strMarc = ""; // 转换为MARC { string strOutMarcSyntax = ""; // 将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; } this.m_strMARC = strMarc; } bool bAjax = true; if (this.DisableAjax == true) { bAjax = false; } else { if (app != null && app.WebUiDom != null && app.WebUiDom.DocumentElement != null) { XmlNode nodeBiblioControl = app.WebUiDom.DocumentElement.SelectSingleNode( "biblioControl"); if (nodeBiblioControl != null) { DomUtil.GetBooleanParam(nodeBiblioControl, "ajax", true, out bAjax, out strError); } } } if (bAjax == false) { string strBiblio = ""; string strBiblioDbName = StringUtil.GetDbName(this.RecPath); // 需要从内核映射过来文件 string strLocalPath = ""; nRet = app.MapKernelScriptFile( // null, // sessioninfo, strBiblioDbName, "./cfgs/opac_biblio.fltx", // OPAC查询固定认这个角色的配置文件,作为公共查询书目格式创建的脚本。而流通前端,创建书目格式的时候,找的是loan_biblio.fltx配置文件 out strLocalPath, out strError); if (nRet == -1) { goto ERROR1; } // 将种记录数据从XML格式转换为HTML格式 KeyValueCollection result_params = null; // 2006/11/28 changed string strFilterFileName = strLocalPath; // app.CfgDir + "\\biblio.fltx"; nRet = app.ConvertBiblioXmlToHtml( strFilterFileName, strBiblioXml, this.RecPath, out strBiblio, out result_params, out strError); if (nRet == -1) { goto ERROR1; } // TODO: Render的时候设置,已经晚了半拍 // 要想办法在全部Render前得到题名和进行设置 if (this.AutoSetPageTitle == true && result_params != null && result_params.Count > 0) { string strTitle = result_params["title"].Value; if (string.IsNullOrEmpty(strTitle) == false) { this.Page.Title = strTitle; } bool bHasDC = false; // 探测一下,是否有至少一个DC.开头的 key ? foreach (KeyValue item in result_params) { if (StringUtil.HasHead(item.Key, "DC.") == true) { bHasDC = true; break; } } if (bHasDC == true) { // <header profile="http://dublincore.org/documents/2008/08/04/dc-html/"> this.Page.Header.Attributes.Add("profile", "http://dublincore.org/documents/2008/08/04/dc-html/"); // DC rel // HtmlLink link = new HtmlLink(); link.Href = "http://purl.org/dc/elements/1.1/"; link.Attributes.Add("rel", "schema.DC"); this.Page.Header.Controls.Add(link); // <link rel="schema.DCTERMS" href="http://purl.org/dc/terms/" > link = new HtmlLink(); link.Href = "http://purl.org/dc/terms/"; link.Attributes.Add("rel", "schema.DCTERMS"); this.Page.Header.Controls.Add(link); foreach (KeyValue item in result_params) { if (StringUtil.HasHead(item.Key, "DC.") == false && StringUtil.HasHead(item.Key, "DCTERMS.") == false) { continue; } HtmlMeta meta = new HtmlMeta(); meta.Name = item.Key; meta.Content = item.Value; if (StringUtil.HasHead(item.Value, "urn:") == true || StringUtil.IsHttpUrl(item.Value) == true || StringUtil.HasHead(item.Value, "info:") == true ) { meta.Attributes.Add("scheme", "DCTERMS.URI"); } this.Page.Header.Controls.Add(meta); } } } this.m_strOpacBiblio = strBiblio; } return(0); ERROR1: return(-1); }
void submit_button_Click(object sender, EventArgs e) { int nRet = 0; long lRet = 0; string strError = ""; // string strOutputPath = ""; 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; } if (bManager == false) { strError = "当前帐户不具备 managecomment 权限, 不能进行修改书目状态的操作"; goto ERROR1; } LibraryChannel channel = sessioninfo.GetChannel(true); try { string strBiblioRecPath = this.BiblioRecPath; byte[] timestamp = null; string strBiblioXml = ""; string[] formats = new string[1]; formats[0] = "xml"; string[] results = null; lRet = // sessioninfo.Channel. channel.GetBiblioInfos( null, strBiblioRecPath, "", formats, out results, out timestamp, out strError); if (lRet == -1) { strError = "获得书目记录 '" + strBiblioRecPath + "' 时出错: " + strError; goto ERROR1; } if (lRet == 0) { strError = "书目记录 '" + strBiblioRecPath + "' 不存在"; goto ERROR1; } if (results == null || results.Length < 1) { strError = "results error {11AD709F-2DBC-41DE-8129-184FFAD59815}"; goto ERROR1; } strBiblioXml = results[0]; byte[] old_timestamp = ByteArray.GetTimeStampByteArray(this.Timestamp); if (ByteArray.Compare(timestamp, old_timestamp) != 0) { strError = "修改被拒绝。因为记录 '" + strBiblioRecPath + "' 在保存前已经被其他人修改过。请重新装载"; goto ERROR1; } 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; } string strBiblioState = MarcDocument.GetFirstSubfield(strMarc, "998", "s"); // 状态 // 修改998字段 string strOldBiblioState = strBiblioState; this.GetStateValueFromControls(ref strBiblioState); if (strOldBiblioState == strBiblioState) { // 也退出编辑态 cancel_button_Click(this, new EventArgs()); strError = "状态没有发生变化,放弃保存书目记录"; goto ERROR1; } MarcUtil.SetFirstSubfield(ref strMarc, "998", "s", strBiblioState); // 保存 // 将MARC格式转换为XML格式 // 2015/10/12 从 Marc2Xml() 修改为 Marc2XmlEx() string strXml = strBiblioXml; nRet = MarcUtil.Marc2XmlEx( strMarc, strOutMarcSyntax, ref strXml, out strError); if (nRet == -1) { goto ERROR1; } string strOutputBiblioRecPath = ""; byte[] baOutputTimestamp = null; lRet = // sessioninfo.Channel. channel.SetBiblioInfo( null, "change", strBiblioRecPath, "xml", strXml, timestamp, "", out strOutputBiblioRecPath, out baOutputTimestamp, out strError); if (lRet == -1) { goto ERROR1; } this.Timestamp = ByteArray.GetHexTimeStampString(baOutputTimestamp); return; } finally { sessioninfo.ReturnChannel(channel); } ERROR1: this.SetDebugInfo("errorinfo", strError); }
// 提前获得记录体,然后可以获得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); }
// 删除全部的消息 void deleteallbutton_Click(object sender, EventArgs e) { string strError = ""; long nRet = 0; bool bMoveToRecycleBin = true; OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; if (BoxesInfo.IsRecycleBin(this.CurrentBoxType) == true) { bMoveToRecycleBin = false; } else { bMoveToRecycleBin = true; } string strStyle = this.CurrentBoxType; if (bMoveToRecycleBin == true) { strStyle += ",movetorecyclebin"; } LibraryChannel channel = sessioninfo.GetChannel(true); try { MessageData[] output_messages = null; nRet = // sessioninfo.Channel. channel.SetMessage("deleteall", strStyle, null, out output_messages, out strError); if (nRet == -1) { this.SetDebugInfo("errorinfo", strError); return; } } finally { sessioninfo.ReturnChannel(channel); } if (bMoveToRecycleBin == true) { // text-level: 用户提示 this.SetDebugInfo( string.Format(this.GetString("已将s个消息移动到废件箱"), // "已将 {0} 个消息移动到废件箱。" nRet.ToString())); // "已将 " + nStart.ToString() + " 个消息移动到废件箱。" } else { // text-level: 用户提示 this.SetDebugInfo( string.Format(this.GetString("已将s个消息永久删除"), // "已将 {0} 个消息永久删除。" nRet.ToString())); // "已将 " + nStart.ToString() + " 个消息永久删除。" } this.RefreshList(); // 刷新当前结果集显示 }
void submit_button_Click(object sender, EventArgs e) { string strError = ""; OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; string strCreator = sessioninfo.UserID; // 先创建一条书目记录 TextBox biblio_title = (TextBox)this.FindControl("edit_biblio_title"); TextBox biblio_author = (TextBox)this.FindControl("edit_biblio_author"); TextBox biblio_publisher = (TextBox)this.FindControl("edit_biblio_publisher"); TextBox biblio_isbn = (TextBox)this.FindControl("edit_biblio_isbn"); TextBox biblio_price = (TextBox)this.FindControl("edit_biblio_price"); TextBox biblio_summary = (TextBox)this.FindControl("edit_biblio_summary"); // 检查必备字段 if (String.IsNullOrEmpty(biblio_title.Text) == true) { strError = "尚未输入书名/刊名"; goto ERROR1; } DropDownList store_dbname = (DropDownList)this.FindControl("store_dbname"); string strBiblioDbName = store_dbname.SelectedValue; if (String.IsNullOrEmpty(strBiblioDbName) == true) { strError = "尚未选定目标库"; goto ERROR1; } string strBiblioRecPath = ""; string strMarcSyntax = ""; string strMARC = ""; // 得到目标书目库的MARC格式 ItemDbCfg cfg = app.GetBiblioDbCfg(strBiblioDbName); if (cfg == null) { strError = "目标库 '" + strBiblioDbName + "' 不是系统定义的的书目库"; goto ERROR1; } strMarcSyntax = cfg.BiblioDbSyntax; int nRet = BuildBiblioRecord( strMarcSyntax, biblio_title.Text, biblio_author.Text, biblio_publisher.Text, biblio_isbn.Text, biblio_price.Text, biblio_summary.Text, strCreator, out strMARC, out strError); if (nRet == -1) { goto ERROR1; } // 保存 // 将MARC格式转换为XML格式 nRet = MarcUtil.Marc2Xml( strMARC, strMarcSyntax, out string strXml, out strError); if (nRet == -1) { goto ERROR1; } #if NO SessionInfo temp_sessioninfo = new SessionInfo(app); temp_sessioninfo.UserID = app.ManagerUserName; temp_sessioninfo.Password = app.ManagerPassword; temp_sessioninfo.IsReader = false; #endif string strOutputBiblioRecPath = ""; LibraryChannel channel = sessioninfo.GetChannel(true); try { strBiblioRecPath = strBiblioDbName + "/?"; long lRet = // temp_sessioninfo.Channel. channel.SetBiblioInfo( null, "new", strBiblioRecPath, "xml", strXml, null, "", out strOutputBiblioRecPath, out byte[] baOutputTimestamp, out strError); if (lRet == -1) { strError = "创建书目记录发生错误: " + strError; goto ERROR1; } } finally { #if NO temp_sessioninfo.CloseSession(); temp_sessioninfo = null; #endif sessioninfo.ReturnChannel(channel); } // 清除每个输入域的内容 biblio_title.Text = ""; biblio_author.Text = ""; biblio_publisher.Text = ""; biblio_isbn.Text = ""; biblio_summary.Text = ""; biblio_price.Text = ""; strBiblioRecPath = strOutputBiblioRecPath; CommentControl commentcontrol = (CommentControl)this.FindControl("commentcontrol"); // 创建评注记录 if (String.IsNullOrEmpty(commentcontrol.EditTitle) == false || String.IsNullOrEmpty(commentcontrol.EditContent) == false) { string strWarning = ""; commentcontrol.BiblioRecPath = strBiblioRecPath; nRet = commentcontrol.DoSubmit( out strWarning, out strError); if (nRet == -1) { goto ERROR1; } if (String.IsNullOrEmpty(strWarning) == false) { this.SetDebugInfo("warninginfo", strWarning); } } string strUrl = "./book.aspx?bibliorecpath=" + HttpUtility.UrlEncode(strBiblioRecPath); string strText = "新的荐购书目记录创建成功。点击此处可查看:<a href='" + strUrl + "' target='_blank'>" + strUrl + "</a>"; SetInfo(strText); this.SetDebugInfo("succeedinfo", strText); return; ERROR1: SetDebugInfo("errorinfo", strError); }
protected override void Render(HtmlTextWriter output) { if (this.RecPath == "") { output.Write("尚未指定记录路径"); return; } int nRet = 0; long lRet = 0; string strError = ""; // string strOutputPath = ""; OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; string strBiblioXml = ""; LibraryChannel channel = sessioninfo.GetChannel(true); try { lRet = // sessioninfo.Channel. channel.GetBiblioInfo( null, this.RecPath, "", "xml", out strBiblioXml, out strError); /* * string strMetaData = ""; * byte[] timestamp = null; * lRet = channel.GetRes(this.RecPath, * out strBiblioXml, * out strMetaData, * out timestamp, * out strOutputPath, * out strError); * */ if (lRet == -1) { strError = "获得书目记录 '" + this.RecPath + "' 时出错: " + strError; goto ERROR1; } } finally { sessioninfo.ReturnChannel(channel); } 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; } // string strBiblioDbName = ResPath.GetDbName(this.RecPath); string strPrefix = ""; if (this.Wrapper == true) { strPrefix = this.GetPrefixString("MARC", "content_wrapper") + "<div class='biblio_wrapper'>"; } string strPostfix = ""; if (this.Wrapper == true) { strPostfix = "</div>" + this.GetPostfixString(); } // output.Write(strBiblio); LiteralControl literal = (LiteralControl)this.FindControl("biblio"); literal.Text = strPrefix + GetHtmlOfMarc(strMarc, this.SubfieldReturn) + strPostfix; base.Render(output); return; ERROR1: output.Write(strError); }
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 = " "; 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); }