Beispiel #1
0
        // 修改一个节点的定义
        private void toolStripButton_opacBrowseFormats_modify_Click(object sender, EventArgs e)
        {
            string strError = "";
            int nRet = 0;

            // 当前节点
            TreeNode current_treenode = this.treeView_opacBrowseFormats.SelectedNode;

            if (current_treenode == null)
            {
                MessageBox.Show(this, "尚未选定要修改的库名或格式节点");
                return;
            }

            if (current_treenode.Parent == null)
            {
                // 库名节点


                // 当前已经存在的数据库名都是需要排除的
                List<string> existing_dbnames = new List<string>();
                for (int i = 0; i < this.treeView_opacBrowseFormats.Nodes.Count; i++)
                {
                    string strDatabaseName = this.treeView_opacBrowseFormats.Nodes[i].Text;
                    existing_dbnames.Add(strDatabaseName);
                }

                OpacNormalDatabaseDialog dlg = new OpacNormalDatabaseDialog();
                MainForm.SetControlFont(dlg, this.Font, false);

                dlg.Text = "修改数据库名";
                dlg.ManagerForm = this;
                dlg.DatabaseName = current_treenode.Text;
                dlg.ExcludingDbNames = existing_dbnames;
                dlg.StartPosition = FormStartPosition.CenterScreen;
                dlg.ShowDialog(this);

                if (dlg.DialogResult != DialogResult.OK)
                    return;

                current_treenode.Text = dlg.DatabaseName;

                // 确保展开
                if (current_treenode.Parent != null)
                    current_treenode.Parent.Expand();

                // 需要立即向服务器提交修改
                nRet = SubmitOpacBrowseFormatDef(out strError);
                if (nRet == -1)
                {
                    current_treenode.ImageIndex = 2;    // 表示未能提交的定义变化请求
                    goto ERROR1;
                }
            }
            else
            {
                // 格式节点

                string strXml = (string)current_treenode.Tag;

                if (String.IsNullOrEmpty(strXml) == true)
                {
                    strError = "节点 " + current_treenode.Text + " 没有Tag定义";
                    goto ERROR1;
                }

                XmlDocument dom = new XmlDocument();
                try
                {
                    dom.LoadXml(strXml);
                }
                catch (Exception ex)
                {
                    strError = "XML装入DOM时出错: " + ex.Message;
                    goto ERROR1;
                }


                // 显示格式
                OpacBrowseFormatDialog dlg = new OpacBrowseFormatDialog();
                MainForm.SetControlFont(dlg, this.Font, false);

                dlg.Text = "请指定显示格式的属性";
                // dlg.FormatName = DomUtil.GetAttr(dom.DocumentElement, "name");
                dlg.CaptionsXml = dom.DocumentElement.InnerXml; // 2009/6/27
                dlg.FormatType = DomUtil.GetAttr(dom.DocumentElement, "type");
                dlg.ScriptFile = DomUtil.GetAttr(dom.DocumentElement, "scriptfile");
                dlg.FormatStyle = DomUtil.GetAttr(dom.DocumentElement, "style");
                dlg.StartPosition = FormStartPosition.CenterScreen;
                dlg.ShowDialog(this);

                if (dlg.DialogResult != DialogResult.OK)
                    return;

                /*
                string strDisplayText = dlg.FormatName;
                DomUtil.SetAttr(dom.DocumentElement, "name", dlg.FormatName);

                if (String.IsNullOrEmpty(dlg.FormatType) == false)
                {
                    strDisplayText += " type=" + dlg.FormatType;
                    DomUtil.SetAttr(dom.DocumentElement, "type", dlg.FormatType);
                }

                if (String.IsNullOrEmpty(dlg.ScriptFile) == false)
                {
                    strDisplayText += " scriptfile=" + dlg.ScriptFile;
                    DomUtil.SetAttr(dom.DocumentElement, "scriptfile", dlg.ScriptFile);
                }

                if (String.IsNullOrEmpty(dlg.FormatStyle) == false)
                {
                    strDisplayText += " style=" + dlg.FormatStyle;
                    DomUtil.SetAttr(dom.DocumentElement, "style", dlg.FormatStyle);
                }
                 * */

                // 2009/6/27
                if (String.IsNullOrEmpty(dlg.CaptionsXml) == false)
                    dom.DocumentElement.InnerXml = dlg.CaptionsXml;

                // 2009/6/27
                current_treenode.Text = GetFormatDisplayString(dom.DocumentElement);

                current_treenode.Tag = dom.DocumentElement.OuterXml;

                // 确保展开
                current_treenode.Parent.Expand();


                // 需要立即向服务器提交修改
                nRet = SubmitOpacBrowseFormatDef(out strError);
                if (nRet == -1)
                {
                    current_treenode.ImageIndex = 2;    // 表示未能提交的定义变化请求
                    goto ERROR1;
                }
            }

            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }
