// 装载数据 public override bool LoadData() { string strError = ""; int nRet = 0; BiblioInfo info = this.BiblioInfo; string strRecPath = this.BiblioInfo.RecPath; if (string.IsNullOrEmpty(info.OldXml) == true) { lock (syncRoot) { channel = this.Container.MainForm.GetChannel(); } try { // 显示 正在处理 this.HTML = GetWaitingHtml("正在获取 "+this.DbType+" 记录 " + strRecPath); ShowData(); byte [] baTimestamp = null; string strOutputRecPath = ""; string strBiblio = ""; string strBiblioRecPath = ""; string strXml = ""; // 获得记录 channel.Timeout = new TimeSpan(0, 0, 5); long lRet = 0; if (this.DbType == "item") { lRet = channel.GetItemInfo( this.Stop, "@path:" + strRecPath, "xml", out strXml, out strOutputRecPath, out baTimestamp, "", out strBiblio, out strBiblioRecPath, out strError); } else if (this.DbType == "order") { lRet = channel.GetOrderInfo( this.Stop, "@path:" + strRecPath, "xml", out strXml, out strOutputRecPath, out baTimestamp, "", out strBiblio, out strBiblioRecPath, out strError); } else if (this.DbType == "issue") { lRet = channel.GetIssueInfo( this.Stop, "@path:" + strRecPath, "xml", out strXml, out strOutputRecPath, out baTimestamp, "", out strBiblio, out strBiblioRecPath, out strError); } else if (this.DbType == "comment") { lRet = channel.GetCommentInfo( this.Stop, "@path:" + strRecPath, "xml", out strXml, out strOutputRecPath, out baTimestamp, "", out strBiblio, out strBiblioRecPath, out strError); } else if (this.DbType == "patron") { string[] results = null; // 获得读者记录 lRet = channel.GetReaderInfo( this.Stop, "@path:" + strRecPath, "xml", out results, out strOutputRecPath, out baTimestamp, out strError); if (lRet == 1) { if (results == null || results.Length == 0) { strError = "results error"; nRet = -1; } else strXml = results[0]; } } else { lRet = -1; strError = "无法识别的 DbType '"+this.DbType+"'"; } if (lRet == 0) { nRet = -1; strError = "获取记录 " + strRecPath + " 时出错: " + strError; } else if (lRet == -1) { nRet = -1; strError = "获取记录 " + strRecPath + " 时出错: " + strError; } else { info.OldXml = strXml; info.Timestamp = baTimestamp; info.RecPath = strRecPath; } } finally { LibraryChannel temp_channel = channel; lock (syncRoot) { channel = null; } this.Container.MainForm.ReturnChannel(temp_channel); } } string strXml1 = ""; string strHtml2 = ""; if (nRet == -1) { strHtml2 = HttpUtility.HtmlEncode(strError); } else { nRet = ItemSearchForm.GetXmlHtml(info, out strXml1, out strHtml2, out strError); if (nRet == -1) throw new Exception(strError); } this.HTML = "<html>" + this.Container.MainForm.GetMarcHtmlHeadString(true) + "<body>" + strHtml2 + EntityForm.GetTimestampHtml(info.Timestamp) + "</body></html>"; this.XML = strXml1; return true; }
//return: // -1 出错 // 0 没有找到 // 1 找到 static int GetRecord( LibraryChannel channel, Stop stop, string strDbType, string strRecPath, out string strXml, out byte[] baTimestamp, out string strError) { strError = ""; strXml = ""; baTimestamp = null; string strOutputRecPath = ""; string strBiblio = ""; string strBiblioRecPath = ""; // 获得册记录 long lRet = 0; if (strDbType == "item") { lRet = channel.GetItemInfo( stop, "@path:" + strRecPath, "xml", out strXml, out strOutputRecPath, out baTimestamp, "", out strBiblio, out strBiblioRecPath, out strError); } else if (strDbType == "order") { lRet = channel.GetOrderInfo( stop, "@path:" + strRecPath, "xml", out strXml, out strOutputRecPath, out baTimestamp, "", out strBiblio, out strBiblioRecPath, out strError); } else if (strDbType == "issue") { lRet = channel.GetIssueInfo( stop, "@path:" + strRecPath, "xml", out strXml, out strOutputRecPath, out baTimestamp, "", out strBiblio, out strBiblioRecPath, out strError); } else if (strDbType == "comment") { lRet = channel.GetCommentInfo( stop, "@path:" + strRecPath, "xml", out strXml, out strOutputRecPath, out baTimestamp, "", out strBiblio, out strBiblioRecPath, out strError); } else { strError = "未知的 strDbType '" + strDbType + "'"; return(-1); } if (lRet == 0) { return(0); // 是否设定为特殊状态? } if (lRet == -1) { return(-1); } return(1); }
// 装载数据 public override bool LoadData() { string strError = ""; int nRet = 0; BiblioInfo info = this.BiblioInfo; string strRecPath = this.BiblioInfo.RecPath; if (string.IsNullOrEmpty(info.OldXml) == true) { lock (syncRoot) { channel = Program.MainForm.GetChannel(); } try { // 显示 正在处理 this.HTML = GetWaitingHtml("正在获取 " + this.DbType + " 记录 " + strRecPath); ShowData(); byte [] baTimestamp = null; string strOutputRecPath = ""; string strBiblio = ""; string strBiblioRecPath = ""; string strXml = ""; // 获得记录 channel.Timeout = new TimeSpan(0, 0, 5); long lRet = 0; if (this.DbType == "item") { lRet = channel.GetItemInfo( this.Stop, "@path:" + strRecPath, "xml", out strXml, out strOutputRecPath, out baTimestamp, "", out strBiblio, out strBiblioRecPath, out strError); } else if (this.DbType == "order") { lRet = channel.GetOrderInfo( this.Stop, "@path:" + strRecPath, "xml", out strXml, out strOutputRecPath, out baTimestamp, "", out strBiblio, out strBiblioRecPath, out strError); } else if (this.DbType == "issue") { lRet = channel.GetIssueInfo( this.Stop, "@path:" + strRecPath, "xml", out strXml, out strOutputRecPath, out baTimestamp, "", out strBiblio, out strBiblioRecPath, out strError); } else if (this.DbType == "comment") { lRet = channel.GetCommentInfo( this.Stop, "@path:" + strRecPath, "xml", out strXml, out strOutputRecPath, out baTimestamp, "", out strBiblio, out strBiblioRecPath, out strError); } else if (this.DbType == "patron") { string[] results = null; // 获得读者记录 lRet = channel.GetReaderInfo( this.Stop, "@path:" + strRecPath, "xml", out results, out strOutputRecPath, out baTimestamp, out strError); if (lRet == 1) { if (results == null || results.Length == 0) { strError = "results error"; nRet = -1; } else { strXml = results[0]; } } } else { lRet = -1; strError = "无法识别的 DbType '" + this.DbType + "'"; } if (lRet == 0) { nRet = -1; strError = "获取记录 " + strRecPath + " 时出错: " + strError; } else if (lRet == -1) { nRet = -1; strError = "获取记录 " + strRecPath + " 时出错: " + strError; } else { info.OldXml = strXml; info.Timestamp = baTimestamp; info.RecPath = strRecPath; } } finally { LibraryChannel temp_channel = channel; lock (syncRoot) { channel = null; } Program.MainForm.ReturnChannel(temp_channel); } } string strXml1 = ""; string strHtml2 = ""; if (nRet == -1) { strHtml2 = HttpUtility.HtmlEncode(strError); } else { nRet = ItemSearchForm.GetXmlHtml(info, out strXml1, out strHtml2, out strError); if (nRet == -1) { throw new Exception(strError); } } this.HTML = "<html>" + Program.MainForm.GetMarcHtmlHeadString(true) + "<body>" + strHtml2 + EntityForm.GetTimestampHtml(info.Timestamp) + "</body></html>"; this.XML = strXml1; return(true); }
// 根据册记录路径,检索出从属的书目记录路径。 public static int SearchBiblioRecPath( Stop stop, LibraryChannel Channel, string strDbType, string strItemRecPath, out string strBiblioRecPath, out string strError) { strError = ""; strBiblioRecPath = ""; string strItemText = ""; string strBiblioText = ""; byte[] item_timestamp = null; long lRet = 0; if (strDbType == "item") lRet = Channel.GetItemInfo( stop, "@path:" + strItemRecPath, null, out strItemText, out strItemRecPath, out item_timestamp, "recpath", out strBiblioText, out strBiblioRecPath, out strError); else if (strDbType == "comment") lRet = Channel.GetCommentInfo( stop, "@path:" + strItemRecPath, // "", null, out strItemText, out strItemRecPath, out item_timestamp, "recpath", out strBiblioText, out strBiblioRecPath, out strError); else if (strDbType == "order") lRet = Channel.GetOrderInfo( stop, "@path:" + strItemRecPath, // "", null, out strItemText, out strItemRecPath, out item_timestamp, "recpath", out strBiblioText, out strBiblioRecPath, out strError); else if (strDbType == "issue") lRet = Channel.GetIssueInfo( stop, "@path:" + strItemRecPath, // "", null, out strItemText, out strItemRecPath, out item_timestamp, "recpath", out strBiblioText, out strBiblioRecPath, out strError); else throw new Exception("未知的DbType '" + strDbType + "'"); if (lRet == -1) return -1; // error return (int)lRet; // not found }
// 根据册记录路径,检索出从属的书目记录路径。 public static int SearchBiblioRecPath( Stop stop, LibraryChannel Channel, string strDbType, string strItemRecPath, out string strBiblioRecPath, out string strError) { strError = ""; strBiblioRecPath = ""; string strItemText = ""; string strBiblioText = ""; byte[] item_timestamp = null; long lRet = 0; if (strDbType == "item") { lRet = Channel.GetItemInfo( stop, "@path:" + strItemRecPath, null, out strItemText, out strItemRecPath, out item_timestamp, "recpath", out strBiblioText, out strBiblioRecPath, out strError); } else if (strDbType == "comment") { lRet = Channel.GetCommentInfo( stop, "@path:" + strItemRecPath, // "", null, out strItemText, out strItemRecPath, out item_timestamp, "recpath", out strBiblioText, out strBiblioRecPath, out strError); } else if (strDbType == "order") { lRet = Channel.GetOrderInfo( stop, "@path:" + strItemRecPath, // "", null, out strItemText, out strItemRecPath, out item_timestamp, "recpath", out strBiblioText, out strBiblioRecPath, out strError); } else if (strDbType == "issue") { lRet = Channel.GetIssueInfo( stop, "@path:" + strItemRecPath, // "", null, out strItemText, out strItemRecPath, out item_timestamp, "recpath", out strBiblioText, out strBiblioRecPath, out strError); } else { throw new Exception("未知的DbType '" + strDbType + "'"); } if (lRet == -1) { return(-1); // error } return((int)lRet); // not found }