// // return: // -1 出错,不希望继续以后的操作 // 0 成功 // 1 出错,但希望继续后面的操作 /// <summary> /// 获得读者库属性列表 /// </summary> /// <returns>-1: 出错,不希望继续以后的操作; 0: 成功; 1: 出错,但希望继续后面的操作</returns> public int InitialReaderDbProperties() { REDO: int nRet = PrepareSearch(); if (nRet == 0) return -1; string strError = ""; Stop.OnStop += new StopEventHandler(this.DoStop); Stop.Initial("正在获得读者库属性列表 ..."); Stop.BeginLoop(); try { string strValue = ""; long lRet = 0; this.ReaderDbProperties = new List<ReaderDbProperty>(); this.m_readerDbNames = null; // 新用法:一次性获得全部参数 lRet = Channel.GetSystemParameter(Stop, "system", "readerDbGroup", out strValue, out strError); if (lRet == -1) { strError = "针对服务器 " + Channel.Url + " 获得读者库信息过程发生错误:" + strError; goto ERROR1; } if (String.IsNullOrEmpty(strValue) == true) { // 还是用旧方法 lRet = Channel.GetSystemParameter(Stop, "reader", "dbnames", out strValue, out strError); if (lRet == -1) { strError = "针对服务器 " + Channel.Url + " 获得读者库名列表过程发生错误:" + strError; goto ERROR1; } string[] readerDbNames = strValue.Split(new char[] { ',' }); for (int i = 0; i < readerDbNames.Length; i++) { ReaderDbProperty property = new ReaderDbProperty(); property.DbName = readerDbNames[i]; this.ReaderDbProperties.Add(property); } } else { // 新方法 XmlDocument dom = new XmlDocument(); dom.LoadXml("<root />"); try { dom.DocumentElement.InnerXml = strValue; } catch (Exception ex) { strError = "category=system,name=readerDbGroup所返回的XML片段在装入InnerXml时出错: " + ex.Message; goto ERROR1; } XmlNodeList nodes = dom.DocumentElement.SelectNodes("database"); for (int i = 0; i < nodes.Count; i++) { XmlNode node = nodes[i]; ReaderDbProperty property = new ReaderDbProperty(); this.ReaderDbProperties.Add(property); property.DbName = DomUtil.GetAttr(node, "name"); property.LibraryCode = DomUtil.GetAttr(node, "libraryCode"); bool bValue = true; nRet = DomUtil.GetBooleanParam(node, "inCirculation", true, out bValue, out strError); property.InCirculation = bValue; } } // MessageBox.Show(this, Convert.ToString(lRet) + " : " + strError); } finally { Stop.EndLoop(); Stop.OnStop -= new StopEventHandler(this.DoStop); Stop.Initial(""); EndSearch(); } return 0; ERROR1: DialogResult result = MessageBox.Show(this, strError + "\r\n\r\n是否重试?", "dp2Circulation", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (result == System.Windows.Forms.DialogResult.Yes) goto REDO; if (result == DialogResult.No) return 1; // 出错,但希望继续后面的操作 return -1; // 出错,不希望继续以后的操作 }
// // return: // -1 出错,不希望继续以后的操作 // 0 成功 // 1 出错,但希望继续后面的操作 /// <summary> /// 获得读者库属性列表 /// </summary> /// <param name="bPrepareSearch">是否要准备通道</param> /// <returns>-1: 出错,不希望继续以后的操作; 0: 成功; 1: 出错,但希望继续后面的操作</returns> public int InitialReaderDbProperties(bool bPrepareSearch = true) { REDO: if (bPrepareSearch == true) { if (PrepareSearch() == 0) return -1; } string strError = ""; int nRet = 0; Stop.OnStop += new StopEventHandler(this.DoStop); Stop.Initial("正在初始化读者库属性列表 ..."); Stop.BeginLoop(); try { this.ReaderDbProperties = new List<ReaderDbProperty>(); this.m_readerDbNames = null; if (this.AllDatabaseDom == null) return 0; XmlNodeList nodes = this.AllDatabaseDom.DocumentElement.SelectNodes("database[@type='reader']"); foreach (XmlNode node in nodes) { ReaderDbProperty property = new ReaderDbProperty(); this.ReaderDbProperties.Add(property); property.DbName = DomUtil.GetAttr(node, "name"); property.LibraryCode = DomUtil.GetAttr(node, "libraryCode"); bool bValue = true; nRet = DomUtil.GetBooleanParam(node, "inCirculation", true, out bValue, out strError); property.InCirculation = bValue; } // MessageBox.Show(this, Convert.ToString(lRet) + " : " + strError); } finally { Stop.EndLoop(); Stop.OnStop -= new StopEventHandler(this.DoStop); Stop.Initial(""); if (bPrepareSearch == true) EndSearch(); } return 0; #if NO ERROR1: DialogResult result = MessageBox.Show(this, strError + "\r\n\r\n是否重试?", "dp2Circulation", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (result == System.Windows.Forms.DialogResult.Yes) goto REDO; if (result == DialogResult.No) return 1; // 出错,但希望继续后面的操作 return -1; // 出错,不希望继续以后的操作 #endif }