Ejemplo n.º 1
0
        private void button_unionCatalog_findDp2Server_Click(object sender, EventArgs e)
        {
            dp2SearchForm dp2_searchform = this.MainForm.GetDp2SearchForm();

            GetDp2ResDlg dlg = new GetDp2ResDlg();

            GuiUtil.SetControlFont(dlg, this.Font);

            dlg.Text = "请指定要绑定的 dp2library 服务器名";
#if OLD_CHANNEL
            dlg.dp2Channels = dp2_searchform.Channels;
#endif
            dlg.ChannelManager = this.MainForm;
            dlg.Servers        = this.MainForm.Servers;
            dlg.EnabledIndices = new int[] { dp2ResTree.RESTYPE_SERVER };
            dlg.Path           = this.textBox_unionCatalog_bindingDp2ServerName.Text;

            dlg.ShowDialog(this);

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

            this.textBox_unionCatalog_bindingDp2ServerName.Text = dlg.Path;
        }
Ejemplo n.º 2
0
        // return:
        //      -1  error
        //      0   not found
        //      1   found
        int GetOneRecordSyntax(int index,
                               out string strSyntax,
                               out string strError)
        {
            strError  = "";
            strSyntax = "";

            if (index >= this.listView_browse.Items.Count)
            {
                strError = "越过结果集尾部";
                return(-1);
            }

            ListViewItem curItem = this.listView_browse.Items[index];

            string strServerName = this.LibraryServerName;
            string strPurePath   = curItem.Text;

            // 拉上一个dp2检索窗,好办事
            dp2SearchForm dp2_searchform = this.GetDp2SearchForm();

            if (dp2_searchform == null)
            {
                strError = "没有打开的dp2检索窗,无法GetOneRecordSyntax()";
                return(-1);
            }

            /*
             * // 获得server url
             * dp2Server server = this.dp2ResTree1.Servers.GetServerByName(strServerName);
             * string strServerUrl = server.Url;
             * */
            string strBiblioDbName = dp2SearchForm.GetDbName(strPurePath);

            // 获得一个数据库的数据syntax
            // parameters:
            //      stop    如果!=null,表示使用这个stop,它已经OnStop +=
            //              如果==null,表示会自动使用this.stop,并自动OnStop+=
            // return:
            //      -1  error
            //      0   not found
            //      1   found
            int nRet = dp2_searchform.GetDbSyntax(
                null,
                strServerName,
                strBiblioDbName,
                out strSyntax,
                out strError);

            if (nRet == -1)
            {
                return(-1);
            }

            return(nRet);
        }
