// readerdom发生变化后,刷新相关域 public static void RefreshReaderAccount(ref ReaderInfo readerinfo, XmlDocument readerdom) { readerinfo.Barcode = DomUtil.GetElementText(readerdom.DocumentElement, "barcode"); readerinfo.Name = DomUtil.GetElementText(readerdom.DocumentElement, "name"); readerinfo.DisplayName = DomUtil.GetElementText(readerdom.DocumentElement, "displayName"); readerinfo.ReaderDomLastTime = DateTime.Now; }
// 获得当前session中已经登录的读者记录DOM // return: // -2 当前登录的用户不是reader类型 // -1 出错 // 0 尚未登录 // 1 成功 public int GetLoginReaderDom( out XmlDocument readerdom, out string strError) { strError = ""; readerdom = null; if (string.IsNullOrEmpty(this.UserID) == true) { strError = "尚未登录"; return(0); } if (this.IsReader == false) { strError = "当前登录的用户不是读者类型"; return(-2); } // 2015/11/20 if (this.UserID.IndexOf(":") != -1) { strError = "this.UserID '" + this.UserID + "' 中不应包含冒号"; return(-1); } Debug.Assert(this.UserID.IndexOf(":") == -1, "UserID中不能包含冒号"); if (this.ReaderInfo == null) { this.ReaderInfo = new ReaderInfo(); } // 看看缓存的readerdom是否失效 TimeSpan delta = DateTime.Now - this.ReaderInfo.ReaderDomLastTime; if (delta.TotalSeconds > 60 && this.ReaderInfo.ReaderDomChanged == false) { this.ReaderInfo.ReaderDom = null; } // 如果语言不同 if (this.ChannelLang != this.ReaderInfo.Lang) { this.ReaderInfo.ReaderDom = null; } if (this.ReaderInfo.ReaderDom == null) { string strBarcode = ""; strBarcode = this.UserID; if (strBarcode == "") { strError = "帐户信息中读者证条码号为空,无法定位读者记录。"; goto ERROR1; } string strXml = ""; string strOutputPath = ""; byte[] timestamp = null; string strResultTypeList = "advancexml"; string[] results = null; LibraryChannel channel = this.GetChannel(true); // this.GetChannel(true, this.m_strParameters); try { long lRet = //this.Channel. channel.GetReaderInfo(null, strBarcode, strResultTypeList, out results, out strOutputPath, out timestamp, out strError); if (lRet == -1) // TODO: 0? { goto ERROR1; } // 2011/11/22 if (lRet == 0) { strError = "证条码号为 '" + strBarcode + "' 的读者记录没有找到..."; goto ERROR1; } } finally { //ReleaseTempChannel(temp); this.ReturnChannel(channel); } if (results.Length != 1) { strError = "results.Length error"; goto ERROR1; } strXml = results[0]; readerdom = new XmlDocument(); try { readerdom.LoadXml(strXml); } catch (Exception ex) { strError = "装载读者XML记录进入DOM时出错: " + ex.Message; goto ERROR1; } this.ReaderInfo.ReaderDomPath = strOutputPath; this.ReaderInfo.ReaderDomTimestamp = timestamp; this.ReaderInfo.ReaderDom = readerdom; this.ReaderInfo.ReaderDomLastTime = DateTime.Now; this.ReaderInfo.Lang = this.ChannelLang; RefreshReaderAccount(ref this.ReaderInfo, readerdom); } else { readerdom = this.ReaderInfo.ReaderDom; // 沿用cache中的 } return(1); ERROR1: return(-1); }
// 获得当前session中已经登录的读者记录DOM // return: // -2 当前登录的用户不是reader类型 // -1 出错 // 0 尚未登录 // 1 成功 public int GetLoginReaderDom( out XmlDocument readerdom, out string strError) { strError = ""; readerdom = null; if (string.IsNullOrEmpty(this.UserID) == true) { strError = "尚未登录"; return 0; } if (this.IsReader == false) { strError = "当前登录的用户不是读者类型"; return -2; } // 2015/11/20 if (this.UserID.IndexOf(":") != -1) { strError = "this.UserID '" + this.UserID + "' 中不应包含冒号"; return -1; } Debug.Assert(this.UserID.IndexOf(":") == -1, "UserID中不能包含冒号"); if (this.ReaderInfo == null) this.ReaderInfo = new ReaderInfo(); // 看看缓存的readerdom是否失效 TimeSpan delta = DateTime.Now - this.ReaderInfo.ReaderDomLastTime; if (delta.TotalSeconds > 60 && this.ReaderInfo.ReaderDomChanged == false) { this.ReaderInfo.ReaderDom = null; } // 如果语言不同 if (this.ChannelLang != this.ReaderInfo.Lang) this.ReaderInfo.ReaderDom = null; if (this.ReaderInfo.ReaderDom == null) { string strBarcode = ""; strBarcode = this.UserID; if (strBarcode == "") { strError = "帐户信息中读者证条码号为空,无法定位读者记录。"; goto ERROR1; } string strXml = ""; string strOutputPath = ""; byte[] timestamp = null; string strResultTypeList = "advancexml"; string[] results = null; LibraryChannel channel = this.GetChannel(true); // this.GetChannel(true, this.m_strParameters); try { long lRet = //this.Channel. channel.GetReaderInfo(null, strBarcode, strResultTypeList, out results, out strOutputPath, out timestamp, out strError); if (lRet == -1) // TODO: 0? goto ERROR1; // 2011/11/22 if (lRet == 0) { strError = "证条码号为 '" + strBarcode + "' 的读者记录没有找到..."; goto ERROR1; } } finally { //ReleaseTempChannel(temp); this.ReturnChannel(channel); } if (results.Length != 1) { strError = "results.Length error"; goto ERROR1; } strXml = results[0]; readerdom = new XmlDocument(); try { readerdom.LoadXml(strXml); } catch (Exception ex) { strError = "装载读者XML记录进入DOM时出错: " + ex.Message; goto ERROR1; } this.ReaderInfo.ReaderDomPath = strOutputPath; this.ReaderInfo.ReaderDomTimestamp = timestamp; this.ReaderInfo.ReaderDom = readerdom; this.ReaderInfo.ReaderDomLastTime = DateTime.Now; this.ReaderInfo.Lang = this.ChannelLang; RefreshReaderAccount(ref this.ReaderInfo, readerdom); } else { readerdom = this.ReaderInfo.ReaderDom; // 沿用cache中的 } return 1; ERROR1: return -1; }
// 管理员获得特定证条码号的读者记录DOM // return: // -2 当前登录的用户不是librarian类型 // -1 出错 // 0 尚未登录 // 1 成功 public int GetOtherReaderDom( string strReaderBarcode, out XmlDocument readerdom, out string strError) { strError = ""; readerdom = null; if (string.IsNullOrEmpty(this.UserID) == true) { strError = "尚未登录"; return 0; } if (this.IsReader == true) { strError = "当前登录的用户不是工作人员类型"; return -2; } if (this.ReaderInfo == null) this.ReaderInfo = new ReaderInfo(); // 看看缓存的readerdom是否失效 TimeSpan delta = DateTime.Now - this.ReaderInfo.ReaderDomLastTime; if (delta.TotalSeconds > 60 && this.ReaderInfo.ReaderDomChanged == false) { this.ReaderInfo.ReaderDom = null; } // 如果语言不同 if (this.ChannelLang != this.ReaderInfo.Lang) this.ReaderInfo.ReaderDom = null; if (this.ReaderInfo.ReaderDom == null) { string strXml = ""; string strOutputPath = ""; byte[] timestamp = null; string strResultTypeList = "advancexml"; string[] results = null; //TempChannel temp = GetTempChannel(this.Password); try { long lRet = this.Channel.GetReaderInfo(null, strReaderBarcode, strResultTypeList, out results, out strOutputPath, out timestamp, out strError); if (lRet == -1) // TODO: 0? goto ERROR1; // 2011/11/22 if (lRet == 0) { strError = "证条码号为 '" + strReaderBarcode + "' 的读者记录没有找到..."; goto ERROR1; } } finally { //ReleaseTempChannel(temp); } if (results.Length != 1) { strError = "results.Length error"; goto ERROR1; } strXml = results[0]; // timestamp = ByteArray.GetTimeStampByteArray(results[1]); /* // 获得读者记录 int nRet = this.GetReaderRecXml( sessioninfo.Channels, strBarcode, out strXml, out strOutputPath, out timestamp, out strError); if (nRet == -1) goto ERROR1; if (nRet == 0) goto ERROR1; * */ readerdom = new XmlDocument(); try { readerdom.LoadXml(strXml); } catch (Exception ex) { strError = "装载读者XML记录进入DOM时出错: " + ex.Message; goto ERROR1; } this.ReaderInfo.ReaderDomPath = strOutputPath; this.ReaderInfo.ReaderDomTimestamp = timestamp; this.ReaderInfo.ReaderDom = readerdom; this.ReaderInfo.ReaderDomLastTime = DateTime.Now; this.ReaderInfo.Lang = this.ChannelLang; RefreshReaderAccount(ref this.ReaderInfo, readerdom); } else { readerdom = this.ReaderInfo.ReaderDom; // 沿用cache中的 } return 1; ERROR1: return -1; }