Beispiel #2
0
        // 插入OPAC普通库
        private void toolStripMenuItem_insertOpacDatabase_normal_Click(object sender, EventArgs e)
        {
            string strError = "";
            int nRet = 0;

            // 已经存在的库名
            List<string> existing_dbnames = new List<string>();
            for (int i = 0; i < this.listView_opacDatabases.Items.Count; i++)
            {
                existing_dbnames.Add(this.listView_opacDatabases.Items[i].Text);
            }

            OpacNormalDatabaseDialog dlg = new OpacNormalDatabaseDialog();
            MainForm.SetControlFont(dlg, this.Font, false);

            dlg.Text = "新增普通库定义";
            dlg.ManagerForm = this;
            dlg.ExcludingDbNames = existing_dbnames;

            this.MainForm.AppInfo.LinkFormState(dlg, "ManagerForm_OpacNormalDatabaseDialog_state");
            dlg.ShowDialog(this);
            this.MainForm.AppInfo.UnlinkFormState(dlg);

            if (dlg.DialogResult != DialogResult.OK)
                return;

            List<ListViewItem> items = new List<ListViewItem>();
            List<string> dbnames = StringUtil.SplitList(dlg.DatabaseName);

            foreach (string strName in dbnames)
            {
                XmlDocument dom = new XmlDocument();
                dom.LoadXml("<database name='' />");
                // 从<virtualDatabase>元素下的若干<caption>中,选出符合当前工作语言的一个名字字符串
                // 从一个元素的下级<caption>元素中, 提取语言符合的文字值
                //// string strName = dlg.DatabaseName;
                string strType = "database";

                DomUtil.SetAttr(dom.DocumentElement, "name", strName);

                ListViewItem item = new ListViewItem(strName, 0);
                item.SubItems.Add(GetOpacDatabaseTypeDisplayString(strType));
                item.Tag = dom.DocumentElement.OuterXml;   // 记载XML定义片断

                this.listView_opacDatabases.Items.Add(item);

                items.Add(item);
            }

            // 需要立即向服务器提交修改
            nRet = SubmitOpacDatabaseDef(out strError);
            if (nRet == -1)
            {
                foreach (ListViewItem item in items)
                {
                    item.ImageIndex = 2;    // 表示未能提交的新增请求
                }
                goto ERROR1;
            }

            // 选定刚刚插入的普通库
            foreach (ListViewItem item in items)
            {
                item.Selected = true;
                this.listView_opacDatabases.FocusedItem = item;
            }

            DialogResult result = System.Windows.Forms.DialogResult.Cancel;
            foreach (string strName in dbnames)
            {
                // 如果是书目库,看看这个数据库的显示格式定义是否已经存在?
                // 如果不存在,提示插入建议
                if (IsDatabaseBiblioType(strName) == true
                    && HasBrowseFormatDatabaseExist(strName) == false)
                {
                    if (result == System.Windows.Forms.DialogResult.Cancel)
                    {
                        result = MessageBox.Show(this,
                            "刚新增的书目库 " + strName + " 还没有OPAC记录显示格式定义。\r\n\r\n要自动给它创建常规的OPAC记录显示格式定义么? ",
                            "ManagerForm",
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question,
                            MessageBoxDefaultButton.Button1);
                    }
                    if (result == DialogResult.Yes)
                    {
                        // 为书目库插入OPAC显示格式节点(后插)
                        nRet = NewBiblioOpacBrowseFormat(strName,
                            out strError);
                        if (nRet == -1)
                            goto ERROR1;
                    }
                }
            }

            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }
Beispiel #3
0
        // 插入库名节点(后插)
        private void toolStripMenuItem_opacBrowseFormats_insertDatabaseNameNode_Click(object sender, EventArgs e)
        {
            string strError = "";
            int nRet = 0;

            // 当前节点
            TreeNode current_treenode = this.treeView_opacBrowseFormats.SelectedNode;

            // 如果不是根级的节点,则向上找到根级别
            if (current_treenode != null && current_treenode.Parent != null)
            {
                current_treenode = current_treenode.Parent;
            }

            // 插入点
            int index = this.treeView_opacBrowseFormats.Nodes.IndexOf(current_treenode);
            if (index == -1)
                index = this.treeView_opacBrowseFormats.Nodes.Count;
            else
                index++;
            

            // 当前已经存在的数据库名都是需要排除的
            List<string> existing_dbnames = new List<string>();
            for (int i = 0; i < this.treeView_opacBrowseFormats.Nodes.Count; i++)
            {
                string strDatabaseName = this.treeView_opacBrowseFormats.Nodes[i].Text;
                existing_dbnames.Add(strDatabaseName);
            }

            // 询问数据库名
            OpacNormalDatabaseDialog dlg = new OpacNormalDatabaseDialog();
            MainForm.SetControlFont(dlg, this.Font, false);

            dlg.Text = "请指定数据库名";
            dlg.ManagerForm = this;
            dlg.DatabaseName = "";
            dlg.ExcludingDbNames = existing_dbnames;
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);

            if (dlg.DialogResult != DialogResult.OK)
                return;

            TreeNode new_treenode = new TreeNode(dlg.DatabaseName, 0, 0);

            this.treeView_opacBrowseFormats.Nodes.Insert(index, new_treenode);

            this.treeView_opacBrowseFormats.SelectedNode = new_treenode;

            // 需要立即向服务器提交修改
            nRet = SubmitOpacBrowseFormatDef(out strError);
            if (nRet == -1)
            {
                new_treenode.ImageIndex = 2;    // 表示未能提交的新插入节点请求
                goto ERROR1;
            }

            return;
        ERROR1:
            MessageBox.Show(this, strError);

        }
Beispiel #4
0
        // 修改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);
        }