Ejemplo n.º 3
0
        // 获得缺省查重起点路径
        private void button_dp2library_searchDup_findDefaultStartPath_Click(object sender, EventArgs e)
        {
            string strError = "";

            dp2SearchForm dp2_searchform = this.MainForm.GetDp2SearchForm();

            if (dp2_searchform == null)
            {
                strError = "无法获得打开的 dp2检索窗,无法获得 dp2library 数据库名";
                goto ERROR1;
            }

            string strDefaultStartPath = Global.GetForwardStyleDp2Path(this.textBox_dp2library_searchDup_defaultStartPath.Text);

            // 临时指定一个dp2library服务器和数据库
            GetDp2ResDlg dlg = new GetDp2ResDlg();

            GuiUtil.SetControlFont(dlg, this.Font);

            dlg.Text = "请指定一个 dp2library 数据库,以作为模拟的查重起点";
#if OLD_CHANNEL
            dlg.dp2Channels = dp2_searchform.Channels;
#endif
            dlg.ChannelManager = Program.MainForm;

            dlg.Servers        = this.MainForm.Servers;
            dlg.EnabledIndices = new int[] { dp2ResTree.RESTYPE_DB };
            dlg.Path           = strDefaultStartPath;

            this.MainForm.AppInfo.LinkFormState(dlg,
                                                "searchdup_selectstartpath_dialog_state");

            dlg.ShowDialog(this);

            this.MainForm.AppInfo.UnlinkFormState(dlg);

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

            strDefaultStartPath = Global.GetBackStyleDp2Path(dlg.Path + "/?");


            this.textBox_dp2library_searchDup_defaultStartPath.Text = strDefaultStartPath;
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Ejemplo n.º 4
0
        dp2SearchForm GetDp2SearchForm()
        {
            dp2SearchForm dp2_searchform = this.MainForm.TopDp2SearchForm;

            if (dp2_searchform == null)
            {
                // 新开一个dp2检索窗
                dp2_searchform             = new dp2SearchForm();
                dp2_searchform.MainForm    = this.MainForm;
                dp2_searchform.MdiParent   = this.MainForm;
                dp2_searchform.WindowState = FormWindowState.Minimized;
                dp2_searchform.Show();
            }


            return(dp2_searchform);
        }
Ejemplo n.º 5
0
        dp2SearchForm GetDp2SearchForm()
        {
            dp2SearchForm dp2_searchform = null;

            dp2_searchform = this.MainForm.TopDp2SearchForm;

            if (dp2_searchform == null)
            {
                // 新开一个dp2检索窗
                FormWindowState old_state = this.WindowState;

                dp2_searchform = new dp2SearchForm();
                dp2_searchform.MainForm = this.MainForm;
                dp2_searchform.MdiParent = this.MainForm;
                dp2_searchform.WindowState = FormWindowState.Minimized;
                dp2_searchform.Show();

                this.WindowState = old_state;
                this.Activate();

                // 需要等待初始化操作彻底完成
                dp2_searchform.WaitLoadFinish();
            }

            return dp2_searchform;
        }
Ejemplo n.º 6
0
        // 获得一条MARC/XML记录
        // return:
        //      -1  error 包括not found
        //      0   found
        //      1   为诊断记录
        public int GetOneRecord(
            string strStyle,
            int nTest,
            string strPathParam,
            string strParameters,   // bool bHilightBrowseLine,
            out string strSavePath,
            out string strRecord,
            out string strXmlFragment,
            out string strOutStyle,
            out byte[] baTimestamp,
            out long lVersion,
            out DigitalPlatform.Z3950.Record record,
            out Encoding currrentEncoding,
            out LoginInfo logininfo,
            out string strError)
        {
            strXmlFragment   = "";
            strRecord        = "";
            record           = null;
            strError         = "";
            currrentEncoding = this.CurrentEncoding;
            baTimestamp      = null;
            strSavePath      = "";
            strOutStyle      = "marc";
            logininfo        = new LoginInfo();
            lVersion         = 0;

            // 防止重入
            if (m_bInSearch == true)
            {
                strError = "当前窗口正在被一个未结束的长操作使用,无法获得记录。请稍后再试。";
                return(-1);
            }

            if (strStyle != "marc" && strStyle != "xml")
            {
                strError = "DupForm只支持获取MARC格式记录和xml格式记录,不支持 '" + strStyle + "' 格式的记录";
                return(-1);
            }
            int nRet = 0;

            int    index        = -1;
            string strPath      = "";
            string strDirection = "";

            nRet = Global.ParsePathParam(strPathParam,
                                         out index,
                                         out strPath,
                                         out strDirection,
                                         out strError);
            if (nRet == -1)
            {
                return(-1);
            }

            if (index == -1)
            {
                strError = "暂时不支持没有 index 的用法";
                return(-1);
            }

            bool bHilightBrowseLine = StringUtil.IsInList("hilight_browse_line", strParameters);

            if (index >= this.listView_browse.Items.Count)
            {
                strError = "越过结果集尾部";
                return(-1);
            }
            ListViewItem curItem = this.listView_browse.Items[index];

            if (bHilightBrowseLine == true)
            {
                // 修改listview中事项的选定状态
                for (int i = 0; i < this.listView_browse.SelectedItems.Count; i++)
                {
                    this.listView_browse.SelectedItems[i].Selected = false;
                }

                curItem.Selected = true;
                curItem.EnsureVisible();
            }

            string strPurePath   = curItem.Text;
            string strServerName = this.LibraryServerName;

            strPath = strPurePath + "@" + this.LibraryServerName;

            strSavePath = this.CurrentProtocol + ":" + strPath;

            // 拉上一个dp2检索窗,好办事
            dp2SearchForm dp2_searchform = this.GetDp2SearchForm();

            if (dp2_searchform == null)
            {
                strError = "没有打开的dp2检索窗,无法GetOneRecordSyntax()";
                return(-1);
            }

            // 获得server url
            string strServerUrl = dp2_searchform.GetServerUrl(strServerName);

            if (strServerUrl == null)
            {
                strError = "没有找到服务器名 '" + strServerName + "' 对应的URL";
                return(-1);
            }

            this.Channel = this.Channels.GetChannel(strServerUrl);

            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在初始化浏览器组件 ...");
            stop.BeginLoop();

            this.Update();
            this.MainForm.Update();

            try
            {
                stop.SetMessage("正在装入书目记录 " + strPath + " ...");

                string[] formats = null;
                formats    = new string[1];
                formats[0] = "xml";

                string[] results = null;

                long lRet = Channel.GetBiblioInfos(
                    stop,
                    strPurePath,
                    "",
                    formats,
                    out results,
                    out baTimestamp,
                    out strError);
                if (lRet == 0)
                {
                    strError = "路径为 '" + strPath + "' 的书目记录没有找到 ...";
                    goto ERROR1;   // not found
                }

                if (lRet == -1)
                {
                    goto ERROR1;
                }

                // this.BiblioTimestamp = baTimestamp;

                if (results == null)
                {
                    strError = "results == null";
                    goto ERROR1;
                }
                if (results.Length != formats.Length)
                {
                    strError = "result.Length != formats.Length";
                    goto ERROR1;
                }

                string strXml = results[0];

                if (strStyle == "marc")
                {
                    string strMarcSyntax    = "";
                    string strOutMarcSyntax = "";
                    // 从数据记录中获得MARC格式
                    nRet = MarcUtil.Xml2Marc(strXml,
                                             true,
                                             strMarcSyntax,
                                             out strOutMarcSyntax,
                                             out strRecord,
                                             out strError);
                    if (nRet == -1)
                    {
                        strError = "XML转换到MARC记录时出错: " + strError;
                        goto ERROR1;
                    }


                    // 获得书目以外的其它XML片断
                    nRet = dp2SearchForm.GetXmlFragment(strXml,
                                                        out strXmlFragment,
                                                        out strError);
                    if (nRet == -1)
                    {
                        goto ERROR1;
                    }
                }
                else
                {
                    strRecord   = strXml;
                    strOutStyle = strStyle;
                }
            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStop);
                stop.Initial("");
            }
            return(0);

ERROR1:
            return(-1);
        }
