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格式 string strXml = ""; nRet = MarcUtil.Marc2Xml( strMARC, strMarcSyntax, out strXml, out strError); if (nRet == -1) goto ERROR1; /* // 临时的SessionInfo对象 SessionInfo temp_sessioninfo = new SessionInfo(app); // 模拟一个账户 Account account = new Account(); account.LoginName = "neworderbiblio"; account.Password = ""; account.Rights = "setbiblioinfo"; account.Type = ""; account.Barcode = ""; account.Name = "neworderbiblio"; account.UserID = "neworderbiblio"; account.RmsUserName = app.ManagerUserName; account.RmsPassword = app.ManagerPassword; temp_sessioninfo.Account = account; * */ SessionInfo temp_sessioninfo = new SessionInfo(app); temp_sessioninfo.UserID = app.ManagerUserName; temp_sessioninfo.Password = app.ManagerPassword; temp_sessioninfo.IsReader = false; string strOutputBiblioRecPath = ""; try { strBiblioRecPath = strBiblioDbName + "/?"; byte[] baOutputTimestamp = null; long lRet = temp_sessioninfo.Channel.SetBiblioInfo( null, "new", strBiblioRecPath, "xml", strXml, null, "", out strOutputBiblioRecPath, out baOutputTimestamp, out strError); if (lRet == -1) { strError = "创建书目记录发生错误: " + strError; goto ERROR1; } /* LibraryServerResult result = app.SetBiblioInfo( temp_sessioninfo, "new", strBiblioRecPath, "xml", strXml, null, out strOutputBiblioRecPath, out baOutputTimestamp); if (result.Value == -1) { strError = result.ErrorInfo; goto ERROR1; } * */ } finally { temp_sessioninfo.CloseSession(); temp_sessioninfo = null; } // 清除每个输入域的内容 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 void Page_Load(object sender, EventArgs e) { if (WebUtil.PrepareEnvironment(this, ref app, ref sessioninfo) == false) return; // 是否登录? if (sessioninfo.UserID == "") { sessioninfo.UserID = "public"; sessioninfo.IsReader = false; } string strError = ""; int nRet = 0; SessionInfo temp_sessioninfo = new SessionInfo(app); temp_sessioninfo.UserID = app.ManagerUserName; temp_sessioninfo.Password = app.ManagerPassword; temp_sessioninfo.IsReader = false; try { bool bHintDisplayName = false; // []暗示为显示名 string strDisplayName = this.Request["displayName"]; string strBarcode = this.Request["barcode"]; string strEncyptBarcode = Request.QueryString["encrypt_barcode"]; string strText = ""; // 如果为加密的条码形态 if (String.IsNullOrEmpty(strEncyptBarcode) == false) { strBarcode = OpacApplication.DecryptPassword(strEncyptBarcode); if (strBarcode == null) { strError = "encrypt_barcode参数值格式错误"; goto ERROR1; } bHintDisplayName = true; goto SEARCH_COMMENT; } { if (String.IsNullOrEmpty(strDisplayName) == false) { if (strDisplayName.IndexOfAny(new char[] { '[', ']' }) != -1) bHintDisplayName = true; strDisplayName = strDisplayName.Replace("[", "").Trim(); strDisplayName = strDisplayName.Replace("]", "").Trim(); } nRet = 0; string strReaderXml = ""; string strOutputReaderPath = ""; if (String.IsNullOrEmpty(strDisplayName) == false) { byte[] timestamp = null; /* // 通过读者显示名获得读者记录 // return: // -1 error // 0 not found // 1 命中1条 // >1 命中多于1条 nRet = app.GetReaderRecXmlByDsiplayName( sessioninfo.Channels, strDisplayName, out strReaderXml, out strOutputReaderPath, out timestamp, out strError); if (nRet == -1) goto ERROR1; if (nRet == 0 && bHintDisplayName == true) { strBarcode = ""; goto SEARCH_COMMENT; } */ string[] results = null; long lRet = temp_sessioninfo.Channel.GetReaderInfo( null, "@displayName:" + strDisplayName, "xml", out results, out strOutputReaderPath, out timestamp, out strError); if (lRet == -1) goto ERROR1; if (lRet == 0 && bHintDisplayName == true) { strBarcode = ""; goto SEARCH_COMMENT; } strReaderXml = results[0]; CONTINUE1: if (nRet == 0) strBarcode = strDisplayName; } SEARCH_BARCODE: if (nRet == 0 && String.IsNullOrEmpty(strBarcode) == false) { strReaderXml = ""; byte[] timestamp = null; /* // 试探当做读者证条码号检索 // 通过读者证条码号获得读者记录 // return: // -1 error // 0 not found // 1 命中1条 // >1 命中多于1条 nRet = app.GetReaderRecXml( sessioninfo.Channels, strBarcode, out strReaderXml, out strOutputReaderPath, out timestamp, out strError); if (nRet == -1) goto ERROR1; if (nRet == 0) { goto SEARCH_COMMENT; } * */ string[] results = null; long lRet = temp_sessioninfo.Channel.GetReaderInfo( null, strBarcode, "xml", out results, out strOutputReaderPath, out timestamp, out strError); if (lRet == -1) goto ERROR1; if (lRet == 0) { goto SEARCH_COMMENT; } strReaderXml = results[0]; } if (nRet == 0) { /* strError = "读者显示名或者证条码号 '" + strDisplayName + "' 不存在"; goto ERROR1; * */ if (String.IsNullOrEmpty(strBarcode) == true) strBarcode = strDisplayName; goto SEARCH_COMMENT; } XmlDocument readerdom = null; nRet = OpacApplication.LoadToDom(strReaderXml, out readerdom, out strError); if (nRet == -1) { strError = "装载读者记录 '" + strOutputReaderPath + "' 进入XML DOM时发生错误: " + strError; goto ERROR1; } strDisplayName = DomUtil.GetElementText(readerdom.DocumentElement, "displayName"); strBarcode = DomUtil.GetElementInnerXml(readerdom.DocumentElement, "barcode"); } SEARCH_COMMENT: strText = strDisplayName; if (String.IsNullOrEmpty(strText) == true) strText = strBarcode; this.Label_name.Text = strText; string strRecipient = ""; /* if (String.IsNullOrEmpty(strDisplayName) == false) { if (strDisplayName.IndexOf("[") == -1) strRecipient = "[" + strDisplayName + "]"; else strRecipient = strDisplayName; if (String.IsNullOrEmpty(strEncyptBarcode) == false) strRecipient += " encrypt_barcode:" + strEncyptBarcode; } else strRecipient = strBarcode; * */ strRecipient = BoxesInfo.BuildOneAddress(strDisplayName, strBarcode); string strSendMessageUrl = "./message.aspx?recipient=" + HttpUtility.UrlEncode(strRecipient); this.Button_sendMessage.OnClientClick = "window.open('" + strSendMessageUrl + "','_blank'); return cancelClick();"; LoginState loginstate = GlobalUtil.GetLoginState(this.Page); if (loginstate == LoginState.NotLogin || loginstate == LoginState.Public) this.Button_sendMessage.Enabled = false; this.BrowseSearchResultControl1.Title = strText + " 所发表的书评"; if (String.IsNullOrEmpty(strEncyptBarcode) == false) this.Image_photo.ImageUrl = "./getphoto.aspx?encrypt_barcode=" + HttpUtility.UrlEncode(strEncyptBarcode) + "&displayName=" + HttpUtility.UrlEncode(strDisplayName); else this.Image_photo.ImageUrl = "./getphoto.aspx?barcode=" + HttpUtility.UrlEncode(strBarcode); this.Image_photo.Width = 128; this.Image_photo.Height = 128; if (this.IsPostBack == false) { string strXml = ""; if (String.IsNullOrEmpty(strDisplayName) == false && String.IsNullOrEmpty(strBarcode) == false) { // 创建评注记录XML检索式 // 用作者和作者显示名共同限定检索 nRet = ItemSearchControl.BuildCommentQueryXml( app, strDisplayName, strBarcode, "<全部>", 15000, // app.SearchMaxResultCount true, out strXml, out strError); if (nRet == -1) goto ERROR1; } else if (String.IsNullOrEmpty(strBarcode) == false) { // 创建XML检索式 nRet = ItemSearchControl.BuildQueryXml( this.app, "comment", strBarcode, "<全部>", "作者", "exact", 15000, // app.SearchMaxResultCount true, out strXml, out strError); if (nRet == -1) goto ERROR1; } else if (String.IsNullOrEmpty(strDisplayName) == false) { // 创建XML检索式 nRet = ItemSearchControl.BuildQueryXml( this.app, "comment", strDisplayName, "<全部>", "作者显示名", "exact", 15000, // app.SearchMaxResultCount true, out strXml, out strError); if (nRet == -1) goto ERROR1; } else { strError = "strBarcode和strDisplayName均为空,无法进行检索"; goto ERROR1; } string strResultSetName = "opac_userinfo"; sessioninfo.Channel.Idle += new IdleEventHandler(channel_Idle); try { long lRet = sessioninfo.Channel.Search( null, strXml, strResultSetName, "", // strOutputStyle out strError); if (lRet == -1) goto ERROR1; // not found if (lRet == 0) { this.BrowseSearchResultControl1.Title = strText + " 没有发表过任何书评"; } else { this.BrowseSearchResultControl1.ResultSetName = strResultSetName; this.BrowseSearchResultControl1.ResultCount = (int)lRet; this.BrowseSearchResultControl1.StartIndex = 0; } return; } finally { sessioninfo.Channel.Idle -= new IdleEventHandler(channel_Idle); } } return; ERROR1: Response.Write(HttpUtility.HtmlEncode(strError)); Response.End(); } finally { temp_sessioninfo.CloseSession(); } }
// 获得一个库的浏览列标题 // return: // -1 出错 // 0 没有找到 // 1 找到 public int GetBrowseColumnCaptions( SessionInfo sessioninfo, string strDbName, string strLang, out List <string> captions, out string strError) { strError = ""; captions = null; REDO: List <BrowseColumnCaption> results = (List <BrowseColumnCaption>) this.BrowsColumnTable[strDbName]; if (results != null && results.Count > 0) { if (results.Count == 1) { captions = results[0].ColumnCaptions; return(1); } string strLangLeft = ""; string strLangRight = ""; DomUtil.SplitLang(strLang, out strLangLeft, out strLangRight); for (int i = 0; i < results.Count; i++) { BrowseColumnCaption cur_captions = results[i]; string strThisLang = cur_captions.Lang; string strThisLangLeft = ""; string strThisLangRight = ""; DomUtil.SplitLang(strThisLang, out strThisLangLeft, out strThisLangRight); // 是不是左右都匹配则更好?如果不行才是第一个左边匹配的 if (strThisLangLeft == strLangLeft) { captions = cur_captions.ColumnCaptions; return(1); } } captions = results[0].ColumnCaptions; return(1); } string strRemotePath = strDbName + "/cfgs/browse"; string strLocalPath = ""; #if NO // 临时的SessionInfo对象 SessionInfo session = new SessionInfo(this); session.UserID = this.ManagerUserName; session.Password = this.ManagerPassword; session.IsReader = false; session.Parameters = ""; // 2014/12/23 #endif LibraryChannel channel = this.GetChannel(); try { int nRet = this.CfgsMap.MapFileToLocal( channel, //session.Channel, strRemotePath, out strLocalPath, out strError); if (nRet == -1) { strError = "获得配置文件 '" + strRemotePath + "' 时发生错误:" + strError; return(-1); } if (nRet == 0) { return(0); } } finally { #if NO session.CloseSession(); #endif this.ReturnChannel(channel); } XmlDocument dom = new XmlDocument(); try { dom.Load(strLocalPath); } catch (Exception ex) { strError = "数据库 " + strDbName + " 的browse配置文件 '" + strLocalPath + "' 装入XMLDOM时出错: " + ex.Message; return(-1); } List <BrowseColumnCaption> defs = new List <BrowseColumnCaption>(); XmlNodeList lang_nodes = dom.DocumentElement.SelectNodes("//col/title/caption/@lang"); if (lang_nodes.Count > 0) { List <string> langs = new List <string>(); foreach (XmlNode node in lang_nodes) { string strValue = node.Value; if (langs.IndexOf(strValue) == -1) { langs.Add(strValue); } } XmlNodeList col_nodes = dom.DocumentElement.SelectNodes("//col"); foreach (string lang in langs) { BrowseColumnCaption one = new BrowseColumnCaption(); one.Lang = lang; one.ColumnCaptions = new List <string>(); defs.Add(one); foreach (XmlNode node in col_nodes) { XmlNode nodeTitle = node.SelectSingleNode("title"); if (nodeTitle != null) { string strCaption = DomUtil.GetLangedNodeText( lang, nodeTitle, "caption", true); one.ColumnCaptions.Add(strCaption); } else { // 被迫使用<col>元素的title属性 one.ColumnCaptions.Add(DomUtil.GetAttr(node, "title")); } } } this.BrowsColumnTable[strDbName] = defs; goto REDO; } { BrowseColumnCaption one = new BrowseColumnCaption(); one.Lang = "zh"; // 缺省为zh one.ColumnCaptions = new List <string>(); defs.Add(one); XmlNodeList nodes = dom.DocumentElement.SelectNodes("//col"); for (int j = 0; j < nodes.Count; j++) { string strColumnTitle = DomUtil.GetAttr(nodes[j], "title"); one.ColumnCaptions.Add(strColumnTitle); } this.BrowsColumnTable[strDbName] = defs; goto REDO; } }
// 获得一个库的浏览列标题 // return: // -1 出错 // 0 没有找到 // 1 找到 public int GetBrowseColumnCaptions( SessionInfo sessioninfo, string strDbName, string strLang, out List<string> captions, out string strError) { strError = ""; captions = null; REDO: List<BrowseColumnCaption> results = (List<BrowseColumnCaption>)this.BrowsColumnTable[strDbName]; if (results != null && results.Count > 0) { if (results.Count == 1) { captions = results[0].ColumnCaptions; return 1; } string strLangLeft = ""; string strLangRight = ""; DomUtil.SplitLang(strLang, out strLangLeft, out strLangRight); for (int i = 0; i < results.Count; i++) { BrowseColumnCaption cur_captions = results[i]; string strThisLang = cur_captions.Lang; string strThisLangLeft = ""; string strThisLangRight = ""; DomUtil.SplitLang(strThisLang, out strThisLangLeft, out strThisLangRight); // 是不是左右都匹配则更好?如果不行才是第一个左边匹配的 if (strThisLangLeft == strLangLeft) { captions = cur_captions.ColumnCaptions; return 1; } } captions = results[0].ColumnCaptions; return 1; } string strRemotePath = strDbName + "/cfgs/browse"; string strLocalPath = ""; #if NO // 临时的SessionInfo对象 SessionInfo session = new SessionInfo(this); session.UserID = this.ManagerUserName; session.Password = this.ManagerPassword; session.IsReader = false; session.Parameters = ""; // 2014/12/23 #endif LibraryChannel channel = this.GetChannel(); try { int nRet = this.CfgsMap.MapFileToLocal( channel, //session.Channel, strRemotePath, out strLocalPath, out strError); if (nRet == -1) { strError = "获得配置文件 '" + strRemotePath + "' 时发生错误:" + strError; return -1; } if (nRet == 0) return 0; } finally { #if NO session.CloseSession(); #endif this.ReturnChannel(channel); } XmlDocument dom = new XmlDocument(); try { dom.Load(strLocalPath); } catch (Exception ex) { strError = "数据库 " + strDbName + " 的browse配置文件 '" + strLocalPath + "' 装入XMLDOM时出错: " + ex.Message; return -1; } List<BrowseColumnCaption> defs = new List<BrowseColumnCaption>(); XmlNodeList lang_nodes = dom.DocumentElement.SelectNodes("//col/title/caption/@lang"); if (lang_nodes.Count > 0) { List<string> langs = new List<string>(); foreach (XmlNode node in lang_nodes) { string strValue = node.Value; if (langs.IndexOf(strValue) == -1) langs.Add(strValue); } XmlNodeList col_nodes = dom.DocumentElement.SelectNodes("//col"); foreach (string lang in langs) { BrowseColumnCaption one = new BrowseColumnCaption(); one.Lang = lang; one.ColumnCaptions = new List<string>(); defs.Add(one); foreach (XmlNode node in col_nodes) { XmlNode nodeTitle = node.SelectSingleNode("title"); if (nodeTitle != null) { string strCaption = DomUtil.GetLangedNodeText( lang, nodeTitle, "caption", true); one.ColumnCaptions.Add(strCaption); } else { // 被迫使用<col>元素的title属性 one.ColumnCaptions.Add(DomUtil.GetAttr(node, "title")); } } } this.BrowsColumnTable[strDbName] = defs; goto REDO; } { BrowseColumnCaption one = new BrowseColumnCaption(); one.Lang = "zh"; // 缺省为zh one.ColumnCaptions = new List<string>(); defs.Add(one); XmlNodeList nodes = dom.DocumentElement.SelectNodes("//col"); for (int j = 0; j < nodes.Count; j++) { string strColumnTitle = DomUtil.GetAttr(nodes[j], "title"); one.ColumnCaptions.Add(strColumnTitle); } this.BrowsColumnTable[strDbName] = defs; goto REDO; } }
public void ThreadPoolCallBack(object context) { FilterTaskInput input = (FilterTaskInput)context; string strError = ""; #if NO // 临时的SessionInfo对象 SessionInfo session = new SessionInfo(input.App); session.UserID = input.App.ManagerUserName; session.Password = input.App.ManagerPassword; session.IsReader = false; #endif LibraryChannel channel = input.App.GetChannel(); try { Hashtable result_table = null; long lHitCount = 0; int nRet = ResultsetFilter.DoFilter( input.App, channel, // session.Channel, input.ResultSetName, input.FilterFileName, input.MaxCount, _SetProgress, ref result_table, out lHitCount, out strError); if (nRet == -1) { this.ErrorInfo = strError; this.TaskState = TaskState.Done; return; } this.HitCount = lHitCount; // 继续加工 List <NodeInfo> output_items = null; nRet = ResultsetFilter.BuildResultsetFile(result_table, input.DefDom, // input.aggregation_names, input.TempDir, // input.SessionInfo.GetTempDir(), out output_items, out strError); if (nRet == -1) { this.ErrorInfo = strError; this.TaskState = TaskState.Done; return; } { this.ResultItems = output_items; this.TaskState = TaskState.Done; } if (input.ShareResultSet == true) { // 删除全局结果集对象 // 管理结果集 // parameters: // strAction share/remove 分别表示共享为全局结果集对象/删除全局结果集对象 long lRet = // session.Channel. channel.ManageSearchResult( null, "remove", "", input.ResultSetName, out strError); if (lRet == -1) { this.ErrorInfo = strError; } input.ShareResultSet = false; input.ResultSetName = ""; } } finally { #if NO session.CloseSession(); #endif input.App.ReturnChannel(channel); } #if NO if (input.SessionInfo != null && string.IsNullOrEmpty(input.TaskName) == false) { input.SessionInfo.SetFilterTask(input.TaskName, this); } #endif input.App.SetFilterTask(input.TaskName, this); }
public void ThreadPoolCallBack(object context) { FilterTaskInput input = (FilterTaskInput)context; string strError = ""; #if NO // 临时的SessionInfo对象 SessionInfo session = new SessionInfo(input.App); session.UserID = input.App.ManagerUserName; session.Password = input.App.ManagerPassword; session.IsReader = false; #endif LibraryChannel channel = input.App.GetChannel(); try { Hashtable result_table = null; long lHitCount = 0; int nRet = ResultsetFilter.DoFilter( input.App, channel, // session.Channel, input.ResultSetName, input.FilterFileName, input.MaxCount, _SetProgress, ref result_table, out lHitCount, out strError); if (nRet == -1) { this.ErrorInfo = strError; this.TaskState = TaskState.Done; return; } this.HitCount = lHitCount; // 继续加工 List<NodeInfo> output_items = null; nRet = ResultsetFilter.BuildResultsetFile(result_table, input.DefDom, // input.aggregation_names, input.TempDir, // input.SessionInfo.GetTempDir(), out output_items, out strError); if (nRet == -1) { this.ErrorInfo = strError; this.TaskState = TaskState.Done; return; } { this.ResultItems = output_items; this.TaskState = TaskState.Done; } if (input.ShareResultSet == true) { // 删除全局结果集对象 // 管理结果集 // parameters: // strAction share/remove 分别表示共享为全局结果集对象/删除全局结果集对象 long lRet = // session.Channel. channel.ManageSearchResult( null, "remove", "", input.ResultSetName, out strError); if (lRet == -1) this.ErrorInfo = strError; input.ShareResultSet = false; input.ResultSetName = ""; } } finally { #if NO session.CloseSession(); #endif input.App.ReturnChannel(channel); } #if NO if (input.SessionInfo != null && string.IsNullOrEmpty(input.TaskName) == false) input.SessionInfo.SetFilterTask(input.TaskName, this); #endif input.App.SetFilterTask(input.TaskName, this); }
public void ThreadPoolCallBack(object context) { FilterTaskInput input = (FilterTaskInput)context; Hashtable result_table = null; string strError = ""; // 临时的SessionInfo对象 SessionInfo session = new SessionInfo(input.App); session.UserID = input.App.ManagerUserName; session.Password = input.App.ManagerPassword; session.IsReader = false; try { long lHitCount = 0; int nRet = ResultsetFilter.DoFilter( input.App, session.Channel, input.ResultSetName, input.FilterFileName, input.MaxCount, _SetProgress, ref result_table, out lHitCount, out strError); if (nRet == -1) { this.ErrorInfo = strError; this.TaskState = TaskState.Done; return; } this.HitCount = lHitCount; /* if (string.IsNullOrEmpty(strFacetDefXml) == false) { this.DefDom = new XmlDocument(); try { this.DefDom.LoadXml(strFacetDefXml); } catch (Exception ex) { this.ErrorInfo = "strDefXml装入XMLDOM出错: " + ex.Message; this.TaskState = TaskState.Done; return; } } * */ // 继续加工 List<NodeInfo> output_items = null; nRet = ResultsetFilter.BuildResultsetFile(result_table, input.DefDom, // input.aggregation_names, input.SessionInfo.GetTempDir(), out output_items, out strError); if (nRet == -1) { this.ErrorInfo = strError; this.TaskState = TaskState.Done; return; } { this.ResultItems = output_items; this.TaskState = TaskState.Done; } if (input.ShareResultSet == true) { // 删除全局结果集对象 // 管理结果集 // parameters: // strAction share/remove 分别表示共享为全局结果集对象/删除全局结果集对象 long lRet = session.Channel.ManageSearchResult( null, "remove", "", input.ResultSetName, out strError); if (lRet == -1) this.ErrorInfo = strError; input.ShareResultSet = false; input.ResultSetName = ""; } } finally { session.CloseSession(); } if (input.SessionInfo != null && string.IsNullOrEmpty(input.TaskName) == false) input.SessionInfo.SetFilterTask(input.TaskName, this); }
public int DownloadObject(System.Web.UI.Page Page, LibraryChannel channel, string strPath, bool bSaveAs, string strStyle, out string strError) { strError = ""; if (channel == null) { // 临时的SessionInfo对象 // 用管理员身份 SessionInfo session = new SessionInfo(this); session.UserID = this.ManagerUserName; session.Password = this.ManagerPassword; session.IsReader = false; try { return DownloadObject0(Page, session.Channel, strPath, bSaveAs, strStyle, out strError); } finally { session.CloseSession(); } } else { return DownloadObject0(Page, channel, strPath, bSaveAs, strStyle, out strError); } }
public int SaveUploadFile( System.Web.UI.Page page, string strXmlRecPath, string strFileID, string strResTimeStamp, HttpPostedFile postedFile, int nLogoLimitW, int nLogoLimitH, out string strError) { strError = ""; // 临时的SessionInfo对象 SessionInfo session = new SessionInfo(this); session.UserID = this.ManagerUserName; session.Password = this.ManagerPassword; session.IsReader = false; try { return SaveUploadFile(page, session.Channel, strXmlRecPath, strFileID, strResTimeStamp, postedFile, nLogoLimitW, nLogoLimitH, out strError); } finally { session.CloseSession(); } }
public int GetReaderPhotoPath( // SessionInfo sessioninfo, string strReaderBarcode, string strEncyptBarcode, string strDisplayName, out string strPhotoPath, out string strError) { strError = ""; strPhotoPath = ""; if (String.IsNullOrEmpty(strEncyptBarcode) == false) { string strTemp = OpacApplication.DecryptPassword(strEncyptBarcode); if (strTemp == null) { strError = "strEncyptBarcode中包含的文字格式不正确"; return -1; } strReaderBarcode = strTemp; } // 临时的SessionInfo对象 SessionInfo session = new SessionInfo(this); session.UserID = this.ManagerUserName; session.Password = this.ManagerPassword; session.IsReader = false; try { // 读入读者记录 string strReaderXml = ""; byte[] reader_timestamp = null; string strOutputReaderRecPath = ""; string strResultTypeList = "xml"; string[] results = null; long lRet = session.Channel.GetReaderInfo(null, this.dp2LibraryVersion >= 2.22 ? "@barcode:" + strReaderBarcode // dp2Library V2.22 及以后可以使用这个方法 : strReaderBarcode, strResultTypeList, out results, out strOutputReaderRecPath, out reader_timestamp, out strError); if (lRet == 0) { strError = "读者证条码号 '" + strReaderBarcode + "' 不存在"; return 0; } if (lRet == -1) { // text-level: 内部错误 strError = "读入读者记录时发生错误: " + strError; return -1; } if (lRet > 1) { // text-level: 内部错误 strError = "读入读者记录时,发现读者证条码号 '" + strReaderBarcode + "' 命中 " + lRet.ToString() + " 条,这是一个严重错误,请系统管理员尽快处理。"; return -1; } if (results.Length != 1) { strError = "results.Length error"; return -1; } strReaderXml = results[0]; /* int nRet = this.GetReaderRecXml( sessioninfo.Channels, strReaderBarcode, out strReaderXml, out strOutputReaderRecPath, out reader_timestamp, out strError); if (nRet == 0) { strError = "读者证条码号 '" + strReaderBarcode + "' 不存在"; return 0; } if (nRet == -1) { // text-level: 内部错误 strError = "读入读者记录时发生错误: " + strError; return -1; } if (nRet > 1) { // text-level: 内部错误 strError = "读入读者记录时,发现读者证条码号 '" + strReaderBarcode + "' 命中 " + nRet.ToString() + " 条,这是一个严重错误,请系统管理员尽快处理。"; return -1; } * */ XmlDocument readerdom = null; int nRet = OpacApplication.LoadToDom(strReaderXml, out readerdom, out strError); if (nRet == -1) { // text-level: 内部错误 strError = "装载读者记录进入XML DOM时发生错误: " + strError; return -1; } // 验证显示名 if (String.IsNullOrEmpty(strDisplayName) == false) { string strDisplayNameValue = DomUtil.GetElementText(readerdom.DocumentElement, "displayName"); if (strDisplayName.Trim() != strDisplayNameValue.Trim()) { strError = "虽然读者记录找到了,但是显示名已经不匹配"; return 0; } } // 看看是不是已经有图像对象 XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable()); nsmgr.AddNamespace("dprms", DpNs.dprms); // 全部<dprms:file>元素 XmlNodeList nodes = readerdom.DocumentElement.SelectNodes("//dprms:file[@usage='photo']", nsmgr); if (nodes.Count == 0) { strError = "读者记录中没有头像对象"; return 0; } strPhotoPath = strOutputReaderRecPath + "/object/" + DomUtil.GetAttr(nodes[0], "id"); return 1; } finally { session.CloseSession(); } }
public int GetXmlDefs( bool bOuputDebugInfo, out string strDebugInfo, out string strError) { strError = ""; strDebugInfo = ""; long lRet = 0; this.m_lock.AcquireWriterLock(m_nLockTimeout); try { // 临时的SessionInfo对象 SessionInfo session = new SessionInfo(this); session.UserID = this.ManagerUserName; session.Password = this.ManagerPassword; session.IsReader = false; try { // 检查版本号 { string strVersion = ""; string strUID = ""; lRet = session.Channel.GetVersion( null, out strVersion, out strUID, out strError); if (lRet == -1) { strError = "针对 dp2Library 服务器 " + session.Channel.Url + " 获得版本号的过程发生错误:" + strError; goto ERROR1; } double value = 0; if (string.IsNullOrEmpty(strVersion) == true) { strVersion = "2.0以下"; value = 2.0; } else { // 检查最低版本号 if (double.TryParse(strVersion, out value) == false) { strError = "dp2Library 版本号 '" + strVersion + "' 格式不正确"; goto ERROR1; } } this.dp2LibraryVersion = value; this.dp2LibraryUID = strUID; double base_version = 2.40; // 2.18 if (value < base_version) { strError = "当前 dp2OPAC 版本需要和 dp2Library " + base_version + " 或以上版本配套使用 (而当前 dp2Library 版本号为 '" + strVersion + "' )。请立即升级 dp2Library 到最新版本。"; return -2; } } // 获取虚拟库定义 string strXml = ""; lRet = session.Channel.GetSystemParameter( null, "virtual", "def", out strXml, out strError); if (lRet == -1) { strError = "(" + session.UserID + ")获取虚拟库定义时发生错误: " + strError; // this.WriteErrorLog(strError); goto ERROR1; } if (bOuputDebugInfo == true) strDebugInfo += "*** virtual/def:\r\n" + strXml + "\r\n"; XmlNode node_virtual = this.OpacCfgDom.DocumentElement.SelectSingleNode("virtualDatabases"); if (node_virtual == null) { node_virtual = this.OpacCfgDom.CreateElement("virtualDatabases"); this.OpacCfgDom.DocumentElement.AppendChild(node_virtual); } node_virtual = DomUtil.SetElementOuterXml(node_virtual, strXml); Debug.Assert(node_virtual != null, ""); // 获取<arrived>定义 lRet = session.Channel.GetSystemParameter( null, "system", "arrived", out strXml, out strError); if (lRet == -1) { strError = "(" + session.UserID + ")获取<arrived>定义时发生错误: " + strError; // this.WriteErrorLog(strError); goto ERROR1; } if (bOuputDebugInfo == true) strDebugInfo += "*** system/arrived:\r\n" + strXml + "\r\n"; XmlNode node_arrived = this.OpacCfgDom.DocumentElement.SelectSingleNode("arrived"); if (node_arrived == null) { node_arrived = this.OpacCfgDom.CreateElement("arrived"); this.OpacCfgDom.DocumentElement.AppendChild(node_arrived); } node_arrived = DomUtil.SetElementOuterXml(node_arrived, strXml); Debug.Assert(node_arrived != null, ""); // 获取<browseformats>定义 lRet = session.Channel.GetSystemParameter( null, "opac", "browseformats", out strXml, out strError); if (lRet == -1) { strError = "(" + session.UserID + ")获取<browseformats>定义时发生错误: " + strError; // this.WriteErrorLog(strError); goto ERROR1; } if (bOuputDebugInfo == true) strDebugInfo += "*** opac/browseformats:\r\n" + strXml + "\r\n"; XmlNode node_browseformats = this.OpacCfgDom.DocumentElement.SelectSingleNode("browseformats"); if (node_browseformats == null) { node_browseformats = this.OpacCfgDom.CreateElement("browseformats"); this.OpacCfgDom.DocumentElement.AppendChild(node_browseformats); } node_browseformats.InnerXml = strXml; // 获取<biblioDbGroup>定义 lRet = session.Channel.GetSystemParameter( null, "system", "biblioDbGroup", out strXml, out strError); if (lRet == -1) { strError = "(" + session.UserID + ")获取<biblioDbGroup>定义时发生错误: " + strError; // this.WriteErrorLog(strError); goto ERROR1; } if (bOuputDebugInfo == true) strDebugInfo += "*** system/biblioDbGroup:\r\n" + strXml + "\r\n"; XmlNode node_biblioDbGroup = this.OpacCfgDom.DocumentElement.SelectSingleNode("biblioDbGroup"); if (node_biblioDbGroup == null) { node_biblioDbGroup = this.OpacCfgDom.CreateElement("biblioDbGroup"); this.OpacCfgDom.DocumentElement.AppendChild(node_biblioDbGroup); } node_biblioDbGroup.InnerXml = strXml; ClearInvisibleDatabaseDef(ref node_biblioDbGroup, node_virtual); // 2012/10/23 // 获取<readerDbGroup>定义 { lRet = session.Channel.GetSystemParameter( null, "system", "readerDbGroup", out strXml, out strError); if (lRet == -1) { strError = "(" + session.UserID + ")获取<readerDbGroup>定义时发生错误: " + strError; // this.WriteErrorLog(strError); goto ERROR1; } if (bOuputDebugInfo == true) strDebugInfo += "*** system/readerDbGroup:\r\n" + strXml + "\r\n"; XmlNode node_readerDbGroup = this.OpacCfgDom.DocumentElement.SelectSingleNode("readerDbGroup"); if (node_readerDbGroup == null) { node_readerDbGroup = this.OpacCfgDom.CreateElement("readerDbGroup"); this.OpacCfgDom.DocumentElement.AppendChild(node_readerDbGroup); } node_readerDbGroup.InnerXml = strXml; } this.Changed = true; this.ActivateManagerThread(); // 检查 simulatereader 和 simulateworder 权限 if (StringUtil.IsInList("simulatereader", session.Channel.Rights) == false || StringUtil.IsInList("simulateworker", session.Channel.Rights) == false) { strError = "OPAC 代理账户 '" + this.ManagerUserName + "' 缺乏 simulatereader 和 simulateworker 权限。请在 dp2library 中为它增配这两个权限"; return -1; } this.XmlLoaded = true; // 预约到书 // 元素<arrived> // 属性dbname/reserveTimeSpan/outofReservationThreshold/canReserveOnshelf XmlNode node = this.OpacCfgDom.DocumentElement.SelectSingleNode("//arrived"); if (node != null) { this.ArrivedDbName = DomUtil.GetAttr(node, "dbname"); this.ArrivedReserveTimeSpan = DomUtil.GetAttr(node, "reserveTimeSpan"); int nValue = 0; int nRet = DomUtil.GetIntegerParam(node, "outofReservationThreshold", 10, out nValue, out strError); if (nRet == -1) { strError = "元素<arrived>属性outofReservationThreshold读入时发生错误: " + strError; goto ERROR1; } this.OutofReservationThreshold = nValue; bool bValue = false; nRet = DomUtil.GetBooleanParam(node, "canReserveOnshelf", true, out bValue, out strError); if (nRet == -1) { strError = "元素<arrived>属性canReserveOnshelf读入时发生错误: " + strError; goto ERROR1; } this.CanReserveOnshelf = bValue; } return 0; } finally { session.CloseSession(); } } finally { this.m_lock.ReleaseWriterLock(); } ERROR1: return -1; }
public int GetDbFroms( string strDbType, string strLang, out BiblioDbFromInfo[] infos, out string strError) { strError = ""; infos = null; string strKey = strDbType + "|" + strLang; infos = (BiblioDbFromInfo[])this.m_fromTable[strKey]; if (infos != null) return 1; this.m_lock.AcquireWriterLock(m_nLockTimeout); try { // 临时的SessionInfo对象 SessionInfo session = new SessionInfo(this); session.UserID = this.ManagerUserName; session.Password = this.ManagerPassword; session.IsReader = false; try { // 获取虚拟库定义 long lRet = session.Channel.ListDbFroms(null, strDbType, strLang, out infos, out strError); if (lRet == -1) { strError = "(" + session.UserID + ")获得from定义时发生错误: " + strError; // this.WriteErrorLog(strError); goto ERROR1; } } finally { session.CloseSession(); } } finally { this.m_lock.ReleaseWriterLock(); } this.m_fromTable[strKey] = infos; return 0; ERROR1: return -1; }