示例#1
0
        private void button_findDatabaseName_Click(object sender, EventArgs e)
        {
            // 需要有DTLP资源对话框。需要有DtlpChannels的支持
            if (this.DupCfgDialog == null)
            {
                MessageBox.Show(this, "DupCfgDialog成员为空,无法打开选择目标数据库的对话框");
                return;
            }

            GetDtlpResDialog dlg = new GetDtlpResDialog();

            dlg.Text = "请选择数据库";
            dlg.Initial(this.DupCfgDialog.DtlpChannels,
                        this.DupCfgDialog.DtlpChannel);
            dlg.StartPosition  = FormStartPosition.CenterScreen;
            dlg.Path           = this.textBox_databaseName.Text;
            dlg.EnabledIndices = new int[] { DtlpChannel.TypeStdbase };
            dlg.ShowDialog(this);

            this.textBox_databaseName.Text = dlg.Path;
        }
示例#2
0
        // 保存到 DTLP协议 模板
        // parameters:
        //      strPath DTLP协议内路径。例如 localhost/中文图书/ctlno/0000001
        public int SaveToDtlpTemplate(string strPath)
        {
            int nRet = 0;
            string strError = "";

            DtlpSearchForm dtlp_searchform = this.GetDtlpSearchForm();

            if (dtlp_searchform == null)
            {
                strError = "没有连接的或者打开的DTLP检索窗,无法保存模板";
                goto ERROR1;
            }


            string strServerAddr = "";
            string strDbName = "";
            string strNumber = "";

            // 解析保存路径
            // return:
            //      -1  出错
            //      0   成功
            nRet = DtlpChannel.ParseWritePath(strPath,
                out strServerAddr,
                out strDbName,
                out strNumber,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            string strStartPath = strServerAddr + "/" + strDbName;

            GetDtlpResDialog dlg = new GetDtlpResDialog();
            GuiUtil.SetControlFont(dlg, this.Font);

            dlg.Text = "请选择目标数据库";
            dlg.Initial(dtlp_searchform.DtlpChannels,
                dtlp_searchform.DtlpChannel);
            dlg.EnabledIndices = new int[] { DtlpChannel.TypeStdbase };
            dlg.Path = strStartPath;
            dlg.StartPosition = FormStartPosition.CenterScreen;

            dlg.ShowDialog(this);

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

            // 获得default.cfg配置文件
            string strCfgPath = dlg.Path + "/cfgs/default.cfg";
            string strContent = "";

            Cursor.Current = Cursors.WaitCursor;
            nRet = dtlp_searchform.DtlpChannel.GetCfgFile(strCfgPath,
                out strContent,
                out strError);
            Cursor.Current = Cursors.Default;

            if (nRet == -1)
                goto ERROR1;

            // 选择模板
            SelectRecordTemplateDialog tempdlg = new SelectRecordTemplateDialog();
            GuiUtil.SetControlFont(tempdlg, this.Font);

            tempdlg.LoadMode = false;
            tempdlg.Content = strContent;
            tempdlg.SelectedRecordMarc = this.MarcEditor.Marc;
            tempdlg.StartPosition = FormStartPosition.CenterScreen;

            tempdlg.ShowDialog(this);

            if (tempdlg.DialogResult != DialogResult.OK)
                return 0;

            if (tempdlg.Changed == false)
                return 0;

            Cursor.Current = Cursors.WaitCursor;
            nRet = dtlp_searchform.DtlpChannel.WriteCfgFile(strCfgPath,
                tempdlg.Content,
                out strError);
            Cursor.Current = Cursors.Default;

            if (nRet == -1)
                goto ERROR1;


            MessageBox.Show(this, "修改模板 '" + strCfgPath + "' 成功");
            return 0;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }
示例#3
0
        // DTLP协议下 装载模板
        // parameters:
        //      strPath DTLP协议内路径。例如 localhost/中文图书/ctlno/0000001
        public int LoadDtlpTemplate(string strPath)
        {
            int nRet = 0;
            string strError = "";

            DtlpSearchForm dtlp_searchform = this.GetDtlpSearchForm();

            if (dtlp_searchform == null)
            {
                strError = "没有连接的或者打开的DTLP检索窗,无法装载模板";
                goto ERROR1;
            }


            string strServerAddr = "";
            string strDbName = "";
            string strNumber = "";

            // 解析保存路径
            // return:
            //      -1  出错
            //      0   成功
            nRet = DtlpChannel.ParseWritePath(strPath,
                out strServerAddr,
                out strDbName,
                out strNumber,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            string strStartPath = "";

            if (String.IsNullOrEmpty(strServerAddr) == false
                && String.IsNullOrEmpty(strDbName) == false)
                strStartPath = strServerAddr + "/" + strDbName;
            else if (String.IsNullOrEmpty(strServerAddr) == false)
                strStartPath = strServerAddr;

            GetDtlpResDialog dlg = new GetDtlpResDialog();
            GuiUtil.SetControlFont(dlg, this.Font);


            dlg.Text = "请选择目标数据库";
            dlg.Initial(dtlp_searchform.DtlpChannels,
                dtlp_searchform.DtlpChannel);
            dlg.EnabledIndices = new int[] { DtlpChannel.TypeStdbase };
            dlg.Path = strStartPath;
            dlg.StartPosition = FormStartPosition.CenterScreen;

            dlg.ShowDialog(this);

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

            // 获得default.cfg配置文件
            string strCfgPath = dlg.Path + "/cfgs/default.cfg";
            string strContent = "";

            Cursor.Current = Cursors.WaitCursor;
            nRet = dtlp_searchform.DtlpChannel.GetCfgFile(strCfgPath,
                out strContent,
                out strError);
            Cursor.Current = Cursors.Default;

            if (nRet == -1)
                goto ERROR1;

            // 选择模板
            SelectRecordTemplateDialog tempdlg = new SelectRecordTemplateDialog();
            GuiUtil.SetControlFont(tempdlg, this.Font);

            tempdlg.Content = strContent;
            tempdlg.StartPosition = FormStartPosition.CenterScreen;

            tempdlg.ShowDialog(this);

            if (tempdlg.DialogResult != DialogResult.OK)
                return 0;

            this.SavePath = "DTLP" + ":" + dlg.Path + "/ctlno/?";

            // 自动识别MARC格式
            string strOutMarcSyntax = "";
            // 探测记录的MARC格式 unimarc / usmarc / reader
            nRet = MarcUtil.DetectMarcSyntax(tempdlg.SelectedRecordMarc,
                out strOutMarcSyntax);
            if (strOutMarcSyntax == "")
                strOutMarcSyntax = "unimarc";

            if (strOutMarcSyntax == "unimarc" || strOutMarcSyntax == "")
                this.AutoDetectedMarcSyntaxOID = "1.2.840.10003.5.1";
            else if (strOutMarcSyntax == "usmarc")
                this.AutoDetectedMarcSyntaxOID = "1.2.840.10003.5.10";
            else if (strOutMarcSyntax == "dt1000reader")
                this.AutoDetectedMarcSyntaxOID = "1.2.840.10003.5.dt1000reader";
            else
            {
                /*
                strError = "未知的MARC syntax '" + strOutMarcSyntax + "'";
                goto ERROR1;
                 * */
                // TODO: 可以出现菜单选择
            }

            this.MarcEditor.ClearMarcDefDom();
            this.MarcEditor.Marc = tempdlg.SelectedRecordMarc;
            this.CurrentTimestamp = null;

            this.ObjectChanged = false;
            this.BiblioChanged = false;

            DisplayHtml(tempdlg.SelectedRecordMarc, this.AutoDetectedMarcSyntaxOID);

            this.LinkedSearchForm = null;  // 切断和原来关联的检索窗的联系。这样就没法前后翻页了
            return 0;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }
示例#4
0
        private void button_findDatabaseName_Click(object sender, EventArgs e)
        {
            // 需要有DTLP资源对话框。需要有DtlpChannels的支持
            if (this.DupCfgDialog == null)
            {
                MessageBox.Show(this, "DupCfgDialog成员为空,无法打开选择目标数据库的对话框");
                return;
            }

            GetDtlpResDialog dlg = new GetDtlpResDialog();

            dlg.Text = "请选择目标数据库";
            dlg.Initial(this.DupCfgDialog.DtlpChannels,
                this.DupCfgDialog.DtlpChannel);
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.Path = this.textBox_databaseName.Text;
            dlg.EnabledIndices = new int[] { DtlpChannel.TypeStdbase };
            dlg.ShowDialog(this);

            this.textBox_databaseName.Text = dlg.Path;
        }