Ejemplo n.º 7
0
        // 装载MARC记录,根据记录路径
        // parameters:
        //      strPath 路径。例如 "图书总库/1@本地服务器"
        //      bReload 是否确保从数据库装载
        public int LoadDp2Record(dp2SearchForm dp2_searchform,
            string strPath,
            string strDirection,
            bool bLoadResObject,
            bool bReload = false)
        {
            string strError = "";

            if (dp2_searchform == null)
            {
                strError = "dp2_searchform参数不能为空";
                goto ERROR1;
            }

            if (dp2_searchform.CurrentProtocol != "dp2library")
            {
                strError = "所提供的检索窗不是 dp2library 协议";
                goto ERROR1;
            }

            DigitalPlatform.Z3950.Record record = null;
            Encoding currentEncoding = null;

            this.CurrentRecord = null;

            byte[] baTimestamp = null;
            string strOutStyle = "";

            string strSavePath = "";
            string strMARC;

            long lVersion = 0;
            LoginInfo logininfo = null; 
            string strXmlFragment = "";

            int nRet = dp2_searchform.GetOneRecord(
                //true,
                "marc",
                //strPath,
                //strDirection,
                0,  // test
                "path:" + strPath + ",direction:" + strDirection,
                bReload == true ? "reload" : "",
                out strSavePath,
                out strMARC,
                out strXmlFragment,
                out strOutStyle,
                out baTimestamp,
                out lVersion,
                out record,
                out currentEncoding,
                out logininfo,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            nRet = this.LoadXmlFragment(strXmlFragment,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            this.CurrentTimestamp = baTimestamp;
            // this.SavePath = dp2_searchform.CurrentProtocol + ":" + strOutputPath;
            this.SavePath = strSavePath;
            this.CurrentEncoding = currentEncoding;


            /*
            // 接着装入对象资源
            if (bLoadResObject == true)
            {
                this.binaryResControl1.Channel = dp2_searchform.GetChannel(dp2_searchform.GetServerUrl(strServerName));
                nRet = this.binaryResControl1.LoadObject(strLocalPath,
                    strRecordXml,
                    out strError);
                if (nRet == -1)
                {
                    MessageBox.Show(this, strError);
                    return -1;
                }
            }*/
            // 装入MARC编辑器
            this.MarcEditor.Marc = strMARC;


            this.m_nDisableInitialAssembly++; 
            this.CurrentRecord = record;
            this.m_nDisableInitialAssembly--; 

            if (this.m_currentRecord != null)
            {
                // 装入二进制编辑器
                this.binaryEditor_originData.SetData(
                    this.m_currentRecord.m_baRecord);

                // 装入ISO2709文本
                nRet = this.Set2709OriginText(this.m_currentRecord.m_baRecord,
                    this.CurrentEncoding,
                    out strError);
                if (nRet == -1)
                {
                    this.textBox_originData.Text = strError;
                }

                // 数据库名
                this.textBox_originDatabaseName.Text = this.m_currentRecord.m_strDBName;

                // Marc syntax OID
                this.textBox_originMarcSyntaxOID.Text = this.m_currentRecord.m_strSyntaxOID;

                // 2014/5/18
                if (this.UseAutoDetectedMarcSyntaxOID == true)
                {
                    this.AutoDetectedMarcSyntaxOID = this.m_currentRecord.AutoDetectedSyntaxOID;
                    if (string.IsNullOrEmpty(this.AutoDetectedMarcSyntaxOID) == false)
                        this.textBox_originMarcSyntaxOID.Text = this.AutoDetectedMarcSyntaxOID;
                }

#if NO
                // 让确定的OID起作用 2008/3/25
                if (String.IsNullOrEmpty(this.m_currentRecord.m_strSyntaxOID) == false)
                    this.AutoDetectedMarcSyntaxOID = "";
#endif
            }
            else
            {
                byte[] baMARC = this.CurrentEncoding.GetBytes(strMARC);
                // 装入二进制编辑器
                this.binaryEditor_originData.SetData(
                    baMARC);

                // 装入ISO2709文本
                nRet = this.Set2709OriginText(baMARC,
                    this.CurrentEncoding,
                    out strError);
                if (nRet == -1)
                {
                    this.textBox_originData.Text = strError;
                }
            }

            DisplayHtml(strMARC, this.textBox_originMarcSyntaxOID.Text);

            // 构造路径
            /*
            string strPath = searchform.CurrentProtocol + ":"
                + searchform.CurrentResultsetPath
                + "/" + (index + 1).ToString();

            this.textBox_tempRecPath.Text = strPath;
             * */
            if (strDirection != "current")  // 2013/9/18
                this.textBox_tempRecPath.Text = "";


            this.MarcEditor.MarcDefDom = null; // 强制刷新字段名提示
            this.MarcEditor.RefreshNameCaption();

            this.BiblioChanged = false;

            if (this.MarcEditor.FocusedFieldIndex == -1)
                this.MarcEditor.FocusedFieldIndex = 0;

            this.MarcEditor.Focus();
            return 0;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }
Ejemplo n.º 8
0
        dp2SearchForm GetDp2SearchForm()
        {
            dp2SearchForm dp2_searchform = null;

            if (this.LinkedSearchForm != null
                && this.LinkedSearchForm.IsValid() == true   // 2008/3/17
                && this.LinkedSearchForm is dp2SearchForm)
            {
                dp2_searchform = (dp2SearchForm)this.LinkedSearchForm;
            }
            else
            {
                dp2_searchform = this.MainForm.TopDp2SearchForm;

                if (dp2_searchform == null)
                {
                    // 新开一个dp2检索窗
                    FormWindowState old_state = this.WindowState;

                    dp2_searchform = new dp2SearchForm();
                    dp2_searchform.MainForm = this.MainForm;
                    dp2_searchform.MdiParent = this.MainForm;
                    dp2_searchform.WindowState = FormWindowState.Minimized;
                    dp2_searchform.Show();

                    // 2008/3/17
                    this.WindowState = old_state;
                    this.Activate();

                    // 需要等待初始化操作彻底完成
                    dp2_searchform.WaitLoadFinish();
                }
            }

            return dp2_searchform;
        }
Ejemplo n.º 9
0
        dp2SearchForm GetDp2SearchForm()
        {
            dp2SearchForm dp2_searchform = this.MainForm.TopDp2SearchForm;

            if (dp2_searchform == null)
            {
                // 新开一个dp2检索窗
                dp2_searchform = new dp2SearchForm();
                dp2_searchform.MainForm = this.MainForm;
                dp2_searchform.MdiParent = this.MainForm;
                dp2_searchform.WindowState = FormWindowState.Minimized;
                dp2_searchform.Show();
            }


            return dp2_searchform;
        }
Ejemplo n.º 10
0
        // 装载XML记录,根据记录路径
        // parameters:
        //      strPath 路径。例如 "图书总库/1@本地服务器"
        public int LoadDp2Record(dp2SearchForm dp2_searchform,
            string strPath,
            string strDirection,
            bool bLoadResObject)
        {
            string strError = "";
            string strRecordXml = "";

            if (dp2_searchform == null)
            {
                strError = "dp2_searchform参数不能为空";
                goto ERROR1;
            }

            if (dp2_searchform.CurrentProtocol != "dp2library")
            {
                strError = "所提供的检索窗不是dp2library协议";
                goto ERROR1;
            }

            DigitalPlatform.Z3950.Record record = null;
            Encoding currentEncoding = null;

            this.CurrentRecord = null;

            byte[] baTimestamp = null;
            string strOutStyle = "";

            string strSavePath = "";

            long lVersion = 0;
            LoginInfo logininfo = null;
            string strXmlFragment = "";

            int nRet = dp2_searchform.GetOneRecord(
                // true,
                "xml",
                // strPath,
                // strDirection,
                0,   // test
                "path:" + strPath + ",direction:" + strDirection,
                "",
                out strSavePath,
                out strRecordXml,
                out strXmlFragment,

                out strOutStyle,
                out baTimestamp,
                out lVersion,
                out record,
                out currentEncoding,
                out logininfo,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            this.CurrentTimestamp = baTimestamp;
            // this.SavePath = dp2_searchform.CurrentProtocol + ":" + strOutputPath;
            this.SavePath = strSavePath;
            this.CurrentEncoding = currentEncoding;

            string strServerName = "";
            string strLocalPath = "";

            strPath = strSavePath;

            // 解析记录路径。
            // 记录路径为如下形态 "中文图书/1 @服务器"
            dp2SearchForm.ParseRecPath(strPath,
                out strServerName,
                out strLocalPath);

            string strBiblioDbName = dp2SearchForm.GetDbName(strLocalPath);

            // 获得cfgs\dcdef
            string strCfgFileName = "dcdef";

            string strCfgPath = strBiblioDbName + "/cfgs/" + strCfgFileName + "@" + strServerName;

            // 和以前的不同,才有必要重新载入
            if (this.DcCfgFilename != strCfgPath)
            {
                string strCode = "";
                byte[] baCfgOutputTimestamp = null;
                // return:
                //      -1  error
                //      0   not found
                //      1   found
                nRet = dp2_searchform.GetCfgFile(strCfgPath,
                    out strCode,
                    out baCfgOutputTimestamp,
                    out strError);
                if (nRet == -1 || nRet == 0)
                    goto ERROR1;

                nRet = this.DcEditor.LoadCfgCode(strCode,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;

                this.DcCfgFilename = strCfgPath;
            }

            // 接着装入对象资源
            if (bLoadResObject == true)
            {
                // this.binaryResControl1.Channel = dp2_searchform.GetChannel(dp2_searchform.GetServerUrl(strServerName));
                nRet = this.binaryResControl1.LoadObject(
                    dp2_searchform.GetChannel(dp2_searchform.GetServerUrl(strServerName)),
                    strLocalPath,
                    strRecordXml,
                    "0",  // TODO
                    out strError);
                if (nRet == -1)
                {
                    MessageBox.Show(this, strError);
                    return -1;
                }
            }




            // TODO: 再次装入的时候有问题
            // 装入DC编辑器
            this.DcEditor.Xml = strRecordXml;


            this.CurrentRecord = record;

            this.BiblioChanged = false;

            this.DcEditor.Focus();
            return 0;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }