void SetSideBarVisible() { bool bItemSearchVisible = true; bool bCommentSearchVisible = true; XmlNode nodeItemSearch = app.WebUiDom.DocumentElement.SelectSingleNode("itemSearch"); if (nodeItemSearch != null) { bItemSearchVisible = DomUtil.GetBooleanParam(nodeItemSearch, "visible", true); } XmlNode nodeCommentSearch = app.WebUiDom.DocumentElement.SelectSingleNode("commentSearch"); if (nodeCommentSearch != null) { bCommentSearchVisible = DomUtil.GetBooleanParam(nodeCommentSearch, "visible", true); } if (bItemSearchVisible == false && bCommentSearchVisible == false) { this.SideBarControl1.Visible = false; } }
// 解析通用启动参数 // 格式 /* * <root clearFirst='...' continueWhenError='...' /> * clearFirst 缺省为 false * continueWhenError 缺省值为 false * */ public static int ParseLogRecoverParam(string strParam, out bool bClearFirst, out bool bContinueWhenError, out string strError) { strError = ""; bClearFirst = false; bContinueWhenError = false; if (String.IsNullOrEmpty(strParam) == true) { return(0); } XmlDocument dom = new XmlDocument(); try { dom.LoadXml(strParam); } catch (Exception ex) { strError = "strParam参数装入XML DOM时出错: " + ex.Message; return(-1); } bClearFirst = DomUtil.GetBooleanParam(dom.DocumentElement, "clearFirst", false); // 2016/3/8 bContinueWhenError = DomUtil.GetBooleanParam(dom.DocumentElement, "continueWhenError", false); return(0); }
static List <string> GetReaderDbNames(XmlDocument database_dom) { List <string> results = new List <string>(); XmlNodeList nodes = database_dom.DocumentElement.SelectNodes("database[@type='reader']"); foreach (XmlElement node in nodes) { string dbName = node.GetAttribute("name"); string libraryCode = node.GetAttribute("libraryCode"); #if NO bool bValue = true; nRet = DomUtil.GetBooleanParam(node, "inCirculation", true, out bValue, out strError); property.InCirculation = bValue; #endif if (string.IsNullOrEmpty(dbName) == false) { results.Add(dbName); } } return(results); }
static List <string> GetItemDbNames(XmlDocument database_dom) { List <string> results = new List <string>(); XmlNodeList nodes = database_dom.DocumentElement.SelectNodes("database[@type='biblio']"); foreach (XmlElement node in nodes) { string strName = node.GetAttribute("name"); string strType = node.GetAttribute("type"); string itemDbName = node.GetAttribute("entityDbName"); string syntax = node.GetAttribute("syntax"); string issueDbName = node.GetAttribute("issueDbName"); string orderDbName = node.GetAttribute("orderDbName"); string commentDbName = node.GetAttribute("commentDbName"); string role = node.GetAttribute("role"); if (string.IsNullOrEmpty(itemDbName) == false) { results.Add(itemDbName); } #if NO bool bValue = true; nRet = DomUtil.GetBooleanParam(node, "inCirculation", true, out bValue, out strError); property.InCirculation = bValue; #endif } return(results); }
/* * <config amerce_interface="<无>" im_server_url="http://dp2003.com:8083/dp2MServer" green_package_server_url="" pinyin_server_url="http://dp2003.com/dp2library" gcat_server_url="http://dp2003.com/dp2library" circulation_server_url="net.pipe://localhost/dp2library/XE"/> * <default_account tempCode="" phoneNumber="" occur_per_start="true" location="" isreader="false" savepassword_long="true" savepassword_short="true" username="******" password="******"/> * */ public static int GetDp2circulationUserName( out string url, out string userName, out string password, out bool savePassword, out string strError) { strError = ""; url = ""; userName = ""; password = ""; savePassword = false; string strXmlFilename = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "dp2circulation_v2\\dp2circulation.xml"); if (File.Exists(strXmlFilename) == false) { return(0); } XmlDocument dom = new XmlDocument(); dom.PreserveWhitespace = true; try { dom.Load(strXmlFilename); } catch (Exception ex) { strError = $"打开 XML 文件失败: {ex.Message}"; return(-1); } { XmlElement default_account = dom.DocumentElement.SelectSingleNode("default_account") as XmlElement; if (default_account != null) { userName = default_account.GetAttribute("username"); savePassword = DomUtil.GetBooleanParam(default_account, "savepassword_long", false); if (savePassword == true) { string password_text = default_account.GetAttribute("password"); password = DecryptDp2circulationPasssword(password_text); } } } { XmlElement config = dom.DocumentElement.SelectSingleNode("config") as XmlElement; if (config != null) { url = config.GetAttribute("circulation_server_url"); } } return(1); }
// 解析通用启动参数 // 格式 /* * <root recoverLevel='...' clearFirst='...' continueWhenError='...'/> * recoverLevel 缺省为 Snapshot * clearFirst 缺省为 false * continueWhenError 缺省值为 false * */ public static int ParseLogRecoverParam(string strParam, out string strRecoverLevel, out bool bClearFirst, out bool bContinueWhenError, out string strStyle, out string strError) { strError = ""; bClearFirst = false; strRecoverLevel = ""; bContinueWhenError = false; strStyle = ""; if (String.IsNullOrEmpty(strParam) == true) { return(0); } XmlDocument dom = new XmlDocument(); try { dom.LoadXml(strParam); } catch (Exception ex) { strError = "strParam参数装入XML DOM时出错: " + ex.Message; return(-1); } /* * Logic = 0, // 逻辑操作 * LogicAndSnapshot = 1, // 逻辑操作,若失败则转用快照恢复 * Snapshot = 3, // (完全的)快照 * Robust = 4, * */ strRecoverLevel = DomUtil.GetAttr(dom.DocumentElement, "recoverLevel"); string strClearFirst = DomUtil.GetAttr(dom.DocumentElement, "clearFirst"); if (strClearFirst.ToLower() == "yes" || strClearFirst.ToLower() == "true") { bClearFirst = true; } else { bClearFirst = false; } // 2016/3/8 bContinueWhenError = DomUtil.GetBooleanParam(dom.DocumentElement, "continueWhenError", false); strStyle = DomUtil.GetAttr(dom.DocumentElement, "style"); return(0); }
int FillList(string strXml, out string strError) { strError = ""; int nRet = 0; this.listView_location_list.Items.Clear(); if (String.IsNullOrEmpty(strXml) == true) { return(0); } XmlDocument dom = new XmlDocument(); try { dom.LoadXml(strXml); } catch (Exception ex) { strError = "XML装载到DOM时出错: " + ex.Message; return(-1); } XmlNodeList nodes = dom.DocumentElement.SelectNodes("item"); for (int i = 0; i < nodes.Count; i++) { XmlNode node = nodes[i]; string strText = node.InnerText.Trim(); bool bCanBorrow = false; // 获得布尔型的属性参数值 // return: // -1 出错。但是bValue中已经有了bDefaultValue值,可以不加警告而直接使用 // 0 正常获得明确定义的参数值 // 1 参数没有定义,因此代替以缺省参数值返回 nRet = DomUtil.GetBooleanParam(node, "canborrow", false, out bCanBorrow, out strError); if (nRet == -1) { return(-1); } ListViewItem item = new ListViewItem(); item.Text = strText; item.SubItems.Add(bCanBorrow == true ? "是" : "否"); this.listView_location_list.Items.Add(item); } return(0); }
void LoadData() { if (this.CfgDom == null || this.CfgDom.DocumentElement == null) { return; } this.textBox_title_typeName.Text = DomUtil.GetElementText(this.CfgDom.DocumentElement, "typeName"); // XmlNode node_title = this.CfgDom.DocumentElement.SelectSingleNode("title"); this.textBox_title_title.Text = DomUtil.GetElementText(this.CfgDom.DocumentElement, "title").Replace("\\r", "\r\n"); this.textBox_title_comment.Text = DomUtil.GetElementText(this.CfgDom.DocumentElement, "titleComment").Replace("\\r", "\r\n"); this.listView_columns.Items.Clear(); XmlNodeList nodes = this.CfgDom.DocumentElement.SelectNodes("columns/column"); foreach (XmlNode node in nodes) { string strName = DomUtil.GetAttr(node, "name"); string strDataType = DomUtil.GetAttr(node, "type"); string strAlign = DomUtil.GetAttr(node, "align"); string strSum = DomUtil.GetAttr(node, "sum"); string strClass = DomUtil.GetAttr(node, "class"); string strEval = DomUtil.GetAttr(node, "eval"); ListViewItem item = new ListViewItem(); ListViewUtil.ChangeItemText(item, COLUMN_NAME, strName); ListViewUtil.ChangeItemText(item, COLUMN_DATATYPE, strDataType); ListViewUtil.ChangeItemText(item, COLUMN_ALIGN, strAlign); ListViewUtil.ChangeItemText(item, COLUMN_SUM, strSum); ListViewUtil.ChangeItemText(item, COLUMN_CSSCLASS, strClass); ListViewUtil.ChangeItemText(item, COLUMN_EVAL, strEval); this.listView_columns.Items.Add(item); } this.textBox_columns_sortStyle.Text = DomUtil.GetElementText(this.CfgDom.DocumentElement, "columnSortStyle"); this.textBox_css_content.Text = DomUtil.GetElementText(this.CfgDom.DocumentElement, "css").Replace("\\r", "\r\n").Replace("\\t", "\t"); this.checkedComboBox_property_createFreq.Text = DomUtil.GetElementText(this.CfgDom.DocumentElement, "createFrequency"); this.checkBox_property_fresh.Checked = DomUtil.GetBooleanParam( this.CfgDom.DocumentElement, "property", "fresh", false); }
bool GetVisible(string strType) { XmlNode nodeItemSearch = app.WebUiDom.DocumentElement.SelectSingleNode(strType.ToLower() + "Search"); if (nodeItemSearch == null) { return(true); } return(DomUtil.GetBooleanParam(nodeItemSearch, "visible", true)); }
// 从报表配置文件中获得各种配置信息 // return: // -1 出错 // 0 没有找到配置文件 // 1 成功 internal static int GetReportConfig(string strCfgFile, out ReportConfigStruct config, out string strError) { strError = ""; config = new ReportConfigStruct(); XmlDocument dom = new XmlDocument(); try { dom.Load(strCfgFile); } catch (FileNotFoundException) { strError = "配置文件 '" + strCfgFile + "' 没有找到"; return(0); } catch (Exception ex) { strError = "报表配置文件 " + strCfgFile + " 打开错误: " + ex.Message; return(-1); } XmlNode nodeProperty = dom.DocumentElement.SelectSingleNode("property"); if (nodeProperty != null) { bool bValue = false; int nRet = DomUtil.GetBooleanParam(nodeProperty, "fresh", false, out bValue, out strError); if (nRet == -1) { return(-1); } config.Fresh = bValue; } config.ColumnSortStyle = DomUtil.GetElementText(dom.DocumentElement, "columnSortStyle"); config.TypeName = DomUtil.GetElementText(dom.DocumentElement, "typeName"); config.CreateFreq = DomUtil.GetElementText(dom.DocumentElement, "createFrequency"); return(1); }
/// <summary> /// 构造函数 /// 根据XML配置文件, 从服务器获取目录信息, 初始化数据结构 /// </summary> public int Initial(XmlNode root, out string strError) { strError = ""; // Debug.Assert(false, ""); // 列出所有虚拟库XML节点 // XmlNodeList virtualnodes = root.SelectNodes("virtualDatabase"); for (int i = 0; i < root.ChildNodes.Count; i++) { XmlNode node = root.ChildNodes[i]; if (node.NodeType != XmlNodeType.Element) { continue; } // 2017/12/12 if (DomUtil.GetBooleanParam(node, "hide", false) == true) { continue; } if (node.Name == "virtualDatabase") { // 构造虚拟数据库对象 VirtualDatabase vdb = new VirtualDatabase(); vdb.nodeDatabase = node; this.Add(vdb); continue; } if (node.Name == "database") // 普通库 { // 构造普通数据库对象 VirtualDatabase vdb = new VirtualDatabase(); vdb.nodeDatabase = node; this.Add(vdb); continue; } } return(0); }
public int InitialBiblioDbProperties( out string strError) { strError = ""; int nRet = 0; this.BiblioDbProperties = new List <BiblioDbProperty>(); if (this.AllDatabaseDom == null) { return(0); } XmlNodeList nodes = this.AllDatabaseDom.DocumentElement.SelectNodes("database[@type='biblio']"); foreach (XmlNode node in nodes) { string strName = DomUtil.GetAttr(node, "name"); string strType = DomUtil.GetAttr(node, "type"); // string strRole = DomUtil.GetAttr(node, "role"); // string strLibraryCode = DomUtil.GetAttr(node, "libraryCode"); BiblioDbProperty property = new BiblioDbProperty(); this.BiblioDbProperties.Add(property); property.DbName = DomUtil.GetAttr(node, "name"); property.ItemDbName = DomUtil.GetAttr(node, "entityDbName"); property.Syntax = DomUtil.GetAttr(node, "syntax"); property.IssueDbName = DomUtil.GetAttr(node, "issueDbName"); property.OrderDbName = DomUtil.GetAttr(node, "orderDbName"); property.CommentDbName = DomUtil.GetAttr(node, "commentDbName"); property.Role = DomUtil.GetAttr(node, "role"); bool bValue = true; nRet = DomUtil.GetBooleanParam(node, "inCirculation", true, out bValue, out strError); property.InCirculation = bValue; } return(0); }
public bool GetFresh() { XmlNode nodeProperty = this._cfgDom.DocumentElement.SelectSingleNode("property"); if (nodeProperty != null) { string strError = ""; bool bValue = false; int nRet = DomUtil.GetBooleanParam(nodeProperty, "fresh", false, out bValue, out strError); if (nRet == -1) { throw new Exception(strError); } return(bValue); } return(false); }
protected override void Render(HtmlTextWriter writer) { int nRet = 0; string strError = ""; OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; bool bManager = false; if (String.IsNullOrEmpty(sessioninfo.UserID) == true || StringUtil.IsInList("managecomment", sessioninfo.RightsOrigin) == false) { bManager = false; } else { bManager = true; } LoginState loginstate = GlobalUtil.GetLoginState(this.Page); bool bReader = false; if (sessioninfo.ReaderInfo != null && sessioninfo.IsReader == true && loginstate != LoginState.Public) { bReader = true; } if (bManager == false) { Button delete_button = (Button)this.FindControl("delete_button"); delete_button.Visible = false; Button open_modify_state_button = (Button)this.FindControl("open_modify_state_button"); open_modify_state_button.Visible = false; Button selectall_button = (Button)this.FindControl("selectall_button"); selectall_button.Visible = false; Button unselectall_button = (Button)this.FindControl("unselectall_button"); unselectall_button.Visible = false; } /* * if (sessioninfo.Account == null) * { * // 临时的SessionInfo对象 * SessionInfo temp_sessioninfo = new SessionInfo(app); * * // 模拟一个账户 * Account account = new Account(); * account.LoginName = "opac_column"; * account.Password = ""; * account.Rights = "getbibliosummary"; * * account.Type = ""; * account.Barcode = ""; * account.Name = "opac_column"; * account.UserID = "opac_column"; * account.RmsUserName = app.ManagerUserName; * account.RmsPassword = app.ManagerPassword; * * temp_sessioninfo.Account = account; * sessioninfo = temp_sessioninfo; * } * */ bool bUseBiblioSummary = false; // 使用书目摘要(否则就是详细书目格式) bool bDitto = true; // 书目 同上... XmlNode nodeBookReview = app.WebUiDom.DocumentElement.SelectSingleNode("bookReview"); if (nodeBookReview != null) { DomUtil.GetBooleanParam(nodeBookReview, "ditto", true, out bDitto, out strError); DomUtil.GetBooleanParam(nodeBookReview, "useBiblioSummary", false, out bUseBiblioSummary, out strError); } int nPageNo = this.StartIndex / this.PageMaxLines; SetTitle(String.IsNullOrEmpty(this.Title) == true ? this.GetString("栏目") : this.Title); SetResultInfo(); if (this.CommentColumn == null || this.CommentColumn.Opened == false) { this.SetDebugInfo("errorinfo", "尚未创建栏目缓存..."); } if (this.CommentColumn != null) { LibraryChannel channel = sessioninfo.GetChannel(true); app.m_lockCommentColumn.AcquireReaderLock(app.m_nCommentColumnLockTimeout); try { string strPrevBiblioRecPath = ""; for (int i = 0; i < this.PageMaxLines; i++) { PlaceHolder line = (PlaceHolder)this.FindControl("line" + Convert.ToString(i)); if (line == null) { PlaceHolder insertpoint = (PlaceHolder)this.FindControl("insertpoint"); PlaceHolder content = (PlaceHolder)this.FindControl("content"); line = this.NewContentLine(content, i, insertpoint); } LiteralControl no = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_no"); HyperLink pathcontrol = (HyperLink)this.FindControl("line" + Convert.ToString(i) + "_path"); // LiteralControl contentcontrol = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_content"); CommentControl commentcontrol = (CommentControl)this.FindControl("line" + Convert.ToString(i) + "_comment"); LiteralControl bibliosummarycontrol = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_bibliosummary"); HyperLink bibliorecpathcontrol = (HyperLink)this.FindControl("line" + Convert.ToString(i) + "_bibliorecpath"); Button newreview = (Button)this.FindControl("line" + Convert.ToString(i) + "_newreview"); PlaceHolder biblioinfo_holder = (PlaceHolder)this.FindControl("line" + Convert.ToString(i) + "_biblioinfo_holder"); BiblioControl bibliocontrol = (BiblioControl)this.FindControl("line_" + i.ToString() + "_bibliocontrol"); CheckBox checkbox = (CheckBox)this.FindControl("line" + Convert.ToString(i) + "_checkbox"); if (bManager == false) { checkbox.Visible = false; } int index = this.StartIndex + i; if (index >= this.CommentColumn.Count) { checkbox.Visible = false; commentcontrol.Visible = false; bibliocontrol.Visible = false; continue; } TopArticleItem record = (TopArticleItem)this.CommentColumn[index]; // 序号 string strNo = " "; strNo = Convert.ToString(i + this.StartIndex + 1); no.Text = "<div>" + strNo + "</div>"; // 路径 string strPath = record.Line.m_strRecPath; // 2012/7/11 commentcontrol.RecPath = app.GetLangItemRecPath( "comment", this.Lang, strPath); byte[] timestamp = null; string strXml = ""; // return: // -1 出错 // 0 没有找到 // 1 找到 nRet = commentcontrol.GetRecord( app, null, // sessioninfo, channel, strPath, out strXml, out timestamp, out strError); if (nRet == -1) { goto ERROR1; } if (nRet == 0) { } string strBiblioRecPath = ""; if (string.IsNullOrEmpty(strXml) == false) { string strParentID = ""; nRet = CommentControl.GetParentID(strXml, out strParentID, out strError); if (nRet == -1) { goto ERROR1; } strBiblioRecPath = CommentControl.GetBiblioRecPath( app, strPath, strParentID); } else { strBiblioRecPath = ""; } // if (bManager == true || bReader == true) { string strUrl = "./book.aspx?BiblioRecPath=" + HttpUtility.UrlEncode(strBiblioRecPath) + "&CommentRecPath=" + HttpUtility.UrlEncode(strPath) + "#newreview"; newreview.OnClientClick = "window.open('" + strUrl + "','_blank'); return cancelClick();"; // newreview.ToolTip = this.GetString("创建新的评注, 属于书目记录") + ":" + strBiblioRecPath; // newreview.Attributes.Add("target", "_blank"); newreview.Visible = true; } else { newreview.Visible = false; } if (string.IsNullOrEmpty(strBiblioRecPath) == true) { biblioinfo_holder.Controls.Add(new LiteralControl("<div class='ditto'>" + this.GetString("无法定位书目记录") + "</div>")); bibliocontrol.Visible = false; } else if (bDitto == true && strBiblioRecPath == strPrevBiblioRecPath) { biblioinfo_holder.Controls.Add(new LiteralControl("<div class='ditto'>" + this.GetString("同上") + "</div>")); bibliocontrol.Visible = false; } else { if (bUseBiblioSummary == true) { // 获得摘要 string strBarcode = "@bibliorecpath:" + strBiblioRecPath; string strSummary = ""; string strOutputBiblioRecPath = ""; long lRet = //sessioninfo.Channel. channel.GetBiblioSummary( null, strBarcode, null, null, out strOutputBiblioRecPath, out strSummary, out strError); if (lRet == -1 || lRet == 0) { strSummary = strError; } bibliosummarycontrol.Text = strSummary; bibliocontrol.Visible = false; } else { bibliocontrol.RecPath = strBiblioRecPath; bibliocontrol.Visible = true; } } strPrevBiblioRecPath = strBiblioRecPath; } } finally { app.m_lockCommentColumn.ReleaseReaderLock(); sessioninfo.ReturnChannel(channel); } } else { // 显示空行 for (int i = 0; i < this.PageMaxLines; i++) { PlaceHolder line = (PlaceHolder)this.FindControl("line" + Convert.ToString(i)); if (line == null) { continue; } CheckBox checkbox = (CheckBox)this.FindControl("line" + Convert.ToString(i) + "_checkbox"); checkbox.Visible = false; CommentControl commentcontrol = (CommentControl)this.FindControl("line" + Convert.ToString(i) + "_comment"); commentcontrol.Visible = false; BiblioControl bibliocontrol = (BiblioControl)this.FindControl("line_" + i.ToString() + "_bibliocontrol"); bibliocontrol.Visible = false; } } this.SetLineClassAndControlActive(); base.Render(writer); return; ERROR1: this.SetDebugInfo("errorinfo", strError); base.Render(writer); }
public static int Build(XmlDocument dom, out LabelParam label_param, out string strError) { strError = ""; int nRet = 0; label_param = new LabelParam(); XmlNode label = dom.DocumentElement.SelectSingleNode("label"); if (label != null) { // int nValue = 0; double fValue = 0; // width nRet = DomUtil.GetDoubleParam(label, "width", 0, out fValue, out strError); if (nRet == -1) { return(-1); } label_param.LabelWidth = fValue; // height nRet = DomUtil.GetDoubleParam(label, "height", 0, out fValue, out strError); if (nRet == -1) { return(-1); } label_param.LabelHeight = fValue; // lineSep nRet = DomUtil.GetDoubleParam(label, "lineSep", 0, out fValue, out strError); if (nRet == -1) { return(-1); } label_param.LineSep = fValue; { DecimalPadding margins; string strPaddings = DomUtil.GetAttr(label, "paddings"); nRet = GetMarginValue( strPaddings, out margins, out strError); if (nRet == -1) { strError = "<label>元素paddings属性值格式错误: " + strError; return(-1); } label_param.LabelPaddings = margins; } #if NO try { string strPaddings = DomUtil.GetAttr(label, "paddings"); string[] parts = strPaddings.Split(new char[] { ',' }); if (parts.Length > 0) { label_param.LabelPaddings.Left = Convert.ToInt32(parts[0]); } if (parts.Length > 1) { label_param.LabelPaddings.Top = Convert.ToInt32(parts[1]); } if (parts.Length > 2) { label_param.LabelPaddings.Right = Convert.ToInt32(parts[2]); } if (parts.Length > 3) { label_param.LabelPaddings.Bottom = Convert.ToInt32(parts[3]); } } catch (Exception ex) { strError = "<label>元素paddings属性值格式错误: " + ex.Message; return(-1); } #endif string strFont = DomUtil.GetAttr(label, "font"); if (String.IsNullOrEmpty(strFont) == false) { if (Global.IsVirtualBarcodeFont(ref strFont) == true) { label_param.IsBarcodeFont = true; } try { label_param.Font = Global.BuildFont(strFont); } catch (Exception ex) { strError = "<label>元素 font 属性值格式错误: " + ex.Message; return(-1); } } } XmlNode page = dom.DocumentElement.SelectSingleNode("page"); if (page != null) { { // int nValue = 0; double fValue = 0; // width nRet = DomUtil.GetDoubleParam(page, "width", 0, out fValue, out strError); if (nRet == -1) { return(-1); } label_param.PageWidth = fValue; // height nRet = DomUtil.GetDoubleParam(page, "height", 0, out fValue, out strError); if (nRet == -1) { return(-1); } label_param.PageHeight = fValue; } { DecimalPadding margins; string strMargins = DomUtil.GetAttr(page, "margins"); nRet = GetMarginValue( strMargins, out margins, out strError); if (nRet == -1) { strError = "<page>元素margins属性值格式错误: " + strError; return(-1); } label_param.PageMargins = margins; } #if NO try { string strMargins = DomUtil.GetAttr(page, "margins"); string[] parts = strMargins.Split(new char[] { ',' }); if (parts.Length > 0) { label_param.PageMargins.Left = Convert.ToInt32(parts[0]); } if (parts.Length > 1) { label_param.PageMargins.Top = Convert.ToInt32(parts[1]); } if (parts.Length > 2) { label_param.PageMargins.Right = Convert.ToInt32(parts[2]); } if (parts.Length > 3) { label_param.PageMargins.Bottom = Convert.ToInt32(parts[3]); } } catch (Exception ex) { strError = "<page>元素margins属性值格式错误: " + ex.Message; return(-1); } #endif label_param.DefaultPrinter = DomUtil.GetAttr(page, "defaultPrinter"); #if NO bool bValue = false; nRet = DomUtil.GetBooleanParam(page, "landscape", false, out bValue, out strError); if (nRet == -1) { strError = "<page> 元素的 landscape 属性错误: " + strError; return(-1); } label_param.Landscape = bValue; #endif int nValue = 0; DomUtil.GetIntegerParam(page, "rotate", 0, out nValue, out strError); if (nRet == -1) { strError = "<page> 元素的 rotate 属性错误: " + strError; return(-1); } label_param.RotateDegree = nValue; } XmlNodeList nodes = dom.DocumentElement.SelectNodes("lineFormats/line"); label_param.LineFormats = new List <LineFormat>(); for (int i = 0; i < nodes.Count; i++) { XmlNode node = nodes[i]; string strFont = DomUtil.GetAttr(node, "font"); LineFormat format = new LineFormat(); if (Global.IsVirtualBarcodeFont(ref strFont) == true) { format.IsBarcodeFont = true; } if (string.IsNullOrEmpty(strFont) == false) { try { format.Font = Global.BuildFont(strFont); } catch (Exception ex) { strError = "<line>元素font属性值格式错误: " + ex.Message; return(-1); } } else { format.Font = null; // 继承页面的字体 } format.Align = DomUtil.GetAttr(node, "align"); string strOffset = DomUtil.GetAttr(node, "offset"); if (string.IsNullOrEmpty(strOffset) == false) { try { double left = 0; double right = 0; ParsetTwoDouble(strOffset, false, out left, out right); format.OffsetX = left; format.OffsetY = right; } catch (Exception ex) { strError = "<line>元素offset属性值格式错误: " + ex.Message; return(-1); } } string strStart = DomUtil.GetAttr(node, "start"); if (string.IsNullOrEmpty(strStart) == false) { try { double left = double.NaN; double right = double.NaN; ParsetTwoDouble(strStart, true, out left, out right); format.StartX = left; format.StartY = right; } catch (Exception ex) { strError = "<line>元素start属性值格式错误: " + ex.Message; return(-1); } } string strSize = DomUtil.GetAttr(node, "size"); if (string.IsNullOrEmpty(strSize) == false) { try { double left = double.NaN; double right = double.NaN; ParsetTwoDouble(strSize, true, out left, out right); format.Width = left; format.Height = right; } catch (Exception ex) { strError = "<line>元素size属性值格式错误: " + ex.Message; return(-1); } } format.ForeColor = DomUtil.GetAttr(node, "foreColor"); format.BackColor = DomUtil.GetAttr(node, "backColor"); label_param.LineFormats.Add(format); } return(0); }
// 获得一些数据库的全部浏览格式配置信息 // parameters: // dbnames 要列出哪些数据库的浏览格式?如果==null, 则表示列出全部可能的格式名 // return: // -1 出错 // >=0 formatname个数 public int GetBrowseFormatNames( string strLang, List <string> dbnames, out List <string> formatnames, out string strError) { strError = ""; formatnames = new List <string>(); XmlNode root = this.OpacCfgDom.DocumentElement.SelectSingleNode("browseformats"); if (root == null) { strError = "<browseformats>元素尚未配置..."; return(-1); } XmlNodeList dbnodes = root.SelectNodes("database"); for (int i = 0; i < dbnodes.Count; i++) { XmlNode nodeDatabase = dbnodes[i]; string strDbName = DomUtil.GetAttr(nodeDatabase, "name"); // dbnames如果==null, 则表示列出全部可能的格式名 if (dbnames != null) { if (dbnames.IndexOf(strDbName) == -1) { continue; } } XmlNodeList nodes = nodeDatabase.SelectNodes("format"); for (int j = 0; j < nodes.Count; j++) { XmlNode node = nodes[j]; string strFormatName = DomUtil.GetCaption(strLang, node); if (String.IsNullOrEmpty(strFormatName) == true) { strFormatName = DomUtil.GetAttr(node, "name"); } /* * if (String.IsNullOrEmpty(strFormatName) == true) * { * strError = "格式配置片断 '" + node.OuterXml + "' 格式不正确..."; * return -1; * }*/ if (formatnames.IndexOf(strFormatName) == -1) { formatnames.Add(strFormatName); } } } bool bMarcVisible = true; XmlNode nodeMarcControl = this.WebUiDom.DocumentElement.SelectSingleNode("marcControl"); if (nodeMarcControl != null) { bMarcVisible = DomUtil.GetBooleanParam(nodeMarcControl, "visible", true); } // 2011/1/2 // 从内置的格式里面找 // TODO: 对一些根本不是MARC格式的数据库,排除"MARC"格式名 { XmlDocument dom = new XmlDocument(); dom.LoadXml(m_strKernelBrowseFomatsXml); XmlNodeList nodes = dom.DocumentElement.SelectNodes("format"); for (int j = 0; j < nodes.Count; j++) { XmlNode node = nodes[j]; string strFormatName = DomUtil.GetCaption(strLang, node); if (String.IsNullOrEmpty(strFormatName) == true) { strFormatName = DomUtil.GetAttr(node, "name"); } // 2012/11/29 if (bMarcVisible == false && strFormatName == "MARC") { continue; } if (formatnames.IndexOf(strFormatName) == -1) { formatnames.Add(strFormatName); } } } return(formatnames.Count); }
int PrepareBiblioRecord( out string strError) { strError = ""; int nRet = 0; long lRet = 0; // string strOutputPath = ""; if (string.IsNullOrEmpty(this.RecPath) == true) { return(0); // 此时无法进行初始化 } OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; string strBiblioXml = ""; LibraryChannel channel = sessioninfo.GetChannel(true); try { // string strBiblioState = ""; byte[] timestamp = null; string[] formats = new string[1]; formats[0] = "xml"; string[] results = null; lRet = // sessioninfo.Channel. channel.GetBiblioInfos( null, this.RecPath, "", formats, out results, out timestamp, out strError); if (lRet == -1) { strError = "获得书目记录 '" + this.RecPath + "' 时出错: " + strError; goto ERROR1; } if (lRet == 0) { strError = "书目记录 '" + this.RecPath + "' 不存在"; goto ERROR1; } if (results == null || results.Length < 1) { strError = "results error {A9217775-645E-42F1-8307-22B26C0E1D69}"; goto ERROR1; } strBiblioXml = results[0]; this.m_strXml = strBiblioXml; this.Timestamp = ByteArray.GetHexTimeStampString(timestamp); this.BiblioRecPath = this.RecPath; } finally { sessioninfo.ReturnChannel(channel); } if (app.SearchLog != null) { SearchLogItem log = new SearchLogItem(); log.IP = this.Page.Request.UserHostAddress.ToString(); log.Query = ""; log.Time = DateTime.UtcNow; log.HitCount = 1; log.Format = "biblio"; log.RecPath = this.RecPath; app.SearchLog.AddLogItem(log); } string strMarc = ""; // 转换为MARC { string strOutMarcSyntax = ""; // 将MARCXML格式的xml记录转换为marc机内格式字符串 // parameters: // bWarning ==true, 警告后继续转换,不严格对待错误; = false, 非常严格对待错误,遇到错误后不继续转换 // strMarcSyntax 指示marc语法,如果=="",则自动识别 // strOutMarcSyntax out参数,返回marc,如果strMarcSyntax == "",返回找到marc语法,否则返回与输入参数strMarcSyntax相同的值 nRet = MarcUtil.Xml2Marc(strBiblioXml, true, "", // this.CurMarcSyntax, out strOutMarcSyntax, out strMarc, out strError); if (nRet == -1) { goto ERROR1; } this.m_strMARC = strMarc; } bool bAjax = true; if (this.DisableAjax == true) { bAjax = false; } else { if (app != null && app.WebUiDom != null && app.WebUiDom.DocumentElement != null) { XmlNode nodeBiblioControl = app.WebUiDom.DocumentElement.SelectSingleNode( "biblioControl"); if (nodeBiblioControl != null) { DomUtil.GetBooleanParam(nodeBiblioControl, "ajax", true, out bAjax, out strError); } } } if (bAjax == false) { string strBiblio = ""; string strBiblioDbName = StringUtil.GetDbName(this.RecPath); // 需要从内核映射过来文件 string strLocalPath = ""; nRet = app.MapKernelScriptFile( // null, // sessioninfo, strBiblioDbName, "./cfgs/opac_biblio.fltx", // OPAC查询固定认这个角色的配置文件,作为公共查询书目格式创建的脚本。而流通前端,创建书目格式的时候,找的是loan_biblio.fltx配置文件 out strLocalPath, out strError); if (nRet == -1) { goto ERROR1; } // 将种记录数据从XML格式转换为HTML格式 KeyValueCollection result_params = null; // 2006/11/28 changed string strFilterFileName = strLocalPath; // app.CfgDir + "\\biblio.fltx"; nRet = app.ConvertBiblioXmlToHtml( strFilterFileName, strBiblioXml, this.RecPath, out strBiblio, out result_params, out strError); if (nRet == -1) { goto ERROR1; } // TODO: Render的时候设置,已经晚了半拍 // 要想办法在全部Render前得到题名和进行设置 if (this.AutoSetPageTitle == true && result_params != null && result_params.Count > 0) { string strTitle = result_params["title"].Value; if (string.IsNullOrEmpty(strTitle) == false) { this.Page.Title = strTitle; } bool bHasDC = false; // 探测一下,是否有至少一个DC.开头的 key ? foreach (KeyValue item in result_params) { if (StringUtil.HasHead(item.Key, "DC.") == true) { bHasDC = true; break; } } if (bHasDC == true) { // <header profile="http://dublincore.org/documents/2008/08/04/dc-html/"> this.Page.Header.Attributes.Add("profile", "http://dublincore.org/documents/2008/08/04/dc-html/"); // DC rel // HtmlLink link = new HtmlLink(); link.Href = "http://purl.org/dc/elements/1.1/"; link.Attributes.Add("rel", "schema.DC"); this.Page.Header.Controls.Add(link); // <link rel="schema.DCTERMS" href="http://purl.org/dc/terms/" > link = new HtmlLink(); link.Href = "http://purl.org/dc/terms/"; link.Attributes.Add("rel", "schema.DCTERMS"); this.Page.Header.Controls.Add(link); foreach (KeyValue item in result_params) { if (StringUtil.HasHead(item.Key, "DC.") == false && StringUtil.HasHead(item.Key, "DCTERMS.") == false) { continue; } HtmlMeta meta = new HtmlMeta(); meta.Name = item.Key; meta.Content = item.Value; if (StringUtil.HasHead(item.Value, "urn:") == true || StringUtil.IsHttpUrl(item.Value) == true || StringUtil.HasHead(item.Value, "info:") == true ) { meta.Attributes.Add("scheme", "DCTERMS.URI"); } this.Page.Header.Controls.Add(meta); } } } this.m_strOpacBiblio = strBiblio; } return(0); ERROR1: return(-1); }
protected override void Render(HtmlTextWriter output) { if (this.RecPath == "") { output.Write("尚未指定记录路径"); return; } int nRet = 0; long lRet = 0; string strError = ""; // string strOutputPath = ""; OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; bool bManager = false; if (string.IsNullOrEmpty(sessioninfo.UserID) == true || StringUtil.IsInList("managecomment", sessioninfo.RightsOrigin) == false) { bManager = false; } else { bManager = true; } PlaceHolder inputline = (PlaceHolder)this.FindControl("inputline"); PlaceHolder cmdline = (PlaceHolder)this.FindControl("cmdline"); if (bManager == false) { cmdline.Visible = false; } string strBiblioState = ""; #if NO string strBiblioXml = ""; // 获得书目XML { byte[] timestamp = null; string[] formats = new string[1]; formats[0] = "xml"; string[] results = null; lRet = sessioninfo.Channel.GetBiblioInfos( null, this.RecPath, formats, out results, out timestamp, out strError); if (lRet == -1) { strError = "获得种记录 '" + this.RecPath + "' 时出错: " + strError; goto ERROR1; } if (results == null || results.Length < 1) { strError = "results error "; goto ERROR1; } strBiblioXml = results[0]; this.Timestamp = ByteArray.GetHexTimeStampString(timestamp); this.BiblioRecPath = this.RecPath; } string strMarc = ""; // 转换为MARC { string strOutMarcSyntax = ""; // 将MARCXML格式的xml记录转换为marc机内格式字符串 // parameters: // bWarning ==true, 警告后继续转换,不严格对待错误; = false, 非常严格对待错误,遇到错误后不继续转换 // strMarcSyntax 指示marc语法,如果=="",则自动识别 // strOutMarcSyntax out参数,返回marc,如果strMarcSyntax == "",返回找到marc语法,否则返回与输入参数strMarcSyntax相同的值 nRet = MarcUtil.Xml2Marc(strBiblioXml, true, "", // this.CurMarcSyntax, out strOutMarcSyntax, out strMarc, out strError); if (nRet == -1) { goto ERROR1; } } #endif bool bAjax = true; if (this.DisableAjax == true) { bAjax = false; } else { if (app != null && app.WebUiDom != null && app.WebUiDom.DocumentElement != null) { XmlNode nodeBiblioControl = app.WebUiDom.DocumentElement.SelectSingleNode( "biblioControl"); if (nodeBiblioControl != null) { DomUtil.GetBooleanParam(nodeBiblioControl, "ajax", true, out bAjax, out strError); } } } string strMarc = ""; if (string.IsNullOrEmpty(this.m_strMARC) == true) { nRet = PrepareBiblioRecord(out strError); if (nRet == -1) { goto ERROR1; } strMarc = this.m_strMARC; } strBiblioState = MarcDocument.GetFirstSubfield(strMarc, "998", "s"); // 状态 string strOriginCreator = MarcDocument.GetFirstSubfield(strMarc, "998", "z"); bool bReaderCreate = false; if (StringUtil.IsInList("读者创建", strBiblioState) == true) { bReaderCreate = true; } // 不是读者创建的记录,就不让在这里修改状态 if (bReaderCreate == false) { cmdline.Visible = false; } bool bDisplayOriginContent = false; if (StringUtil.IsInList("审查", strBiblioState) == false && StringUtil.IsInList("屏蔽", strBiblioState) == false) { bDisplayOriginContent = true; } // 管理员和作者本人都能看到被屏蔽的内容 if (bManager == true || strOriginCreator == sessioninfo.UserID) { bDisplayOriginContent = true; } string strBiblio = ""; if (bDisplayOriginContent == true) { if (bAjax == true) { strBiblio = "<div class='pending'>biblio_html:" + HttpUtility.HtmlEncode(this.RecPath) + "</div>"; } else { strBiblio = this.m_strOpacBiblio; #if NO string strBiblioDbName = ResPath.GetDbName(this.RecPath); // 需要从内核映射过来文件 string strLocalPath = ""; nRet = app.MapKernelScriptFile( null, // sessioninfo, strBiblioDbName, "./cfgs/opac_biblio.fltx", // OPAC查询固定认这个角色的配置文件,作为公共查询书目格式创建的脚本。而流通前端,创建书目格式的时候,找的是loan_biblio.fltx配置文件 out strLocalPath, out strError); if (nRet == -1) { goto ERROR1; } // 将种记录数据从XML格式转换为HTML格式 Hashtable result_params = null; // 2006/11/28 changed string strFilterFileName = strLocalPath; // app.CfgDir + "\\biblio.fltx"; nRet = app.ConvertBiblioXmlToHtml( strFilterFileName, strBiblioXml, this.RecPath, out strBiblio, out result_params, out strError); if (nRet == -1) { goto ERROR1; } // TODO: Render的时候设置,已经晚了半拍 // 要想办法在全部Render前得到题名和进行设置 if (this.AutoSetPageTitle == true && result_params != null) { string strTitle = (string)result_params["title"]; if (string.IsNullOrEmpty(strTitle) == false) { this.Page.Title = strTitle; } } /* * string strPrefix = ""; * if (this.Wrapper == true) * strPrefix = this.GetPrefixString("书目信息", "content_wrapper") + "<div class='biblio_wrapper'>"; + + string strPostfix = ""; + if (this.Wrapper == true) + strPostfix = "</div>" + this.GetPostfixString(); * */ /* * LiteralControl literal = (LiteralControl)FindControl("biblio"); * literal.Text = strPrefix + strBiblio + strPostfix; * */ // strBiblio = strPrefix + strBiblio + strPostfix; #endif } } // 屏蔽等状态显示 string strResult = ""; string strImage = ""; if (StringUtil.IsInList("精品", strBiblioState) == true) { strImage = "<img src='" + MyWebPage.GetStylePath(app, "valuable.gif") + "'/>"; strResult += "<div class='valuable' title='精品'>" + strImage + this.GetString("精品") + "</div>"; } if (StringUtil.IsInList("锁定", strBiblioState) == true) { strImage = "<img src='" + MyWebPage.GetStylePath(app, "locked.gif") + "'/>"; strResult += "<div class='locked' title='锁定'>" + strImage + this.GetString("锁定") + "</div>"; } string strDisplayState = ""; if (StringUtil.IsInList("审查", strBiblioState) == true) { strImage = "<img src='" + MyWebPage.GetStylePath(app, "censor.gif") + "'/>"; strDisplayState = this.GetString("审查"); } if (StringUtil.IsInList("屏蔽", strBiblioState) == true) { strImage = "<img src='" + MyWebPage.GetStylePath(app, "disable.gif") + "'/>"; if (String.IsNullOrEmpty(strDisplayState) == false) { strDisplayState += ","; } strDisplayState += this.GetString("屏蔽"); } if (String.IsNullOrEmpty(strDisplayState) == false) { strResult += "<div class='forbidden' title='" + this.GetString("屏蔽原因") + "'>" + strImage + string.Format(this.GetString("本书目记录目前为X状态"), strDisplayState) + (strOriginCreator == sessioninfo.UserID ? "," + this.GetString("其他人(非管理员)看不到下列内容") : "") + "</div>"; } if (String.IsNullOrEmpty(strResult) == false) { strResult = "<div class='biblio_state'>" + strResult + "</div>"; } if (this.EditAction == "changestate") { inputline.Visible = true; SetStateValueToControls(strBiblioState); cmdline.Visible = false; // 在编辑态,命令条就不要出现了 } else { inputline.Visible = false; } if (this.Active == false) { cmdline.Visible = false; inputline.Visible = false; // 即便在编辑态也要加以压抑 } string strClass = "biblio"; if ((String.IsNullOrEmpty(strResult) == false || inputline.Visible == true) && this.Wrapper == false) { strClass += " frame-border"; } LiteralControl outer_class = (LiteralControl)this.FindControl("outer_class"); outer_class.Text = strClass; // output.Write(strBiblio); LiteralControl literal = (LiteralControl)FindControl("biblio"); // literal.Text = "<div class='"+strClass+"'>" + strResult + strBiblio + "</biblio>"; literal.Text = strResult + strBiblio; base.Render(output); return; ERROR1: output.Write(strError); }
// 读入<biblioDbGroup>相关配置 // return: // <biblioDbGroup>元素下<database>元素的个数。如果==0,表示配置不正常 public int LoadBiblioDbGroupParam( out string strError) { strError = ""; this.m_lock.AcquireWriterLock(m_nLockTimeout); try { XmlDocument dom = this.OpacCfgDom; this.ItemDbs = new List <ItemDbCfg>(); XmlNodeList nodes = dom.DocumentElement.SelectNodes("//biblioDbGroup/database"); if (nodes.Count == 0) { return(0); } for (int i = 0; i < nodes.Count; i++) { XmlNode node = nodes[i]; ItemDbCfg item = new ItemDbCfg(); item.DbName = DomUtil.GetAttr(node, "itemDbName"); item.BiblioDbName = DomUtil.GetAttr(node, "biblioDbName"); item.BiblioDbSyntax = DomUtil.GetAttr(node, "syntax"); item.IssueDbName = DomUtil.GetAttr(node, "issueDbName"); item.OrderDbName = DomUtil.GetAttr(node, "orderDbName"); item.CommentDbName = DomUtil.GetAttr(node, "commentDbName"); item.UnionCatalogStyle = DomUtil.GetAttr(node, "unionCatalogStyle"); // 2008/6/4 bool bValue = true; int nRet = DomUtil.GetBooleanParam(node, "inCirculation", true, out bValue, out strError); if (nRet == -1) { strError = "元素<//biblioDbGroup/database>属性inCirculation读入时发生错误: " + strError; return(-1); } item.InCirculation = bValue; item.Role = DomUtil.GetAttr(node, "role"); this.ItemDbs.Add(item); } return(nodes.Count); } finally { this.m_lock.ReleaseWriterLock(); } }
public void SetVersion(LibEntity libEntity, string version) { string strError = ""; // 设置版本 this._version = version; // 更新状态 this.UpdateState(); // 获取数据库信息 if (this.State != LibraryManager.C_State_Hangup || (this.State == LibraryManager.C_State_Hangup && this.Version != "-1")) { // 得到期库 //用点对点的 getSystemParameter 功能。category 为 "system", name 为 "biblioDbGroup", //可以获得一段 XML 字符串,格式和 library.xml 中的 itemdbgroup 元素相仿, //但每个 database 元素的 name 属性名字变为 itemDbName。 // item.IssueDbName = DomUtil.GetAttr(node, "issueDbName"); List <string> dataList = new List <string>(); //(较早的dp2Capo在上述功能被调用时会返回ErrorInfo=未知的 category '_clock' 和 name '',ErrorCode=NotFound) int nRet = dp2WeiXinService.Instance.GetSystemParameter(libEntity, "system", "biblioDbGroup", out dataList, out strError); if (nRet == -1 || nRet == 0) { goto ERROR1; } // 取出数据库配置xml this.BiblioDbGroup = "<root>" + dataList[0] + "</root>"; XmlDocument dom = new XmlDocument(); dom.LoadXml(this.BiblioDbGroup); XmlNodeList databaseList = dom.DocumentElement.SelectNodes("database"); foreach (XmlNode node in databaseList) { DbCfg db = new DbCfg(); db.DbName = DomUtil.GetAttr(node, "itemDbName"); db.BiblioDbName = DomUtil.GetAttr(node, "biblioDbName"); db.BiblioDbSyntax = DomUtil.GetAttr(node, "syntax"); db.IssueDbName = DomUtil.GetAttr(node, "issueDbName"); db.OrderDbName = DomUtil.GetAttr(node, "orderDbName"); db.CommentDbName = DomUtil.GetAttr(node, "commentDbName"); db.UnionCatalogStyle = DomUtil.GetAttr(node, "unionCatalogStyle"); // 2008/6/4 bool bValue = true; nRet = DomUtil.GetBooleanParam(node, "inCirculation", true, out bValue, out strError); if (nRet == -1) { throw new Exception("元素<//biblioDbGroup/database>属性inCirculation读入时发生错误: " + strError); } db.InCirculation = bValue; db.Role = DomUtil.GetAttr(node, "role"); this.DbList.Add(db); } } return; ERROR1: dp2WeiXinService.Instance.WriteErrorLog1("获取库信息出错:" + strError); }
private void ZServerPropertyForm_Load(object sender, EventArgs e) { this.textBox_serverName.Text = DomUtil.GetAttr(this.XmlNode, "name"); this.textBox_serverAddr.Text = DomUtil.GetAttr(this.XmlNode, "addr"); this.textBox_serverPort.Text = DomUtil.GetAttr(this.XmlNode, "port"); this.textBox_homepage.Text = DomUtil.GetAttr(this.XmlNode, "homepage"); /// string strAuthMethod = DomUtil.GetAttr(this.XmlNode, "authmethod"); int nAuthMethod = 0; try { nAuthMethod = Convert.ToInt32(strAuthMethod); } catch { } if (nAuthMethod == 0) { this.radioButton_authenStyeOpen.Checked = true; } else { this.radioButton_authenStyleIdpass.Checked = true; } this.textBox_groupID.Text = DomUtil.GetAttr(this.XmlNode, "groupid"); this.textBox_userName.Text = DomUtil.GetAttr(this.XmlNode, "username"); string strPassword = DomUtil.GetAttr(this.XmlNode, "password"); this.textBox_password.Text = GetPassword(strPassword); this.checkBox_autoDetectEACC.Checked = GetBool( DomUtil.GetAttr(this.XmlNode, "converteacc")); this.checkBox_alwaysUseFullElementSet.Checked = GetBool(DomUtil.GetAttr(this.XmlNode, "firstfull")); this.checkBox_autoDetectMarcSyntax.Checked = GetBool(DomUtil.GetAttr(this.XmlNode, "detectmarcsyntax")); this.checkBox_ignoreRerenceID.Checked = GetBool( DomUtil.GetAttr(this.XmlNode, "ignorereferenceid")); // 对ISBN的预处理 this.m_nDisableCheckIsbnParameters++; try { this.checkBox_isbn_forceIsbn13.Checked = GetBool( DomUtil.GetAttr(this.XmlNode, "isbn_force13")); this.checkBox_isbn_forceIsbn10.Checked = GetBool( DomUtil.GetAttr(this.XmlNode, "isbn_force10")); this.checkBox_isbn_addHyphen.Checked = GetBool( DomUtil.GetAttr(this.XmlNode, "isbn_addhyphen")); this.checkBox_isbn_removeHyphen.Checked = GetBool( DomUtil.GetAttr(this.XmlNode, "isbn_removehyphen")); this.checkBox_isbn_wild.Checked = GetBool( DomUtil.GetAttr(this.XmlNode, "isbn_wild")); } finally { this.m_nDisableCheckIsbnParameters--; } // 2018/8/25 string strValue = DomUtil.GetAttr(this.XmlNode, "issn_force8"); if (string.IsNullOrEmpty(strValue)) { strValue = "1"; // 缺省值为 1 } this.checkBox_forceIssn8.Checked = GetBool(strValue); this.textBox_presentPerCount.Text = DomUtil.GetAttr(this.XmlNode, "recsperbatch"); // 数据库名 XmlNodeList nodes = this.XmlNode.SelectNodes("database"); for (int i = 0; i < nodes.Count; i++) { string strDatabaseName = DomUtil.GetAttr(nodes[i], "name"); if (this.textBox_databaseNames.Text != "") { this.textBox_databaseNames.Text += "\r\n"; } this.textBox_databaseNames.Text += strDatabaseName; // 全选时候要排除的数据库名 bool bValue = false; string strError = ""; DomUtil.GetBooleanParam(nodes[i], "notInAll", false, out bValue, out strError); if (bValue == true) { if (this.textBox_notInAllDatabaseNames.Text != "") { this.textBox_notInAllDatabaseNames.Text += "\r\n"; } this.textBox_notInAllDatabaseNames.Text += strDatabaseName; } } Global.FillEncodingList(this.comboBox_defaultEncoding, true); this.comboBox_defaultEncoding.Text = DomUtil.GetAttr(this.XmlNode, "defaultEncoding"); /* * // 补充MARC-8 * this.comboBox_defaultEncoding.Items.Add("MARC-8"); * */ Global.FillEncodingList(this.comboBox_queryTermEncoding, false); // 检索词暂时不让用MARC-8编码方式 this.comboBox_queryTermEncoding.Text = DomUtil.GetAttr(this.XmlNode, "queryTermEncoding"); this.comboBox_defaultMarcSyntaxOID.Text = DomUtil.GetAttr(this.XmlNode, "defaultMarcSyntaxOID"); this.comboBox_defaultElementSetName.Text = DomUtil.GetAttr(this.XmlNode, "defaultElementSetName"); string strBindingDef = DomUtil.GetAttr(this.XmlNode, "recordSyntaxAndEncodingBinding"); SetBinding(strBindingDef); // 字符集协商 this.checkBox_charNegoUTF8.Checked = GetBool(DomUtil.GetAttr(this.XmlNode, "charNegoUtf8")); this.checkBox_charNegoRecordsInSelectedCharSets.Checked = GetBool(DomUtil.GetAttr(this.XmlNode, "charNego_recordsInSeletedCharsets")); checkBox_charNegoUTF8_CheckedChanged(null, null); // initial result info /* * this.textBox_initializeInfomation.Text = DomUtil.GetAttr(this.XmlNode, * "extraInfo"); * */ this.textBox_initializeInfomation.Text = InitialResultInfo; // set initial button state textBox_homepage_TextChanged(this, null); // 联合编目 this.textBox_unionCatalog_bindingDp2ServerName.Text = DomUtil.GetAttr( this.XmlNode, "unionCatalog_bindingDp2ServerName"); this.textBox_unionCatalog_bindingUcServerUrl.Text = DomUtil.GetAttr( this.XmlNode, "unionCatalog_bindingUcServerUrl"); }
// 为数据库属性集合中增补需要从xml文件中获得的其他属性 int AppendDbProperties(out string strError) { strError = ""; // 增补MaxResultCount if (this.CfgDom == null) { strError = "调用 GetBiblioDbProperties()以前,需要先初始化和装载CfgDom"; return(-1); } Debug.Assert(this.CfgDom != null, ""); for (int i = 0; i < this.BiblioDbProperties.Count; i++) { BiblioDbProperty prop = this.BiblioDbProperties[i]; string strDbName = prop.DbName; XmlNode nodeDatabase = this.CfgDom.DocumentElement.SelectSingleNode("//databases/database[@name='" + strDbName + "']"); if (nodeDatabase == null) { continue; } // maxResultCount // 获得整数型的属性参数值 // return: // -1 出错。但是nValue中已经有了nDefaultValue值,可以不加警告而直接使用 // 0 正常获得明确定义的参数值 // 1 参数没有定义,因此代替以缺省参数值返回 int nRet = DomUtil.GetIntegerParam(nodeDatabase, "maxResultCount", -1, out prop.MaxResultCount, out strError); if (nRet == -1) { strError = "为数据库 '" + strDbName + "' 配置的<databases/database>元素的" + strError; return(-1); } // alias prop.DbNameAlias = DomUtil.GetAttr(nodeDatabase, "alias"); // addField901 // 2007/12/16 nRet = DomUtil.GetBooleanParam(nodeDatabase, "addField901", false, out prop.AddField901, out strError); if (nRet == -1) { strError = "为数据库 '" + strDbName + "' 配置的<databases/database>元素的" + strError; return(-1); } } return(0); }
public void GetDbs(Library library) { int nRet = 0; string strError = ""; // 获取数据库 //用点对点的 getSystemParameter 功能。category 为 "system", name 为 "biblioDbGroup", //可以获得一段 XML 字符串,格式和 library.xml 中的 itemdbgroup 元素相仿, //但每个 database 元素的 name 属性名字变为 itemDbName。 // item.IssueDbName = DomUtil.GetAttr(node, "issueDbName"); List <string> dataList = new List <string>(); //(较早的dp2Capo在上述功能被调用时会返回ErrorInfo=未知的 category '_clock' 和 name '',ErrorCode=NotFound) nRet = dp2WeiXinService.Instance.GetSystemParameter(library.Entity, "system", "biblioDbGroup", out dataList, out strError); // -1 记录错误日志,不影响其它馆使用 if (nRet == -1 || nRet == 0) //0是什么情况? { dp2WeiXinService.Instance.WriteErrorLog("获取[" + library.Entity.libName + "]的数据库信息出错:" + strError); return; } // 取出数据库配置xml library.BiblioDbGroup = "<root>" + dataList[0] + "</root>"; XmlDocument dom = new XmlDocument(); dom.LoadXml(library.BiblioDbGroup); XmlNodeList databaseList = dom.DocumentElement.SelectNodes("database"); foreach (XmlNode node in databaseList) { DbCfg db = new DbCfg(); db.DbName = DomUtil.GetAttr(node, "itemDbName"); db.BiblioDbName = DomUtil.GetAttr(node, "biblioDbName"); db.BiblioDbSyntax = DomUtil.GetAttr(node, "syntax"); db.IssueDbName = DomUtil.GetAttr(node, "issueDbName"); db.OrderDbName = DomUtil.GetAttr(node, "orderDbName"); db.CommentDbName = DomUtil.GetAttr(node, "commentDbName"); db.UnionCatalogStyle = DomUtil.GetAttr(node, "unionCatalogStyle"); // 2008/6/4 bool bValue = true; nRet = DomUtil.GetBooleanParam(node, "inCirculation", true, out bValue, out strError); if (nRet == -1) { throw new Exception("元素<//biblioDbGroup/database>属性inCirculation读入时发生错误: " + strError); } db.InCirculation = bValue; db.Role = DomUtil.GetAttr(node, "role"); library.DbList.Add(db); } }