// 修改OPAC数据库定义 private void toolStripButton_modifyOpacDatabase_Click(object sender, EventArgs e) { string strError = ""; int nRet = 0; if (this.listView_opacDatabases.SelectedItems.Count == 0) { strError = "尚未选定要修改的OPAC数据库事项"; goto ERROR1; } ListViewItem item = this.listView_opacDatabases.SelectedItems[0]; string strType = GetOpacDatabaseTypeString(ListViewUtil.GetItemText(item, 1)); if (strType == "virtualDatabase") { // 已经存在的库名 List<string> existing_opac_normal_dbnames = new List<string>(); for (int i = 0; i < this.listView_opacDatabases.Items.Count; i++) { ListViewItem current_item = this.listView_opacDatabases.Items[i]; string strCurrentName = current_item.Text; string strCurrentType = ListViewUtil.GetItemText(current_item, 1); if (strCurrentType == "普通库") existing_opac_normal_dbnames.Add(strCurrentName); } OpacVirtualDatabaseDialog dlg = new OpacVirtualDatabaseDialog(); MainForm.SetControlFont(dlg, this.Font, false); dlg.Text = "修改虚拟库定义"; dlg.ExistingOpacNormalDbNames = existing_opac_normal_dbnames; /* dlg.ManagerForm = this; dlg.CreateMode = false; * */ nRet = dlg.Initial(this, false, (string)item.Tag, out strError); if (nRet == -1) goto ERROR1; // dlg.StartPosition = FormStartPosition.CenterScreen; this.MainForm.AppInfo.LinkFormState(dlg, "ManagerForm_OpacVirtualDatabaseDialog_state"); dlg.ShowDialog(this); this.MainForm.AppInfo.UnlinkFormState(dlg); if (dlg.DialogResult != DialogResult.OK) return; XmlDocument dom = new XmlDocument(); try { dom.LoadXml(dlg.Xml); } catch (Exception ex) { strError = "从对话框中获得的XML装入DOM时出错: " + ex.Message; goto ERROR1; } // 从<virtualDatabase>元素下的若干<caption>中,选出符合当前工作语言的一个名字字符串 // 从一个元素的下级<caption>元素中, 提取语言符合的文字值 string strName = DomUtil.GetCaption("zh", dom.DocumentElement); strType = dom.DocumentElement.Name; item.Text = strName; ListViewUtil.ChangeItemText(item, 1, GetOpacDatabaseTypeDisplayString(strType)); item.Tag = dlg.Xml; // 记载XML定义片断 // 需要立即向服务器提交修改 nRet = SubmitOpacDatabaseDef(out strError); if (nRet == -1) { item.ImageIndex = 2; // 表示未能提交的修改请求 goto ERROR1; } // 观察这个刚修改的虚拟库的成员库,如果还没有具备OPAC显示格式定义,则提醒自动加入 List<string> newly_biblio_dbnames = new List<string>(); List<string> member_dbnames = dlg.MemberDatabaseNames; for (int i = 0; i < member_dbnames.Count; i++) { string strMemberDbName = member_dbnames[i]; if (IsDatabaseBiblioType(strMemberDbName) == false) continue; if (HasBrowseFormatDatabaseExist(strMemberDbName) == true) continue; newly_biblio_dbnames.Add(strMemberDbName); } if (newly_biblio_dbnames.Count > 0) { DialogResult result = MessageBox.Show(this, "刚被修改的虚拟库 " + strName + " 其成员库中,库 " + StringUtil.MakePathList(newly_biblio_dbnames) + " 还没有OPAC记录显示格式定义。\r\n\r\n要自动给它(们)创建常规的OPAC记录显示格式定义么? ", "ManagerForm", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (result == DialogResult.Yes) { for (int i = 0; i < newly_biblio_dbnames.Count; i++) { // 为书目库插入OPAC显示格式节点(后插) nRet = NewBiblioOpacBrowseFormat(newly_biblio_dbnames[i], out strError); if (nRet == -1) goto ERROR1; } } } } else if (strType == "database") { OpacNormalDatabaseDialog dlg = new OpacNormalDatabaseDialog(); MainForm.SetControlFont(dlg, this.Font, false); string strXml = (string)item.Tag; XmlDocument dom = new XmlDocument(); try { dom.LoadXml(strXml); } catch (Exception ex) { strError = "XML装入DOM时出错: " + ex.Message; goto ERROR1; } dlg.Text = "普通库名"; dlg.ManagerForm = this; dlg.DatabaseName = DomUtil.GetAttr(dom.DocumentElement, "name"); this.MainForm.AppInfo.LinkFormState(dlg, "ManagerForm_OpacNormalDatabaseDialog_state"); dlg.ShowDialog(this); this.MainForm.AppInfo.UnlinkFormState(dlg); if (dlg.DialogResult != DialogResult.OK) return; DomUtil.SetAttr(dom.DocumentElement, "name", dlg.DatabaseName); item.Text = dlg.DatabaseName; item.Tag = dom.DocumentElement.OuterXml; // 记载XML定义片断 // 需要立即向服务器提交修改 nRet = SubmitOpacDatabaseDef(out strError); if (nRet == -1) { item.ImageIndex = 2; // 表示未能提交的修改请求 goto ERROR1; } } return; ERROR1: MessageBox.Show(this, strError); }
// 插入虚拟库定义 private void toolStripMenuItem_insertOpacDatabase_virtual_Click(object sender, EventArgs e) { string strError = ""; OpacVirtualDatabaseDialog dlg = new OpacVirtualDatabaseDialog(); dlg.Text = "新增虚拟库定义"; /* dlg.ManagerForm = this; dlg.CreateMode = true; * */ int nRet = dlg.Initial(this, true, "", out strError); if (nRet == -1) goto ERROR1; // dlg.StartPosition = FormStartPosition.CenterScreen; this.MainForm.AppInfo.LinkFormState(dlg, "ManagerForm_OpacVirtualDatabaseDialog_state"); dlg.ShowDialog(this); this.MainForm.AppInfo.UnlinkFormState(dlg); if (dlg.DialogResult != DialogResult.OK) return; XmlDocument dom = new XmlDocument(); try { dom.LoadXml(dlg.Xml); } catch (Exception ex) { strError = "从对话框中获得的XML装入DOM时出错: " + ex.Message; goto ERROR1; } // 从<virtualDatabase>元素下的若干<caption>中,选出符合当前工作语言的一个名字字符串 // 从一个元素的下级<caption>元素中, 提取语言符合的文字值 string strName = DomUtil.GetCaption("zh", dom.DocumentElement); string strType = dom.DocumentElement.Name; ListViewItem item = new ListViewItem(strName, 1); item.SubItems.Add(GetOpacDatabaseTypeDisplayString(strType)); item.Tag = dom.DocumentElement.OuterXml; // 记载XML定义片断 this.listView_opacDatabases.Items.Add(item); // 需要立即向服务器提交修改 nRet = SubmitOpacDatabaseDef(out strError); if (nRet == -1) { item.ImageIndex = 2; // 表示未能提交的新增请求 goto ERROR1; } // 选定刚刚插入的虚拟库 item.Selected = true; this.listView_opacDatabases.FocusedItem = item; // 观察这个刚插入的虚拟库的成员库,如果还没有具备OPAC显示格式定义,则提醒自动加入 List<string> newly_biblio_dbnames = new List<string>(); List<string> member_dbnames = dlg.MemberDatabaseNames; for (int i = 0; i < member_dbnames.Count; i++) { string strMemberDbName = member_dbnames[i]; if (IsDatabaseBiblioType(strMemberDbName) == false) continue; if (HasBrowseFormatDatabaseExist(strMemberDbName) == true) continue; newly_biblio_dbnames.Add(strMemberDbName); } if (newly_biblio_dbnames.Count > 0) { DialogResult result = MessageBox.Show(this, "刚新增的虚拟库 " + strName + " 其成员库中,库 " + StringUtil.MakePathList(newly_biblio_dbnames) + " 还没有OPAC记录显示格式定义。\r\n\r\n要自动给它(们)创建常规的OPAC记录显示格式定义么? ", "ManagerForm", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (result == DialogResult.Yes) { for (int i = 0; i < newly_biblio_dbnames.Count; i++) { // 为书目库插入OPAC显示格式节点(后插) nRet = NewBiblioOpacBrowseFormat(newly_biblio_dbnames[i], out strError); if (nRet == -1) goto ERROR1; } } } return; ERROR1: MessageBox.Show(this, strError); }