int GetRecordProperties( string strXml, DbZhongcihaoProperty prop, XmlNamespaceManager mngr, out string strNumber, out string strTitle, out string strAuthor, out string strError) { strNumber = ""; strTitle = ""; strAuthor = ""; strError = ""; XmlDocument dom = new XmlDocument(); try { dom.LoadXml(strXml); } catch (Exception ex) { strError = "XML装入DOM时出错: " + ex.Message; return(-1); } try { if (prop.NumberXPath != "") { XmlNode node = dom.DocumentElement.SelectSingleNode(prop.NumberXPath, mngr); if (node != null) { strNumber = node.Value; } } if (prop.TitleXPath != "") { XmlNode node = dom.DocumentElement.SelectSingleNode(prop.TitleXPath, mngr); if (node != null) { strTitle = node.Value; } } if (prop.AuthorXPath != "") { XmlNode node = dom.DocumentElement.SelectSingleNode(prop.AuthorXPath, mngr); if (node != null) { strAuthor = node.Value; } } } catch (Exception ex) { strError = ex.Message; return(-1); } return(0); }
int GetRecordProperties( string strXml, DbZhongcihaoProperty prop, XmlNamespaceManager mngr, out string strNumber, out string strTitle, out string strAuthor, out string strError) { strNumber = ""; strTitle = ""; strAuthor = ""; strError = ""; XmlDocument dom = new XmlDocument(); try { dom.LoadXml(strXml); } catch (Exception ex) { strError = "XML装入DOM时出错: " + ex.Message; return -1; } try { if (prop.NumberXPath != "") { XmlNode node = dom.DocumentElement.SelectSingleNode(prop.NumberXPath, mngr); if (node != null) strNumber = node.Value; } if (prop.TitleXPath != "") { XmlNode node = dom.DocumentElement.SelectSingleNode(prop.TitleXPath, mngr); if (node != null) strTitle = node.Value; } if (prop.AuthorXPath != "") { XmlNode node = dom.DocumentElement.SelectSingleNode(prop.AuthorXPath, mngr); if (node != null) strAuthor = node.Value; } } catch (Exception ex) { strError = ex.Message; return -1; } return 0; }
public LibraryServerResult GetZhongcihaoSearchResult( SessionInfo sessioninfo, string strZhongcihaoGroupName, string strResultSetName, long lStart, long lCount, string strBrowseInfoStyle, string strLang, out ZhongcihaoSearchResult[] searchresults) { string strError = ""; searchresults = null; LibraryServerResult result = new LibraryServerResult(); int nRet = 0; long lRet = 0; if (String.IsNullOrEmpty(strZhongcihaoGroupName) == true) { strError = "strZhongcihaoGroupName参数值不能为空"; goto ERROR1; } if (strZhongcihaoGroupName[0] == '!') { string strTemp = GetZhongcihaoGroupName(strZhongcihaoGroupName.Substring(1)); if (strTemp == null) { strError = "书目库名 " + strZhongcihaoGroupName.Substring(1) + " 没有找到对应的种次号组名"; goto ERROR1; } strZhongcihaoGroupName = strTemp; } RmsChannel channel = sessioninfo.Channels.GetChannel(this.WsUrl); if (channel == null) { result.Value = -1; result.ErrorInfo = "get channel error"; result.ErrorCode = ErrorCode.SystemError; return(result); } // XmlNode nodeNsTable = this.LibraryCfgDom.DocumentElement.SelectSingleNode("//zhongcihao/nstable"); XmlNamespaceManager mngr = null; if (nodeNsTable != null) { // 准备名字空间环境 nRet = PrepareNs( nodeNsTable, out mngr, out strError); if (nRet == -1) { goto ERROR1; } } // 构造数据库定义和库名的对照表 XmlNodeList nodes = this.LibraryCfgDom.DocumentElement.SelectNodes("//zhongcihao/group[@name='" + strZhongcihaoGroupName + "']/database"); if (nodes.Count == 0) { strError = "library.xml中尚未配置有关 '" + strZhongcihaoGroupName + "'的<zhongcihao>/<group>/<database>相关参数"; goto ERROR1; } Hashtable db_prop_table = new Hashtable(); for (int i = 0; i < nodes.Count; i++) { XmlNode node = nodes[i]; DbZhongcihaoProperty prop = new DbZhongcihaoProperty(); prop.DbName = DomUtil.GetAttr(node, "name"); prop.NumberXPath = DomUtil.GetAttr(node, "rightxpath"); prop.TitleXPath = DomUtil.GetAttr(node, "titlexpath"); prop.AuthorXPath = DomUtil.GetAttr(node, "authorxpath"); db_prop_table[prop.DbName] = prop; } if (String.IsNullOrEmpty(strResultSetName) == true) { strResultSetName = "default"; } Record[] origin_searchresults = null; // lRet = channel.DoGetSearchResult( strResultSetName, lStart, lCount, "id", strLang, null, out origin_searchresults, out strError); if (lRet == -1) { goto ERROR1; } long lResultCount = lRet; searchresults = new ZhongcihaoSearchResult[origin_searchresults.Length]; for (int i = 0; i < origin_searchresults.Length; i++) { ZhongcihaoSearchResult item = new ZhongcihaoSearchResult(); item.Path = origin_searchresults[i].Path; searchresults[i] = item; // 继续填充其余成员 string strXml = ""; string strMetaData = ""; byte[] timestamp = null; string strOutputPath = ""; lRet = channel.GetRes(item.Path, out strXml, out strMetaData, out timestamp, out strOutputPath, out strError); if (lRet == -1) { item.Zhongcihao = "获取记录 '" + item.Path + "' 出错: " + strError; continue; } string strDbName = ResPath.GetDbName(item.Path); DbZhongcihaoProperty prop = (DbZhongcihaoProperty)db_prop_table[strDbName]; if (prop == null) { item.Zhongcihao = "数据库名 '" + strDbName + "' 不在定义的种次号特性(<zhongcihao>/<group>/<database>)中"; continue; } string strNumber = ""; string strTitle = ""; string strAuthor = ""; nRet = GetRecordProperties( strXml, prop, mngr, out strNumber, out strTitle, out strAuthor, out strError); if (nRet == -1) { item.Zhongcihao = strError; continue; } item.Zhongcihao = strNumber; item.Cols = new string[2]; item.Cols[0] = strTitle; item.Cols[1] = strAuthor; } result.Value = lResultCount; return(result); ERROR1: result.Value = -1; result.ErrorCode = ErrorCode.SystemError; result.ErrorInfo = strError; return(result); }
public LibraryServerResult GetZhongcihaoSearchResult( SessionInfo sessioninfo, string strZhongcihaoGroupName, string strResultSetName, long lStart, long lCount, string strBrowseInfoStyle, string strLang, out ZhongcihaoSearchResult[] searchresults) { string strError = ""; searchresults = null; LibraryServerResult result = new LibraryServerResult(); int nRet = 0; long lRet = 0; if (String.IsNullOrEmpty(strZhongcihaoGroupName) == true) { strError = "strZhongcihaoGroupName参数值不能为空"; goto ERROR1; } if (strZhongcihaoGroupName[0] == '!') { string strTemp = GetZhongcihaoGroupName(strZhongcihaoGroupName.Substring(1)); if (strTemp == null) { strError = "书目库名 " + strZhongcihaoGroupName.Substring(1) + " 没有找到对应的种次号组名"; goto ERROR1; } strZhongcihaoGroupName = strTemp; } RmsChannel channel = sessioninfo.Channels.GetChannel(this.WsUrl); if (channel == null) { result.Value = -1; result.ErrorInfo = "get channel error"; result.ErrorCode = ErrorCode.SystemError; return result; } // XmlNode nodeNsTable = this.LibraryCfgDom.DocumentElement.SelectSingleNode("//zhongcihao/nstable"); XmlNamespaceManager mngr = null; if (nodeNsTable != null) { // 准备名字空间环境 nRet = PrepareNs( nodeNsTable, out mngr, out strError); if (nRet == -1) goto ERROR1; } // 构造数据库定义和库名的对照表 XmlNodeList nodes = this.LibraryCfgDom.DocumentElement.SelectNodes("//zhongcihao/group[@name='" + strZhongcihaoGroupName + "']/database"); if (nodes.Count == 0) { strError = "library.xml中尚未配置有关 '" + strZhongcihaoGroupName + "'的<zhongcihao>/<group>/<database>相关参数"; goto ERROR1; } Hashtable db_prop_table = new Hashtable(); for (int i = 0; i < nodes.Count; i++) { XmlNode node = nodes[i]; DbZhongcihaoProperty prop = new DbZhongcihaoProperty(); prop.DbName = DomUtil.GetAttr(node, "name"); prop.NumberXPath = DomUtil.GetAttr(node, "rightxpath"); prop.TitleXPath = DomUtil.GetAttr(node, "titlexpath"); prop.AuthorXPath = DomUtil.GetAttr(node, "authorxpath"); db_prop_table[prop.DbName] = prop; } if (String.IsNullOrEmpty(strResultSetName) == true) strResultSetName = "default"; Record[] origin_searchresults = null; // lRet = channel.DoGetSearchResult( strResultSetName, lStart, lCount, "id", strLang, null, out origin_searchresults, out strError); if (lRet == -1) goto ERROR1; long lResultCount = lRet; searchresults = new ZhongcihaoSearchResult[origin_searchresults.Length]; for (int i = 0; i < origin_searchresults.Length; i++) { ZhongcihaoSearchResult item = new ZhongcihaoSearchResult(); item.Path = origin_searchresults[i].Path; searchresults[i] = item; // 继续填充其余成员 string strXml = ""; string strMetaData = ""; byte[] timestamp = null; string strOutputPath = ""; lRet = channel.GetRes(item.Path, out strXml, out strMetaData, out timestamp, out strOutputPath, out strError); if (lRet == -1) { item.Zhongcihao = "获取记录 '" + item.Path + "' 出错: " + strError; continue; } string strDbName = ResPath.GetDbName(item.Path); DbZhongcihaoProperty prop = (DbZhongcihaoProperty)db_prop_table[strDbName]; if (prop == null) { item.Zhongcihao = "数据库名 '" + strDbName + "' 不在定义的种次号特性(<zhongcihao>/<group>/<database>)中"; continue; } string strNumber = ""; string strTitle = ""; string strAuthor = ""; nRet = GetRecordProperties( strXml, prop, mngr, out strNumber, out strTitle, out strAuthor, out strError); if (nRet == -1) { item.Zhongcihao = strError; continue; } item.Zhongcihao = strNumber; item.Cols = new string[2]; item.Cols[0] = strTitle; item.Cols[1] = strAuthor; } result.Value = lResultCount; return result; ERROR1: result.Value = -1; result.ErrorCode = ErrorCode.SystemError; result.ErrorInfo = strError; return result; }